|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; K* ^0 Z7 m( C, {- [code]EDMA sample test application
( x- [" M3 T8 J9 F# U, N - /*
8 ?4 Z) ~4 x) R7 @# S7 Z) N+ { - * edma_test.c2 G1 [- E% U& ?$ a( Q! S, ~
- *
& h! \' A, E5 \* |7 X6 m- L: I - * brief EDMA3 Test Application
/ \! V4 I' |& ~ - *: m0 {/ \1 B3 C! x7 i7 W
- * This file contains EDMA3 Test code.3 U6 e# s8 n, {: d6 T
- *
2 Z: \! Q3 i b, a4 _# Q - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
, E3 X2 r0 v; i; U9 ^3 _& U: `, T - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT- [# g2 b# l6 y
- * TO CHANGE.
4 v; P) m) Q$ m* p) D - *! z& D/ J$ A, t! i
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/% }9 J; l& P2 I. V: Q
- *
- i% H4 ^; b( [1 H - * This program is free software; you can redistribute it and/or$ O% s, c5 } v5 j: B5 E
- * modify it under the terms of the GNU General Public License as
% q) Q, O5 ^$ w z( I - * published by the Free Software Foundation version 2.& \, h) v' I2 e X, Y5 T9 k) s# {
- *& y: r6 C |& B2 g: [
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any0 k) l0 N% n) n3 W6 w+ _4 _; [
- * kind, whether express or implied; without even the implied warranty9 C% V* v& p8 m) l) ?
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 P$ L+ \! X- f6 t0 H
- * GNU General Public License for more details." C( |4 w. f: E' X: F4 _( A
- */
7 O& g4 F) ]1 R
& f5 y7 [, c) f3 S& g- #include <linux/module.h>
% ~& A7 w7 y: f) H0 p a6 b - #include <linux/init.h>
0 Z: j4 J( [3 q - #include <linux/errno.h>/ ^* A r; i3 `5 m* \+ d3 N
- #include <linux/types.h>
$ G* `; U/ J& G - #include <linux/interrupt.h>) R6 R h* S- L$ Z) j& @5 h( ^
- #include <asm/io.h>
/ S' b& ~( z/ t* H* i% W0 u - #include <linux/moduleparam.h>; i3 }5 `' H6 Y7 p5 g
- #include <linux/sysctl.h>$ v5 Q7 S& t, Z- U4 G2 m. R# m
- #include <linux/mm.h>! E$ `8 ~0 t8 `/ P* a3 @0 V3 G
- #include <linux/dma-mapping.h>- j7 d* F a, a" t8 w
- & f! x: I! d5 L4 n
- #include <mach/memory.h>" U8 H; K8 \) U# Z* Q" j; k1 m
- #include <mach/hardware.h>
5 n# _4 ~$ H1 w$ ?0 N+ H - #include <mach/irqs.h>
* o3 x' j% m3 I - #include <asm/hardware/edma.h>
) i' c b& g7 f) p5 Y+ f6 F
) D& V3 F: o! g& ~4 S9 U8 i- #undef EDMA3_DEBUG
1 R9 i1 S. ]0 X+ { - /*#define EDMA3_DEBUG*/
1 [. q" i4 P% P. ~/ N" T
2 r4 H* e/ r- ?& A2 [, y8 h- #ifdef EDMA3_DEBUG
1 S9 m! a% a! k( N' y F8 e. S - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)5 [7 R" \; _: Q% c
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
" Q) n# b: }; e( f0 K# ` - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
9 x. l4 `0 e- V$ D' R - #else
2 F, v @3 M& G5 o - #define DMA_PRINTK( x... )
- }; C! G' q7 ~, [, s0 C( f - #define DMA_FN_IN; R. D7 R0 R% b$ ?$ Q0 N
- #define DMA_FN_OUT
7 \# e- M: _% j% x0 @& S, S - #endif- c' w4 q0 i5 _. H I9 c
- ! ?- i, {+ v8 l: x: F; K
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)5 k2 K5 o& r& X5 t5 s* s# P# }
- #define STATIC_SHIFT 3
' D- i# m1 ]7 g - #define TCINTEN_SHIFT 20) u/ `( O/ N3 J! G! `
- #define ITCINTEN_SHIFT 21
* C7 I8 k- r) A8 A - #define TCCHEN_SHIFT 22
. X* k4 Q9 s$ g3 K4 Y$ [ - #define ITCCHEN_SHIFT 238 W! J, f, k1 a$ b( X+ }8 ^0 j% Y6 _
- ' B+ Z4 r" [$ d$ g9 ? d" l* ]: u& A
- static volatile int irqraised1 = 0;6 h2 x0 A0 d5 P" K6 o. s$ d9 z2 I
- static volatile int irqraised2 = 0;4 c/ |* }9 E' z, q! x
- ; {/ o' q) w6 c) H. W9 |
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 B, {% m# b% k
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 A" i4 A# g2 }$ a3 ~1 `/ u( x) `8 H2 W7 s - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 [( }- l2 B& u# o9 E
- : u2 Q' N4 l& r7 ]
- dma_addr_t dmaphyssrc1 = 0;
' `5 W: x* N& `0 }5 | } - dma_addr_t dmaphyssrc2 = 0;- s. `/ ]4 F# y* b2 D
- dma_addr_t dmaphysdest1 = 0;% P; |4 H; a6 g- n
- dma_addr_t dmaphysdest2 = 0; _- C( R f( H; `
' k! y) j4 M8 }6 w4 q$ r4 C9 w- char *dmabufsrc1 = NULL;2 L. K( V* U3 y3 e1 r( a; q' W
- char *dmabufsrc2 = NULL;5 \, g$ w/ f2 G x9 F. g
- char *dmabufdest1 = NULL;
+ e& c0 H6 ~5 S5 R! e. o2 Q - char *dmabufdest2 = NULL;! a. r; {+ `- U7 m1 q
8 A& B/ U+ \& j0 V, k5 y# ]- static int acnt = 512;
0 x2 ?! [) d4 K - static int bcnt = 8;
4 x8 C- x5 f8 H3 P - static int ccnt = 8;( ~4 U8 v9 ?; A% ]
7 { J1 F/ f/ l, d' t% U- module_param(acnt, int, S_IRUGO);" ^. i7 s7 h' f& |4 [' a
- module_param(bcnt, int, S_IRUGO);
0 B9 ^+ R( V C/ e& U( z - module_param(ccnt, int, S_IRUGO);
复制代码 % [. _" n. N2 @( s
p4 M4 F: a( R0 M, @ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
. S/ R; d' m6 b; t! iarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。: N2 \: y$ l$ p$ ?: l3 h* w. g
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
0 ~3 ]# G% }. L
- N& B: ?9 Q, R1 J; ~' i! f y/ a
& B" b! \+ Q! q) C' c1 I |
|