|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
- x, F5 a5 |% _& a# V# b& Z- [code]EDMA sample test application
) z7 b5 a, k8 Q( r - /*: C( z4 q% C5 q' x4 T
- * edma_test.c
: Z& D* W9 i; T( Z - */ Z* W7 T3 B2 P2 K; F: I7 y
- * brief EDMA3 Test Application+ \1 r4 G1 i7 G+ ]& d6 [
- *$ u% h: T$ T6 V# {
- * This file contains EDMA3 Test code.
0 o& [1 |' Z* W% y5 X) l0 [ - *- j9 [1 K3 Z3 G+ s
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
8 a2 r/ w1 n, \2 O - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT. h2 J6 u' S$ A0 E% A7 x2 q
- * TO CHANGE.
2 y: l9 X& d: l5 f; L - *. X) ~+ i) K! f3 n! g {' m
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- y% ]* t0 p* D, L
- *9 r$ U4 K/ g% z0 m! ~
- * This program is free software; you can redistribute it and/or
6 t! a" e" t2 } - * modify it under the terms of the GNU General Public License as
! D7 e6 |" y G - * published by the Free Software Foundation version 2.
1 [8 l& u) |& X; T! t" f - *
4 W7 c% c9 r; x3 D5 [ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 g& f" k( j1 N. @; B, t! P
- * kind, whether express or implied; without even the implied warranty; R8 I; z( l1 f6 m- S: J2 w6 N& C
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 s$ t* G. _, n; R - * GNU General Public License for more details.
& B& k p% F; @9 o - */
1 q. F. S' Q$ M3 b6 i; o - 0 x: X; ]) Y& C7 u8 A" n! W
- #include <linux/module.h>
, G0 O' W2 [' A# ] _ - #include <linux/init.h>
+ r+ l' E! N, X& F - #include <linux/errno.h>
, j3 N$ q# T/ V7 X3 m! i( O - #include <linux/types.h>9 p1 K; m/ {2 K7 u" w
- #include <linux/interrupt.h>% D6 u) p) m6 Z. ]+ h- v3 @$ W
- #include <asm/io.h>1 A$ J4 M7 `, C" [* i
- #include <linux/moduleparam.h>
6 O% K4 [% Z# b; m - #include <linux/sysctl.h>& Q' z$ q3 T H1 q: w* O
- #include <linux/mm.h>
d/ P- w* R i- L! C b+ E - #include <linux/dma-mapping.h>% Y0 \" o* n7 }4 T
* p& ?! j2 h8 E- #include <mach/memory.h>
9 W7 i0 H) Y9 Z - #include <mach/hardware.h>
$ a6 `# T1 u, G X6 {, o - #include <mach/irqs.h># k8 I# W4 {) D( `/ }0 u
- #include <asm/hardware/edma.h>
6 v* o2 l+ ~8 ?/ \" Q5 r ^ - 3 o8 N# _! d% a
- #undef EDMA3_DEBUG( y" b7 X5 i5 K: `7 f9 G$ `
- /*#define EDMA3_DEBUG*/9 }1 v7 k0 v1 x' ^: y/ o! H5 G
0 g2 Y! [ r1 b- #ifdef EDMA3_DEBUG* E) f3 V: D( Y. w) S+ z% y3 \
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)/ w# G! S2 B- }6 o" N7 j
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)! l7 t6 [7 y# G2 ?- i/ E& \
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)9 q& g3 w3 Q' b R! m5 K
- #else
8 r, n* g2 a9 B: M- P# N+ \# \ - #define DMA_PRINTK( x... )+ t4 N- c4 w# o9 ^; J
- #define DMA_FN_IN
+ ]8 \. V# a; e+ Z - #define DMA_FN_OUT4 x& ?1 f. u4 \$ g% \8 V, J, j7 S
- #endif$ d3 E0 U! M! u. N9 X
, D% D) y2 y9 i- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
' C6 l0 t1 f1 D- @7 n# U6 H' s0 c7 i - #define STATIC_SHIFT 36 c3 w, W/ T7 H& o& F1 L8 g& t; G# r j
- #define TCINTEN_SHIFT 20
5 T. [8 L; D+ S; s8 |- k8 \: h - #define ITCINTEN_SHIFT 21% U" |& b) K9 U5 U! W
- #define TCCHEN_SHIFT 22
. }9 P7 I8 F& T - #define ITCCHEN_SHIFT 23
& k* @; Z6 S- j( C - # z& i# N% B( Z% S, l
- static volatile int irqraised1 = 0;
' w% G( d6 d3 i/ h6 r, G% k - static volatile int irqraised2 = 0;3 z- t" P, H5 J) i- j. n2 O9 j7 g* d% z
- / `# P& p! ^' B( u' l: s! H& R
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 g9 }9 B) J' |' q, \
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. `7 U" E: `6 n ] - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 G2 z# _' G3 l3 S7 v7 m+ T
- 2 j, i7 W2 L" `6 f) e1 t4 B
- dma_addr_t dmaphyssrc1 = 0;
/ }$ p8 `1 Y6 b! z - dma_addr_t dmaphyssrc2 = 0;; W! A w0 i/ P% l
- dma_addr_t dmaphysdest1 = 0;
+ [8 w5 P0 J5 a) J$ E9 b - dma_addr_t dmaphysdest2 = 0;
- d& ]9 u- m0 H - - ~- ~: M2 f! F9 O
- char *dmabufsrc1 = NULL;
! z. m& f9 S5 D Z( H5 w2 y - char *dmabufsrc2 = NULL;, w& f: }4 e1 N0 W/ y8 E
- char *dmabufdest1 = NULL;- u" U/ W2 N$ ]1 \* t0 a. h% R
- char *dmabufdest2 = NULL;" n9 @4 N0 b( p. [/ C. S
- 3 ~/ x( W* F. M) I" w$ L' I
- static int acnt = 512;
( t+ x# W" p+ L: b$ W8 c1 b - static int bcnt = 8;
' H y* d; W" H6 ] - static int ccnt = 8;* D* f* q% c7 H# z, q
6 [$ o. w8 C- b/ O- module_param(acnt, int, S_IRUGO);; s: w5 E, w0 p7 C/ O2 E) N3 m
- module_param(bcnt, int, S_IRUGO);
. o* g- N, ]$ T/ k - module_param(ccnt, int, S_IRUGO);
复制代码
- a& y, N) O1 O9 [( I9 z5 ^: F4 I3 S1 z1 T' w
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用' H3 _8 f- O7 Y7 G1 n
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。' |6 k6 K* F0 R- ~% G
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
; e ]. w7 t- p
7 H/ T4 G2 R p, T- k2 h5 V3 }9 ~- I6 {" `
|
|