|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 $ ^9 T6 U( I- E, r' F3 b f* N
- [code]EDMA sample test application
" G2 b& i. ], i7 o- e - /*
" h3 v, E6 V5 {, z4 P; D* z - * edma_test.c
5 @7 ?, W C$ u" a - *5 {& k$ r9 k) N- G) j5 I2 U) {9 W
- * brief EDMA3 Test Application5 \2 ]+ r) F! K) o2 N' A( d2 T
- *
' ^9 N2 S" b) Y3 Q: q- K' K" l, P - * This file contains EDMA3 Test code.+ S/ O, z% n+ ]9 b# H/ o
- *
! m1 o: w8 a3 i3 }# A7 g) B - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- E' C. A4 p" J+ }1 [5 C - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" }% \' A: f* l! ?
- * TO CHANGE. C6 C# M* [2 O* |. I/ `1 i; U! g
- *
( ]# K% t- A+ M% w: V% o8 G/ ] - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
3 a. ~8 B( f2 I$ J. } - *
3 g0 p6 l' ~' R+ N& S! d, i - * This program is free software; you can redistribute it and/or- c0 B7 t, n. L) w3 l
- * modify it under the terms of the GNU General Public License as* z U) ?2 `0 n0 ?
- * published by the Free Software Foundation version 2.
# |& }/ ^" e' r. Z& L& j - *
4 C. v6 ]$ w9 ?: w* Y - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
0 Z, Q5 P U- ?* F' E1 m; X - * kind, whether express or implied; without even the implied warranty
8 f( ? E! M9 N! D( a7 n - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the$ Q' U C% V9 U. H, o; l' O
- * GNU General Public License for more details.
5 {& D9 e! b; V/ _* c - */& {2 V3 Y: T4 K4 |+ l N
- " o" a% U7 S) _% L
- #include <linux/module.h>
% w5 ]! ?. ^# T4 p# J: ^% _- }* ?! ~ - #include <linux/init.h>( g8 B, y1 K! h1 ]( @ j, R
- #include <linux/errno.h>, \" z! f3 b' Q9 H: t6 y
- #include <linux/types.h>1 _. ^% X8 v+ U1 E* C3 ^! V/ Z2 L
- #include <linux/interrupt.h>: {+ a$ y9 M0 }% E8 `! S
- #include <asm/io.h>
; u! }+ r- z0 Y: Z+ w - #include <linux/moduleparam.h>: t% T8 h9 H" V j+ w
- #include <linux/sysctl.h>
" T4 U4 u% P* K1 g1 [1 q - #include <linux/mm.h>
4 @" ?: h* q' C- _6 \' _ - #include <linux/dma-mapping.h>: M8 S W* r& ^- O7 D) a j) {: m7 x
- : f) ^. h" f N% ?# u K
- #include <mach/memory.h>7 `" C! ~- B; R1 ]- H" U, C
- #include <mach/hardware.h>7 h8 W; @2 b1 q$ ]" ?2 V3 H
- #include <mach/irqs.h>
2 X2 B4 L! A, a3 a- w7 \ - #include <asm/hardware/edma.h>
" D% A0 S& R# J( B
; d1 K; k. J$ U( x+ s- #undef EDMA3_DEBUG4 ?5 m4 H( o7 e. _. H1 Q
- /*#define EDMA3_DEBUG*/
7 X6 _/ s4 e1 I: o
) c% U) \: v" x/ r# v1 A1 F- \- #ifdef EDMA3_DEBUG- p9 a* T) e- h
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 J" h" u0 T! C# u) b - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 I* c/ p4 M' W, M, h8 y$ Z - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__). l1 K! c0 V" o; j) w7 f; b. ~
- #else# H) B7 h! \! `6 i
- #define DMA_PRINTK( x... )
5 }5 U: e& e: l. O F - #define DMA_FN_IN) U& M1 `4 m+ w3 m* d
- #define DMA_FN_OUT# }+ ?" i# O/ Q! }1 E+ H
- #endif* ~ X+ R6 H% w& v3 }# _
( a- |! Z# Z {, ~- #define MAX_DMA_TRANSFER_IN_BYTES (32768)4 I. q7 k( f9 G. }* ^8 d) R
- #define STATIC_SHIFT 31 N, Y: Z- I+ L" E+ D& S
- #define TCINTEN_SHIFT 20
, [' A7 b0 ]$ T" f$ R! Y - #define ITCINTEN_SHIFT 21& b. `/ y! v# W2 W! {/ V# V( H
- #define TCCHEN_SHIFT 22/ W7 o9 A+ x9 S. D
- #define ITCCHEN_SHIFT 23 k3 F1 v$ h; R) Y% Q+ U
- 3 M/ o9 N1 M+ m6 y
- static volatile int irqraised1 = 0;7 q. d7 r; ~" ^* d( S! Y& i% T
- static volatile int irqraised2 = 0;
6 t6 } v2 v/ {5 F+ g* ?) ^1 p - . g* s7 Q& f1 F4 P1 s) e
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( Y$ ^1 n% A5 V& Y& I: y
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 x0 @" d t, v5 _
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) u3 K# n: k+ Q) w4 m# ~( f! D
/ T5 p8 b! p' K" I- dma_addr_t dmaphyssrc1 = 0;5 ~) `/ T1 v/ z) E3 d- ?) b$ G
- dma_addr_t dmaphyssrc2 = 0;9 K4 O7 v& f+ l3 ~5 O$ Z
- dma_addr_t dmaphysdest1 = 0;& k- S5 h9 r! n8 s
- dma_addr_t dmaphysdest2 = 0;
; G: C6 S. T% p1 S
5 \. E1 b$ y4 h: X! c- char *dmabufsrc1 = NULL;, z7 H6 n% _4 e5 ^/ F
- char *dmabufsrc2 = NULL;
& Q# l+ C _$ \; g5 w a( m - char *dmabufdest1 = NULL;: U( Y+ O* i# p: G) w* [# N6 v
- char *dmabufdest2 = NULL;
; C# J5 ^) C% R* _) j
4 U$ z( @8 T6 i: Z- static int acnt = 512;9 o( e6 z" i' G! R3 h3 U1 L: E- q
- static int bcnt = 8;
8 O- _$ E3 d4 F - static int ccnt = 8;+ R- m+ O. \! m9 {( x$ v: X7 }, W
5 @5 M6 d/ N5 X! b( y+ x- module_param(acnt, int, S_IRUGO);
0 J$ v) i4 [6 Y; B) ^ - module_param(bcnt, int, S_IRUGO);
2 Q* p# |9 E2 J4 Z& C - module_param(ccnt, int, S_IRUGO);
复制代码
* R6 C% i T% `, V$ y2 g
' m; \1 d; R [6 p3 v: e: J' O 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用% \# r! T3 m6 Z( ?0 i4 E* @" s# R& J
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
: ~ ~1 c6 g% {" `2 Y 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。3 G4 V4 |; t9 w2 b( ~; M
2 Q/ c8 ^2 F9 v+ V6 v5 v2 c `4 G% `
|
|