|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 " m5 a$ U2 w( B* I# X
- [code]EDMA sample test application
1 }1 u" p M ^ - /*
2 t$ k p# h, L) N( Q - * edma_test.c
9 O) d) r" {: K3 D# | - *
- E3 P) A9 Q: {! f5 V - * brief EDMA3 Test Application* G1 C* a9 v% X
- *
- r3 R7 ^( L4 J - * This file contains EDMA3 Test code.
) D7 R# i# S* a+ s - *
7 S( T3 V2 r7 r2 L" @# f9 v - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE- t8 g( q* w9 x3 r( Y" e/ @
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT. w5 U# C/ i3 p
- * TO CHANGE.2 A) d6 ]% u; p( S) _' D
- *
5 @, s- W1 L: _7 C/ n6 P - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 P& @1 y, e% N( S1 p, \ o0 O7 h
- *
- u, k5 V* r* W& `, ]! N5 O - * This program is free software; you can redistribute it and/or
* W r8 p# ~! V6 }! X1 z - * modify it under the terms of the GNU General Public License as
1 Z, c' @% a5 Q7 R% n& H q$ Y - * published by the Free Software Foundation version 2.8 w% v4 C$ C+ t1 Y; y: I
- *9 E8 `' M; ~0 u0 m
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any, j* ~1 [/ Y4 V6 Q
- * kind, whether express or implied; without even the implied warranty
( E% n" C) N s; Z8 ^1 N5 g - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7 K4 a8 q/ d E - * GNU General Public License for more details.
9 \ b1 W% J' j- N - */
" T$ j$ y! k& I9 K5 B, ]5 x# Y
+ y3 p: B! N5 a5 t7 s& l- #include <linux/module.h>7 B7 _1 S8 ]1 k% ~8 K( j/ {* I
- #include <linux/init.h>
8 h1 l" _+ d# ?+ H n4 d - #include <linux/errno.h>
7 y. f: R, l2 {& |) i9 h0 a - #include <linux/types.h>; q# V5 b8 k! l0 ^( ?
- #include <linux/interrupt.h>4 }: y I) `: b0 a& K% Y
- #include <asm/io.h>0 H F, k6 j' |8 q! Z
- #include <linux/moduleparam.h>
% a! ?* N8 m$ r2 n' V) h$ t: O I - #include <linux/sysctl.h>5 L; g- y) c* o9 F5 K* i0 R
- #include <linux/mm.h>
/ ~0 T% b' h) ?5 B/ i/ L# h - #include <linux/dma-mapping.h>% t3 Z- r6 h; N* H6 i/ W# q" f' G7 E
- % U r2 \3 |7 w' O w
- #include <mach/memory.h>
; L% |1 I C3 x) U; k8 ~9 Q - #include <mach/hardware.h>: j O/ V; V6 o, w8 H; t" D% U2 \
- #include <mach/irqs.h>+ }0 G! Z& b% |
- #include <asm/hardware/edma.h>8 s, M6 `" k" @9 x0 E) O4 T
2 D) r9 [* o- X, Z \% h- #undef EDMA3_DEBUG
- R% h \6 C' n$ P3 Q - /*#define EDMA3_DEBUG*/, r9 j- N8 {( N! x
- % m4 x" M% B6 N* y! z! U+ h. H
- #ifdef EDMA3_DEBUG6 R# X7 |# D8 a
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS), c. d# |$ t% Z' O4 I4 l3 `$ [
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
0 P5 l u) n8 }7 n, _ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
; k* @# N" z% y- f3 a! \ - #else
5 m! U% x% x1 E3 O: i - #define DMA_PRINTK( x... )
0 s+ X! F# g/ A; J4 e# o3 v - #define DMA_FN_IN
) r$ K% L% ?4 r: m9 X6 { - #define DMA_FN_OUT
% a; a H% q2 J! P ~ - #endif
, L. b6 y/ T. r$ Z( Z& h - - P2 o+ z) {8 w3 i9 T* u
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
$ w: e" t: t+ r/ n6 y; S( Z+ B" M+ B - #define STATIC_SHIFT 3
$ U$ r4 n) S) P t- W - #define TCINTEN_SHIFT 20" D5 F2 |6 @6 N- ]; ~' C
- #define ITCINTEN_SHIFT 21
8 {& V; {6 o, U7 Z9 J c - #define TCCHEN_SHIFT 221 ^' C! G; h( H9 |9 _/ {3 q
- #define ITCCHEN_SHIFT 23
7 z6 P4 U/ P2 |; F/ Y - ! l# B) D1 n5 ^( i4 h: i3 N
- static volatile int irqraised1 = 0;
F; u4 ]( ?: `! X9 l, G - static volatile int irqraised2 = 0;
! m; s2 k7 l7 x6 V* w
& a" f: j0 r% J. w5 z/ u& U5 g" j- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- |- {5 {$ k( ^/ ]* D( [; } - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# T2 @$ f- W! |' }1 [ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, J2 K, x) Q- _2 X
9 f" M+ {8 k, T( W2 H- dma_addr_t dmaphyssrc1 = 0;
/ E9 S* `1 T; j( G - dma_addr_t dmaphyssrc2 = 0;7 t; k4 U* f6 P" |6 M3 H
- dma_addr_t dmaphysdest1 = 0;( T# q: N: H+ {; N, }, N
- dma_addr_t dmaphysdest2 = 0;' t( u! |( v- r6 l: d- x2 x
& K4 N$ m$ k5 | _8 I; V9 e- char *dmabufsrc1 = NULL;4 Z: K) Q0 u u3 n$ B
- char *dmabufsrc2 = NULL;% F7 N' }0 o6 N$ f6 a/ F
- char *dmabufdest1 = NULL;5 ~: V& ^# v6 t( X
- char *dmabufdest2 = NULL;$ R7 L/ ^+ V8 u9 W& ]: A7 b4 H: f
2 ~- t- B/ U( i) N) O- static int acnt = 512;
% ?8 ~1 q7 ^7 H- |7 ]5 `5 [" D - static int bcnt = 8;- H# Y2 d) A2 w) S& G
- static int ccnt = 8;5 X+ K9 D% v7 _; K/ v8 @& N# q
- 5 p6 k) U- j! @0 A+ r. @. y" y
- module_param(acnt, int, S_IRUGO);
$ f' P3 R2 C. t. m$ {$ B8 s - module_param(bcnt, int, S_IRUGO);
9 {0 k) g, c# y+ C J - module_param(ccnt, int, S_IRUGO);
复制代码 2 O5 p |. ^% H" g7 h2 T C
* g1 A" a3 t0 H) C0 b3 }
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
8 ?+ k4 s4 J1 t2 d/ Aarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
' s4 q4 {& \. b7 I& ? 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。) F# Z# m6 u6 q6 D+ b0 O
: H% h! O% B7 d, l% K
2 q: x4 Y: {. M" Y! U5 N$ q7 ^
|
|