|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 `( O u1 R2 {, u
- [code]EDMA sample test application
* J8 F* {( h1 _3 l+ u T8 P - /*6 |% f7 {3 } r# W2 x
- * edma_test.c
( O F* {" y2 T; V# I9 f; W( ]% v - *
$ l2 n9 Z7 [; [ x, Y" `* G! ? z" ~ - * brief EDMA3 Test Application0 ]' H: g; C- V% t1 E7 N: O! [
- *
4 b( X9 n5 o/ w; d1 q/ y+ A0 A - * This file contains EDMA3 Test code.0 x) |) r* t V ?, e2 ]( h; }
- *
9 [$ }4 X( T0 T) r+ ?' j% [# F6 a - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE9 J* ?. ]+ `$ V0 q F( A
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% b4 B6 E4 o/ j4 d) @, \
- * TO CHANGE.3 U9 O' A) B2 `4 O4 b
- *( u3 {) \) o1 {* s0 @) R0 m- e8 o& J
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
7 G- L/ x9 T" u2 \1 t& X" I - *6 e! v( u R7 x. C4 G
- * This program is free software; you can redistribute it and/or
1 n4 m/ A9 q) c# v3 k) W - * modify it under the terms of the GNU General Public License as1 E; E# x+ `7 O+ Z: `
- * published by the Free Software Foundation version 2.
$ C5 ~( X$ e! p# B9 Z0 K - *. B* Z+ Y. O; `* x% u j
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any& T' [4 V- o6 N% \
- * kind, whether express or implied; without even the implied warranty
]5 M( R/ _8 l; ~ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
q) b6 |8 D2 F% U - * GNU General Public License for more details.' ]4 u1 ]/ w s# e% [8 H
- */
1 ]4 ~/ p m) |7 ?% S( t: e) R
1 D( k! }7 ~6 Y- ^' V( O( m- C" w- #include <linux/module.h>
0 f) L: ~9 e+ [0 w( \8 o* J; p M - #include <linux/init.h>+ E. ?/ Q- O* [) l- n
- #include <linux/errno.h>
! V, q( B* ?4 E! M - #include <linux/types.h>
6 u9 z* K# w6 x2 f2 @4 w$ W - #include <linux/interrupt.h>
5 b6 i: f; t' J6 u6 i3 s - #include <asm/io.h>$ j+ e2 l8 c) m4 f$ W
- #include <linux/moduleparam.h>
. G" e5 n/ ^2 C; R* r1 U; ^ - #include <linux/sysctl.h>: H y! J5 O, L6 B
- #include <linux/mm.h>
5 l6 T3 t$ Q2 E# k/ N( z - #include <linux/dma-mapping.h>
1 j7 Y$ Z+ t( U' c
* D" O7 N A& O- #include <mach/memory.h>4 E! H) k$ L; i. _; K' u
- #include <mach/hardware.h>
' ~7 _+ c* P6 t/ W5 f: z - #include <mach/irqs.h>6 b. f) g" k9 N( n, f( ]; s0 Y
- #include <asm/hardware/edma.h>
; o6 i' o7 H2 V3 Z& b1 p D' k/ }* S - : b2 E l, V# v' X1 `
- #undef EDMA3_DEBUG
8 t' \; l* E8 J+ D8 }2 ^8 t, W5 _ - /*#define EDMA3_DEBUG*/) \2 Z; t1 A, G+ f+ t; M, Z( H3 e* V- l
- ( ^) c/ O9 B, C1 q, M1 Z0 I E
- #ifdef EDMA3_DEBUG. q. n. x3 Q4 X# v0 j2 T; `
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
0 V' m: T L- M; O0 A2 }7 w - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)6 l9 v$ B# C4 f, K$ a6 d
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)5 f, K/ h* {. z
- #else
8 |4 m, n) w( A6 k) n- | - #define DMA_PRINTK( x... )1 w5 F3 b) x. h- I
- #define DMA_FN_IN
, X- u2 D, [1 M$ q - #define DMA_FN_OUT
( l* H* o$ @( Z# @* a1 W1 J - #endif' J: k2 A8 A" C$ y- m* |
- 4 _, I. w* {/ j4 `
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: m% H7 V! b4 Y! U0 U" P2 V - #define STATIC_SHIFT 39 \0 z( D$ }5 [7 `6 O2 b
- #define TCINTEN_SHIFT 20
1 e4 f+ d, q; k* v: s$ u - #define ITCINTEN_SHIFT 21
: X: o* e; Q% R/ F( r - #define TCCHEN_SHIFT 229 W3 S9 m0 t5 V7 s# @3 n
- #define ITCCHEN_SHIFT 231 ]$ b% |. l2 a5 p' m
A4 `& Y* j. a- static volatile int irqraised1 = 0;5 W: h2 \: x- J; J& O
- static volatile int irqraised2 = 0;1 |0 k+ m# M( Q
! X* N6 j' v2 u- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! H1 b: p) ~$ R% f
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# S: j0 ~2 k3 l: m* M% O* Q5 |" G9 m - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ O X$ ~ u9 q# e" {8 P- F7 e - - L8 K5 ^, n C+ A6 L( i0 V
- dma_addr_t dmaphyssrc1 = 0;6 X' E! T5 w& u& [, B
- dma_addr_t dmaphyssrc2 = 0;' R* a, @ y2 a+ M
- dma_addr_t dmaphysdest1 = 0;
$ U2 y( l* a( c& K5 {0 ?1 N - dma_addr_t dmaphysdest2 = 0;' k3 N4 v H: e% C
& I7 h g+ ~8 `% O- char *dmabufsrc1 = NULL;. |$ `- y. h5 O( o" D1 x
- char *dmabufsrc2 = NULL;/ y: k- W! m. M- s9 R. K( K3 V& L
- char *dmabufdest1 = NULL;
' y) B# e0 I: I: @, Z: L/ A; b* L - char *dmabufdest2 = NULL;
+ d! L. s3 h2 z0 z
6 ?( Q2 r/ j; m% g- static int acnt = 512;
/ ^/ M5 [' u+ J Z' H1 M - static int bcnt = 8;
3 T( L l' R; Y7 C# m - static int ccnt = 8;
7 p' A1 z( @0 D) S - $ K' y2 r7 R9 N0 z8 {
- module_param(acnt, int, S_IRUGO);
; W# i# A% t. L+ h: @; v: G - module_param(bcnt, int, S_IRUGO);4 Y# Z: b# ]0 X0 P
- module_param(ccnt, int, S_IRUGO);
复制代码
) y" q: M0 T$ u1 z' g
' H& R5 `3 u* X0 a2 n% O 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
1 J# w& e' U5 B+ s0 Barm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" I! K/ a) E- `& E! L. s
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
0 y$ q6 @( v6 U3 e1 H/ {/ X; Y; F% b9 _7 \ u
; `; d$ h( [' A9 Q |
|