|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
' N7 d: V) Y U1 c2 V: G4 v+ f- [code]EDMA sample test application
, O- h, t" x& L0 L$ \ - /** J H& S: u2 ~1 E8 r
- * edma_test.c
# \3 a6 M2 T1 x) S; t) h. F - *
3 I# N( h" \. e- E4 t* x - * brief EDMA3 Test Application
. Y2 Q2 d) L! P* _& [/ L m) ? - *
$ h. _- `6 h7 j$ X8 v - * This file contains EDMA3 Test code.
$ B9 s! ~% S& R C3 ?8 W - *
9 t0 H# M9 d# }5 S2 o* ? - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE1 _) l4 X& z. a/ E% N& v8 W
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT: C, V; X; ~3 R8 W' R, s; k
- * TO CHANGE.( n. K% m) S: A
- *$ g1 I( `# g4 G
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; K# [4 t, U' c: l1 f4 a c" k - *" z% }2 r( r0 B9 Y! R
- * This program is free software; you can redistribute it and/or
! c4 `1 B. H. |* v, p6 A# T - * modify it under the terms of the GNU General Public License as
7 V0 M5 v. K! Y - * published by the Free Software Foundation version 2.
+ v) N" H" A$ K1 ~ - *
, I O3 A) S t1 R5 _2 \/ Q% g - * This program is distributed "as is" WITHOUT ANY WARRANTY of any) I& {7 J' u- ?0 V2 g- U
- * kind, whether express or implied; without even the implied warranty
( D- ]7 y) s: q* j$ O - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 {/ l S7 ^9 i- \$ Y: } - * GNU General Public License for more details.
# C/ v1 x% K1 m6 m% r - */
! ?1 [0 h; d+ a( A% o, G - 7 s0 X) J2 ^# d" j
- #include <linux/module.h>
6 Q( b% N; W; Y' ` - #include <linux/init.h>5 d: G& J, m: k2 r$ M
- #include <linux/errno.h>8 v1 o. x+ f& x8 W% h/ S0 \
- #include <linux/types.h>
' x$ w. j; C3 p; U! c6 f1 M - #include <linux/interrupt.h>
# S$ u( j- R# B# S% `7 F - #include <asm/io.h>/ G9 d* n* g: }4 y- d# W. T
- #include <linux/moduleparam.h>
$ ~5 x$ v3 p2 k0 ^+ M - #include <linux/sysctl.h>: |' f8 j( W6 Z6 D9 C; t9 N% Q
- #include <linux/mm.h>
+ R0 b4 R5 O1 j" o - #include <linux/dma-mapping.h>
! O4 o0 y1 r) h ?
. W4 Q' b# ^9 Z7 i: x/ R& n- #include <mach/memory.h>1 D3 @+ O4 O3 z8 [: {
- #include <mach/hardware.h>
( {9 q3 A) _; b - #include <mach/irqs.h>8 f( V4 ~, d% _, Q, y
- #include <asm/hardware/edma.h>( x% E2 `! H" g" t
- - t& ^$ m+ k, o' J" e) ]* j/ ~
- #undef EDMA3_DEBUG
4 Y4 V/ K. V. s; u' t - /*#define EDMA3_DEBUG*/' p+ Y" }4 \! |
- 9 r- K- M1 h2 t$ F1 R0 g: o* V, i
- #ifdef EDMA3_DEBUG
2 d7 e w4 m! E& G1 R* R' u* l$ | - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)1 S+ H4 Q) f3 d: `
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)4 A, m( j2 f3 x0 G. i
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__); z2 T% D* v- a/ J6 U& {* c
- #else+ e- D. I3 s- u( A) {# [8 ?
- #define DMA_PRINTK( x... )
3 I5 A a; L0 J; G - #define DMA_FN_IN
# i- \6 j$ c+ h/ b$ Q& {0 ? - #define DMA_FN_OUT
x9 u7 X+ J/ Q% E - #endif
" q' r& `+ p8 L* |" P - 2 m, w) o: ^6 m
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
( v0 V% e# ]% ?; S! T - #define STATIC_SHIFT 3
" X' i; ]8 s1 X1 m' ^ - #define TCINTEN_SHIFT 20
- W- ~8 ]) w4 G- K0 j; q - #define ITCINTEN_SHIFT 21& c4 h6 N0 R1 S8 W% p2 |8 U
- #define TCCHEN_SHIFT 22
9 @- _) J3 D" ~4 g - #define ITCCHEN_SHIFT 23
/ M: f9 D! r$ g5 }; R) j( Y% `: z) Z - 4 g. f' \% f- p) t1 g; r6 u
- static volatile int irqraised1 = 0;
" h0 f" |8 \: {+ Z - static volatile int irqraised2 = 0;
/ O# f2 @* C0 m$ [$ F
; }0 p) y" \1 d% L, N; S0 H- A- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 q) m! H: v9 V [7 q0 c& @
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% T! a1 K/ o) g* ^
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ A( i8 a1 d R4 e
! P9 I0 G _! S# v- dma_addr_t dmaphyssrc1 = 0;
/ O. ~6 A l& ~* o6 G( J - dma_addr_t dmaphyssrc2 = 0;
- S$ \ m3 P: `! A - dma_addr_t dmaphysdest1 = 0;7 w! I" \# B, [% K' n h k: r
- dma_addr_t dmaphysdest2 = 0;
9 q- S$ }) _/ z7 x - . u+ S) s8 O+ j) _: r( C) ~; _1 d
- char *dmabufsrc1 = NULL;
0 c/ W) o# i& y9 l - char *dmabufsrc2 = NULL;4 B0 P H& f* [ b
- char *dmabufdest1 = NULL;
2 i3 k: S, g: e( D' c; V+ B) n - char *dmabufdest2 = NULL; l& a3 D0 H' S9 S
- 6 Q/ o& ~0 A" m5 j" m' f R5 K! e
- static int acnt = 512;
& Z1 c# f9 X/ k - static int bcnt = 8;8 r" q$ Q: b+ u7 S. H; j9 D7 `
- static int ccnt = 8;0 a% ]7 k9 T, i. y9 N/ }/ |, n; H' M
- ! `. {8 Z2 h% M6 J3 h9 n; R/ Y/ l: d
- module_param(acnt, int, S_IRUGO);
; L# Q7 ]. A" v0 ]# L - module_param(bcnt, int, S_IRUGO);
3 p& A3 q: f9 ~7 Y) G8 L; T - module_param(ccnt, int, S_IRUGO);
复制代码 6 O) I1 F' I3 r% C4 P" x! O
" R0 N/ g; J* `: N0 F( Y) @ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用' V. k- k7 Y) K
arm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。8 K' d" f: o4 ~2 w$ q. G, A
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。9 |+ f8 O4 h, n, |3 m2 w4 y1 D; M
1 A* M; A$ H6 |; }9 r: K3 e- L) O
# y8 [8 D3 s5 U7 J& r$ I |
|