|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ; M5 A4 c! r' F u; s( E8 y* V8 Z: N: ~
- [code]EDMA sample test application7 W/ R. d" v7 ], X
- /*
0 g/ S2 w4 T' I; n* K% q6 @ - * edma_test.c
- u3 ?! R0 k* N& R' K; \, `0 k/ o - * s0 `, H+ J, O1 j
- * brief EDMA3 Test Application* f$ s \" S: r, x6 w. R
- *
0 T! Y& q5 [6 O0 a3 G2 { - * This file contains EDMA3 Test code.; i) i' _2 ?6 y. M6 C
- *
x, v. ~. l. ~0 \5 v+ ^) i - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE e+ o5 L. T1 c/ N9 l- r
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT9 ~# \6 p q$ g% R
- * TO CHANGE.; ^- }$ X- M! ]
- *
. V! R$ y" Z z" i o2 j6 m - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# g6 s2 y/ v! T/ H: w
- *
( P6 {5 J. [6 Y- d9 D - * This program is free software; you can redistribute it and/or
& J( O/ P. l s( z% w, `6 d - * modify it under the terms of the GNU General Public License as$ s' n; `" Y2 v% s- l) z6 ^' I, t
- * published by the Free Software Foundation version 2.5 i* y. E) q% X$ j$ h5 y
- *( x$ W: Z; H& C1 D! d
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any$ d, T" [6 F+ P; D2 K, P; p6 e
- * kind, whether express or implied; without even the implied warranty
/ }* Q# {% D$ b4 F6 _+ M4 E- J% \9 U - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the, ^5 I. `( t, E8 _
- * GNU General Public License for more details.
1 t" t7 W7 G8 u: \3 M3 y - */9 Q5 v: P* K/ Q& H
2 u& g4 [ g/ z, _" s. E- #include <linux/module.h>
; ` A8 N' g% G, U4 u - #include <linux/init.h>& g# i6 M$ Y5 T/ F6 G( R( |* L
- #include <linux/errno.h>
, s8 k/ R5 }, l+ \7 l8 z - #include <linux/types.h>* S5 X3 q9 O* Y, w& g N
- #include <linux/interrupt.h>* {6 f- T; c( n _+ X$ h4 U
- #include <asm/io.h>' o1 }# s% D; O6 R
- #include <linux/moduleparam.h>
" c9 ~, G- D) W/ P; l: Q' u x - #include <linux/sysctl.h>) Z1 [. b5 |+ e9 F; v! _
- #include <linux/mm.h>
9 m3 @" s5 w+ T& H" f. | _- a - #include <linux/dma-mapping.h>
4 }" a" I/ b# o1 D - $ S% Y* Z/ a# R2 n9 G5 k
- #include <mach/memory.h>$ v" B& x; }7 {" b- ~; I J: ~5 S0 W
- #include <mach/hardware.h>! M7 |" V+ W7 [ C, m# Z, [$ j( u
- #include <mach/irqs.h>6 }/ W0 v" B4 V. E' W c) E1 _+ W
- #include <asm/hardware/edma.h>9 q g% y& v+ a" H# Z% Z
' G1 u4 y5 ]+ A* C" t$ _: l- #undef EDMA3_DEBUG
Z* r, N$ y4 l5 A% O# y - /*#define EDMA3_DEBUG*/" m1 C( z% L# Z/ I& `* q( X: p& F
- 1 `: {0 a! N+ T: c9 W
- #ifdef EDMA3_DEBUG# V% e. J# r, [! Y/ w) g
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
: U5 N( s( S+ H/ ]# I# \) P: e - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
" @8 p" f4 N) d. {8 U; S - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 p) h$ w e& L; `, z' M+ m
- #else' q% u2 a' p. C2 z
- #define DMA_PRINTK( x... ); Z6 \4 s' u$ r# ~! J
- #define DMA_FN_IN' b4 V) u+ i- z& ?
- #define DMA_FN_OUT
6 ?4 c8 b- b9 M/ d - #endif* V8 L4 p9 e0 u5 m. c% p
4 m! i& D$ }2 c I- J6 E5 W4 m- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" e- ^) r0 Z- U `3 Y
- #define STATIC_SHIFT 31 O; `7 v; [! l/ r$ N
- #define TCINTEN_SHIFT 201 {) a6 F( j! i2 q/ q# T% r
- #define ITCINTEN_SHIFT 21
! i( j( \1 h" b+ i& l7 K - #define TCCHEN_SHIFT 22
4 a. m0 R, ?& G! n0 x( f2 m - #define ITCCHEN_SHIFT 23
, ?! m% c8 c, j. s/ P
2 q T: ~5 o; m6 V+ m8 W( ?7 Q9 T: F- static volatile int irqraised1 = 0;4 ]% P. T* {# r9 W, F% a+ e
- static volatile int irqraised2 = 0;7 z+ i) L$ l" H0 t R7 C- m
; j4 q/ N: M* J- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! i2 j, c/ b! S3 s" Z' V
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: y) v9 b# Q* k! U - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( d& q( z1 B+ O5 k( c7 L - 8 S, l! R) P! a; u1 S; n
- dma_addr_t dmaphyssrc1 = 0;$ l# H- t2 q$ a/ _, P
- dma_addr_t dmaphyssrc2 = 0;: m/ k2 @) }* N* N6 R* E
- dma_addr_t dmaphysdest1 = 0;
* R, r, n. m$ b; W$ j+ Q - dma_addr_t dmaphysdest2 = 0;
4 C$ F: K) h! L6 M - 8 ^) k/ T( Y- C+ c) U* v! `
- char *dmabufsrc1 = NULL;
0 u% k4 H. O4 J: S6 G7 I B - char *dmabufsrc2 = NULL;
, t% B1 Z8 x" Y5 {. J% \: B - char *dmabufdest1 = NULL;* F2 X/ Y* o. N* i7 Q- q
- char *dmabufdest2 = NULL;
: {+ s+ @8 W- O0 ]
" M* ^0 M$ [: |* P( [9 s* `+ Q% c- static int acnt = 512;
2 {( I. x1 j& N4 R( p ~4 Z5 C - static int bcnt = 8;
* I! T0 a" @' w5 a0 ]2 L - static int ccnt = 8;7 y7 u# w( r. M; O
/ B( n; ~1 O& g. q7 t% C- module_param(acnt, int, S_IRUGO);
# D4 D2 U$ N' p& ^) t9 a: g - module_param(bcnt, int, S_IRUGO);
$ _+ n2 ?" E8 p: g0 t1 }' X - module_param(ccnt, int, S_IRUGO);
复制代码
1 K6 _2 v1 _" ~: o' r: j* a# H
/ f' ` t @1 H5 _9 w4 i 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用9 J- H7 g8 u1 Y$ j, d* W2 O0 ~
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。3 R6 m' `; y" s2 a6 v7 ~9 d) W
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。7 e6 A4 }. _' r
4 o4 c8 {) r$ C: v. R
" ^ l) K% Q/ I* E+ X |
|