|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% o5 B$ v8 X. v7 O6 m" g- [code]EDMA sample test application
3 d1 Q: \, G, y$ Q" E$ t/ N - /*, G: g+ K' [4 v$ \; M# |
- * edma_test.c; a0 \% e/ L* E% ^: h$ a; D
- *2 W4 C: Q$ D& P& V# K
- * brief EDMA3 Test Application
% |4 F7 u2 r2 N, ~) `+ w1 D - *
* `& b. w! R m - * This file contains EDMA3 Test code.
1 ` _7 _9 Z4 k7 h3 X - *
" r5 l0 A% W1 M. n - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
. z, K: z6 k9 u& u - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
; w' X/ z0 _) }2 E; P - * TO CHANGE.! g* A( {% M6 e$ s1 l, [
- ** W/ U# o/ O. Y: u! e
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* x U. L' M. E& Y' V - *
, o& f! K" d, j* T0 c - * This program is free software; you can redistribute it and/or
' _* c1 x/ x$ B2 K+ h - * modify it under the terms of the GNU General Public License as
6 V/ u# M! `3 `7 x7 o& G# }& Y - * published by the Free Software Foundation version 2.
" U* A- _/ A% R5 B4 }) k) v - *
/ i/ R# {4 }/ n! c - * This program is distributed "as is" WITHOUT ANY WARRANTY of any3 J- }3 |5 v- ?) r4 n9 j
- * kind, whether express or implied; without even the implied warranty2 _9 [& T6 m u4 q6 @
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) w% A# z2 u3 O$ B% b - * GNU General Public License for more details.7 h) p- {- V- f2 {6 Z
- */% \3 [& [ E! L) _4 r, q
z; h4 r: d) M" {' I2 Y' g- #include <linux/module.h>
% {" c! _, ]0 _5 r. N3 \ - #include <linux/init.h>
" U- p: K) J- X& q5 @! j$ Y3 a; D - #include <linux/errno.h>( ]' s" ~8 O4 l9 |* ]
- #include <linux/types.h>
' V0 N- @% S' X% U, S1 b) |& a - #include <linux/interrupt.h>
9 d6 M7 r" J% T" b- c% E5 ^% J; v+ O; ] - #include <asm/io.h>
9 j+ |( f/ S" J8 M3 q d2 F3 @) N - #include <linux/moduleparam.h>
% T9 E3 s" A" X/ M$ O& h9 _ - #include <linux/sysctl.h>
8 g r' X9 N8 m! C - #include <linux/mm.h>4 q8 m+ T4 N3 ]6 m2 z1 [* \
- #include <linux/dma-mapping.h>
$ r9 @' B9 m) H- h" V5 C# | - ( e# E8 Y7 Z0 X J
- #include <mach/memory.h>
5 E. q5 |+ g6 G; d8 U& S- @- Y' `+ @8 x - #include <mach/hardware.h>
; X9 {# s' c& j. R9 F% h - #include <mach/irqs.h>
' B3 N) S0 J2 H. G% R, g7 x8 p1 Z - #include <asm/hardware/edma.h>1 }2 D# U3 f# `
- 0 X& f. r8 p6 L2 x) F
- #undef EDMA3_DEBUG
! q% T( f- z) N - /*#define EDMA3_DEBUG*/
2 t$ H' I& g" E9 U( n
1 Y1 O1 y2 |. s) {- #ifdef EDMA3_DEBUG
5 v- O9 Z/ u! N6 q4 [: s, ] - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)9 E* v- v& j% z8 I2 f, U6 l* A
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)0 S4 v% v7 i: l( F/ B& P
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) j6 g* ?3 S w+ ]* n - #else
0 S" Q* r. k% g- Q Q - #define DMA_PRINTK( x... )9 d6 F1 j/ K+ j9 H( v
- #define DMA_FN_IN3 X* ?8 x: U/ v, `) ~6 z7 B9 I" A
- #define DMA_FN_OUT
$ Q0 M6 \+ }* D - #endif7 P. |, \: ^5 F2 d
- % u. b& E; }2 O7 ?: S* K; ~3 L8 J5 K
- #define MAX_DMA_TRANSFER_IN_BYTES (32768). l) K: V* s4 R4 \, u4 n
- #define STATIC_SHIFT 3
# v5 B0 _8 H& z: S - #define TCINTEN_SHIFT 20
5 Z' V0 J& F0 ~- w/ ~ - #define ITCINTEN_SHIFT 21% c/ m( A1 t' \* O6 c
- #define TCCHEN_SHIFT 22
* j* P" a. c8 A- I' Q - #define ITCCHEN_SHIFT 23) `; y" |/ \' Z, E; ~* o# ~6 ]
- 9 L9 ?3 W9 q+ r' H4 H q C( Z
- static volatile int irqraised1 = 0;9 d, B: g+ m4 ]6 ~! Y, z. a
- static volatile int irqraised2 = 0;% U* P9 ^4 {( ^8 h
- ) g' j- C8 x8 o! v3 q
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 q X, M) _) x) O* O* v" w - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ K- `- U5 ]3 a7 w7 z7 a0 t
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& m f) h, `; ]( H) }0 H* @/ b" n
0 z4 d& a7 w, U o5 Y" L# I$ O2 {- dma_addr_t dmaphyssrc1 = 0;1 T' o) r7 I5 Y! N$ U" `
- dma_addr_t dmaphyssrc2 = 0;
0 I* t* K1 C% Z3 j1 a9 Y% q: \# J - dma_addr_t dmaphysdest1 = 0;
: A' h. Q7 u1 u) ^1 s4 B - dma_addr_t dmaphysdest2 = 0;) H1 b9 f2 u, E$ t
) [/ o2 \3 f$ O) \+ Y- char *dmabufsrc1 = NULL;
" E0 P& z6 |4 Z1 | - char *dmabufsrc2 = NULL;* [+ Z8 V4 j. _0 r# K* ?" t
- char *dmabufdest1 = NULL;# q' C. n* m9 O Z3 f( }
- char *dmabufdest2 = NULL;
0 {% Q9 ?' s' F8 A. K9 x
9 O" z0 P( k5 z6 f0 T+ n- static int acnt = 512;
* l! L; @7 i# ?6 B4 ^; i8 f - static int bcnt = 8;: j, }' p9 ~& v* L2 s' P
- static int ccnt = 8;, V( v* R4 \4 x" y
- 0 X* W& y6 o U
- module_param(acnt, int, S_IRUGO);
2 u2 z' a8 U' G8 y9 z4 d - module_param(bcnt, int, S_IRUGO);+ Q" w' W3 j% O* C! K, x: t& |1 Z# A
- module_param(ccnt, int, S_IRUGO);
复制代码
$ s; J& I% m* c/ x; G) ~+ K. b1 K6 s, L0 r4 s' G; D' N; U! J# F' P
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& Z5 ]6 y% }5 h8 X3 G7 E4 h
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
5 Q9 f4 e+ E. _3 S% a. D 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。! E E4 A! l( s. w
- p8 s+ I* z9 l' {& a X5 C
9 @: ^( z+ i. V9 F" R! J9 v8 X |
|