|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 C' {6 N5 K3 M3 F ^2 a# A- [code]EDMA sample test application
1 n+ r F3 i. l' C9 K* v - /*
) `/ S! c; T$ `! N R0 { - * edma_test.c
; G& h2 ?% M* \2 t - *2 |) p# |0 u6 t: w6 O/ m) W
- * brief EDMA3 Test Application
! u5 V% i8 A8 n' ^3 p - *" y% a& m- p( |4 q
- * This file contains EDMA3 Test code.7 \8 R3 r2 p6 n# n5 J V
- *$ ]1 K2 o% z/ V
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE; _3 B q; B# w6 Y5 m
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 F% A- f/ l, h
- * TO CHANGE.4 H: N* N$ A* p! R
- *
; H! E; ?6 D3 V6 Z - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ U1 E3 ?8 F4 E& @% y0 W - *
; \! \) ?0 r& t: M - * This program is free software; you can redistribute it and/or F' L% z* e: s/ J+ j8 h5 }; @4 }' ]
- * modify it under the terms of the GNU General Public License as
" ?) i1 r3 O0 e/ v - * published by the Free Software Foundation version 2.
# j/ ~2 N4 ]( v5 y% j, K - *
! M- \# l8 ?) s! T$ m& R - * This program is distributed "as is" WITHOUT ANY WARRANTY of any" v% c" r# K- v
- * kind, whether express or implied; without even the implied warranty5 y+ \! O1 l# R( Z. F7 c9 x# A
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1 {+ ?4 e; P! s9 F8 q
- * GNU General Public License for more details.2 H9 V5 o" }1 v4 `: K0 C$ n. `9 I
- */
+ |, Y7 l# P% g$ [! E
6 m9 b; ]' `0 q/ ]* a- #include <linux/module.h>
% G* U6 e! H6 C' m/ H - #include <linux/init.h>+ [" u+ P1 P, ^0 i1 E
- #include <linux/errno.h>1 z; I- g% P7 s9 M
- #include <linux/types.h>/ G: K6 T4 ~3 B9 b0 R, S7 W
- #include <linux/interrupt.h>3 I7 q% I$ K& Z% W0 t
- #include <asm/io.h>, i- @, O- Z, }( d8 \' c# a
- #include <linux/moduleparam.h>; e& Y- T) _& u: E
- #include <linux/sysctl.h>, c) K2 a Z$ d. b; N
- #include <linux/mm.h>
# v5 h) e) z V( @$ R* C1 C - #include <linux/dma-mapping.h>- E& k/ W- I' Y% X( \4 f' y; j/ n
- $ J" \/ T. x# \0 u
- #include <mach/memory.h>0 X: A- J) v1 Q- F K+ M* E" o
- #include <mach/hardware.h>
( ~; Q0 i% }. k3 e - #include <mach/irqs.h>
& O9 }( n: q( n: O- O - #include <asm/hardware/edma.h>
1 K# ~# O, K& n0 [; l" g7 O9 H( {1 x - . f) E: }. i6 P3 l8 j* _6 c
- #undef EDMA3_DEBUG
# _( p- S' b. f$ i" ]4 M) S; Z - /*#define EDMA3_DEBUG*/
; h( o7 S& b, m - ! d0 g9 J0 ^& L9 W$ s
- #ifdef EDMA3_DEBUG
v1 X% a b! x& c- C* ?9 s9 r - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ B" L+ G. `. l4 ^ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. L' B) t. j9 q5 R - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 }7 H" m' |6 u, O5 C5 O, M) G. O5 } - #else
# ^0 l+ }" E* D0 {8 C - #define DMA_PRINTK( x... )) q0 o. W3 e/ C6 A$ A
- #define DMA_FN_IN
2 B I2 _5 Q [) m) z! Y- n - #define DMA_FN_OUT3 v: T0 V. ?; n
- #endif: {7 L$ y8 p. R
- $ u- e, k* ~. N/ T% }
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)4 [4 ]* M) E, W9 n+ ^7 J
- #define STATIC_SHIFT 33 z- X$ z: a) X4 R
- #define TCINTEN_SHIFT 20
. z; d- c" s+ j* k! {& p: @1 Q - #define ITCINTEN_SHIFT 21
4 Z& V+ l" v2 d% [( C$ ?# _ - #define TCCHEN_SHIFT 225 s7 i; {, \/ l, `3 L3 z) N$ A
- #define ITCCHEN_SHIFT 23# s& ]4 R. S* m3 S! p6 m
- ; J+ t2 W5 w: p, X1 w6 E6 \+ F
- static volatile int irqraised1 = 0;
' T" |8 a4 l7 x. X - static volatile int irqraised2 = 0;! r R% T; C7 }
- ; P# U" u/ R, T
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: u- m& Y% w2 x" [8 R* }2 I
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- s4 y- e [( B3 a8 ?0 e
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 o( ]3 j9 ?* |! c: l5 r - ?7 ] S0 b8 R9 x' E
- dma_addr_t dmaphyssrc1 = 0;& H3 r& O% p& t) ^" D. m' h
- dma_addr_t dmaphyssrc2 = 0;
8 G6 I/ u5 ^' Y9 Y' ]" y0 n) f - dma_addr_t dmaphysdest1 = 0;8 m1 r% U: V/ D5 Y, e
- dma_addr_t dmaphysdest2 = 0;5 o( f) | X; F1 [! n% P7 h
- , B i5 ?5 k8 @ H
- char *dmabufsrc1 = NULL;
8 p: U) G, i" a- [3 ~ - char *dmabufsrc2 = NULL;
: n" c6 K; e5 c& K - char *dmabufdest1 = NULL;
. V8 m6 B# ]& C - char *dmabufdest2 = NULL;
% c- A: q! x, Q0 }$ E# m" s$ ]$ b
5 D& ~1 C; a# k; T; ^- static int acnt = 512;- O( r/ g0 C v8 r8 `' ^
- static int bcnt = 8;: E) x2 T& j/ E
- static int ccnt = 8;" ^; X( I/ V* R
- ; s- ?! |. p! c2 i6 {/ V
- module_param(acnt, int, S_IRUGO);
; K$ V" X7 p8 V( @8 g& L! M - module_param(bcnt, int, S_IRUGO);7 t8 K) f# E, I
- module_param(ccnt, int, S_IRUGO);
复制代码 ! b0 f6 |! _9 L% J* a% D2 O
- k8 Z7 K+ [9 Q( S2 S% \7 B* z" z4 _3 B( k
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
% o: q# o; B$ w$ D( zarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。& \) `' X9 D) V+ t% I' ?5 p! |
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
6 d5 a) f" s! V: Y J! Q6 t
, ^( X/ m% j1 P4 i* I1 Q4 Z
5 l8 G8 N7 `1 A* ]* Y& B |
|