|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
- ~' l' a7 {7 J5 i: N; W- [code]EDMA sample test application" U& }/ L7 C( s* X
- /*
0 ~! K, ^( _1 G' a H- q' e0 q - * edma_test.c7 N5 e- B4 D- k4 k0 E/ u& S
- *
* J3 ~) z7 F0 M! V( S - * brief EDMA3 Test Application. M# ?: d+ s r0 e
- *) P4 @8 b- B, q2 R
- * This file contains EDMA3 Test code.
: P8 I. Z) P$ L0 _/ F6 U - *
! B. x) _' L2 P3 A8 ~ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE8 L! _) W5 Z5 h) F# }9 f! k3 o
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
4 v3 u% m5 y6 a* b9 H6 c& j1 ~* q - * TO CHANGE.' Y9 G* l1 S h {. c6 z
- *
5 r& m4 z/ `. y1 ]7 V/ {3 E8 B' ~ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ Q+ {. \! z! }( A
- *5 b+ a, v) G' v0 v
- * This program is free software; you can redistribute it and/or" _' H; A+ H! q3 l
- * modify it under the terms of the GNU General Public License as& c9 M* `+ }+ B6 e( }1 c7 A
- * published by the Free Software Foundation version 2.! d- ~% V9 o# w- M) i$ Y
- *
1 C6 ?2 }" j* d! }) I - * This program is distributed "as is" WITHOUT ANY WARRANTY of any+ f2 } c6 z3 W: E6 F
- * kind, whether express or implied; without even the implied warranty
+ G3 w1 @! ]2 Y+ n - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" c+ S `) G j) M3 a - * GNU General Public License for more details.. B$ a5 k3 P8 d* s$ q
- */
! ^- c( Z0 ]5 ?: m
7 ~4 d. P0 w1 D, g0 p' e- #include <linux/module.h>
$ k0 Y. A& r8 X - #include <linux/init.h>" ~8 U; @$ F, l6 I
- #include <linux/errno.h>
! e( Y% n1 J- y - #include <linux/types.h>
, J; ?7 ?& y* A0 f - #include <linux/interrupt.h>
: ~! ^# R" ]% ^3 F# G; A) T - #include <asm/io.h>
2 p& f( s. c& V) Y - #include <linux/moduleparam.h>: o! Y! ?, I. c$ a
- #include <linux/sysctl.h>
3 W4 u" x* y9 y - #include <linux/mm.h>. W6 d, d# ]) K4 P* o/ t
- #include <linux/dma-mapping.h>
3 I- a% }7 s: ^3 N N0 S' z' s' B
: ^8 m! z$ R) h9 p- #include <mach/memory.h>
2 [% U( T0 o1 s5 f* f1 Z* [ - #include <mach/hardware.h>8 ], T# _+ N' ^( m3 P2 n$ N% l7 X
- #include <mach/irqs.h>, M) Q- H: n) v3 G7 g
- #include <asm/hardware/edma.h>, G6 K: Z8 j- S3 E0 V
) K: g/ N% | V' A* N- #undef EDMA3_DEBUG
: \0 M9 l7 E2 [+ R# ` - /*#define EDMA3_DEBUG*/
M( k- `7 E) q$ ~9 J - 4 {6 R$ I4 y4 O3 B7 s
- #ifdef EDMA3_DEBUG9 Z9 n* {& U! E/ |& p2 m
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
* D! A" ~" I @ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)6 [. y* Q2 F5 ?/ U
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
' a9 K6 M. m9 x9 G8 s9 x2 V$ b* N* u - #else
; {% k! ^1 r" g9 |& a$ Z6 F - #define DMA_PRINTK( x... )4 f. \8 _; R. a* y# d
- #define DMA_FN_IN
+ M- Z) Z/ v+ W. A9 v: ^ - #define DMA_FN_OUT
/ [* U- u, b- x1 M0 s' |: R' T - #endif
m; {7 l6 G" d5 [& P/ e3 B
7 {2 b$ ?3 I/ ]# }$ b% f' I- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
! Z* \- y m# F - #define STATIC_SHIFT 3
* E3 N( p7 A8 D9 T0 ` - #define TCINTEN_SHIFT 20
|( W" v( o- f7 J! m - #define ITCINTEN_SHIFT 21
% p3 M5 C- I" \3 w - #define TCCHEN_SHIFT 22( |4 M4 Y |% E& W3 C& D4 U
- #define ITCCHEN_SHIFT 23; f c+ ]( L$ |! @/ @+ s
- ( _1 g" \% L9 z2 \$ d4 v, `/ B' Z u: T
- static volatile int irqraised1 = 0;
4 d1 G! m# ?, q/ t! K* T' U$ P - static volatile int irqraised2 = 0;6 B: ?4 H; o& ^0 K! G J, D H
* y- g* n- D3 d7 c. t+ a# O- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 F' U$ i- X* P/ [# K8 X% A' {- [* E
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" i: T9 ?( n9 n" q - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: ]8 m& k3 a6 v: l3 I
- ( b k7 j1 W) K6 F
- dma_addr_t dmaphyssrc1 = 0;' r8 r/ D" q- D
- dma_addr_t dmaphyssrc2 = 0;: |5 i' X& P9 l5 P, G
- dma_addr_t dmaphysdest1 = 0;
w4 ~, f+ i$ ` - dma_addr_t dmaphysdest2 = 0;2 x$ Y1 h& Q/ q- Z! f1 T
- * E6 e+ R9 Y: Y; a% ~3 D# L
- char *dmabufsrc1 = NULL;
' k; u$ A' b8 c4 r - char *dmabufsrc2 = NULL;
- _( t* T. o/ Y - char *dmabufdest1 = NULL;
5 s% E1 e9 E( V$ p - char *dmabufdest2 = NULL;5 @9 \ V9 j5 v2 f5 a
- * i2 D* j `6 S8 g- N
- static int acnt = 512;
: y3 B& ~# u3 ~, q Q$ O0 U - static int bcnt = 8;0 v$ V: b, b% R; Q) P5 H7 b
- static int ccnt = 8;& g8 I) r/ B1 x4 ~0 w8 S" z
- 5 S+ e j# q! e" I8 C: ?
- module_param(acnt, int, S_IRUGO);
3 t4 Y7 q! z; @) \# j - module_param(bcnt, int, S_IRUGO);4 I. u3 |0 D4 y" _2 j
- module_param(ccnt, int, S_IRUGO);
复制代码 % s/ n: Y+ B6 ~" s$ e
$ V7 w# e3 P4 {) {
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
" f8 D! }; _3 ^, H- Xarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。4 n% \ S5 M# I* h7 E% N
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% L( i9 D" P& l, K8 N* g
. x: x x7 r6 Y c8 x! q* ? g1 e" q# ^6 J4 i
|
|