|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 G( f; E/ b! o5 g8 K: @- [code]EDMA sample test application
3 J1 j0 v; l' P- u4 L p - /*
' g0 m) |; E! f. f; v+ } - * edma_test.c5 N1 v1 l2 R/ n( o7 s: B7 }& o
- *
& w' w' A# L! b$ f" u5 @9 s - * brief EDMA3 Test Application7 R$ T& `2 `5 ~8 w6 `$ U
- *
6 w7 f( C7 E) C - * This file contains EDMA3 Test code.
& G! S- l$ @( ~- I- I. n3 L - *
/ Q4 [7 A) [1 |3 ~ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE+ z) M3 D/ D& h( i9 @) d. A
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT P& e. F& M0 K/ s
- * TO CHANGE.8 e4 E* T$ |. |$ G A
- *
# Y) a3 s! @ J - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' U/ ?/ Q6 ?* U$ ^3 J- ^6 [, d - *
5 e8 H) g4 t/ i. K2 c* I5 k - * This program is free software; you can redistribute it and/or
! D9 E ]: K0 x; R - * modify it under the terms of the GNU General Public License as' i# T+ k' _, {7 `4 a9 S. h+ ]
- * published by the Free Software Foundation version 2.) }' P6 p) P5 x) x' x
- ** e B$ d# Y) T+ A/ p: L0 Z0 ?
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any* F$ \% t" Q; p) K4 h
- * kind, whether express or implied; without even the implied warranty/ a& H0 O) v8 u. p& V9 o
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" l: Z$ `, a0 z
- * GNU General Public License for more details.8 x/ X% h7 q v
- */1 h0 s! V1 Y, G6 T) t3 A: q3 A
9 |" h+ q2 S& R7 X3 K+ ~9 S- #include <linux/module.h>
, @! h) V* g5 ~1 w- o - #include <linux/init.h>
# f2 Y; R# q3 v3 c% O - #include <linux/errno.h>
- e, t& u5 Q- C; y. S5 W& y% y - #include <linux/types.h>
! P5 m: H* W6 Y/ L6 i v - #include <linux/interrupt.h>; ~7 W8 A, p4 o2 l# M
- #include <asm/io.h>
7 \* X2 M) Q$ W* u - #include <linux/moduleparam.h>, @6 O! J/ ]0 t# o
- #include <linux/sysctl.h>
; d! f3 i/ V" T - #include <linux/mm.h>2 p2 ~: g, g. |. q/ F
- #include <linux/dma-mapping.h>
0 A* K7 ? t( U2 {# w3 ~* z1 H - , |; g# J- k9 M% ~3 R# [- G
- #include <mach/memory.h>: \" K2 ~, z6 h* e5 i2 b
- #include <mach/hardware.h>3 A4 y, G- E8 ?2 w' o- D( V9 w
- #include <mach/irqs.h>) I$ D0 S! E* q! J
- #include <asm/hardware/edma.h>) f' F* f& m2 k( l7 M1 @
* I8 }6 Q' `* L8 `' t( }- #undef EDMA3_DEBUG" a/ a, y0 E2 K9 j
- /*#define EDMA3_DEBUG*/
" R4 ~3 F) d; P( P7 A+ o
k" y# q( L; I2 l6 r) I! ~- #ifdef EDMA3_DEBUG* y. [3 _! H# r% X% j4 r
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
2 [' x6 i; Z9 b9 V! t( c7 ] - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 C) @. g: a5 y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
% e% |7 t+ w% t, ]# V! M, H - #else4 C# J. P! [0 a- R3 z) a8 j
- #define DMA_PRINTK( x... ); l6 A3 {+ Y+ I/ q# o9 ?
- #define DMA_FN_IN
9 j; | m$ P8 V0 h% i% ~8 m7 H# C - #define DMA_FN_OUT& i- ]3 v5 \* i& Z6 F) {/ K
- #endif
- @' k5 x1 W$ W( Z3 [2 \6 I+ } - 8 {. C% Y$ v5 g# u
- #define MAX_DMA_TRANSFER_IN_BYTES (32768): i: z" D9 A' B
- #define STATIC_SHIFT 3
$ }: E1 F$ M6 `) B. g; S1 ^ - #define TCINTEN_SHIFT 204 ]/ {7 n2 u& c+ i7 J9 t& p* ~* V
- #define ITCINTEN_SHIFT 212 U5 Z; _; n; Q! C% w8 f/ P1 \' u
- #define TCCHEN_SHIFT 22
$ h/ {" u2 S5 k5 \ - #define ITCCHEN_SHIFT 23& p$ ]3 Y$ z: R- `$ B
) b' T% Z! g$ |; N ]" a0 j" ^- static volatile int irqraised1 = 0;
( P) S! T3 L+ J6 }! k6 z# G - static volatile int irqraised2 = 0;
$ k* \: d+ X2 E
3 V, c5 i) g; l$ X X1 ~- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# K8 `+ R0 }0 `. n$ k" L - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: X6 [0 H5 h! Y5 U! l
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 O: _9 o% {$ e- l8 Q: ^6 D - . O3 o) [2 v. G
- dma_addr_t dmaphyssrc1 = 0;( `! _' u: q" j8 X
- dma_addr_t dmaphyssrc2 = 0;
3 p* P- I5 o! M; }' W! W - dma_addr_t dmaphysdest1 = 0;
0 ?+ Q% ?7 G. U - dma_addr_t dmaphysdest2 = 0;4 L8 J, d) Z' e0 r$ ]* I
9 l: ?" `) F7 L T( u9 W- char *dmabufsrc1 = NULL;: v1 p/ W5 `% ]- c' q
- char *dmabufsrc2 = NULL;
i" r5 E: C& S; X5 t, n - char *dmabufdest1 = NULL;6 k! X# W0 z+ Y1 @' z+ R2 B
- char *dmabufdest2 = NULL;0 j5 u8 r. P; G+ l! ~
" \" I, [) v. G5 A/ J1 v- static int acnt = 512;
- b2 t3 J1 V. K# w- `# V8 j - static int bcnt = 8;% v. ?( B; X0 {% Z, q) @+ x6 U/ T3 Z
- static int ccnt = 8;
$ B+ V; |5 E5 e! Y' `$ Y2 n - ! f6 E. q; N) p6 U
- module_param(acnt, int, S_IRUGO);' X( `& A, C! s1 i8 _
- module_param(bcnt, int, S_IRUGO);
0 l! N d L- n8 y! G - module_param(ccnt, int, S_IRUGO);
复制代码 * G; q" }$ e/ F; C }
/ S9 _8 K i7 o# f
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
; Y% e4 p- P. c3 }3 w! Karm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。 p7 e( [. Q* H. |
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% g+ d$ I2 F/ H L
& O q v- z4 `4 T7 J5 A4 O! U9 i# X2 Z. P# Q- |. z" F/ s
|
|