|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
& j# ? c0 v' x- [code]EDMA sample test application
% U' j4 U3 Q9 w2 Y - /*
+ |8 b& _# P! `& ]$ y3 B7 J - * edma_test.c% A" ^7 G/ Q/ |% B% J
- *
0 c5 S" O \: ^ x Z - * brief EDMA3 Test Application
4 N$ r ~7 p2 K" D+ \; g6 V8 Q+ i - *
3 x3 }2 m$ Y( f$ t% w0 U- x - * This file contains EDMA3 Test code.
, w+ @, Z8 G* a7 ?$ e# a: @ - *3 S+ d2 _( A% A
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
, n6 h) x. H9 z6 q6 O# J - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
$ b7 N; I9 q" D2 f4 \ - * TO CHANGE.
" }1 \9 m- g3 |# s" N* s1 a - *; Q0 }7 R+ _. S0 {5 `
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/* r2 |7 }% w+ }7 V1 r- i
- *( ?. @5 W+ A5 F
- * This program is free software; you can redistribute it and/or
5 \+ u9 |! w2 `; W% D( l H8 W9 J - * modify it under the terms of the GNU General Public License as
) z: _! n5 ?) V5 i8 w% |/ m - * published by the Free Software Foundation version 2." G b- X& P0 a/ K1 A& u
- *
7 a8 M9 U' f% o2 X - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
5 b( A. ~/ Q- e( W! s: Z - * kind, whether express or implied; without even the implied warranty
! M9 o6 }" B( g) o8 O' c' }. L - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& @7 H) v. e( p4 R5 s- d - * GNU General Public License for more details.
# G! o8 C' ?. u4 ~ - */
0 l! ]+ n0 t8 F- N - 6 o& C q, Q5 ^) p1 {
- #include <linux/module.h>
8 }) f+ t; L4 V+ K- ^$ c2 g" d% Z) C - #include <linux/init.h>
+ f8 S- N& i. f* `$ X# T1 q - #include <linux/errno.h>
! `" l- G, ?8 D( F - #include <linux/types.h>
" T; r4 N: h. Z: B# W! F0 f# J A, [ - #include <linux/interrupt.h>4 j5 e8 w' r9 n$ @9 |* n- }+ p, Y
- #include <asm/io.h>* d2 Z* [" D* @9 v$ a( G
- #include <linux/moduleparam.h>3 ]2 B; J+ k7 B* r
- #include <linux/sysctl.h>, @- e' K: H: p5 }* g. {
- #include <linux/mm.h>. q5 o& l: l0 M- P+ U: _5 P* \
- #include <linux/dma-mapping.h>$ H0 N" e2 L/ M. [1 G5 B4 p( ~
l# s, q5 W; ?6 ~- #include <mach/memory.h>/ d, @7 C; q' Y
- #include <mach/hardware.h>! f4 [1 v! w9 h h: }$ k
- #include <mach/irqs.h>
" M. Z6 i, m9 I2 N4 `* j# w4 o - #include <asm/hardware/edma.h>5 R# m. P/ e; R' W# o
) l0 Q- i9 |+ Y- #undef EDMA3_DEBUG- v4 E1 D% s& D7 {6 W
- /*#define EDMA3_DEBUG*/
% v' H' B7 a. M* F. U. L - 6 }" b1 A8 n+ ^1 @9 A6 }
- #ifdef EDMA3_DEBUG
' W* l9 Y7 N+ e2 q - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
, ^( J; a- y0 K- b% I" I. J - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
4 L, {* m6 A) ]4 B/ Q3 d - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)$ p' f4 ]$ s* H' k* Q, ? y) ?
- #else5 m" S9 t1 m, W6 y5 c$ \
- #define DMA_PRINTK( x... )4 R3 \: P* A. Y. j$ @& P
- #define DMA_FN_IN, u; @5 q& Y' V
- #define DMA_FN_OUT6 ~( v8 t3 N6 K6 ^8 J
- #endif! B9 |' F/ G4 r- F# n8 W
- ' [" E Y0 L% {- R3 X+ G' }# P
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ @ ^; z/ H" ~
- #define STATIC_SHIFT 3
+ J \ o) b2 j5 ~. i/ o- H - #define TCINTEN_SHIFT 20
0 [1 G4 _+ A' s9 z: J - #define ITCINTEN_SHIFT 21
4 c; r' t% `1 p- L6 @* }7 { - #define TCCHEN_SHIFT 22
" d. L8 z6 U: V' l$ ] - #define ITCCHEN_SHIFT 23, ]: T. a& I/ `
5 e. u/ y2 b, Z- w- static volatile int irqraised1 = 0;
/ M) z& p$ H/ j0 [0 U2 S% z - static volatile int irqraised2 = 0;6 T+ j, t( C" C H7 }
- 3 o. F/ j! y# ]9 A3 Z
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* M% a( e" X- v
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# r5 y( w/ q/ Z7 g9 p( J% K - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' c% U* @5 `, @$ s, D/ h+ v - * m; o- |, B0 I1 d
- dma_addr_t dmaphyssrc1 = 0;. L: }& t* }/ _, |% C8 p
- dma_addr_t dmaphyssrc2 = 0;9 H# X0 L9 @6 I0 z/ e0 W
- dma_addr_t dmaphysdest1 = 0;
) K$ r2 z- O. B& w7 J6 Z3 @* C - dma_addr_t dmaphysdest2 = 0; F* a- q* }. c2 V1 d
% P. q/ |* E ^; ^- char *dmabufsrc1 = NULL;0 J. b* z* q% O* c r" D
- char *dmabufsrc2 = NULL;
& ?1 l& J: o( y. i - char *dmabufdest1 = NULL;
$ Z4 G0 t3 @) V+ Y) h - char *dmabufdest2 = NULL;
6 u2 I+ I& }7 V3 R* j9 E - - z: P- |% o, z+ r
- static int acnt = 512;
" U7 w. ?/ I: H! q3 i9 D - static int bcnt = 8;
: ?+ v; |! M2 @; Y - static int ccnt = 8;) U+ |8 k; F; s6 q
- ( h- ]% }9 ~2 g* n# w" N
- module_param(acnt, int, S_IRUGO);) a, N0 t* V. J8 V- H$ ~
- module_param(bcnt, int, S_IRUGO);& _9 l+ E7 D1 e# A+ _' N4 ^
- module_param(ccnt, int, S_IRUGO);
复制代码
9 J' `0 a# s" C/ y* U3 |# M
: l2 [$ I* e/ b- `8 u 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用8 t$ w5 v, U% D* X
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。2 [6 K! e5 l7 s1 ^" ]% P% N. E
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
& t1 S% I' c4 p3 n- Y: K' y5 b$ \! n2 t# r1 _
" F' T* y; h0 }, } |
|