|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
O1 L, x0 a: }* X3 c& Q. a$ K- [code]EDMA sample test application
. x! u5 c4 O% J' Z" a, t9 d0 q - /*
2 n* x/ E" b2 I5 `" Y! `& `! v0 ~! z - * edma_test.c" g: C+ F+ c+ ]
- *
/ w4 f3 V3 ]* k$ ?9 o2 ^( @ - * brief EDMA3 Test Application8 V* ?- T- r. K. _- k
- *
# H; f4 o0 N; u: k - * This file contains EDMA3 Test code.& T M4 `3 w4 u4 I c
- ** q0 q% v. f8 V9 Z2 j
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- T/ J& {5 |& ^# D" ~2 K# n - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
) z/ K- {) t% j! V - * TO CHANGE." D% [) m, q3 N i5 _" {& @5 s
- *
% l1 ]- i, E# y, L - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/$ s5 L. h* v) _$ Y* w
- *
* h! K/ c- _ d Z( N2 v" H2 I - * This program is free software; you can redistribute it and/or
$ U) [0 i' d* E4 X3 ~" b - * modify it under the terms of the GNU General Public License as4 m, P; S0 ~2 u% m
- * published by the Free Software Foundation version 2.
+ J+ ?) H ]% L h5 { - *
! `8 G: _, G% N% Y - * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 @+ J9 O! e$ w- F4 W$ h
- * kind, whether express or implied; without even the implied warranty
% F3 k$ p1 E' |6 { - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! I' Y: P# {4 p* N1 H/ d& h4 } - * GNU General Public License for more details.5 U9 p9 d/ [; L% U) _, w
- */
/ Z# \" Q" S- Q# J% z' j( l - 5 j+ E3 f8 f4 j/ v1 i
- #include <linux/module.h>
1 Q3 A2 O2 @! t - #include <linux/init.h>
7 }# `% E( y! Z$ f/ Y* N - #include <linux/errno.h>; p7 B4 T. A0 T4 ]
- #include <linux/types.h>
1 F" l- L4 r1 v - #include <linux/interrupt.h>6 _0 z3 e5 g. c& j6 t8 }
- #include <asm/io.h>2 U4 K" T+ x) q5 w" ~9 |
- #include <linux/moduleparam.h>: _6 r6 o/ U8 D+ d; D1 Y$ Q
- #include <linux/sysctl.h>& ]% a% w3 [7 h" Y3 `3 W
- #include <linux/mm.h>
1 J/ ~- r. \- Q' j L# k - #include <linux/dma-mapping.h>
3 F; p6 H' @" X# C8 }! e: y
$ J, A" y& i8 L5 D5 B% h; S) d h- #include <mach/memory.h>
0 v2 s) I _6 o- a) K - #include <mach/hardware.h>1 l; R5 R$ C3 l9 { M7 P
- #include <mach/irqs.h>
) l# T$ H0 i% O2 \! _# D - #include <asm/hardware/edma.h>2 s8 h5 R$ x) S8 G) F
V! k' L! U, ]2 ]( I- #undef EDMA3_DEBUG7 Z) {7 t2 x* J2 G; ? G0 |$ c- n
- /*#define EDMA3_DEBUG*/* Q( t1 o: D7 O0 `
- : }8 X. l7 f3 e: T; e
- #ifdef EDMA3_DEBUG
! G- L0 c3 w, p - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)+ g8 ]: H: {2 z( t9 |( [
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)7 _3 ~ P3 t. Y( F* `9 N
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ C' `9 i/ D' U4 n: a* q Z" {1 q1 y - #else
2 R2 f8 O3 W# x+ Y! ?0 t" C - #define DMA_PRINTK( x... )
A& k! D0 W1 F* x( @ w - #define DMA_FN_IN
0 u! l4 L! K+ I7 }- D f - #define DMA_FN_OUT
3 w; |& p G: P: D - #endif) T: K* g7 W7 O% t0 y4 T0 `
6 ?, `: E, j) [- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" x: ^9 l: g! y - #define STATIC_SHIFT 3& G' `! P8 E9 V+ R
- #define TCINTEN_SHIFT 20
6 H8 T4 g8 \' \' S+ _ - #define ITCINTEN_SHIFT 21% K) ~1 l1 U% i; ^
- #define TCCHEN_SHIFT 22
7 L# S: a* R$ `! f* q: x, } H - #define ITCCHEN_SHIFT 23- X" D9 `" y5 W+ t) ^" X2 @& W: y
- - F, j# c8 W$ F- ]
- static volatile int irqraised1 = 0;
; H+ |; o7 r* H* Z - static volatile int irqraised2 = 0;4 F0 p1 }6 i3 r: s: c3 _5 Y1 Z) t0 x
/ ?0 {3 N+ M4 E0 u5 {! p- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 E$ @3 m- `) }6 I - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. @, y) H/ ^) T+ d. O- O - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ [2 U' b% ^. X- \1 O3 }& a9 ~ - ' t( j' n$ M5 a. K$ e. @+ `
- dma_addr_t dmaphyssrc1 = 0;
% l# J, w; l7 }3 _2 Y - dma_addr_t dmaphyssrc2 = 0;
; G/ C3 U5 V- @ Y - dma_addr_t dmaphysdest1 = 0;. o, |; m6 Q; g$ ]
- dma_addr_t dmaphysdest2 = 0;7 ^. C- ^( R7 S @; q0 A+ @
- ?) }( |' {4 G- j
- char *dmabufsrc1 = NULL;% H% C s- U9 R) |0 H( D" y* _
- char *dmabufsrc2 = NULL;
1 G- L {3 R/ `* p9 w - char *dmabufdest1 = NULL;' z/ d- V% k* p/ w y/ F0 q) v
- char *dmabufdest2 = NULL;% ]7 c( J7 _; A5 W- h
! t6 m1 I! |3 {- }" B: n: j- static int acnt = 512;
) B: O2 s! a4 n) t9 Q, }* I$ [ - static int bcnt = 8;
' {# x: M- Y& S3 I, N - static int ccnt = 8;
0 }4 Z) ?% d) ^" `6 G. v: c - 4 `! n7 s0 V8 ~5 X, u+ G+ i
- module_param(acnt, int, S_IRUGO);2 P# Z( a9 s' L; T7 g+ d
- module_param(bcnt, int, S_IRUGO);
- h) g( T* t' b) H: a8 `, i* N - module_param(ccnt, int, S_IRUGO);
复制代码
* k6 N* r v+ ]9 x1 N m" `* `( M" d/ F
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用) @- k/ F& W$ d5 n5 ~3 S
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。: g) Y$ G) |0 J4 k" |" O
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
0 q! D# x. X; c5 w9 D9 Z! E' t% r& O
7 c) o- l4 M1 v: K( |$ j+ q, d& o Q4 W( B- ]7 |& z
|
|