|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 x, p0 {, j; E8 |4 Q3 y4 N- [code]EDMA sample test application
# X) Q0 b9 h3 a Y8 m - /*
3 w+ E4 {2 |. L( d3 @1 N3 w. y - * edma_test.c* R/ e; k8 |3 f
- *
8 q* I- y; R; f$ a - * brief EDMA3 Test Application/ l4 b! C& c; |
- *
/ a5 [& C3 M' O I' m% P: ^ - * This file contains EDMA3 Test code./ v* m6 q7 F! z" V: |
- *" O6 |2 y+ M G, k* d
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE9 n" m8 L8 c9 {: s% u. q
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
1 f. u- e# S' P$ n+ X* ]! z' j! b - * TO CHANGE.: N% ?* D: l3 C/ x+ X" x
- *8 x8 H8 ~3 C: v. }; p
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
# |) M) G3 u |/ h - *
( o4 U3 t" I2 Q9 f I! V - * This program is free software; you can redistribute it and/or
+ @/ a6 A4 `; @% |+ z c7 B - * modify it under the terms of the GNU General Public License as
* L6 i1 J6 ^9 Y/ M( R `4 [: m - * published by the Free Software Foundation version 2.
$ m$ M% ]7 R& ~/ N# L. t: x7 b0 V - *
* n' Q7 j9 G( v% O; y- ]! ]& Z5 f - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
) z6 `! I L6 Y2 a# A3 I2 n - * kind, whether express or implied; without even the implied warranty1 C& a1 C3 b) K. C9 ]6 G5 Y
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the5 p8 N- I# u0 M' z1 L; b+ ]% u
- * GNU General Public License for more details.
1 O8 M( u! T+ f4 X+ \2 n- L3 g - */
# T. c6 h6 p5 ]% E } k6 }% Q
6 R$ Y6 l' Z0 |) }! e- #include <linux/module.h>
& X/ M8 }- O8 R - #include <linux/init.h>% `+ E* H. E. J% |; L& S. y! x
- #include <linux/errno.h>; m: j5 v6 o# m4 H" T8 U
- #include <linux/types.h>
7 y4 A1 ~( Z7 q2 J! [2 m - #include <linux/interrupt.h>
6 X/ g6 M/ V0 {. V ^. W* E - #include <asm/io.h>% \; d8 D8 U6 e0 W& r$ Q
- #include <linux/moduleparam.h>
" ~& ~. `' k" g0 F0 |0 G$ V/ `1 G - #include <linux/sysctl.h>
0 W2 T- h0 [) R% i/ v" i+ Z, Z - #include <linux/mm.h>
7 T: ?* J: L" x3 t; s. L% O - #include <linux/dma-mapping.h>7 {" x' l( \. C" g# W" I
- : j# K/ `( |) U) \: `7 U
- #include <mach/memory.h>7 [( q2 E, L; g2 @2 q% L
- #include <mach/hardware.h>
* p* [, P5 Z' V# G6 Z g - #include <mach/irqs.h>
! E" Y' R: ~/ p% W8 v+ I& l - #include <asm/hardware/edma.h>4 D$ l! d; {2 d4 y; G, g, ~
- i! w" | w% B, {, B' p: G1 R: Y# A- #undef EDMA3_DEBUG8 e4 v2 r$ L& u; {& w3 B: w
- /*#define EDMA3_DEBUG*/( n5 h" [8 T* f$ J& }$ x4 F% h8 P
" {, _. o+ r- s1 @ Y1 F- #ifdef EDMA3_DEBUG; l* a5 ^; m9 { c+ _9 D6 Q
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
3 h/ Z, {4 u0 q0 f% [) g6 C, I - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)8 s- r+ K/ p/ \& ~8 z! Y- A8 N6 h2 i
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( J7 J! Q# l& U+ k8 H1 j) X6 f4 a
- #else
7 ]# \5 p6 {5 [* N) v5 c8 \ - #define DMA_PRINTK( x... )- v& @$ F$ S& z$ v
- #define DMA_FN_IN
, r$ v$ J, Y+ ?; ?: Q+ J# n* [ - #define DMA_FN_OUT6 x: O: @) G) ^. n- k0 z
- #endif; ^% {0 T% }' R& Y! Z: ?
- , X" k9 |9 C+ F4 p# ^- x
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
6 A6 o; a$ I9 L7 ? K - #define STATIC_SHIFT 3
6 u w" ~. l) J, P- H+ D9 l - #define TCINTEN_SHIFT 204 o: f4 L/ g( g# y: D* B$ Y
- #define ITCINTEN_SHIFT 21
% }& v4 d' e& } ?- q' F" Y8 j - #define TCCHEN_SHIFT 22% H0 [) R: U5 n0 y- ]7 ]
- #define ITCCHEN_SHIFT 23' H3 J9 r; H! V
- * r# ?0 [- a( r6 m
- static volatile int irqraised1 = 0;, w1 a: R7 i7 }: X e V
- static volatile int irqraised2 = 0;
) n2 t( k w3 I" l$ {6 ?: q
! g5 u- g! V) t' X- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' }. M% {3 z! I& ?
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 f2 g$ \( \. V7 g9 m - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, r! E R& p5 x Z) o! {
/ S. m! o; C z ^- dma_addr_t dmaphyssrc1 = 0;
- |! z1 i8 [" W8 r6 \" Z3 e9 G - dma_addr_t dmaphyssrc2 = 0;
2 o1 l! U: U9 H$ l0 T0 j$ T - dma_addr_t dmaphysdest1 = 0;
7 R% ~: u9 E, R2 e/ ~ - dma_addr_t dmaphysdest2 = 0;" _! P6 B0 Q9 C/ J- d8 |. y$ e
- ! H& v4 m2 ]- @1 E+ @
- char *dmabufsrc1 = NULL;
& m5 g9 Y C6 O/ ?: D6 u" g" o9 y7 x - char *dmabufsrc2 = NULL;
x8 z# T) Y4 k( m1 A4 l - char *dmabufdest1 = NULL;
1 m% M; ~, f3 |: m - char *dmabufdest2 = NULL;# q( S% F' e5 \% {
- . r, Y/ ]4 h, z
- static int acnt = 512;
. o( ~6 z1 L7 u/ N+ i - static int bcnt = 8;2 ? w! p" }- x
- static int ccnt = 8;
6 K, D/ y( @3 M9 r- ?; p - 3 ]- a' H# K9 G& G1 K, B
- module_param(acnt, int, S_IRUGO);
( B- | c/ }' ^5 A& r0 ] - module_param(bcnt, int, S_IRUGO);3 h$ v9 r# s# s4 d E9 S
- module_param(ccnt, int, S_IRUGO);
复制代码
4 r3 P! @3 x3 i- c) i- p+ N5 o! b' m8 l* n5 Q
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) ], X0 F) x5 j# {9 b1 |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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。+ } D/ [9 a' b: D5 n1 w: l# d
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
M3 V3 U+ r# @
. E2 ^$ ^+ B {+ E1 {3 O, q. D
+ o9 {) E% g. j/ x |
|