|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 - x. S1 ]* Q |1 s s3 h
- [code]EDMA sample test application
7 y1 T: q# v! h. n% j; l4 @ - /*
/ C+ a) b. A5 G( x& S! w - * edma_test.c
' s9 I0 Y( Y; Z6 p* N* W - *5 Z' R. }5 Q, c- v
- * brief EDMA3 Test Application
' a( g2 }* @! e3 |. v8 v1 s- q# z - *
E% u2 W7 B6 d) ?9 L3 N! w - * This file contains EDMA3 Test code.) T1 n7 r' [7 n0 ]7 V
- *
: [; S/ h9 e1 c8 u" [! @ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
2 O' n& s+ P0 t! }2 N0 ?5 z - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT. _0 i* s ^# u5 e+ V+ I0 h( g
- * TO CHANGE.; y! G9 t) Q; z4 W1 X
- *% a2 d8 O. f( k7 Q- t" s! B
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 ?# B/ M+ v& V' E& O2 } - *% z# c0 ~; _: u5 M. ^
- * This program is free software; you can redistribute it and/or7 F, J* @" q5 }; l3 ^2 {/ A: S; o
- * modify it under the terms of the GNU General Public License as
+ i/ e ~4 V. \$ I; E - * published by the Free Software Foundation version 2.$ n! g) I4 i& s. S
- *$ P1 T7 r* k; c( m4 T2 u
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
6 |7 E/ S( H: U, ^4 h2 m) C3 o, L - * kind, whether express or implied; without even the implied warranty
( [& a4 ]9 `9 |% |# l - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 D$ y5 I8 B. M4 u* g8 X
- * GNU General Public License for more details.
% Y3 _2 S/ _; y0 M- P) ^ - */
* x1 c! j& N0 Q9 e/ [2 M% s. L7 E
1 h5 v( S5 d% n3 i' n- #include <linux/module.h>
8 }7 N$ ?9 j/ K) h- u - #include <linux/init.h>
% g* G1 E: @9 ^ |1 g( Q7 W R - #include <linux/errno.h>/ |. F: g* l5 n& G
- #include <linux/types.h>4 \7 m: ?4 i# T* R0 V
- #include <linux/interrupt.h>- m/ R8 U# i. Q- T
- #include <asm/io.h>! U2 f7 s" U9 M: S' D( S4 Z
- #include <linux/moduleparam.h>
- t! C$ C* u0 p - #include <linux/sysctl.h>9 b4 ~* `0 r# `( A* I+ P
- #include <linux/mm.h>! s8 i( ^& Z" _! p$ e$ W A
- #include <linux/dma-mapping.h>( t6 M q. |% N: p$ L
- 3 c+ l w6 o8 c* D
- #include <mach/memory.h>6 Z6 n4 R X1 f1 R5 y Y
- #include <mach/hardware.h>
, J+ ], z! D: a& s0 U* F1 f - #include <mach/irqs.h>
6 f* @( T& O: [& g$ a( P$ ]! l - #include <asm/hardware/edma.h>* V# v) |9 v+ [' ?, ~! X
- ) |. r U( ?3 n
- #undef EDMA3_DEBUG" W- c6 V, J+ x# y
- /*#define EDMA3_DEBUG*/0 U. U) r$ ?- V5 Y
3 W- A/ \ \- U4 A4 c* `* X- #ifdef EDMA3_DEBUG
) E" j: z. T# y S - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
: Q" s* x# }* m0 J6 m B8 Q - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
0 P) A" f; t# O, P1 h3 D+ x - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)+ u9 `4 l4 H& N$ b3 p8 ]# G
- #else" A A N/ p/ f$ l$ S5 h; F
- #define DMA_PRINTK( x... )$ @) F- _% c: h; d" d) {
- #define DMA_FN_IN
: `2 D, b0 u) x# p - #define DMA_FN_OUT
8 ~5 Y1 U$ B {4 [ - #endif
+ J% A+ G5 Z- O# z7 [
& B& p# q& Z/ e7 K7 p- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; X0 b. U8 x' m. {" {8 @/ I% _ - #define STATIC_SHIFT 3
6 t& x% W$ |+ D# h; J- j - #define TCINTEN_SHIFT 20# Z! L5 U) q$ a5 ~- S" V
- #define ITCINTEN_SHIFT 21, ]; a& D% K4 |2 I. I- Y1 f. v
- #define TCCHEN_SHIFT 22
4 r1 n& ^+ g5 M" L/ A3 d8 e8 T - #define ITCCHEN_SHIFT 23
( K. k/ p& w' l- w) w' h* z - 7 G E5 }) g" z% m2 i8 }
- static volatile int irqraised1 = 0;: ]" W2 U. u \. u( _
- static volatile int irqraised2 = 0;
- Z3 c6 q1 _3 R* N
8 k" G# T& g# ], d/ c: G6 H4 Y- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) I7 f5 G0 G, F* \: @6 K# L - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 i- ~! T) X% x - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# ^: }6 [+ T7 f$ h( r& G) e0 R
- 9 B/ g9 P: a% T3 e$ b; F# P
- dma_addr_t dmaphyssrc1 = 0;
( ?" Q* |* D: Y( Y/ X1 _' O - dma_addr_t dmaphyssrc2 = 0;
0 s. z, |8 F8 a* b - dma_addr_t dmaphysdest1 = 0;3 [( H) G: c* @' J
- dma_addr_t dmaphysdest2 = 0;
$ F5 \! W8 X+ C0 _5 L' ]; T. M* L - 5 N& q8 O+ d; H# q
- char *dmabufsrc1 = NULL;' y* w/ W' ~5 e: F/ J' J3 `& s( a) j
- char *dmabufsrc2 = NULL;& f+ O- c' q1 W g. p9 R. V% [
- char *dmabufdest1 = NULL;2 j" y/ D5 _6 ?, C8 E# t
- char *dmabufdest2 = NULL;
% h3 X% U3 }4 V - - G7 }( b$ D6 O9 E* l! v, R
- static int acnt = 512;
$ W. @7 h# N1 h - static int bcnt = 8;
- `! B, {4 q) f' d U, M - static int ccnt = 8;
, D E( J3 W; ~, |7 x7 N* w
* O3 u7 J1 b' z' _. ~$ o1 C m- module_param(acnt, int, S_IRUGO);
$ ^0 E6 A/ u! g/ c6 X. ^ - module_param(bcnt, int, S_IRUGO);
( G* b6 i" h, i; A2 i2 d - module_param(ccnt, int, S_IRUGO);
复制代码
6 {) \) O' |& m' }! t( s
+ N( Y. O0 A0 `$ K9 |* ` 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用% s2 O7 r/ D# Y) u! y+ e6 t
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。$ h7 M- U: K3 b6 D# `
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
4 S/ ]( ~/ r8 ~) f* @% j. S* i" S! c4 F: D; S8 G
1 j/ W+ H* L! @( ]* s |
|