|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 H0 @5 q( P1 B; D x7 u- [code]EDMA sample test application0 [8 g( D7 }* f8 q2 {0 m
- /*
9 A4 C+ J: ]& c: D( O - * edma_test.c
5 r) C* b! }% ? - *
# W9 z* f: z q; u* d( p+ c - * brief EDMA3 Test Application- A+ F$ `+ s8 W5 |
- *
% c( T. E6 I5 Q; e; L - * This file contains EDMA3 Test code.
2 E/ y6 [% Y+ @) P; l - ** V/ ~! [' R$ S! s: Z4 X
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE; f- t2 L+ Z9 m
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT$ T6 ~! \2 y { _, s0 E& j, g
- * TO CHANGE.
) ^4 q. q6 f, ^% ?+ c - *" q n, L: S4 q4 V
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- j4 o% ]: ?# U1 h - *
! m& G+ ]; v+ l - * This program is free software; you can redistribute it and/or
4 k2 x. g' Z3 T9 T' A5 t - * modify it under the terms of the GNU General Public License as
, [$ L: M' B, d# ? - * published by the Free Software Foundation version 2. V+ w0 n. v2 P% j8 P# F' z1 N
- *
- ]+ N1 ^5 S5 T, B* L/ D - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
$ p5 [0 [! @" Y& D - * kind, whether express or implied; without even the implied warranty
9 C- V2 e2 D; I; |: l2 D" b - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the6 Z( |8 ^6 ^) Z
- * GNU General Public License for more details.
: G ?& z0 k& a& t6 b - */3 Z0 [5 `8 Y6 l( Q! [' n
' H |7 D% c$ G- #include <linux/module.h>
7 V, ~0 I1 {5 H- W: M# U3 q - #include <linux/init.h>; t' O0 p9 [, Y: h5 M$ X! L# S
- #include <linux/errno.h>
' p0 \7 n. L# E, d. o) r6 p' D - #include <linux/types.h>: W' u0 I9 m4 `
- #include <linux/interrupt.h>/ ]" O3 N- c$ p# [* F2 O
- #include <asm/io.h>
6 Q; m& S6 i% {% J - #include <linux/moduleparam.h>
s( @5 I8 A: M" j$ H8 Q) s1 j - #include <linux/sysctl.h>
8 ^- x& Q" w2 ?6 L& b0 d4 w - #include <linux/mm.h>; M" D+ O3 z3 w
- #include <linux/dma-mapping.h>
C( I3 h9 l! c! U6 d - - C+ a( O- l' e. X ]# c
- #include <mach/memory.h>
9 v3 j6 d( b( Q1 c - #include <mach/hardware.h>
P! R7 U0 Z2 P" @9 ] - #include <mach/irqs.h>6 @: |5 |- @* s8 N% |$ H
- #include <asm/hardware/edma.h>; |9 h" z: j) a, g: h
0 Z! G3 J( \) d i+ i2 l0 o. c% z- #undef EDMA3_DEBUG
Y3 a' {4 [8 S) `# x) p$ A - /*#define EDMA3_DEBUG*/
" L8 Y2 p: [4 b! f7 n6 i - ( c1 p; ]- V1 P1 q2 c, U
- #ifdef EDMA3_DEBUG0 L/ |3 P* T4 l0 j: b) k! ]
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS), n0 }# ^8 D. R; Z3 h n' s
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)5 H6 k( @" c6 ^4 ?8 Y% Q
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)# W2 r1 B( h# G* Q( t4 V
- #else& e+ P: h) H `5 S* K, f2 h$ N1 u, Q
- #define DMA_PRINTK( x... )/ j. }1 ?& N+ M. `
- #define DMA_FN_IN
. ~- q v! K. s5 [: V' s- K. B! O4 _/ b7 O - #define DMA_FN_OUT C. W* e K5 x' _
- #endif
: w* E* U8 d) L* D$ @4 ?$ ?" k' F
) @" O- E; J* v0 g+ F/ q" r9 d- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. b) E# b4 L5 U" ?' }' \! m - #define STATIC_SHIFT 3
$ U# y5 \& U/ b S* }+ K' k - #define TCINTEN_SHIFT 205 {$ j! b U, N% L0 R: v( h% p
- #define ITCINTEN_SHIFT 21
2 l& \0 z# f* N/ r8 o - #define TCCHEN_SHIFT 22
' R; {* k' e$ V1 E# c- ?% A - #define ITCCHEN_SHIFT 23
2 m; D; x- F2 b# E; q. h
8 ?" j/ Y+ T* E# e- static volatile int irqraised1 = 0;
; T/ x {3 e& n1 C( f* p - static volatile int irqraised2 = 0; b" D+ B( Q g5 W" a( R: v- `
* u# Z$ ?+ L+ u" }! L: S$ d) u+ F- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' u; D1 F- k' x4 M7 U$ @+ |
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ K) b7 i# u# e* w+ V' e
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ _- L+ z7 @1 h8 [$ f+ @ A - 5 i3 O. n& W4 h' i
- dma_addr_t dmaphyssrc1 = 0;5 N8 l% ?9 y& G N/ O( o P* g
- dma_addr_t dmaphyssrc2 = 0;
`: \( o9 Q7 L( y1 D: \ - dma_addr_t dmaphysdest1 = 0;( S" U. J. b" N: T& a: e
- dma_addr_t dmaphysdest2 = 0;2 t) k5 }/ B% B9 u
- - T! R1 w$ ?! m. k1 A
- char *dmabufsrc1 = NULL;: c0 [' V' o. @( G- X: B9 r
- char *dmabufsrc2 = NULL;
$ ~1 @1 ]( E5 u3 x1 L - char *dmabufdest1 = NULL;
7 u' H- u3 a/ f* U& R9 \% j - char *dmabufdest2 = NULL;! F9 m( o; [' |! `
- $ ^# z3 O: z7 o* I( g
- static int acnt = 512;% ` L% X, ]" e
- static int bcnt = 8;
9 {1 l, t0 s) u7 m9 g - static int ccnt = 8;
4 p$ o. u$ x1 j% S) h5 _ x) ? - - A5 P, c8 r" E0 G& f
- module_param(acnt, int, S_IRUGO);
6 w, A" {7 `; j3 N% r - module_param(bcnt, int, S_IRUGO);. V' }' z5 E- X2 D! J: X4 q
- module_param(ccnt, int, S_IRUGO);
复制代码
! ]3 u+ a; y& s2 V7 b% V) u
6 A2 d. j: |- _+ \# w+ E' E 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用( l( X+ A; `2 n" B W+ ^
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
5 S! E7 i7 m3 ~1 n: s+ L 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。" v Q, s: w' K* a* l$ R
8 s* z5 n, X; {- G
0 N! z: l6 }- \
|
|