|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 P# N) l! G( M/ m; ^9 W b- [code]EDMA sample test application
c4 h o: ^' ^7 b" V6 H - /*
" ?4 l% G: ~0 y1 L - * edma_test.c
# J' a* Z: B# C5 i* r D% ` - *
# {) \) ~6 Z. d+ Q5 A - * brief EDMA3 Test Application8 V* A T# W( f3 R3 n, X4 ~+ J
- *
5 N& _1 K& ~$ A1 G9 p - * This file contains EDMA3 Test code.& P$ ` d& F3 a/ K4 |6 c, o
- *: a- j4 m8 _& i1 ~0 k
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
( f8 E! P/ a+ \# c, j - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
* ^( p7 j: y" E- ? - * TO CHANGE.
( I5 l$ s. @3 ?5 S - *; }* y h2 Q7 X! v9 \
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/8 [3 q4 v# t0 W) R& L3 ~7 R# b' a& t
- *
6 W* k" V) e2 ^& B - * This program is free software; you can redistribute it and/or; V' M! L- A* {& l5 z
- * modify it under the terms of the GNU General Public License as% A" ^ q1 O" j% [* S
- * published by the Free Software Foundation version 2.% g. n8 w( A7 d' C% G: a" T; O/ q9 P
- *# i) q2 d: B. c( M' W+ T) W
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any- V4 H% Z9 Z7 M
- * kind, whether express or implied; without even the implied warranty* k- ~. r! P# l7 d& y- w1 ?; \
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 }$ |, p4 S- Y7 @1 b1 R
- * GNU General Public License for more details.' z1 u$ ?1 N1 s5 q3 t
- */8 E3 w+ F4 e* Z( P6 |, @2 u
# h9 `% w6 }9 g* l. T3 g2 Z- #include <linux/module.h>
, h- s! H! Z$ V) n4 T7 P - #include <linux/init.h>
( x2 z. E$ X, e - #include <linux/errno.h>
5 K8 U9 W. q$ j; x% | - #include <linux/types.h>( g; k& W7 B% L5 V
- #include <linux/interrupt.h>7 M. }8 ~: R, ~1 P, R, Y9 m
- #include <asm/io.h>2 u# }( H9 R {
- #include <linux/moduleparam.h>
, X7 W7 ~* O( _% r* q/ ]6 l - #include <linux/sysctl.h>
% h. a& s& Y: {7 ` n - #include <linux/mm.h>
8 m4 G Q+ {; I( w! v. z% V - #include <linux/dma-mapping.h>. P" {* D# @6 W3 L- Y$ t- @% C
- & x+ Q) c9 b' I" w8 K' L7 G- G
- #include <mach/memory.h>
+ C+ N$ w7 \1 T' |. y' i- Q/ O$ c - #include <mach/hardware.h>
/ F( L$ D$ x+ N - #include <mach/irqs.h>
9 d4 ~7 P$ _; k - #include <asm/hardware/edma.h>* N" g8 S- }+ t3 t1 N* l$ V7 }) O2 S
- 8 T8 N$ A% g4 Z T0 J" @
- #undef EDMA3_DEBUG
# f3 J# @% }7 I+ @ - /*#define EDMA3_DEBUG*/; M4 S h4 d6 t# Y
1 J9 a/ N. m6 x- #ifdef EDMA3_DEBUG$ V, U# L/ n# n5 e
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
h* ~* e1 E1 s# n - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
/ C) h' i1 w0 _6 h8 ~+ W - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)/ F( E0 j" g0 K. k
- #else
7 ?3 Y! H% d9 ]. @ - #define DMA_PRINTK( x... )7 B. _/ {, w2 _. P
- #define DMA_FN_IN
- O |& ~' f1 d7 P( f: h - #define DMA_FN_OUT
1 A4 x+ |" `6 D - #endif
: v* t% v3 ?& P9 L& g) P) x - " ~& _" t; O( P; ^
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)2 {" D- q* m! G
- #define STATIC_SHIFT 3# {% E$ a1 v7 x* R: r. p" J6 Q+ }& e8 k
- #define TCINTEN_SHIFT 20
9 K* ~0 V, p7 j% D. F - #define ITCINTEN_SHIFT 21/ k5 p; R$ D' u5 k- L
- #define TCCHEN_SHIFT 22
# Q- b4 x3 X* }( J0 b2 N+ O4 C - #define ITCCHEN_SHIFT 23
8 t+ T) M: C; v2 Q; `0 |& _, I1 i
. M( E _' C1 U0 I2 w- static volatile int irqraised1 = 0;
; Q6 D2 ], C }8 e( @( y - static volatile int irqraised2 = 0;+ x _8 Y; i% N, ~& O! z
2 l4 t( e* [6 J; O9 Y: V# ~/ m- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! i: ~7 m5 u3 y% j7 I$ t# r3 n5 d
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. P9 z( a* o& V5 z
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 o( ]) y8 g" [
; |- E/ f- j* a( i/ ] h1 d- dma_addr_t dmaphyssrc1 = 0;0 B+ n$ b3 m5 y2 X" @
- dma_addr_t dmaphyssrc2 = 0;- r7 m8 G% Z. X0 f
- dma_addr_t dmaphysdest1 = 0;
" q0 [2 c8 j0 ~* D$ k$ g - dma_addr_t dmaphysdest2 = 0;
8 B6 \9 G8 l3 z: y& E
0 @ v3 z# j4 U7 k0 ?; `$ |- char *dmabufsrc1 = NULL;! R, V* \0 [' P5 ^
- char *dmabufsrc2 = NULL;
$ w' v5 v, U, c$ `, j" t$ t - char *dmabufdest1 = NULL; ]3 B: v' R z- o, n! j0 ^$ W3 d
- char *dmabufdest2 = NULL;4 q- ]4 b2 s: t: Q( w' r; S; g/ J
- % |) D3 _5 @" y1 o! j' d
- static int acnt = 512;1 O; g/ e) `/ }8 o$ D1 d f" F
- static int bcnt = 8;
: ?5 B% ]$ R; l. W - static int ccnt = 8;' e' [9 N0 u/ w* {: u. o4 a
: M8 w: m# Y3 w' R6 [* g$ V9 ~9 ] W- module_param(acnt, int, S_IRUGO);
, ?' [- J4 L. v; ^ - module_param(bcnt, int, S_IRUGO);8 P% v8 \7 ^5 V0 ]. ^
- module_param(ccnt, int, S_IRUGO);
复制代码
! k' D6 m! l5 p+ b* f6 |. q3 y8 G: N: l) g7 R
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
* l6 D& q# r* j; X' S+ v2 zarm-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 ~9 G8 w- Y2 a, {3 P- P% S. {
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
. [- C! ^6 P, Z* Z
6 t9 c: d$ Y- L3 B4 E: ^- p1 w
. C, h! P# F7 `1 g6 p" D |
|