|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, ]4 E! f/ B; F! i& C: q" r- [code]EDMA sample test application( A8 B: X% w* {" J. A H, G; [
- /*
1 R% A0 N! Q, y - * edma_test.c
/ _- f' G; @ K! N& i( w0 y - *: K4 g) u* D: e% S: U4 w! \, \
- * brief EDMA3 Test Application, m" D2 ~5 \8 p$ J6 [
- *
1 \: g) i9 q; r - * This file contains EDMA3 Test code.
, t& d, C6 N9 w4 g - *5 U. v8 H }0 X+ X, e9 R0 L$ ^) r& ?: g
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
1 J& W* A/ x* H7 c: E9 K - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% e9 [( A' }" B+ P6 c, x( w! D( F
- * TO CHANGE. K ]# K) `$ v; l5 K
- *
7 B) H* C0 `+ X: d8 b7 N1 m - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
4 G( U y) O( z% g - *
: K4 Z) S8 n* k) A8 G" @3 [; m - * This program is free software; you can redistribute it and/or
2 w4 a& E6 H, {9 N2 K7 j, ~( y - * modify it under the terms of the GNU General Public License as
3 O, b' ~/ m& T! l0 M5 G - * published by the Free Software Foundation version 2.! ^7 h0 x. e& `6 F$ o
- *
" c, F5 W7 V! j* V8 A* `6 t - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
z7 l( I, B+ i4 I6 n m: n$ G - * kind, whether express or implied; without even the implied warranty
! T1 t- c9 ~" F" w6 I - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the7 J4 c7 z, o- f: \
- * GNU General Public License for more details.
6 E3 O. y7 [ M) l! I - */5 a5 n2 [) U; F9 e9 o
- & E7 Z3 m! g( z6 g0 t
- #include <linux/module.h>
+ ]# S$ X' ^4 ]! ^ - #include <linux/init.h>
G, S# |& {# w; t - #include <linux/errno.h>. k2 F; o7 ]6 {2 b9 ^
- #include <linux/types.h>+ O& }& P4 `4 c1 {3 U/ _
- #include <linux/interrupt.h>
; S- M' D4 t% E6 [% I; T; l - #include <asm/io.h>0 _1 X+ ~$ `4 W( X9 g. l
- #include <linux/moduleparam.h>
" p+ _$ ~) p* Z) S6 @0 C5 { - #include <linux/sysctl.h>
* q* f. i+ Z, m - #include <linux/mm.h>9 w- h. E1 ^* P0 Z+ O3 x
- #include <linux/dma-mapping.h>: r+ S: W* i, N/ O' b) I
; u7 i' _' E/ h' S, w- `* ~ d7 y- #include <mach/memory.h>
3 o. ], z M9 { _! C5 p - #include <mach/hardware.h>; _+ x/ R! }3 ?
- #include <mach/irqs.h>
8 F" w# k3 Y2 d5 S8 g R - #include <asm/hardware/edma.h>7 W s3 E5 d4 P/ ?4 n# |% L
- ' h3 \: c& U! p( y8 ~
- #undef EDMA3_DEBUG
% f/ J% v; o8 N& d- {: U/ E4 m - /*#define EDMA3_DEBUG*/
5 E/ @5 K# Y5 q$ c' e
, T) g n8 k0 }: k- #ifdef EDMA3_DEBUG' V! ~+ }& X* ~% g
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS). x! s1 |" G: b" V
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
, {/ c" Y8 G+ R - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# ^, D- T6 j% Y9 U# x3 E - #else" g% _& `8 e5 N; U2 v
- #define DMA_PRINTK( x... )7 H) u C; f3 H% ^, t2 e
- #define DMA_FN_IN
* n! |/ T7 `1 h4 t - #define DMA_FN_OUT9 T: W5 I& \; V6 S% C* n
- #endif
O3 @# Q8 `! C! v" H2 m Z - % _! ~, C8 v4 n) C6 \2 V
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ Z1 |* _5 Z9 v/ m! x/ R- X
- #define STATIC_SHIFT 3
( x8 d% {9 ~9 b& Q' X7 q - #define TCINTEN_SHIFT 200 v4 T& O3 T) q/ ^
- #define ITCINTEN_SHIFT 21* j# V9 L' J2 p1 v) b5 b; ?
- #define TCCHEN_SHIFT 22
j0 h9 s) U: ~$ D - #define ITCCHEN_SHIFT 23" D0 E% W. k$ {/ A m s* L
- % p2 C0 C. s9 ^0 J, D$ j
- static volatile int irqraised1 = 0;' m2 @5 G' V4 o+ x
- static volatile int irqraised2 = 0;) S2 J Y7 `9 j
7 ~( B0 k* {9 F, q, g9 m- T9 c, W- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 {- x8 h3 s, t5 f+ T. v& q
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, g/ @* X. ]6 @ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; P& x/ D; c5 \( X1 q; z
! Q" i% j- \ i! N- dma_addr_t dmaphyssrc1 = 0;
* R- ~9 h" ?2 S B, o d1 \ - dma_addr_t dmaphyssrc2 = 0;) E4 h5 h9 I/ x" h: p
- dma_addr_t dmaphysdest1 = 0;& k$ X, g5 _) m% x6 F3 O/ d+ _
- dma_addr_t dmaphysdest2 = 0;" Y( _7 r, ^. P6 s5 ~3 G
. k! {- o0 d) M, u: i; T" e/ J" V- char *dmabufsrc1 = NULL;
, M5 _1 ]) `' x; k" Q: \ - char *dmabufsrc2 = NULL;
( Y F0 c3 k7 `4 @8 y0 \+ ] - char *dmabufdest1 = NULL;" z+ Q1 m3 ^: {! B. Y; |5 Y
- char *dmabufdest2 = NULL;- p) |9 M* R: ?" R' V- Z
+ v* _+ \7 A5 v6 ^) G. c/ O2 M- static int acnt = 512;
/ A5 H5 k% J8 O& u/ s$ m- E6 h- R6 S - static int bcnt = 8;
, v1 x3 N0 g0 h) H - static int ccnt = 8;
+ `, k0 S, X% m, J8 K/ u - : h; l- L' D/ f- z' H
- module_param(acnt, int, S_IRUGO);/ l7 O4 [" e; Q& p# }1 n% h
- module_param(bcnt, int, S_IRUGO);
2 Q. k4 A2 ?9 {: K - module_param(ccnt, int, S_IRUGO);
复制代码 , u; G3 w' \- {, L- n
5 ], p5 w6 M+ J, j9 ? 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用8 p$ o0 r0 X5 P0 \3 r$ p
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。& ^, r- w% t. [' @9 g' T" e+ R5 _- W( \
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。- n4 f' h" |7 P( u
7 E2 a! u8 C8 k* i* i/ y- x
, U8 n* y1 d1 Y, u |
|