|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 o% q- ]8 ~& l3 |; L: K: U
- [code]EDMA sample test application
% h+ r0 B0 ^: n' ?. t - /*
+ ?0 H7 H0 Y& E' v" e5 P - * edma_test.c6 p5 i1 ^1 v7 x: T. J! |
- *
9 |" L; T2 ?$ w- R F! M# l3 h5 K - * brief EDMA3 Test Application" E( W% ~2 W: e$ g& m- }; p2 T' ~/ x/ r
- *
d4 V' ?2 e* z$ N - * This file contains EDMA3 Test code.
+ @$ K! ~0 {2 B - *
$ a/ {$ S$ X7 ~7 I9 g - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
m, p! ?5 s' E& P - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT( M1 I8 ~ \9 ?/ Y1 p, U' F9 D
- * TO CHANGE.
8 G6 c3 v7 E! @/ k+ O0 e - *8 U2 x8 {3 E& _' r" ^
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; q& S0 |) W+ \- n9 x
- *, q+ V' @" C8 X
- * This program is free software; you can redistribute it and/or
8 ?; i9 s# i, t4 G' K; c - * modify it under the terms of the GNU General Public License as% y1 I7 k7 _/ _% U2 |
- * published by the Free Software Foundation version 2.
$ a% W8 V% _: y8 d2 E - *# r% ?! e0 m0 Q
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
. M! d, ^: b6 w4 _1 O - * kind, whether express or implied; without even the implied warranty; B2 ?# v; N8 d" w& K" Q0 V; {2 M8 t
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 `0 H- o" X2 g, I* K3 | - * GNU General Public License for more details. N; V& u- ?9 i: T
- */' r& f' V$ t. h9 K, `
) g! W; c* @8 ~: u, g4 @: Z/ E- #include <linux/module.h>1 E" u; z) [" H1 b8 S8 q
- #include <linux/init.h>
R8 q* [ c) k% H+ u. S. L# N - #include <linux/errno.h>0 Q" \* x8 Q) H9 o1 n) |
- #include <linux/types.h>
; `% L9 h" g& ^7 p - #include <linux/interrupt.h>
5 w* c# y6 A0 u - #include <asm/io.h>
: S( P4 J- ]3 l$ ^ - #include <linux/moduleparam.h>
# [7 e& ~" k( b1 T - #include <linux/sysctl.h>
5 W2 `7 {4 j7 P: a8 ? - #include <linux/mm.h>
! \! k3 E$ Y0 B" |+ j - #include <linux/dma-mapping.h>7 A4 h1 G9 @: l% @( X9 H
: [) b5 Y0 J* V6 \+ U( ~- #include <mach/memory.h>
# Z }% h/ \, H - #include <mach/hardware.h>" A. O' U6 N" F
- #include <mach/irqs.h>
) @* i9 u( s6 u k6 h: x) E - #include <asm/hardware/edma.h>
5 D1 [% D( N4 N. i1 M4 { - % X) k$ |$ b" f6 r; `; B' i
- #undef EDMA3_DEBUG
9 e2 `# e- |5 ]3 c( ?1 h1 S - /*#define EDMA3_DEBUG*/
2 w M; ? `) S3 m" e
7 J; U" Z; V! P' |+ l; N1 j( B- #ifdef EDMA3_DEBUG `; M2 u( w1 C7 Y: D8 k/ q
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
# J c% y6 n) T: D8 ]- `' H- { - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)% d: d) R& p. q+ C( Z
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)+ [" ?+ T9 b8 w' R
- #else
; J9 |# M0 A f& _1 O: T$ t - #define DMA_PRINTK( x... ); M; k7 w7 B. u1 t* m
- #define DMA_FN_IN' n, V2 M9 D6 d/ y
- #define DMA_FN_OUT
* D8 p( _" ^. s7 O0 G - #endif$ ]" [% T. I7 q4 U
- ! ]* A( F7 r r$ X
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)* l, B! k: K3 g2 x) w% c* z% Q
- #define STATIC_SHIFT 3' T% C( @* A& r" ^' e
- #define TCINTEN_SHIFT 20
7 G7 T- {: ?4 ? - #define ITCINTEN_SHIFT 21* x5 b' U! e' r) d' Y7 W; J
- #define TCCHEN_SHIFT 223 ]. [8 _" Y7 \# q
- #define ITCCHEN_SHIFT 23
+ z5 C# l+ j) o1 V8 J - 5 x3 @& v; F9 ~! E
- static volatile int irqraised1 = 0;
& R# p0 ], W0 R3 t- z - static volatile int irqraised2 = 0;7 W# Z, S. T- o9 s9 l7 z9 L1 X% Y* C$ W
- / X& n9 ]4 L \: d( X/ `( |9 A
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; |6 p' ~1 W. q8 a \0 p
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; @4 ~! i/ l1 f6 i - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ ~7 U+ ~, V" k# o' j$ S
; R/ g$ u0 w8 O3 Y% Y8 W7 }- dma_addr_t dmaphyssrc1 = 0;
: S5 Q3 Q# Z. s - dma_addr_t dmaphyssrc2 = 0;1 L6 c$ e1 G6 m- k9 M
- dma_addr_t dmaphysdest1 = 0;
8 t X0 `( m6 j( V+ P/ a( d" J+ C+ d - dma_addr_t dmaphysdest2 = 0;& c: w6 \. Q! }, N/ |; ]7 L
- " D* q+ T" s6 Z5 I% g& b" u: @
- char *dmabufsrc1 = NULL;
! s& c. E* }4 {1 g7 c - char *dmabufsrc2 = NULL;+ B/ t6 S/ l# e) v7 H
- char *dmabufdest1 = NULL;. Q* x! u% g9 Z0 g( D* g8 c, ^6 k3 ?
- char *dmabufdest2 = NULL;0 i" n% I: B4 V7 u3 N/ Q# H
- J1 L: I W9 p$ n" Z$ Y
- static int acnt = 512;
" S/ `' v0 N) A6 L5 x - static int bcnt = 8;
& l0 z8 D! e7 `0 ~& l - static int ccnt = 8;5 W- D2 A+ `/ W% |: ^% d
+ B2 I& U4 x, d6 \9 [6 s! M1 R1 b$ g- module_param(acnt, int, S_IRUGO);
6 ]1 j+ u% n- S' d$ k# E - module_param(bcnt, int, S_IRUGO);, P! `7 u! w; {& g \; A- x: U
- module_param(ccnt, int, S_IRUGO);
复制代码 # K2 D8 N; [# n/ ^. R4 Q' z
# O& e) U, o- _+ s6 G; v. w
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用: K& P( f# P! W: {/ i! Q& S
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
' G, `. B# v7 Q$ A' }1 [ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
: X7 R$ l/ Z7 q4 e/ ^( A' T/ R: {/ {% K
' q: Y4 C, n1 G. e
+ x, H \- r1 c8 K) V1 c1 f7 X |
|