|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) o) Z5 t5 U5 |6 Z- h! l) b$ t& l5 g- [code]EDMA sample test application8 }& p; h! S" ^: j2 x
- /*
5 L6 R3 `( t5 U - * edma_test.c% |7 ]! {/ \1 Y! C
- *
% N m, S4 k3 G4 G& a0 r- m - * brief EDMA3 Test Application
4 ?* x1 S2 g( D& T# ] - *
* j0 [- |5 k: j - * This file contains EDMA3 Test code.: G$ F1 E: g9 \- }% E7 B
- *- W5 H" n! j0 w2 y% H! B/ E
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- j& v9 C; K7 j' M7 q- | - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
, F- X; l: }: J* ? - * TO CHANGE. X: i/ r' a8 T9 H
- *
/ D2 p$ p. I( X - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/2 v5 `4 x' V1 Q3 @
- *& m. L0 _3 P, g# h* A( N+ G
- * This program is free software; you can redistribute it and/or2 ^4 a0 ?& o5 B# Q$ Y# q( m
- * modify it under the terms of the GNU General Public License as5 F, c4 a% O y# c! N
- * published by the Free Software Foundation version 2.2 O2 p* L& y7 S" ?9 F
- *
. D Y* p+ a0 V. H- p& D3 V( l+ }- [ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
1 R- M7 q. M; l" w# p+ y! h5 P - * kind, whether express or implied; without even the implied warranty
( L5 F0 Q, Y3 U' q1 A5 |8 D- I6 V: f - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
( c& L5 g1 R8 b* e - * GNU General Public License for more details.
/ z0 x4 o5 f* X0 m: F0 { - */
: @1 C O1 {; F! t- e3 g
! t& |' @+ a7 l* @) @; ]8 o- #include <linux/module.h>, c8 M! x; {/ I9 |0 c U
- #include <linux/init.h>
+ F2 o% J. N( J5 {, C - #include <linux/errno.h>; R5 M9 |2 v6 O( m' J6 h
- #include <linux/types.h>
6 j9 l2 Q4 H- a' b W - #include <linux/interrupt.h>
, L, K5 [, W3 | - #include <asm/io.h>8 ?7 J6 X" B3 u) O' o+ ]
- #include <linux/moduleparam.h>' ]6 T% Z: }$ X8 i
- #include <linux/sysctl.h># i1 X5 C2 ^; k6 m, G4 ?
- #include <linux/mm.h>
1 v% S5 l" H" b" s; v& [ - #include <linux/dma-mapping.h>4 z+ _+ P; ?# z' V( ^
- 2 O1 t! @& F; m* {) n" e
- #include <mach/memory.h>8 }' {/ T, l( h0 A k
- #include <mach/hardware.h>) j$ Q9 b7 [8 F: K8 d: M* |0 ^
- #include <mach/irqs.h>5 h) C, M6 X$ P+ `$ k* |
- #include <asm/hardware/edma.h>! A' Y8 W. Q8 t% y# ^; z5 M
- # n m, [8 j8 c& z" O0 f
- #undef EDMA3_DEBUG
1 D8 J$ b- `/ z8 m( K4 s& L; z9 { - /*#define EDMA3_DEBUG*/1 l$ K* _* G% z- }' w
- 0 T& C; ?+ i7 f
- #ifdef EDMA3_DEBUG
8 ?# u8 d' r6 M$ K - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)0 @. m& Q: ~3 C4 ^8 ?5 O# m; d3 h: r
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
) c6 J/ s8 I) v4 U - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
* o5 F, W8 j* K- D$ ^1 e - #else
/ A Z0 Z5 S- D- }; R, ]4 b/ F: V - #define DMA_PRINTK( x... )
! }' s, e. q3 G" x5 ^ - #define DMA_FN_IN0 L+ Y: S5 X! a5 H
- #define DMA_FN_OUT
! V! Y/ x9 s& j5 p; C% { - #endif
D: T3 \7 ]5 m' q( f
" f. [- K$ s3 D3 Z2 ~ b, z( f- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 ? T ?4 N, K f5 ~ - #define STATIC_SHIFT 3
5 l& I4 d- ~) E+ } u% [% h - #define TCINTEN_SHIFT 20/ p7 T4 s6 ]% j) O4 E; Z
- #define ITCINTEN_SHIFT 21
7 X! H4 f+ d# h6 S; [8 i# q - #define TCCHEN_SHIFT 22
u& N3 Q+ G2 I+ q; q+ N* [# g - #define ITCCHEN_SHIFT 23 Q" Z+ }5 N6 k: N% C# X7 S
( u0 a3 L7 ]" A g) W- static volatile int irqraised1 = 0;1 V6 g% Y3 l k6 ]
- static volatile int irqraised2 = 0;, T) v6 c; O: d/ x, H- x( X; M4 U
- ) h1 _+ M9 Y" ?3 U5 s1 s
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 p: T/ \$ K! C! p2 H. {! t" Z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# E* k( w4 \& i* C% o/ w& i - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& F6 G" M1 [) ~5 U1 Y9 j - 5 t+ C3 a3 j) t- p! i& `; V
- dma_addr_t dmaphyssrc1 = 0;
1 G8 k9 w; B* h4 I5 v! i, _/ ~ - dma_addr_t dmaphyssrc2 = 0;
8 L8 J, w4 L1 i8 f0 F. n - dma_addr_t dmaphysdest1 = 0;' M/ i5 G9 z7 \+ Z. Z4 k
- dma_addr_t dmaphysdest2 = 0;
5 R2 d$ U% G+ F; A& @
3 @* p! e8 R. ^- char *dmabufsrc1 = NULL;
4 N7 V) ]" m+ [8 o7 Z9 N - char *dmabufsrc2 = NULL; ^8 i1 V. I2 E
- char *dmabufdest1 = NULL;, D( f3 t; j/ J7 E2 S
- char *dmabufdest2 = NULL;
1 K1 I( Q5 q, e0 d; q, D
7 _5 I$ M! f* V1 D+ R# Q, E- static int acnt = 512;1 G7 i5 k8 B* O! |* ^1 s6 [- o
- static int bcnt = 8;
) d/ L, O7 @1 a0 s- J - static int ccnt = 8;/ W, _3 ]7 w3 k& I9 o$ B1 ]9 B, a4 H4 G
: f& W- J6 }0 N% f) ^6 b- module_param(acnt, int, S_IRUGO);( s- e3 |* N! g Q$ [
- module_param(bcnt, int, S_IRUGO);: n# `; m0 S% U2 l! b) N
- module_param(ccnt, int, S_IRUGO);
复制代码
3 ?! m1 o6 t9 o8 f! s& u. W* I: {5 j) J
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& c3 l+ b- d# k) ^/ K0 Z, D. Rarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。 f# M+ z6 u3 H4 W y A/ M( c
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
" {, p+ v9 a0 D" }8 t8 o! H/ B( \; {/ m- T% d/ T+ l
+ ]8 a% Y/ L3 ? |
|