|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 d1 i9 y) O' J% V9 s/ d/ O- f- [code]EDMA sample test application
$ L( Y/ P( ~7 y6 L, i4 v - /*
& J# t! a' ~' R0 J1 B - * edma_test.c
# V% M( L4 ]; o L, @. `6 B% k) H - *- K# X# G0 ]0 Q' U+ f
- * brief EDMA3 Test Application) b( U% U1 r- U. P
- *" ^; ?4 i+ J+ `- Q
- * This file contains EDMA3 Test code.
6 `! E3 V, o% S6 F/ a" M+ R7 E - *' v# g% t8 d7 `; O2 b7 a$ h( }
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
1 Q" _0 Z9 I) _, q) l8 v" h - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
) N/ S- c) ?" Z* b0 O - * TO CHANGE.
" O9 N! x. G3 D' X - *7 S4 r; K9 a' q
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
6 X+ d! j3 K* u# b% I, c - *
, S! {+ z7 o; `, [ - * This program is free software; you can redistribute it and/or3 b4 V8 q# B5 [5 H- K& E
- * modify it under the terms of the GNU General Public License as
! a" T, @, `/ j" F7 B( H( l - * published by the Free Software Foundation version 2.% X* i- ~7 s! `* B
- *
& N6 l+ g$ N2 W! z4 |' c6 i - * This program is distributed "as is" WITHOUT ANY WARRANTY of any& r) d; y1 \6 A# ?4 D) D" D
- * kind, whether express or implied; without even the implied warranty
S& C/ j5 @: F1 ?5 |& C: X" B# ` - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the3 L- m# J' n0 c T
- * GNU General Public License for more details.! M5 y7 b- V1 U, C/ R# s
- */7 c6 c, ~7 y4 _
T4 F8 ~+ V; P( l0 c- #include <linux/module.h>
# h4 s: R4 a4 O2 b+ e% f: S - #include <linux/init.h>
- X4 V5 a( h: M6 h - #include <linux/errno.h>
9 y4 \( U- y' v5 G! z - #include <linux/types.h>
- m5 u3 {6 f. n& I# X - #include <linux/interrupt.h>
( O5 U; Y6 g% ] - #include <asm/io.h>0 q* \) ^- n- N" U$ Q# C, P! n& o# y
- #include <linux/moduleparam.h>) H4 X v" k7 B2 c9 W
- #include <linux/sysctl.h>
" K. S* n* Y, }% q, {, X I, r - #include <linux/mm.h> l2 B0 P! { m# k/ g9 A
- #include <linux/dma-mapping.h>
B1 @. \) E: c5 N j - 0 ]$ ]' n/ w: H
- #include <mach/memory.h>, U; M7 i- V8 E7 W9 s
- #include <mach/hardware.h>
- n( r& ?7 m8 B8 S0 ]4 { E# v - #include <mach/irqs.h>* j- J5 {9 s& B" L
- #include <asm/hardware/edma.h>& S1 {8 Q6 e, }+ s9 H; k
- # K, i4 b0 o1 }- B
- #undef EDMA3_DEBUG
% m( z4 u. E' A2 D+ e' n - /*#define EDMA3_DEBUG*/% o8 e. n) P7 g
; f8 r3 D m0 n; j1 F- #ifdef EDMA3_DEBUG
8 S1 K. X- e+ j - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)6 N7 U }* v# L
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 N1 W! q" F& g; S$ V" [- c% j5 L - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)1 F0 V4 \/ B$ H
- #else
7 m* |- K: t( d I/ i' o - #define DMA_PRINTK( x... )
. p. M; s# N4 p) C! K. n# { - #define DMA_FN_IN
0 @' B" o; n4 S& k; J/ \ - #define DMA_FN_OUT
3 W$ v8 @( L, J; \ - #endif7 K( ~2 i, t, V9 I0 Y
- " [, N$ D7 f4 J1 i9 C+ L. O# K- }. A8 `
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; C2 |/ p, |: u9 ]/ M" y - #define STATIC_SHIFT 3
8 P7 ]% Z. e% L9 l/ |+ D$ Z - #define TCINTEN_SHIFT 20
$ V2 p' U5 x9 n) V% G$ z0 L9 H4 O - #define ITCINTEN_SHIFT 21
( R# L) @6 M2 i8 S% Q0 k* F( d, n% y( T2 L - #define TCCHEN_SHIFT 22- l1 y$ ]* |. S$ s9 w" W
- #define ITCCHEN_SHIFT 236 d* ^8 n5 B" n
7 F# y' k+ [) ]/ y& Q; @- static volatile int irqraised1 = 0;, s3 ?2 k8 y1 d' z8 o
- static volatile int irqraised2 = 0;
w# e% j) I. S) e
% I& K: y& e+ G9 T1 n5 X+ N- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 H) ]6 H, [7 a* }1 J
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) H2 Z: s- w: g5 b, z( D+ z: S
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ X4 W. L5 y+ A% @! j2 B
- # K8 H7 X2 F S5 X! W
- dma_addr_t dmaphyssrc1 = 0;
1 O5 Z2 S9 Y0 p/ }9 X - dma_addr_t dmaphyssrc2 = 0;
. Y- o1 K% @3 d1 \" R - dma_addr_t dmaphysdest1 = 0;
2 o8 R$ C! `) d6 K, i0 R - dma_addr_t dmaphysdest2 = 0;
0 o( |, i5 u4 F& \$ i8 W% @! B# v4 Q - ( A6 g+ R2 v4 ^8 p! I- H( e" Q$ p
- char *dmabufsrc1 = NULL;
$ h, ~* A. s0 K8 d; Q: o' ? - char *dmabufsrc2 = NULL;
, _6 ?/ ]9 B+ Y+ J+ f - char *dmabufdest1 = NULL;
: C; _; W8 c' }3 Z: f. }# G - char *dmabufdest2 = NULL;
2 L1 p0 k+ A' h9 H4 |
6 Z4 p# A& E0 d0 H- static int acnt = 512;
( i$ a& Y) |, N' H4 C1 ` - static int bcnt = 8;9 P0 G( c: E" h0 \; j0 S
- static int ccnt = 8;6 n4 k: |6 A* k) l
- 3 ?; Y2 d. Z0 ]" D
- module_param(acnt, int, S_IRUGO);/ Q5 N' h% }4 E2 q& I
- module_param(bcnt, int, S_IRUGO);
0 |6 P% e$ O8 ~; }7 F& I& B- X - module_param(ccnt, int, S_IRUGO);
复制代码
5 `3 G$ Q( \# A$ l- Y' U/ X9 q
" R+ ^& T) D* R! P; I- f 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用3 D' g/ S! _% U4 |. P8 z4 l
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。% c8 D5 @- V7 v0 Y
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。$ S6 d. K- g5 p Y" q, @2 W6 |
& L# c' n+ r: ?2 { C* N
8 Y, M9 D, C5 q0 T6 @+ F |
|