|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 # J% C, h1 o* }/ ?" u
- [code]EDMA sample test application; @! C( G3 Z# C2 T/ t. U
- /*
1 X( e' _+ g9 _2 x) u* e" A - * edma_test.c
& ]3 X. e2 f- |! X( F* w& c - *6 l. h4 O! p( b! e
- * brief EDMA3 Test Application% ?' T5 _% ^- ?: \! S" [' t) U
- *
5 R" Y9 d7 @7 ]9 v - * This file contains EDMA3 Test code.! H3 D. S6 k/ {" w; v W# x, n
- *
3 B7 d8 z; m) F5 O& i. n - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE# I: l& U: t I& p5 M
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
8 X/ T4 c1 ^: Z+ I* s. @ - * TO CHANGE.% k8 L# d- ~7 r1 e7 a/ ?6 c$ s. k
- *
2 O" p- c1 L6 n! x$ r$ T. D x - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/' @9 Z! V" r- s- i
- *
) [5 ]; R6 F0 L" @4 L - * This program is free software; you can redistribute it and/or" G$ W, j1 v. j& `% H) F* k
- * modify it under the terms of the GNU General Public License as+ G" `$ U( \7 T% A1 x( S
- * published by the Free Software Foundation version 2., \+ F8 I2 p. V- Q; Z/ }, _( W0 B
- *
7 o1 n5 F/ q5 r* k' _& B: f8 ~9 @ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any( K$ q) o" Q5 f
- * kind, whether express or implied; without even the implied warranty+ {9 e. U- G. f+ V) C
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
, x( Z9 t* V2 S - * GNU General Public License for more details.
% C6 T9 G1 @# w0 M8 ^' k4 Z - */
' \ w% J" x( \7 h
8 }: N6 ], N# d4 j; J2 U- #include <linux/module.h>. J) \4 Z. t* j0 b' c2 L% Q" {- u
- #include <linux/init.h>
; f3 V4 i7 R ]; e. \ - #include <linux/errno.h>6 C. x: [0 y; P0 [) X/ g, O
- #include <linux/types.h>7 p6 A0 C6 w$ |$ f) K4 O
- #include <linux/interrupt.h>
4 a2 Z8 P$ z6 z; d; G5 m& N - #include <asm/io.h>: U- o4 ]* m! B/ ]* i4 `
- #include <linux/moduleparam.h>
$ v2 L+ y9 e. \4 F/ p5 N% W - #include <linux/sysctl.h>/ v7 Q" ?6 k. T# S; D$ c" q+ |
- #include <linux/mm.h>% U+ C. e- q' I, a5 j7 o
- #include <linux/dma-mapping.h>
% @: x' Z; ~- u- M/ u - + j( j9 C! ]# @2 Y; ~# b$ `
- #include <mach/memory.h>% g$ C7 I/ p0 A) `/ g7 _
- #include <mach/hardware.h>
8 a: q: P/ @2 T. D5 @; ~$ t# R - #include <mach/irqs.h>+ u2 h* q6 M# r
- #include <asm/hardware/edma.h>$ ~# H( a+ a" V1 L5 T- @
7 x: D. w8 Q. q4 s5 [. S- #undef EDMA3_DEBUG6 }0 ?( D6 `- S& c
- /*#define EDMA3_DEBUG*/+ k; d% Q1 N$ f
! `* R$ i2 s2 A0 F% o- #ifdef EDMA3_DEBUG& m8 C. n* z3 L2 n" r$ J
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
& A3 y9 J% k) e7 w1 q0 r2 f2 R - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)9 v Z2 R2 g* y7 i0 Y# \4 R0 R0 M9 b
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
% s# V! R& a# ?# I: E5 O - #else$ {) J1 T' r% N
- #define DMA_PRINTK( x... )5 d5 k, _' z1 h) P5 |7 l7 |# f* x
- #define DMA_FN_IN) \/ p2 D- h$ f
- #define DMA_FN_OUT$ F1 P$ ^* g \6 ?
- #endif
' d6 |' {! d' D, J
) i$ w* \0 n& n' X$ x* G# L- #define MAX_DMA_TRANSFER_IN_BYTES (32768)3 c: b8 M r% x+ t, A" }
- #define STATIC_SHIFT 3( _ o6 z& A9 L7 M7 k! K: Z, w
- #define TCINTEN_SHIFT 20/ z- e- Q1 b' I) i! x d/ h) {
- #define ITCINTEN_SHIFT 21' C& X2 P+ j9 I0 U3 C F
- #define TCCHEN_SHIFT 22
: A1 u) P. }5 E1 z- k' g4 Q v - #define ITCCHEN_SHIFT 23
; o) x% B, J' ]% R. o h9 f
% `& \1 i+ f, i- static volatile int irqraised1 = 0;$ X9 I& T* V8 R0 Y2 _4 g3 W6 }
- static volatile int irqraised2 = 0;
0 s* s+ D) h# T% x - ( X9 h; e/ ~# E: g- j* ~2 p" }
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 ?6 a2 E* B4 z - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( t2 l! G, Z5 U5 ~- ? - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 h {2 l: x( M! [9 z( e, a( ^, L1 V
, V$ k) |8 I: {* o- dma_addr_t dmaphyssrc1 = 0;
( z) |" D( l) y V$ X/ u - dma_addr_t dmaphyssrc2 = 0;* z1 Y2 x; F8 }/ V; y! q
- dma_addr_t dmaphysdest1 = 0;- F( Z& e# H: u1 c# m
- dma_addr_t dmaphysdest2 = 0;6 y3 R- ?# q4 u v4 u
Y, o: r5 U+ Q, G, g& `- char *dmabufsrc1 = NULL;9 Q3 V; ^. S1 r2 c) y
- char *dmabufsrc2 = NULL;
% G& G; B Y/ ?) [2 E - char *dmabufdest1 = NULL;
( b) }: _( O, E6 Z" }; _+ d* D0 L - char *dmabufdest2 = NULL;
$ L) j A5 Z. `; |
) I3 a+ z5 W# l+ F3 v- static int acnt = 512;
8 i6 d$ U1 T. _3 _6 J* f! ~6 _, l - static int bcnt = 8;1 y- }5 H V: E
- static int ccnt = 8;
, y/ v1 E+ T% E" f6 K) I
. T" ~! n/ f" B* D" w9 d9 z. ]- module_param(acnt, int, S_IRUGO);
2 N6 I! w n0 l; u' b/ A - module_param(bcnt, int, S_IRUGO);
. e( g! X- \6 i& z6 |! E/ V - module_param(ccnt, int, S_IRUGO);
复制代码
7 N, o7 M1 ]1 W1 }/ Y- e' L9 i
" ~3 ]- k$ V0 x6 y 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 O: ^! f- u9 N5 aarm-none-linux-gnueabi-gcc -I /home/tl/omapl138/linux-3.3/arch/arm/include -I /home/tl/omapl138/linux-3.3/include EDMA3test.cpp -o EDMA3这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# l- Y/ Z0 d H& `
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ U6 l+ F% h) T/ w1 ^3 S
" j, d2 E% W- C: v6 Z% C$ b1 b. d$ o) n+ p
|
|