|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 X) K- \7 _+ U4 R- [code]EDMA sample test application
: f- H3 C& w4 }6 \( _+ Y - /*, D; H, B/ Y- A' {
- * edma_test.c" R$ I, L9 `* B7 i6 K& M4 N
- *8 L& x+ a, o6 C6 l
- * brief EDMA3 Test Application, @+ B4 g6 I5 k
- *7 B/ J/ D. o) X+ [# l
- * This file contains EDMA3 Test code.
: m8 ?9 q) R% A' y. b3 j1 q - *
; I' D8 M5 A% g5 ^ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE. c0 Q% }' C0 z* s4 d
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 {5 W/ @1 C3 @- e2 ?6 R# W. L
- * TO CHANGE.
% v, _- F9 N1 M1 e - *
0 `, O" n4 ^8 N - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
& A" g+ T- y# F# ]5 ^; L1 o4 R - *0 }; s' m, r d! q! R4 j" G1 H- W2 h
- * This program is free software; you can redistribute it and/or
3 Q% k$ U" r9 Y8 Z; h) |% P8 v% j - * modify it under the terms of the GNU General Public License as1 M, e2 y7 Y9 C3 ^: ^2 D" M
- * published by the Free Software Foundation version 2.; H0 G( D' z, `9 h y4 l0 B
- *
7 T3 f: r; z6 F, c - * This program is distributed "as is" WITHOUT ANY WARRANTY of any( b- ^! r# y& k) r/ e/ Y# y, |) z
- * kind, whether express or implied; without even the implied warranty9 g5 k3 ^5 x: L' _7 M
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1 c4 I& ^8 a( O5 ]9 G7 w5 t- U8 e
- * GNU General Public License for more details.
" M+ W& V2 L( v8 a" E! B, d - */
+ x0 N. l% M8 {! F, m7 {& s
: M$ [% K8 c; S: ]; p+ p$ a- n1 Q- #include <linux/module.h>+ D4 p5 W7 _8 [6 U
- #include <linux/init.h>
8 P: H3 b+ [) B! I9 v. y - #include <linux/errno.h>% K' e( g$ B2 ]1 {* N
- #include <linux/types.h>- e7 W* C6 {! ?/ D
- #include <linux/interrupt.h># Y# ^: F& W& ^1 g
- #include <asm/io.h>8 A. X+ y" N- b9 J* q4 z. w
- #include <linux/moduleparam.h>
9 z3 G5 N9 r+ _6 Z% r n - #include <linux/sysctl.h>
/ h! R1 z. R1 b+ o2 ?5 Z2 Z9 K - #include <linux/mm.h>; U2 a6 b7 ]. y- g1 U" O, j9 l
- #include <linux/dma-mapping.h>+ z2 |- \0 H+ y+ r+ @# x$ ~+ F
2 @& u$ K0 O2 L- N! K, _- #include <mach/memory.h>
" T! y& G) w! G# X' ~; Y - #include <mach/hardware.h>$ f3 l" D* j. m) B* t
- #include <mach/irqs.h>/ H* | B2 J' r6 o8 B7 I
- #include <asm/hardware/edma.h>
0 f0 R1 t. d7 w& H$ K0 e; ^
% X- J) s/ X6 A* E5 F& ^- ^) Y- #undef EDMA3_DEBUG& n2 W: D7 K2 [- k, u+ q! M @
- /*#define EDMA3_DEBUG*/& E: u' Q4 I6 M$ o$ X
- ' R% x& D9 L) i5 W) _# _
- #ifdef EDMA3_DEBUG
2 i2 C2 F/ Y1 \5 \, F! _ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
4 @( N( w( W7 e, v! e4 U+ K - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)) I/ k6 L m. [; W0 E
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)5 \' k" o; S1 m! A8 P" o
- #else9 K/ }5 B' r1 U2 H! G
- #define DMA_PRINTK( x... )
1 Y0 j3 H/ b9 i& n7 A! m- d - #define DMA_FN_IN7 o3 O# a& V9 N1 t: N3 _% R7 h
- #define DMA_FN_OUT5 E8 l0 @) ?* a
- #endif
8 L7 d; A% e0 ^4 b' A( e2 i/ z1 A - 1 m' y1 Y2 A, P1 u: [
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. y/ y6 H _+ G8 z - #define STATIC_SHIFT 35 w) Z# \6 I, n1 L. l* r
- #define TCINTEN_SHIFT 20
8 E1 ]) I$ e" e6 C. O - #define ITCINTEN_SHIFT 21! D4 P3 a L3 `0 ?, `
- #define TCCHEN_SHIFT 22- o6 |* \- i- f: X+ S8 I
- #define ITCCHEN_SHIFT 23
, m* z( A! \6 l4 c1 M* f5 s - 7 s n+ ]2 B5 }* D$ |) M, ?3 s C
- static volatile int irqraised1 = 0;
# ]1 q' r- h, G7 } - static volatile int irqraised2 = 0;# |7 K7 u+ n: N( i( |
- q$ b: e+ u: b# Y0 n- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 J# a4 {) H8 Q4 r0 Z p0 a2 f
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 y* t0 G( I/ |' a4 \) m8 _( w, s - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 [( f- F: _1 I3 l' ~/ v2 ]. A
L' Y6 i, z6 z8 ?" u. e6 C) Y1 m- dma_addr_t dmaphyssrc1 = 0;! N& F) Q9 E4 o" X1 G9 s0 Z
- dma_addr_t dmaphyssrc2 = 0;
' s8 B( H/ @5 B$ \* S0 _4 c - dma_addr_t dmaphysdest1 = 0;
* ]- Z- u7 L: K; {( ~6 \0 R - dma_addr_t dmaphysdest2 = 0;
" b. Z* @+ p$ B& \
5 p+ }; C1 K) @7 D$ P; e, l- char *dmabufsrc1 = NULL;5 r1 J7 l: i1 |) P9 Q
- char *dmabufsrc2 = NULL;6 _* F& X: Z, ]
- char *dmabufdest1 = NULL;! h3 A" P( T" Q
- char *dmabufdest2 = NULL;
. C% l1 v8 ?8 N1 @- K! A1 ?% W D0 v - ; ?- p5 o6 L+ ?) Z/ O e& k
- static int acnt = 512;( Z6 R4 b2 z$ B3 [
- static int bcnt = 8;5 l6 K- J) t, {
- static int ccnt = 8;' |, U4 R( _( C- E. [1 p& a
- 2 _0 T, x) z+ Y' _
- module_param(acnt, int, S_IRUGO);4 p. }* L3 R q; ?1 }* @- J9 o' |
- module_param(bcnt, int, S_IRUGO);
% h. I. o7 S, S! I( Z - module_param(ccnt, int, S_IRUGO);
复制代码 ) @8 W0 ]7 H) p2 \6 L$ C% h4 }
7 m* d) ~8 w' f8 k 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用2 ]3 h# ], I# v$ O9 I' c2 |: R
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 o3 y; l) [# B; r
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. Q6 G+ R8 s2 D7 ^. y
2 o7 Z0 g4 Y/ m) U o3 I
- l5 @1 `3 k) r$ t
|
|