|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 t' B. `! |: a; q. i e- [code]EDMA sample test application3 ~8 A& z# x" g. |" B: f
- /*" X8 Z+ @1 }7 N, G1 F) X& ]
- * edma_test.c5 I* {5 k; Y1 f+ D4 P8 o% A) Y
- *% g9 O+ Y4 `& ?% Q: k+ W) u" O7 X
- * brief EDMA3 Test Application
/ ~6 H) T+ Q% g7 j9 W; h7 ? - *5 u5 I3 k5 t9 F1 m/ w6 o
- * This file contains EDMA3 Test code.
2 Z# ?% }$ E, I. X - *
3 q3 Y: ^, D( \8 E - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* K2 U' M2 R) U% q$ g - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
: U% u7 W, y p - * TO CHANGE.
: z* U0 g# N6 n* l# F; [ - *
, }! [* K2 X4 K# I, S8 @- x1 ] - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/, U* G$ {( J! l: h0 M
- *
# t# [% A! t7 ^1 p x4 l - * This program is free software; you can redistribute it and/or
; v8 R a6 ` D" Q/ a/ U - * modify it under the terms of the GNU General Public License as: ~* Z% U9 G% V8 [ F9 m) D0 w
- * published by the Free Software Foundation version 2.7 W# N; k4 q8 d4 W% H
- *! W1 J' d6 a# Z1 O0 l3 l& h
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
6 ]. B. g& ^& U/ p" M' R( q - * kind, whether express or implied; without even the implied warranty7 O1 n! k3 T0 S
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the4 M. L* ?4 H) Q/ M% w4 [& C
- * GNU General Public License for more details.2 u& H" r, Y$ V% {
- */6 }3 Y2 e# a# i e
: \# H' A1 E3 n& A4 R- #include <linux/module.h>
u5 q" S; r/ e" Y - #include <linux/init.h>- |# T" w# f5 F! u
- #include <linux/errno.h># f2 h- {' c/ a2 v. W
- #include <linux/types.h>; q5 T: }4 O d" D$ I
- #include <linux/interrupt.h>
1 u1 l) n; d! y& g7 [2 X* Y - #include <asm/io.h>
% a' }$ t& l8 }# y- ^6 \ - #include <linux/moduleparam.h>- H, a9 m2 _3 ?( _( C/ ^
- #include <linux/sysctl.h>) K. @* B9 k( T( Z5 |$ m
- #include <linux/mm.h>
1 P* q8 ?+ f5 J% n - #include <linux/dma-mapping.h>! A1 D U N; w }. W; d m
0 x& Y' ~: S' p8 y5 p% ]2 h- #include <mach/memory.h>
; J/ d( c4 L: [0 X - #include <mach/hardware.h>- v6 L3 S# |/ J' `6 I
- #include <mach/irqs.h>
" \4 I; V& [ ^" k2 M) }4 e$ r - #include <asm/hardware/edma.h>- o6 b& B5 I" c: J! G$ r( N9 O
. B% f; i4 M4 T& b- #undef EDMA3_DEBUG
3 O5 E0 W3 o6 s* N& T6 F - /*#define EDMA3_DEBUG*/. l( [$ W8 W2 r# I5 o& B6 \
- . q+ p: p v# f9 C4 Q9 }
- #ifdef EDMA3_DEBUG1 d9 _& Z8 j3 ]% l9 x* c! ~) E
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
4 m5 U% N4 S! o - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
- s9 w* ~* c% }& O7 r5 { - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
k* J) S1 ?' L - #else% r5 T- @8 R8 x8 G* W
- #define DMA_PRINTK( x... )7 E& M/ a2 ?" g# X) n% K
- #define DMA_FN_IN
* y3 z1 N1 i: z8 D - #define DMA_FN_OUT
* ~: T! ^1 i/ d - #endif
' O& Q9 o7 ]$ I" e2 x* ?( f0 B
' ~6 B" X( k# h' ?$ Y9 U# D- #define MAX_DMA_TRANSFER_IN_BYTES (32768)4 U; o+ _) [( |
- #define STATIC_SHIFT 3/ ]1 ]( {* x( {. g, E
- #define TCINTEN_SHIFT 20; x$ y! |' y5 D
- #define ITCINTEN_SHIFT 215 S! M# [: ?5 ?) S) |3 X& U+ x
- #define TCCHEN_SHIFT 22- ?0 P. D% Z+ ]2 }
- #define ITCCHEN_SHIFT 23* b: l. M6 I" V+ k0 ^& d1 [
- 7 @1 K3 y; p" V% {9 q) b
- static volatile int irqraised1 = 0;- j- T% X" H% F( N! [3 s: s4 P
- static volatile int irqraised2 = 0;( K! @& q7 d8 O: U
- f# f% o- ~5 f3 z; p) |$ W3 h
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 `3 W \- r) J% |' w' [ L4 m. S( k
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% Y0 S; r7 T" t0 m - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 G4 y" I& `( W
1 D2 B2 a/ k/ f* \ J- dma_addr_t dmaphyssrc1 = 0;6 G8 m: C4 j% r+ S5 K6 D8 I
- dma_addr_t dmaphyssrc2 = 0;# N* b o/ f% _3 r
- dma_addr_t dmaphysdest1 = 0;0 m. d( u4 I; E$ @ i/ w) h
- dma_addr_t dmaphysdest2 = 0;
1 O& J# X B1 V, B9 t( v% H - & m+ ^7 d: _! d2 _
- char *dmabufsrc1 = NULL;
6 G( a; g' w* M# v - char *dmabufsrc2 = NULL;
6 F6 K+ t5 |4 r) e3 H3 E - char *dmabufdest1 = NULL;
4 u( f2 n8 ]9 C( `" l - char *dmabufdest2 = NULL;' S' {9 {+ z% h$ r
- ) u5 a$ t# T- y" f
- static int acnt = 512;
, H, \ t* w7 Y+ v. I# O+ j! C. U/ w - static int bcnt = 8;+ l, F# s0 \. q. T( F7 ^# E9 |9 M
- static int ccnt = 8;
8 i; |% b3 d! o$ M
3 r7 R, h! L8 k- module_param(acnt, int, S_IRUGO);7 s; G) z( \5 b1 k r
- module_param(bcnt, int, S_IRUGO);8 w- I& @1 ^1 K' T! _
- module_param(ccnt, int, S_IRUGO);
复制代码
8 r' X/ I/ n3 f# a9 m' j J5 @8 Z
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用* f, ]# u; B3 c+ R/ x6 G8 c
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
, E( O& x* w2 n 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: w# o. o8 a* I
' O1 A: j: F; Y6 e1 h9 d
) @$ U: t. Z) H% F- ^. x5 [ |
|