|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 # ^% d- ^+ K% @
- [code]EDMA sample test application
4 x1 a5 _/ E! U - /*7 i d( B: }: L- M' v3 A
- * edma_test.c
2 Z- v4 B: T0 `- T5 r# ?6 K - *9 C1 c( G7 X$ P
- * brief EDMA3 Test Application
1 V8 d9 V0 t/ G0 J s1 u - *
+ o) ~! q1 Q- D/ Q/ q - * This file contains EDMA3 Test code.
' o) d0 q. t+ c% D, I - ** k0 J; \: N) Y
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
7 S0 f5 {) G) h, Q - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT+ S; `3 `5 o$ Z4 ^4 v! s, u2 A! J
- * TO CHANGE.
- u ]. K" ]1 x+ } - *9 p# v6 s$ ]9 V5 [) n3 P& I+ ?1 i. l
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
3 s9 `6 V3 i8 X, o3 Q+ w - *
( r' L7 g: N5 l - * This program is free software; you can redistribute it and/or! E& C, z/ Z6 `8 u# z1 ]5 [( ^2 o
- * modify it under the terms of the GNU General Public License as+ t2 b, ] p1 m# g; X/ a" K
- * published by the Free Software Foundation version 2.* Q2 O8 z% S& h& j1 [
- *3 R" o' A% r0 X. A
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any! s4 Z0 s) g7 J. m% \; i+ Y2 B
- * kind, whether express or implied; without even the implied warranty2 v/ A+ b2 u, p6 u0 a
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1 y; ]1 N* N4 m% \) V2 M5 } - * GNU General Public License for more details.
V1 ]( r7 h* n6 H6 x: _6 j/ _ - */
4 t0 O3 u0 }( o" F - * t6 p8 h) d: p0 `: J- l$ p
- #include <linux/module.h>! B k& t6 V7 q# [. n
- #include <linux/init.h>
/ ?, \8 Q2 N) H% y, _2 l - #include <linux/errno.h>
5 ~& B" M8 ~8 L4 ]4 [) W - #include <linux/types.h> J+ k% z" U/ F8 I0 J5 p
- #include <linux/interrupt.h>; i3 [6 ?0 k- i/ ]1 Z7 i
- #include <asm/io.h>
3 U% v* ~" R, _ - #include <linux/moduleparam.h>; u8 R7 d: J* ^! Z. V. k2 R
- #include <linux/sysctl.h>4 U1 f" p6 t9 h: N
- #include <linux/mm.h>6 ^2 o+ A& \! N2 M+ x) G
- #include <linux/dma-mapping.h>
0 `- d! W1 N& ^& A; a - r" ]9 M4 u( o9 I& [( w+ P
- #include <mach/memory.h>3 S" R- V$ F& I# ?# u* W
- #include <mach/hardware.h>
$ `& `" J5 O9 g - #include <mach/irqs.h>( [/ s8 v9 y2 o( O8 u: G# e
- #include <asm/hardware/edma.h>8 Y+ S! _- k' S5 T J
- 2 W' P f* O& a3 A
- #undef EDMA3_DEBUG
% m8 e8 I$ s% z4 c [ - /*#define EDMA3_DEBUG*/: d) h$ O- [ N
- 9 _1 ^4 k: m9 ~9 d. C2 Q
- #ifdef EDMA3_DEBUG7 J9 a' X; ?& ~) W( ?3 G( z' M
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
" \+ {: q W6 z5 p* { - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)% s) `* x& D" [2 S
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
* q% e; r% S7 X0 H' y - #else: P' x6 k& j4 \. r- M4 M8 M
- #define DMA_PRINTK( x... )
; B& `8 j4 m/ O. ^8 A, E - #define DMA_FN_IN4 U4 [3 l1 d! \6 X! L
- #define DMA_FN_OUT1 ]# g8 F( D. Z' H7 W
- #endif5 e" l+ o4 ?) G9 O1 n
- : N& q: {# ^# C6 U9 x, I- R( ^" R9 B
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ W. k0 }( ]0 B - #define STATIC_SHIFT 3
8 J/ u% D0 \8 k9 t - #define TCINTEN_SHIFT 20
9 ^3 A% k! z4 w S5 q6 v+ Q - #define ITCINTEN_SHIFT 21
. k! C" J1 r( c7 L4 `& N - #define TCCHEN_SHIFT 22
9 }3 A/ p0 l# y - #define ITCCHEN_SHIFT 235 |% ^" C; }& i( H" W- u
( I2 ?& ]* x6 h" a! e: d5 v ~. ~9 q- static volatile int irqraised1 = 0;0 U' J* o+ d0 T+ p2 L: X
- static volatile int irqraised2 = 0;" L6 m0 o, I& V
5 v( o# y% h8 j# s! F, ~, i+ x- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' F3 u f: w- P3 [ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" Z- V' s F7 t9 ?& Z) y1 s - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); }9 K$ k2 I% D* ^! O
- 1 b( ]* y6 x- {+ M8 n
- dma_addr_t dmaphyssrc1 = 0;' @. G) x+ F# h2 |* q: [- Z4 F
- dma_addr_t dmaphyssrc2 = 0;
( k" J" x& P$ A/ V l: f9 Y; t - dma_addr_t dmaphysdest1 = 0;
9 D' n( S+ p3 U" ~- l( Z2 V( u - dma_addr_t dmaphysdest2 = 0;$ q! d% e3 Z& b+ z0 m0 u
5 e( Z! l" i Q# Q: g8 D$ _% d- char *dmabufsrc1 = NULL;
2 |5 G& ~* p# Y. g" a4 Z6 C - char *dmabufsrc2 = NULL;5 B/ }) F' ?$ S4 m7 X' z
- char *dmabufdest1 = NULL;; \6 U% ?; v' T% ]- ?0 t
- char *dmabufdest2 = NULL;
M, b1 e5 A) v. ~
2 q- i# s1 s1 x- \: ~8 W2 C) T/ w- static int acnt = 512;/ A6 j# m* Y. N3 W2 u" m, u
- static int bcnt = 8;/ Z& S: L( A5 f, h _
- static int ccnt = 8;1 l' H, N5 I1 C8 J& M$ b
- 4 t. X# L7 k: ^' l, p# O# l6 g. w
- module_param(acnt, int, S_IRUGO);0 s( |8 Y! j& E6 O! q6 T
- module_param(bcnt, int, S_IRUGO);
! K# m. p! i& E U7 x" k. ^$ O* ^ - module_param(ccnt, int, S_IRUGO);
复制代码 + Q: J2 m3 ?, {8 j; b
; S( c; A! ?1 w3 O$ W' \; _3 |
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
; G( l$ Q' {! a! S+ F" }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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
2 j! l1 g' d. `# i0 _: |! N# C 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% z& W4 ~9 B( H6 r' P( l8 `6 a, D- n- r
; d1 L* R+ O8 X |
|