|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; ?: c; A+ X! {9 K* I- [code]EDMA sample test application
4 A1 s6 @& \2 H+ D1 {: G - /*
$ D) v6 L7 e, s% c, }. U - * edma_test.c q+ o, x& ?# S* t& ]7 O7 S
- *
1 q/ x, V! N( m: Q3 g& Y5 e - * brief EDMA3 Test Application
* R9 ^1 q$ M6 G' {# F( r) e$ } - *
# B1 K T* g" U# e( N - * This file contains EDMA3 Test code.; E/ q% }/ i. y" `! B6 S
- *8 b# N" m6 _# O) ^9 x- Q% F* T6 {! e
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
' r' O, d8 [+ w( P* h3 x - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 {' `' _4 ]9 G3 `+ l5 G7 P. ] - * TO CHANGE.( X: M5 \; p7 ?8 c
- *8 E2 { b, K1 b8 T# ~
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/( B7 }! o1 G. e/ {$ ^
- *6 @9 j6 U6 n4 `) \
- * This program is free software; you can redistribute it and/or: K ^# f2 J2 H) Y
- * modify it under the terms of the GNU General Public License as' c, r3 V8 s- }* _6 b+ h9 l
- * published by the Free Software Foundation version 2." ]; E, g& j7 t& n7 B1 t
- *
( J9 G, ~6 `5 y8 ^: T7 W8 w - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
! Y, Z, l- W! { - * kind, whether express or implied; without even the implied warranty
6 e: `4 I/ X& W) W6 a0 r9 _ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the$ E" r T* `/ K6 N# W
- * GNU General Public License for more details.1 g1 u9 C( [, `
- */% F6 d; E7 R3 i' }7 u9 M @
4 k2 z$ u7 K$ v/ h: l( w6 O- Z- #include <linux/module.h>
8 T, \5 J; Z e - #include <linux/init.h>% m: n' h: {: i B
- #include <linux/errno.h># ^: h6 M* E7 {. I O
- #include <linux/types.h>* u+ _: k" X# v: M- V# g2 w+ O
- #include <linux/interrupt.h>
- v5 G* h$ g$ j, j - #include <asm/io.h>4 p% R8 p& k# w
- #include <linux/moduleparam.h>2 l: j' [3 f: ], @; W! T J2 @
- #include <linux/sysctl.h>
- p( y5 r5 x' n - #include <linux/mm.h>
: `# K# K9 v1 E8 d7 o- S4 \ - #include <linux/dma-mapping.h>
' S: Y% ^3 u9 O3 D
( P" Q C& F$ N F/ E5 z- #include <mach/memory.h>
$ q$ @ d m5 L& m3 P( E - #include <mach/hardware.h>
+ ^7 }% ~0 S. q3 W0 v: R: w+ \. f - #include <mach/irqs.h>
* A' y" U! \/ ^, D+ ` - #include <asm/hardware/edma.h>; }5 M7 L4 {4 e9 `5 z0 J
/ \1 n; q: U6 V& G- #undef EDMA3_DEBUG# r W8 W. f' ~ W6 {' K2 S
- /*#define EDMA3_DEBUG*/
2 y6 l, R3 D% v+ v6 [+ b- u - 9 i0 ^" J# _6 i) A
- #ifdef EDMA3_DEBUG1 \$ a/ ~- p3 l# b! T
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
" c( r" Z3 ^% h - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 A/ ^8 b/ ?5 h) M' K! s6 a- P - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)) m. D3 r4 M3 M# u
- #else
* h- x, J2 j8 w2 v; s% X - #define DMA_PRINTK( x... )( P; z1 Z; X8 \8 b$ {8 u: [% J
- #define DMA_FN_IN# \+ {4 o$ w+ u% r7 I1 N
- #define DMA_FN_OUT0 X; z0 ?# v6 V! Y% O
- #endif$ E3 q# E* C9 }% g! A& P
- 7 @9 ^5 a# S' I0 S7 |9 u2 h
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" \6 `+ c: `" J( Z$ V1 m" Y6 ? - #define STATIC_SHIFT 3
9 w4 g# E# v5 L t9 u; |3 b |- G - #define TCINTEN_SHIFT 20
! N# a, V7 I. n# O" {% w - #define ITCINTEN_SHIFT 21( `6 @( q4 F* k4 `" O9 S
- #define TCCHEN_SHIFT 22
. M; P: A7 s/ ~) B - #define ITCCHEN_SHIFT 235 V0 O$ K: n# l- z9 a% c# f
# @, G9 Y+ V; B4 c" h2 A- static volatile int irqraised1 = 0;
: w/ j6 N4 [! {: o - static volatile int irqraised2 = 0;, {; O& x- K% s4 X6 ~% [- L3 F
; X7 j5 h% L2 C2 `9 E7 C1 Q( W) ^0 j" b- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- h$ w0 e0 L4 @( T& r' i0 C5 @
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% H) k8 P7 J, ~; d. [! X - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' x& f. |/ b9 z' c
- 6 e) V( Z/ ]# Z, M6 f8 K( p
- dma_addr_t dmaphyssrc1 = 0;
5 ^7 t& i: ]* [' i - dma_addr_t dmaphyssrc2 = 0;- x% F1 E, U3 y: q4 [
- dma_addr_t dmaphysdest1 = 0;
" A! @: o# p; n - dma_addr_t dmaphysdest2 = 0; i+ c" w [* S8 ?- Y' E9 `
) X* w" k9 G$ m6 V# D- char *dmabufsrc1 = NULL;
! }/ n5 `$ ~! z, s& @* d: G - char *dmabufsrc2 = NULL;2 C8 Q/ c+ b# t2 q: I1 Q
- char *dmabufdest1 = NULL;) f- ], ?$ i- {' A) h
- char *dmabufdest2 = NULL;: G. g( ?" W; `5 |
- 5 l# O( W5 z" g/ q' ~, Y9 M' Q5 F
- static int acnt = 512;
, J! p, t8 Q/ C$ W7 A - static int bcnt = 8;
$ U4 U3 E8 H# A+ L( x( d - static int ccnt = 8;
6 i" M1 }# {+ l6 t- C* r0 {. e
i* ?# A; s' o+ P A T3 y; ]' f. d- module_param(acnt, int, S_IRUGO);
q: V$ X2 P4 I2 r - module_param(bcnt, int, S_IRUGO);+ x4 G. A& _: G, I8 r6 M2 z
- module_param(ccnt, int, S_IRUGO);
复制代码 / j# y% \; T5 Y# v9 h3 q
8 a3 }5 D# S2 E$ W/ O* ^
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用7 ]& Z3 G& d3 q+ {% r7 c4 f
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。5 W; l* L/ t: ^# h
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
! p k' i, `/ S9 {- ?, t/ f8 t( i
+ G) j. f+ {9 n8 h M4 ?& Q3 c
|
|