|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
& N5 c' W4 g1 t* h7 f- [code]EDMA sample test application
5 R1 l: X+ p6 q2 ?. D( ^4 C - /*" @. Q5 g% C: S1 W% H; I& a! N
- * edma_test.c
6 E& P# w& B- O8 F5 g* i/ C, y% C - *
$ U: n2 s$ v% ^, V5 W' N - * brief EDMA3 Test Application
2 ?8 u6 K+ Q7 X+ g+ r - *% [1 `' S: R7 n5 S( L7 {
- * This file contains EDMA3 Test code.4 l% h& t; D/ U0 }4 F, X
- *
0 C; |1 A/ \* ~) E! M# ~ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE# W# f& _2 o' w* j
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
3 Y+ C$ @5 H3 T! X - * TO CHANGE.
8 Z8 {9 F. a4 { - *
# d% l0 d, d5 t) @' c; z/ h - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/2 g" e4 F* y7 e3 B8 l0 W: ?
- *
0 H5 g. N+ Z8 |& ^) Z2 U) M; u - * This program is free software; you can redistribute it and/or q# Z3 I6 a5 T3 s9 M, g
- * modify it under the terms of the GNU General Public License as/ U) C- Q! M" n2 N
- * published by the Free Software Foundation version 2.9 o, M2 y0 P! o7 i
- *9 ?6 f; y3 S( Q9 I% o5 K' S: l8 b" d
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; w" d0 O7 i: |$ x - * kind, whether express or implied; without even the implied warranty
+ b, y( u+ T) f V; G' O - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; E% ` y% I, A# S - * GNU General Public License for more details.
) [& y: f" d- {9 B4 e - */
- P3 t& @2 }! P/ @% G
' m$ U0 v9 I" M- #include <linux/module.h> _# r! u' {6 i0 x; @4 g3 ]
- #include <linux/init.h>
# j2 Y6 E- _9 B5 U4 T" q4 d$ n8 o - #include <linux/errno.h>
2 l+ z$ F, y1 Y. n% ~ - #include <linux/types.h>
# ~7 L9 ? P# \* g. O/ L2 w' {$ z7 L% w5 ^ - #include <linux/interrupt.h>
8 r7 N: U* Q2 L5 b - #include <asm/io.h>) e" H8 J5 Z2 J
- #include <linux/moduleparam.h>
Z4 b1 y; B q# S - #include <linux/sysctl.h>
I* S/ J" u* ~4 n& Z& d - #include <linux/mm.h>( r% Y3 @" R/ e' n! L0 @
- #include <linux/dma-mapping.h>! I7 o) C) E1 R6 R- x9 d
- W& X3 B8 ?2 u) s) ~1 K
- #include <mach/memory.h>
, j6 |) R2 A! {0 B: X - #include <mach/hardware.h>9 l [: I! V: Q" I2 N4 f9 z
- #include <mach/irqs.h>
+ ^; @3 l5 R* ~9 ^ - #include <asm/hardware/edma.h>- ?, d2 P9 E6 i( N$ b
3 P8 Y+ I( Q8 k4 @& F- #undef EDMA3_DEBUG. S- S$ P) s; B# g$ A
- /*#define EDMA3_DEBUG*/
2 e# I( j+ x+ s" S - : y) x8 r/ S/ g7 X! m
- #ifdef EDMA3_DEBUG
7 {& ~. C# o8 |) M' t$ U4 b - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)9 J7 a! s0 w3 Y" m" R$ Z
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): g# ^% R. G6 P y$ H
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ j* |6 @1 _8 I - #else
* c7 e. b- `5 Q - #define DMA_PRINTK( x... )
7 O- Q& l. F. G$ I, j5 Z - #define DMA_FN_IN, p4 Y6 m5 x" E. q7 M
- #define DMA_FN_OUT& f0 n# U) _- H) p
- #endif, ^" ] V. L2 S
, d4 v0 }" K/ y- #define MAX_DMA_TRANSFER_IN_BYTES (32768)' {1 _" I. ?' ]- N3 ~
- #define STATIC_SHIFT 3
7 Q1 |# S5 X+ e - #define TCINTEN_SHIFT 20
% y9 M ]% N- e - #define ITCINTEN_SHIFT 21* U* p- C. q9 \ r3 {. T
- #define TCCHEN_SHIFT 228 {0 p$ ]4 u4 \/ y) Q; e( m
- #define ITCCHEN_SHIFT 23) p3 T7 y3 j/ j6 ]3 [! m5 `4 Z
- : Y' p3 F$ l- A& [8 E# Z
- static volatile int irqraised1 = 0;
: N3 S+ y" T( W. z% j/ |. z! v - static volatile int irqraised2 = 0;
# l; Q( }3 Z% I' @, r0 G. p# H' q - 9 W+ b# ^# t' W7 p: G) S5 o }
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 @6 W0 D" e. n. J% R4 v) b9 u+ S* N
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 H9 l" H! l8 c/ _: n. J8 z, H
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, L9 j; Q1 O0 ], P4 J - ( f7 m, H/ L9 ^
- dma_addr_t dmaphyssrc1 = 0;
# N2 Z" M2 T; D6 Y) H+ x, h - dma_addr_t dmaphyssrc2 = 0; @) z9 g# I! [, H& \
- dma_addr_t dmaphysdest1 = 0;) U" Y7 f) Q+ V! k% R
- dma_addr_t dmaphysdest2 = 0;4 ?, ^2 r! _2 f2 Z7 i/ l
- 9 R: q1 a' \3 L" U* F7 P9 s
- char *dmabufsrc1 = NULL;
% P" b; ]% x& F; n - char *dmabufsrc2 = NULL;) G6 [: I- j1 a4 w" F' l
- char *dmabufdest1 = NULL;0 P' h/ Q( D2 X2 I) w# @- T
- char *dmabufdest2 = NULL;
7 O( A4 D' _2 j' y$ d - ' j, J# ^ `& p
- static int acnt = 512;, _5 \% @& ^% Y, v/ A6 F
- static int bcnt = 8;
+ r. R: ?# c% |) ~, V0 b4 ] - static int ccnt = 8;
0 A5 v# \5 y- |- `$ C) {
# ]* i4 x6 ]8 p, i& [. I$ ?4 o" Q- module_param(acnt, int, S_IRUGO);$ [5 L) {; e8 g" ]' }. v/ E, b
- module_param(bcnt, int, S_IRUGO);. z+ F, m* ?9 x* V
- module_param(ccnt, int, S_IRUGO);
复制代码
( ` B. `. Z6 d- B5 w4 U+ [* g8 I: R0 x" p, R4 o
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
" H- U3 V! V* }- d, ^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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
( X, N. z& a2 E. z8 O 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# o# t/ m K8 I
; E5 |( x8 L% I+ H# B2 c5 ^
( F1 V% w; V4 a& ?6 @' B |
|