|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% J5 `- @# d- g+ X x- [code]EDMA sample test application3 q2 V1 W; r- w& b3 s0 @1 _
- /*
8 a2 @, l. o ^9 H0 A+ w O - * edma_test.c
+ M+ Z% \7 D2 n3 L - *7 B5 Q" O$ |* N
- * brief EDMA3 Test Application
: n* S! C, x7 z - *
6 O& M7 h- d ]" r - * This file contains EDMA3 Test code.
- M; A" n: c, [4 `, j7 [ - *
# k- }' f' H: x) {: U; W: |( C9 B - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
4 B0 b/ l- v+ ?3 |( a - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT+ m! b1 O4 _ y @4 b
- * TO CHANGE.( `3 Q' ~3 `7 @7 }$ [ i6 Y9 L. n
- *7 e0 @* B5 s. B/ J) N0 a! P
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
/ c/ ^" m; X- x S - * }. S- c9 w5 z' g+ p& n
- * This program is free software; you can redistribute it and/or9 b9 C; \/ `+ X" b' Z& r
- * modify it under the terms of the GNU General Public License as5 m# S- U; H1 c% Z1 J
- * published by the Free Software Foundation version 2.& a$ B* s- p8 E6 K/ d
- *! Z6 u" `: L( ~4 {# H
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
" j+ L/ w% Q3 Z% D - * kind, whether express or implied; without even the implied warranty- l4 |2 c! H8 w, T8 D- d) }5 _( Z: y
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the o; m3 Y$ u1 z8 O I! }( V
- * GNU General Public License for more details.
0 |9 ~' X$ j B+ A; P& u - */" u/ K. a0 w3 D4 S8 K
- , C8 _* o9 ~* t: h8 S( k$ x; A e
- #include <linux/module.h>
0 ?* u2 @; j0 f8 b - #include <linux/init.h>
4 f8 { R4 h0 h - #include <linux/errno.h>7 Q: Z* |$ V+ J* H7 |$ [6 `
- #include <linux/types.h>
$ H* y& S. X: } - #include <linux/interrupt.h>3 Y! L$ g! [ t: T' v' ^8 v
- #include <asm/io.h>- p+ b/ ]* ?% g4 i7 q4 @1 k
- #include <linux/moduleparam.h>
0 Q! X" b; r, Z, L; w% }- g - #include <linux/sysctl.h>* @4 N) S# J) W' c1 u
- #include <linux/mm.h>" H1 N: Q O7 W) d
- #include <linux/dma-mapping.h>; O4 i7 Z" W( i0 D3 Q
6 |$ B( `& ~+ f p( S4 ]% T- #include <mach/memory.h>1 k. \% A. R j
- #include <mach/hardware.h>, g( F% n( E+ q" [$ J" Q9 [/ |
- #include <mach/irqs.h>
& F% r# ~4 a: G# s" `# k% b - #include <asm/hardware/edma.h>
, ]9 Y5 L2 w* s4 b7 B4 G" k4 q- D
7 H) f. b5 w+ r4 j2 d( s- #undef EDMA3_DEBUG
9 U$ F: O3 g2 t - /*#define EDMA3_DEBUG*/
' P9 o3 Z' s9 O! ^7 ~ - ! I: y- F3 S9 M7 B2 z. i" n
- #ifdef EDMA3_DEBUG
1 ^4 l0 n+ i) k) R - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
$ T; z4 }/ w) Z - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
( X- C; r" B+ A5 k9 c' P! l( | - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__); p- F+ n, L3 {8 p
- #else* X+ E- O; f6 j5 i
- #define DMA_PRINTK( x... )
8 O" N& r& n5 _* Y( V+ h - #define DMA_FN_IN
6 x& e* Q) u. S! e$ f - #define DMA_FN_OUT
. y' a8 q$ a8 o/ M$ _4 F' d' r7 e - #endif
& {8 D o% t9 d, x7 I; m4 o' L! m - " g- ?- i- k$ L7 M6 |8 N) u$ N
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)! W; I5 R% Z m3 q
- #define STATIC_SHIFT 39 J9 F! m: W( r3 O' B' C
- #define TCINTEN_SHIFT 20) Z* H# {4 `. F- Y( U
- #define ITCINTEN_SHIFT 21, k- n9 ~% P% m8 ?1 o6 o% o
- #define TCCHEN_SHIFT 22- I; e. K9 m; b: V, b
- #define ITCCHEN_SHIFT 23
R2 B; G& D. J; i2 W
; j4 x/ Z6 I, {& |9 a! q5 v# T- static volatile int irqraised1 = 0;1 g" [9 G1 X( D1 R( Y" _% S1 O
- static volatile int irqraised2 = 0;! P* N9 G" [$ ~& \. i k4 M) F. {
- 9 J( u# b8 E% ~8 W, T
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) L2 B- o& Z: P; Y0 Q/ W5 o - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 W/ L9 V( L; b7 d$ f) q - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: Q" K3 ^$ I' U+ E
/ e5 u. m( `5 B) B( [6 l, h- dma_addr_t dmaphyssrc1 = 0;! W4 ]8 D* E5 ^0 J9 z" t6 @
- dma_addr_t dmaphyssrc2 = 0;
6 o8 y* N- p& C8 L6 u - dma_addr_t dmaphysdest1 = 0;$ |& G5 X$ W/ C" _
- dma_addr_t dmaphysdest2 = 0;, u8 s* h" y! r" k. l0 ^# i5 I; T
- 7 c' }' X1 \5 \& c0 }# B; Q
- char *dmabufsrc1 = NULL;4 Q7 p7 J6 G/ ]8 @4 e" S& M
- char *dmabufsrc2 = NULL;$ j* V2 q: k/ w$ [4 R9 u j
- char *dmabufdest1 = NULL;
6 K R4 |2 _8 u/ P8 h3 A2 K% T) V/ d - char *dmabufdest2 = NULL;; m/ `& Y2 ^5 d
0 U% j- w8 `/ a% \/ D l- static int acnt = 512;
9 w( |4 K' P" g/ \ S6 r - static int bcnt = 8;
3 L! V$ t0 x& K6 U/ g$ M: d - static int ccnt = 8;4 q3 J0 ^3 c/ t2 j1 }; A
- 7 `' V3 n# e5 _3 D# ]
- module_param(acnt, int, S_IRUGO);3 T0 x% [, F6 s1 @ b! U* F( I
- module_param(bcnt, int, S_IRUGO);
" {4 d4 r3 D* z5 H& ^ - module_param(ccnt, int, S_IRUGO);
复制代码 & j' d C4 d5 C
0 ~% c' g) T+ T/ D4 Y
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ M: x4 t: Y+ @* a& C/ n' J, qarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。4 q6 x5 L2 F [5 @
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: P% o. n5 R, g$ \) Z
( R1 t/ {5 y9 Z& c4 i5 M* C
+ Y8 s# T" D. U) v/ { |
|