|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
* A. J' T# _' D3 w- [code]EDMA sample test application
% `+ p: g+ D# F* H - /*
5 U, \' Y3 f: f( D, Z - * edma_test.c* R& C- J, @+ q2 V& Z
- *: C9 c9 L0 s* R& d$ O# V& S
- * brief EDMA3 Test Application# h+ F8 w6 R P" \% \1 {: P5 ^/ ^
- *
@/ E, R& K; G9 u2 y, } - * This file contains EDMA3 Test code.* @+ C. A' u7 s, U6 M/ v# ~6 i B
- *- s2 K2 E; e; A4 I) u& G3 i
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE$ ^1 T5 ]( \& J
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT4 h7 {% j; O4 t- H. O! _1 b# Y% Z
- * TO CHANGE. ?5 d4 t1 y/ b
- *
+ Y9 W' t! W" B - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! h! M% J! W! v6 P
- ** k% R1 }3 L$ S: ~# r
- * This program is free software; you can redistribute it and/or
8 j8 h% L' i* E) L- @ - * modify it under the terms of the GNU General Public License as2 x, o2 Z4 U8 R! r5 M5 e
- * published by the Free Software Foundation version 2.. L( j+ X, O+ ^& Y3 u! y s- P* e/ b
- *
- G8 \( t" p/ {3 E& C - * This program is distributed "as is" WITHOUT ANY WARRANTY of any# R; S4 [9 J7 W3 E$ E
- * kind, whether express or implied; without even the implied warranty) a( i8 F" d2 v( R- s
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ @+ E- q6 H% y, d* o - * GNU General Public License for more details.
+ j. x4 c! P& M3 M$ c - */) {) \3 P! \- _
- - |1 Z1 t0 o, {
- #include <linux/module.h>* l' r, }8 p, L+ \8 o- a
- #include <linux/init.h># f ?8 S4 E- V' C7 b( i
- #include <linux/errno.h>" M2 Q8 J- @8 [
- #include <linux/types.h>
4 H/ l" ^( T% R# r5 ~$ R$ ~ - #include <linux/interrupt.h>0 c8 I- {4 @2 h; N9 P: W& w+ e5 K
- #include <asm/io.h>: d/ R2 Z. Z8 e
- #include <linux/moduleparam.h>
@/ a8 [4 W$ `. B1 Q* L6 @, F - #include <linux/sysctl.h>8 k2 _5 H" Q! y& d( g2 B" Z8 Y+ J% q
- #include <linux/mm.h>
" I; y0 R2 ~$ s3 k: x - #include <linux/dma-mapping.h>
! I }; D) q7 h6 Y( I - * d! N# B( |4 s3 r
- #include <mach/memory.h>
1 |% F9 F5 g, B3 O% R. f2 U! T - #include <mach/hardware.h>
# ~6 q5 o+ ]+ r - #include <mach/irqs.h>
; m) P) @9 x. R. |+ v, t& y - #include <asm/hardware/edma.h>
# i; t! J( L- Q, X" g9 E( u - % n/ a* t, c% f# t% p3 B" ]' t
- #undef EDMA3_DEBUG
6 r) I6 m) c, e7 v+ D; [1 \6 n - /*#define EDMA3_DEBUG*// [: D5 u; W, q$ [4 T0 ~) M
) v$ D* i O9 S+ W- #ifdef EDMA3_DEBUG7 l$ e+ [1 t4 F6 o% D: _
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; ]0 o% v: G9 e. z+ Q$ `. R - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): a; J* A9 c7 J& s. K; n
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
! ?( A$ T3 X# s! W* Z - #else
5 N s y+ Y O2 Z3 f" s - #define DMA_PRINTK( x... )
+ d9 _. x3 Y: k# X# }' h - #define DMA_FN_IN
5 {" M( k# W- a+ l' R - #define DMA_FN_OUT
+ H" J' Y; j- G0 x# u3 } - #endif0 ~- |! v0 M ~5 O/ D: P
1 X8 o- e' q8 w# p- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
3 K- P g+ S4 q6 m- w3 q - #define STATIC_SHIFT 30 F& ]/ G8 T. j' o9 i v) l4 y% h
- #define TCINTEN_SHIFT 20
2 L1 C- W; f7 R% y; } - #define ITCINTEN_SHIFT 21
6 ?7 k' z. X: [+ S7 ^+ @' g2 Q - #define TCCHEN_SHIFT 22
2 }/ ] ]5 w8 }' ] - #define ITCCHEN_SHIFT 23
$ _: w* ]& b" f G - ( Y! x# G. K1 C- S9 Q
- static volatile int irqraised1 = 0;; P/ v6 I+ [. D9 K3 j4 M
- static volatile int irqraised2 = 0;
, V/ f* s/ H) V' l+ p - 0 C& F" N3 l% N' l3 q
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 A$ O4 K* D4 c6 f3 A, E/ c& ^ U) c - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 g' I' t& j1 Z& R# w b
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 V9 T" s, c# i; `! x. M
- ; f, t# F9 H2 h* ?! r; I
- dma_addr_t dmaphyssrc1 = 0;) [9 Z/ ]1 C& n, G
- dma_addr_t dmaphyssrc2 = 0;, @4 N6 K/ S% S. {
- dma_addr_t dmaphysdest1 = 0;2 i7 c: n$ a" g8 X* w
- dma_addr_t dmaphysdest2 = 0;8 z; d6 g' D0 N
- + H1 w; V C4 m: U: T
- char *dmabufsrc1 = NULL;# H5 M' E4 i1 w* R( v
- char *dmabufsrc2 = NULL;
6 R0 \# ~" c4 ? - char *dmabufdest1 = NULL;) T; [1 ]! y& }0 j' _
- char *dmabufdest2 = NULL;
3 _* n; ^7 r0 E! T# F9 ~( m& V2 f - + o9 _" C. q2 t. \
- static int acnt = 512;
3 _2 }7 [' T! E/ F3 G# y/ [ - static int bcnt = 8;) D) G7 z( X/ e3 g
- static int ccnt = 8; c7 i/ c3 \ V+ r7 I
% I; N( I3 f5 c7 {0 D8 {5 ]0 ?- module_param(acnt, int, S_IRUGO);
. y9 |# Q1 c! o - module_param(bcnt, int, S_IRUGO);
8 {# z/ ?% b. `0 b - module_param(ccnt, int, S_IRUGO);
复制代码
9 T# z8 V4 m/ c# C4 [+ g$ S. ?. b4 r* z6 K$ C& \
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用% s4 x% y/ k2 o1 @
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。 H8 k$ w2 d: ?3 K, g M
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
1 I) } {; W% W4 D0 l4 l& l2 S5 i- d5 G( P" A& n) `
, [7 Q! U6 f3 ^" M1 S
|
|