|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 ~. G: |( h e. P7 o- [code]EDMA sample test application
; i" f- q* C( b* o# e. |" u) } - /* T5 n" N% M( |. h
- * edma_test.c3 ~$ \6 o: t% y
- *
- c; C1 u3 X4 g* k D - * brief EDMA3 Test Application
& T6 J' t; {9 ~/ G0 \1 T% I# `0 o - *. j4 D6 `. P$ D/ m5 b
- * This file contains EDMA3 Test code.' A# {. S$ D" L# ]% L' q$ i
- *1 \- A7 Q2 y! W3 H! {% G
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
5 v( w3 `# |0 p0 I - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT. U( b* G5 _! l. t# Y
- * TO CHANGE.
2 K, {8 A) y% I5 F - *# |& S+ @+ L7 K2 m k" G, G
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- {9 H$ g S1 U1 `, {& N - *
7 U7 K/ y, v- y7 J8 \ - * This program is free software; you can redistribute it and/or* A4 O* }' o$ o0 ]
- * modify it under the terms of the GNU General Public License as
% q$ Z& ]! B" Z6 O( V7 Y6 K% b - * published by the Free Software Foundation version 2.# ^1 [1 X$ X, b, O9 }- X. ?
- *: j7 c, G+ F% y9 ^4 P: Y
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, V# G/ X# ~2 b9 K - * kind, whether express or implied; without even the implied warranty2 ]# [, d$ L5 L1 U- D2 [& U& ~7 ]
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ b4 G v. E( u: J
- * GNU General Public License for more details.
. p+ @, N& ?& g% o2 X& f9 q/ j7 d% I - */# _' i; ]" `; R7 K: ]4 b
* o1 s# T, J# D' {3 K' S" W1 G3 i. ^- #include <linux/module.h>
9 U4 O M7 b; W% l4 `% k7 S - #include <linux/init.h>
! W' K e( u7 }$ V. M- i, ? - #include <linux/errno.h>( l. K, P# m B9 _5 I
- #include <linux/types.h>
. i& u* x" g" K/ O* z - #include <linux/interrupt.h>
$ C9 A F: r2 C) t7 i3 x& X - #include <asm/io.h>
# u8 u! l. q% o7 |* U - #include <linux/moduleparam.h>
+ o8 ?6 ^& f3 F - #include <linux/sysctl.h>6 ?8 `, g+ I% Z' d3 O8 ?- M
- #include <linux/mm.h>
1 d9 {0 Q& [3 l+ [0 Q$ a5 N - #include <linux/dma-mapping.h>5 L: b' x" V% T& i, s( Y; S7 D
3 P% {, G. x3 G1 x: S- #include <mach/memory.h>4 v6 L+ r, Z% T( ^: f2 H9 }2 s& Z+ L
- #include <mach/hardware.h>9 B3 t7 q+ `0 y' H; e) Z
- #include <mach/irqs.h>- J! R0 ]& v9 e
- #include <asm/hardware/edma.h>+ w, l' D0 l6 A/ H X* b
3 a! n- p; \0 Q- #undef EDMA3_DEBUG) `8 Q E |" l4 S
- /*#define EDMA3_DEBUG*/
) c0 z1 E8 v* M$ i. A - 2 U* \. L5 c2 [
- #ifdef EDMA3_DEBUG8 X j/ f& H8 N; [9 G
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
1 H6 x' u1 d7 t - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
+ l% x. U* B! t- G1 I - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__) v, M6 N! P/ I) C- k" Q
- #else
4 N6 I# ^; _; E2 S0 C+ R/ m2 x - #define DMA_PRINTK( x... )
1 ^1 `- a- y* t5 I R7 O p - #define DMA_FN_IN
* K* ^' O) S7 U. N+ R5 o9 h - #define DMA_FN_OUT
9 U: d4 k6 d% A8 I) C+ B - #endif
+ v& X2 L/ Q- C2 S T( ?7 k - 1 {& R/ Q0 E- r! f6 K
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
' `" _: Y! ]; r6 K3 |3 C1 E - #define STATIC_SHIFT 3
5 w' u! E( @, x - #define TCINTEN_SHIFT 20! p+ j- D' c5 M8 r
- #define ITCINTEN_SHIFT 21& F6 D, X/ G1 {" \8 G* y
- #define TCCHEN_SHIFT 22
; U9 r( Q {- e+ u - #define ITCCHEN_SHIFT 23
% c$ U( m! ^ f7 J! a# n# c - + Q1 ]6 s: P# y" j: s# z$ q
- static volatile int irqraised1 = 0;
0 c7 q& i- r4 e$ Y, v+ x7 D - static volatile int irqraised2 = 0;" L+ V9 ~) F' x7 y1 [8 n
6 B" ^( ]6 I4 n: V3 e# Z- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! n: H! c. ]* S7 K$ F2 O+ _
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 n, p! K& l6 T1 B/ U0 V% U, @
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: H4 c3 A& ?; F1 I/ [' | - 8 C/ k; K$ K4 ^
- dma_addr_t dmaphyssrc1 = 0;
+ t: B2 b. g- W - dma_addr_t dmaphyssrc2 = 0;) L U0 ?" Z5 w9 U1 R& `: F; }6 r
- dma_addr_t dmaphysdest1 = 0;
2 g+ j. {6 G* F - dma_addr_t dmaphysdest2 = 0;
/ I4 H0 P# V3 X6 d) R+ Z, t2 g, S9 { - " @3 G; j5 W2 ^0 ~+ m1 |
- char *dmabufsrc1 = NULL;
, n- D+ F1 u; v+ ^ c$ D - char *dmabufsrc2 = NULL;3 c3 W" o! {# S3 G1 s* r3 O' ^. _
- char *dmabufdest1 = NULL;9 O( O+ B% P& `. M& r$ D' r3 E
- char *dmabufdest2 = NULL;
; z' K2 z( `' B
# k3 \) f: X/ p- static int acnt = 512;
2 u2 F3 n+ g, U - static int bcnt = 8;
7 N7 F3 T% E5 _9 v; \1 B" U - static int ccnt = 8;
: Q8 j. Q( U- A9 ~) M5 N
1 u1 z* D. |5 ~! n! W. E# `- module_param(acnt, int, S_IRUGO);5 @8 Q7 `# ]5 X1 v1 F
- module_param(bcnt, int, S_IRUGO);
, a8 f d' }! z: Y - module_param(ccnt, int, S_IRUGO);
复制代码
# F) ]' M/ f. m% b5 a3 h3 Q7 N1 i# L$ g5 E- P% h: y9 p6 t, G( j
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用. E1 f: g! X, Q) M' l
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。( E! F8 }0 p" [. m
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
5 G/ O- ^5 `( L( p
, H" i* w% O3 V7 ?$ p! P
4 j* M! @) W+ a. S' | |
|