|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; J0 C- i2 h( T/ m6 h- [code]EDMA sample test application+ r, u8 I5 M$ V2 `8 l
- /*& J8 f* H0 w) K# u5 I# Y
- * edma_test.c: X- F7 @3 }0 w5 b u7 L
- *
: k& _& d2 [; Y" S% b8 x; q/ t - * brief EDMA3 Test Application
1 S& P( V, |1 ] - *
) C6 h" }4 D+ Q: I - * This file contains EDMA3 Test code.& f& z2 F! ^, H
- *3 R$ ?0 p! D g b( V! T
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
. v) t! w1 j6 j# c" g2 I - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
4 N! g. F( D R; | - * TO CHANGE.
/ ?. C1 V* f9 T% D* O - *6 H6 e d% Z+ C6 H% I5 n7 V5 V/ ~
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; O$ P7 j8 A8 [2 r
- *
/ U2 l7 w5 j6 E$ E+ A8 e- L - * This program is free software; you can redistribute it and/or" A4 }. k$ k- y& c: D0 u0 f1 P
- * modify it under the terms of the GNU General Public License as
- j( w( c3 Q( E1 {- V$ D- C7 a - * published by the Free Software Foundation version 2.
3 i; | j9 z$ [, f/ P. S$ x' y - *9 M! M3 l; q+ `: _5 L3 m' d- i
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any9 k0 H/ X9 x0 p6 b+ B* p5 Z' V
- * kind, whether express or implied; without even the implied warranty
8 V9 j* z& E1 }) T% m$ G! c - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# o% Z8 W+ |! R
- * GNU General Public License for more details.
4 B' j2 y( i$ C, v - */3 f3 _# m) o! o1 i; V% t, V2 p
- : F( G3 L2 X" P6 O4 y$ p
- #include <linux/module.h>
2 \+ w0 Y' ~ M6 ?4 z( F - #include <linux/init.h>
7 k# c( c+ |/ U' [$ f0 e - #include <linux/errno.h>
% b8 D* F# l! B9 K2 e1 \- Q, \ - #include <linux/types.h>3 O0 }) i4 [8 W& x
- #include <linux/interrupt.h>
: v, C, ~% I1 Q2 G2 q - #include <asm/io.h>
4 F9 c8 c' }+ _2 P - #include <linux/moduleparam.h>- S w) N, }/ F9 g3 Y- Q
- #include <linux/sysctl.h>
. Y4 `! \; N7 m - #include <linux/mm.h>
8 q- o8 E! {- K4 z E& A - #include <linux/dma-mapping.h>
. W g1 U5 d* Q6 t - . Y6 H$ w: J, R! |6 T& i+ Y3 G
- #include <mach/memory.h>, }6 G1 M( E0 @- j( ~& d
- #include <mach/hardware.h># l; ]: k4 K5 r$ T
- #include <mach/irqs.h>
& C# ? s0 {/ x& [$ E/ r - #include <asm/hardware/edma.h>7 r* w) k2 y/ @
" q7 {) j, e5 q$ l- #undef EDMA3_DEBUG$ Z- ]5 V/ q4 |5 G& z& F9 f8 ]
- /*#define EDMA3_DEBUG*/: n: U- L5 B; X7 V% e( y! m
0 G# Y; e" F3 b/ L$ A- #ifdef EDMA3_DEBUG: V4 l9 X4 b: Z# O. i2 r7 C) v, `
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
" }. a. h- |: I7 M! X; @ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
r$ ?5 E7 i4 S6 K0 s - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
5 E- t( t. G" o# x - #else% I) o9 q4 F5 y( i0 f& H
- #define DMA_PRINTK( x... )4 D) P6 [1 G$ j4 y- A, G
- #define DMA_FN_IN
2 v- f! q( h8 W" K% }6 s - #define DMA_FN_OUT6 K) k ^8 \+ w
- #endif. G" r' l- G- h( I2 o4 d! K
- 6 h* i: j: p! z" o2 e5 c; P7 @6 I
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)2 g% j# D2 u' z4 b
- #define STATIC_SHIFT 3( }8 ]6 T! n9 j. w6 B3 j; w8 C# b
- #define TCINTEN_SHIFT 20' O5 H4 y% j0 ]" G; b
- #define ITCINTEN_SHIFT 21
7 b( q, v1 }0 k( r# a - #define TCCHEN_SHIFT 221 a; B; r- r H& `; I; g& ^! u
- #define ITCCHEN_SHIFT 23
, u- k! x: `- {5 ~) M3 D7 _- o - 7 D7 A1 L( c$ H5 N$ G4 B8 l9 \
- static volatile int irqraised1 = 0;
( P1 g9 `2 j7 f, x - static volatile int irqraised2 = 0;
( d3 l; p) b7 I, R
/ ]$ W2 C7 K7 L z, U, M- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 G! x0 y9 K5 h) ^& Q9 l - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! {* r1 R1 z" U: e
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: }+ V% L* w5 b9 e) U) h9 t, e h/ q" T
- ' c+ D' t2 W; S. U( V; H1 T
- dma_addr_t dmaphyssrc1 = 0;
1 P5 a5 d; j$ y - dma_addr_t dmaphyssrc2 = 0;6 X z$ t+ V# G( i
- dma_addr_t dmaphysdest1 = 0;' b' n4 |3 q3 b
- dma_addr_t dmaphysdest2 = 0;
3 w$ D/ S/ c6 T - 6 |9 _! y' K2 {4 c
- char *dmabufsrc1 = NULL;5 c: p+ M& Y+ V' k
- char *dmabufsrc2 = NULL;' I7 ^5 z n; q B+ l
- char *dmabufdest1 = NULL;
4 f2 S- v6 D; h( k* }( _, M - char *dmabufdest2 = NULL;8 c6 X. c/ d' D4 H# g
- + S/ l A5 `5 K& f9 I' D9 H
- static int acnt = 512;
" T" L2 s8 u/ J$ h+ A7 q' Y - static int bcnt = 8;1 \2 c. I' l, K4 ~0 s
- static int ccnt = 8;
1 T% X9 \. B5 A( Y6 ?
0 ~: n2 d1 {4 {6 ?- module_param(acnt, int, S_IRUGO);, N% d% V9 A6 C
- module_param(bcnt, int, S_IRUGO);* b/ v6 w. X2 r7 L2 K1 w
- module_param(ccnt, int, S_IRUGO);
复制代码
, C8 o% f" t# j. h+ w/ o: g5 o: a2 I9 W+ W
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: R% `! f, ?4 `7 Carm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
& q3 @' [' Y% O+ F% a0 U5 v 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
- J$ _/ K7 V5 }$ }
* _0 G0 o; |3 `6 _
5 w0 g* k) W5 @: _" s |
|