|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 + Y4 T% s( P5 @6 O8 p
- [code]EDMA sample test application, ^5 m$ d% ?4 Z: h
- /*
* Q& ^9 P1 M) r& w' J - * edma_test.c
- P2 I8 `0 ]' Z: b) ^. f7 M - *
6 G, K" {( S j2 a) f+ J! Z) B0 q - * brief EDMA3 Test Application
6 t# N1 `+ \0 _) y. b$ o - *8 }2 `4 f# Q- }: q" N2 q6 a
- * This file contains EDMA3 Test code./ k+ L; Q8 u! c# t& ^, ~- ]% k
- *
. R2 R" z0 J2 Z$ S1 W" B - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE' X z' G5 P: m
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 K' A# n0 H3 e/ n! u$ H
- * TO CHANGE.
8 p5 f' K/ y3 h. z - *
( ]+ n+ z7 L$ c* d( { - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/$ }) p; S( \. ~$ s. [! i
- *
) O$ c4 s9 ~+ [- n - * This program is free software; you can redistribute it and/or
" g5 {9 n% Y9 K5 u - * modify it under the terms of the GNU General Public License as# f& J9 c; B. H8 n
- * published by the Free Software Foundation version 2.
4 {' B" u2 J* T2 h/ }+ Y& G' d9 [7 @0 A - *
1 X% _+ b- X5 |2 V. T. }0 Q [- a" Z - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
. o& m: g) ?% W# i5 |9 g - * kind, whether express or implied; without even the implied warranty
- C" e. I2 D) J6 c8 r; e - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
( F# `" x3 w1 f& A) } - * GNU General Public License for more details.; b) d, Y' M+ k, f8 C2 G
- */
" Y% U9 s. g9 [ - ) z) p* y, R; a( R4 p0 U1 U) {
- #include <linux/module.h>! l @; f6 K9 E& ^: J+ V
- #include <linux/init.h>
, R3 ^6 D% `9 W7 q Z i6 ]. u - #include <linux/errno.h>
0 c7 V; @2 F7 O) H6 E) Q6 T - #include <linux/types.h>) e8 h6 j. ?' }( \( c& A
- #include <linux/interrupt.h>" R1 `1 y) |7 H$ D9 @
- #include <asm/io.h>
$ M0 L% P- p4 I - #include <linux/moduleparam.h>3 h- b% O& K( d7 ^6 [. }
- #include <linux/sysctl.h>% V9 ]# d4 a- O9 t( m
- #include <linux/mm.h>
4 _7 P2 j' ]! H: } - #include <linux/dma-mapping.h>
- O; a5 D& D" |8 Y2 t* A( U( u - ' H. Z* P. \/ c. j) q
- #include <mach/memory.h>4 u3 ~3 h% K5 W
- #include <mach/hardware.h>! ]1 y( i& D2 z& R3 D G3 L0 P
- #include <mach/irqs.h>
0 }/ N$ y0 x4 ^0 Y; F! ` - #include <asm/hardware/edma.h> i$ f+ g) V6 B& z, E: e
- 0 {2 t8 ^/ L* b" j
- #undef EDMA3_DEBUG
' R" p) l, o! Y+ g) o1 p - /*#define EDMA3_DEBUG*/. p7 ~) m( G v7 W; i
- - Z# P* Z+ l. j
- #ifdef EDMA3_DEBUG
6 Q9 e& T7 C& L* M5 Q7 A9 _ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
$ z7 c* H& |. U5 S$ o$ t" X - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)9 ~, g0 J0 T6 h( a, E
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
5 d3 N: E2 ~3 W( e+ s- j5 G- `+ h - #else: X( Z3 ~+ }. C$ X
- #define DMA_PRINTK( x... )
9 [; G( D" e/ S* [/ h; a - #define DMA_FN_IN/ S" H- n0 u8 _- S) \+ A1 [
- #define DMA_FN_OUT: ]. u" }2 }0 n: f/ O8 |9 ?
- #endif+ J% k- Q& L+ ~- h8 y% G/ f
- % o* o$ A( p6 i7 b# Y3 R$ N
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 ~8 ~& E' q1 L' ?" _. G; {* Q - #define STATIC_SHIFT 3 c% ^/ B; {* C
- #define TCINTEN_SHIFT 209 C/ X1 e4 Z( u' l- y0 E z' x
- #define ITCINTEN_SHIFT 21
F2 A5 ?. D" ?; L6 `# a - #define TCCHEN_SHIFT 22
5 s0 m) V* v7 ] - #define ITCCHEN_SHIFT 23
9 M+ `; I( P1 }+ a4 k0 R8 s - , I. q% F5 r/ R' K$ t* P
- static volatile int irqraised1 = 0;' n5 V: `& s9 {4 p9 _6 }, H
- static volatile int irqraised2 = 0;
6 I8 p( J/ v, g. K4 U - % N/ O+ P* v! y t( V% A) T
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); O4 q$ Y* Y, P8 L9 ]
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; l* A; T' w7 l) e+ `4 \
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 Y6 j* L# P' m( r; B T2 `
3 _ H4 p' Y: G, S' W$ C" e- P7 Q- dma_addr_t dmaphyssrc1 = 0;
6 j& }3 e, Y, P - dma_addr_t dmaphyssrc2 = 0;, C# K# j" G9 { {2 v
- dma_addr_t dmaphysdest1 = 0;' u0 R/ W- U. f) o8 g8 H+ @
- dma_addr_t dmaphysdest2 = 0;. _/ K: L* p8 ?% V# j% h
- 4 v( I7 [: }: U7 ?0 G' L
- char *dmabufsrc1 = NULL;0 Y/ E2 F0 s e8 B# `3 ]
- char *dmabufsrc2 = NULL;5 U, I3 l! s6 Y) C) g. \+ X
- char *dmabufdest1 = NULL;; s/ @8 o, q2 m5 s1 M6 k) V' D/ e! y
- char *dmabufdest2 = NULL;' i* S+ N4 S, y# j, d" p0 t) u
: o- z4 c9 A1 I# g% I- static int acnt = 512;
# o. p. X9 e3 l - static int bcnt = 8;; P# U, u+ ?+ \1 t6 w1 E" K7 h
- static int ccnt = 8;* l5 g6 [* Y5 x" N1 I
0 r0 p r; Q5 \5 w1 [- module_param(acnt, int, S_IRUGO); a& w2 }1 i9 Q, l6 b
- module_param(bcnt, int, S_IRUGO);
( e s8 ? ?) b; E( k/ b' e - module_param(ccnt, int, S_IRUGO);
复制代码
( i1 \6 ^; ^ p, Z1 j0 u. x; d5 \
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用5 n1 c6 D( {( T2 k. M
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
6 b& d1 Z5 L' ?8 n 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 P0 U5 b7 M( m
4 S* h! k2 |" t2 P% q# h' m
( u! S K: D* ?7 F, B |
|