|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 b) {9 L/ a+ ^- [code]EDMA sample test application
1 o' i2 X3 H8 Z, h) m - /*
4 j) @. `3 o/ T, x/ s0 D - * edma_test.c0 {% `: D! U4 e1 f4 `( \% ^6 ^
- *) Y8 D' z' y- {5 }6 r. Z) O
- * brief EDMA3 Test Application9 h3 W/ Y" \" v1 Q
- *
. {( W3 _# ^/ A' T - * This file contains EDMA3 Test code.. h' B$ [' t$ t% L
- *
1 T3 K) W% U2 f! Y - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE& i! Q8 V9 {6 T! S& T
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT* P1 `8 g+ f: y( `6 d9 _9 a
- * TO CHANGE.8 h' I3 Z4 C6 y! ^& F E9 P; }9 T4 d
- *
3 J4 R8 l3 c: f9 P - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/: Z& ]9 y6 n' L1 o# ~
- *
5 g7 Y) a4 t& P# I q0 z1 t6 p- j - * This program is free software; you can redistribute it and/or) }# [) o2 m9 T: b2 F% y* X( H
- * modify it under the terms of the GNU General Public License as7 l3 [+ k0 X+ h- g6 f% |- M4 I, n2 [
- * published by the Free Software Foundation version 2.
( C3 U# @/ A3 g) t7 u - *
: z0 C: j2 v$ D& m - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
/ M# k5 }0 V$ D* }2 @1 @ - * kind, whether express or implied; without even the implied warranty: c- u( A" F4 }
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; p. ]5 N( R) ~' Y% g. W p - * GNU General Public License for more details.6 w/ Y r) ^6 ~# t* T4 g
- */2 t) ?* Y# }, q% g2 C9 D
- 8 i5 p% J$ f* M$ W6 q n
- #include <linux/module.h>( Q7 i! h& P; [0 i9 s) I1 y
- #include <linux/init.h>/ K: S9 p& P" _" u& \8 ^
- #include <linux/errno.h># s5 Z" t7 d% H$ P1 D4 W
- #include <linux/types.h>: [, u; q" i$ o, H8 ]
- #include <linux/interrupt.h>% P4 o# X0 U* h; H4 ]
- #include <asm/io.h>' w4 [0 {6 ]0 P
- #include <linux/moduleparam.h>
$ Q" t4 ~( n9 o - #include <linux/sysctl.h>; I7 Q- ?$ n0 R# X' s* N, F2 b
- #include <linux/mm.h>+ d9 W% X& w8 z; B% ~
- #include <linux/dma-mapping.h>& J6 W, ]- L8 `; s- [
- ' t, {9 ?' B; k. a" H L
- #include <mach/memory.h>
( v: ?( N! a: F" ?) n - #include <mach/hardware.h>
+ w3 a6 E8 C5 H* V0 \' I p# l( D: _ - #include <mach/irqs.h>
8 g' j! D: {3 d3 ]. w" I" W - #include <asm/hardware/edma.h># r( _' {' `+ Z' q5 n7 b8 r
- - S+ e% |, M1 O6 ^( }
- #undef EDMA3_DEBUG
9 t- z1 d# s! ]# t, N - /*#define EDMA3_DEBUG*/
% }! E/ |, U+ _; r+ R! ? - : c1 q. N. K9 B& m8 L, I
- #ifdef EDMA3_DEBUG5 r4 C, Q- G6 `
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS); {2 _, S, o3 G# u# {$ D$ f
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)7 b/ m2 {0 C6 H b
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)$ X7 l; G; o; `1 I3 t( k) x+ h z
- #else6 A) p+ |4 X0 b- J n, U. x) J0 o
- #define DMA_PRINTK( x... )0 R" ]6 ~0 L0 P, B% m2 }
- #define DMA_FN_IN$ M3 ]5 E8 O5 Q9 l" C' ^
- #define DMA_FN_OUT
# a/ [% o& V; Z$ c+ ]% C - #endif
7 [% a+ T6 B$ M5 T- C) z - 6 J, ~, m+ @' C6 w: I- l( D2 U) Y
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
8 H8 a/ I( Z. j& z - #define STATIC_SHIFT 3 }' Z( U$ f, H) }! m; \5 k
- #define TCINTEN_SHIFT 20
- y1 b, V- K7 p) y - #define ITCINTEN_SHIFT 21
+ W* F& X- ]9 Y - #define TCCHEN_SHIFT 226 s/ X% i4 Z5 E7 s3 l! M
- #define ITCCHEN_SHIFT 230 p- L! [& s! b$ V i
% s- D4 a9 I7 s- m( f+ l) i- static volatile int irqraised1 = 0;4 h: E5 ^% M0 w! n G
- static volatile int irqraised2 = 0;7 v/ i5 U. T9 _3 l
- " M8 |2 D5 v0 Y
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% K! x, R+ u. _3 B' Q% r
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- B, f$ V+ }& q# m# q( i9 _ x3 _3 e! g
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. K+ V( N F w1 Q% J7 j, q - 4 d$ g' ]% @ k3 d& s# A
- dma_addr_t dmaphyssrc1 = 0;9 B1 {- L* @/ @" b$ U/ w% E7 h
- dma_addr_t dmaphyssrc2 = 0;8 |" B* ?% G' N2 h
- dma_addr_t dmaphysdest1 = 0;. {, a& y$ j L9 l
- dma_addr_t dmaphysdest2 = 0;
& H+ l- W8 X( ^$ H$ e- Z D( D' j
4 L0 ^0 p3 v! G" [! v6 A- char *dmabufsrc1 = NULL;
, w- V# o3 g' V - char *dmabufsrc2 = NULL;
& O# }/ X. ~! L - char *dmabufdest1 = NULL;
o/ o: J+ ~4 Q - char *dmabufdest2 = NULL;
$ r' N- E3 u0 p3 V7 ~$ d5 ]
+ g. w. h* q3 ^. H& G, W- static int acnt = 512;6 s W" Y. ?3 }4 c( s; n
- static int bcnt = 8;* r. R4 ^0 w. u- L4 B+ O' ~6 i
- static int ccnt = 8; ?- Z0 Q" Q8 N0 F. `5 k, T
6 s4 s$ i @3 f6 g/ ~- module_param(acnt, int, S_IRUGO);0 w/ n& `, L9 R, A4 g& I8 t1 J
- module_param(bcnt, int, S_IRUGO);! R/ y: m" T" b
- module_param(ccnt, int, S_IRUGO);
复制代码
; a! y$ b( Z _8 _! ]' Y
# {4 R8 Y5 D: G* f- [, W. _ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
. z+ z- F% G i6 O: garm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。& Y8 [* ~0 F4 j
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。4 O: i/ p$ \+ [' |1 _' m& D% z3 H6 T
) N7 d; W: G0 }. O9 P% S
/ d) }, ^' P3 Y: H5 Q+ P3 w l |
|