|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 5 S5 d& t: s! W
- [code]EDMA sample test application7 Z" [8 ]% l2 J* V$ |
- /*
" v+ y" i5 J" M$ s$ s: ~: x - * edma_test.c
0 f* I- N: ^# m - *
! E* u% \ Z: m/ B# I6 T - * brief EDMA3 Test Application
! X- l* m6 y, L- c+ e6 @6 U - ** N3 X2 p+ \* i8 ~
- * This file contains EDMA3 Test code.
+ v: w( y6 M ?: c' S - *
3 G1 M; l( @' D4 N8 q - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 A, o4 U$ n4 e- ~2 m
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( _$ U/ k1 O" T+ `. g+ u - * TO CHANGE.3 _2 q& v! J8 B, d
- *
% x( C) n% E+ n; _3 E6 \ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
, V7 _! y# k! U) N+ x - *
3 _6 E, I1 I$ S7 E9 V) @- I - * This program is free software; you can redistribute it and/or
- T1 z+ X N3 ~5 t( J3 w4 a4 f - * modify it under the terms of the GNU General Public License as5 h" M( S2 s+ F- P |; b9 C' Q
- * published by the Free Software Foundation version 2.! p* y# A. @5 O% ~6 _
- *, _. j" f! ^+ t0 d/ a ^
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
) T7 U, O5 Y' G! c: P9 {5 J1 Z; s - * kind, whether express or implied; without even the implied warranty4 A$ D1 [- o7 K4 e `5 X
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 m# Y A/ d& D9 h
- * GNU General Public License for more details.
e/ ?0 T- C5 | - */3 V+ l1 ]# ^* \- J7 @; I) f9 {
- 3 L6 T+ D! {0 ~: Q
- #include <linux/module.h>
: l3 F0 h% M* m6 C" N5 x - #include <linux/init.h>. V" r7 ?+ x4 r# J3 p
- #include <linux/errno.h>
: P3 I2 f* `! K. ~; |3 n+ e& A - #include <linux/types.h>! x. Z$ \& e1 |) Y
- #include <linux/interrupt.h>
2 a8 `+ p5 T# `. X1 N7 J - #include <asm/io.h>
- i4 d8 n L' N! ` - #include <linux/moduleparam.h>; e7 {0 H3 v7 E- A/ c: b5 }
- #include <linux/sysctl.h>
( B/ x5 `) c. |0 ~& a - #include <linux/mm.h>
+ X% W7 [: k9 D9 x6 w" m8 Q - #include <linux/dma-mapping.h>/ N. C6 G7 s3 q1 O
8 _/ W( S6 p7 r' ~" r* a7 `- #include <mach/memory.h>* e* \/ Y, i0 C1 f# T Z" r, B
- #include <mach/hardware.h>. h9 ?& Y& e2 u; U6 |/ ^: P
- #include <mach/irqs.h>- i! R1 k6 t5 ]$ c( ~7 ^' f/ a
- #include <asm/hardware/edma.h>
; N$ K6 u8 O Y$ Y9 j) d8 k9 Q& `5 p7 ? - / L+ V6 l" ?, H1 ~* k
- #undef EDMA3_DEBUG8 q$ p4 N$ ^2 N, l% P6 O) _
- /*#define EDMA3_DEBUG*/
% k0 P/ c0 e, a* \5 ~: q
% |8 e5 F: b6 h; g- #ifdef EDMA3_DEBUG8 H* w) H, `* Y+ I# V
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
z g% |+ w# F5 Y - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)/ H( a2 p( P8 y0 ]0 q
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)" k0 Y- C0 \/ q4 G$ r! G, D
- #else- m( |2 X; D1 R5 n% C8 i
- #define DMA_PRINTK( x... )
4 p; `3 X; t5 ` - #define DMA_FN_IN0 \0 A" V" D; |9 d, v
- #define DMA_FN_OUT) H% S7 a# w. s4 z" R W' Q1 Y* u
- #endif
+ M" }: m& O" }# C! B- g$ y) P
5 E( }7 W6 {+ m- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ A2 g3 q: ~5 r! z9 y
- #define STATIC_SHIFT 39 N: ]7 Q$ Y# O) w: x/ u$ o5 o' ?
- #define TCINTEN_SHIFT 20! G3 A: |$ [* y# k* R
- #define ITCINTEN_SHIFT 21
8 V8 {# w6 m6 o; G- @- v. t - #define TCCHEN_SHIFT 22
2 a/ D7 g- A- T% ~' G# @ - #define ITCCHEN_SHIFT 23( q. {9 N, R0 M* u ~6 G& K
* S% S X H# L, p: W: h7 j- r9 s- static volatile int irqraised1 = 0;# X% \* Z4 h6 N* o" @4 Q
- static volatile int irqraised2 = 0;( B3 H7 ~# U- K: z+ I# F1 R
6 g8 Q, f$ y, Z2 G- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 q: R. D) z9 h
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. C% H- _! T$ J9 _" d/ Y7 X9 I
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 ?1 A4 b) x4 Z
- 9 }! E1 X5 E# i5 R9 c% E- p6 u3 Y$ \! Z
- dma_addr_t dmaphyssrc1 = 0;5 t6 H( F9 X7 `; W
- dma_addr_t dmaphyssrc2 = 0;
& \4 R: Y, j3 m+ x# ]6 o3 C% w - dma_addr_t dmaphysdest1 = 0;$ |- j6 I: B. D" { P
- dma_addr_t dmaphysdest2 = 0;
; ~6 s+ e7 ], b* \9 {% D& \6 u - 4 g6 C7 n2 k- G$ b- S4 x
- char *dmabufsrc1 = NULL;: @- ]8 C' z* e$ a' J
- char *dmabufsrc2 = NULL;
# h7 w. N |) { - char *dmabufdest1 = NULL;
# e$ `; G# g9 g - char *dmabufdest2 = NULL;
/ W, T; ^4 m4 i& P
7 b5 P5 J6 ~( [8 U$ s2 X* O4 L- static int acnt = 512;- F' e4 T3 T; j8 c1 w1 f
- static int bcnt = 8;
+ T4 w$ e! [" M" U2 [+ ], l, t - static int ccnt = 8;- B- Q: \" F9 t* Y
. x' y4 k @. H* {: `" _& {4 z$ i- module_param(acnt, int, S_IRUGO);
: F! \/ J$ }0 a: S \ - module_param(bcnt, int, S_IRUGO);
; l( s9 N4 A9 T; o$ C# z - module_param(ccnt, int, S_IRUGO);
复制代码
3 m H7 N8 E' k( O4 g; y9 R/ r; c" r8 a. e
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
. r G6 L, d9 \$ uarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
; k% [) r1 @0 {" U' e 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。! w& t$ g) ^" u$ S2 u. j
; l( r M: k' m) O- W+ j, Y. v' e5 `: b1 _4 b" S% A2 P3 o$ x; ~
|
|