|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; Z# A) k3 T% \, J- [code]EDMA sample test application
: b# K# W" G( g& j/ g; A% Q - /*2 B$ k3 \% i- e/ S! @7 ?5 @ }
- * edma_test.c
! J+ \0 m5 ~: c! J4 q( V - ** c5 n( _4 D* ?
- * brief EDMA3 Test Application/ |$ K g' l5 A0 i) K
- *
; m# A [1 `2 a: c2 y, O+ C - * This file contains EDMA3 Test code.
; R' x% i4 O1 f2 J8 V8 w - *5 p+ @' H# O5 P2 v# K
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE) p9 s) E# p& Z9 M& R
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( b; T, O7 y: f# ~; s9 | - * TO CHANGE.
& i- [" q' C* l0 I O V- a - *
! ]2 r3 z0 B$ y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/' l/ B% M4 }' T% |0 Z, l
- *5 z3 R+ X- z. u" s. m
- * This program is free software; you can redistribute it and/or q" k5 e2 f% l6 K1 m r
- * modify it under the terms of the GNU General Public License as
4 P! g, f7 l! G2 V - * published by the Free Software Foundation version 2.
' o, }: h: z3 U* w3 b( J$ r0 q: ` - *
, `$ z. f+ n) [5 o: u1 I( R - * This program is distributed "as is" WITHOUT ANY WARRANTY of any- l+ Y# Q8 d5 K) g
- * kind, whether express or implied; without even the implied warranty% n- l: f+ e5 b9 K7 d, j1 ~
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% d8 g8 }. z" f l" C
- * GNU General Public License for more details.
& L! z5 m Y6 j2 l3 o! S - */. K$ [6 P, v5 T6 S$ L
, }! D% U5 c- W' U: d& M$ k* S- #include <linux/module.h>
& N. `! F( L& A' i( L! i; p3 x - #include <linux/init.h>
+ p. Z& L0 g5 S) s6 h - #include <linux/errno.h>
* n) Y9 X% X! O" O. e% p+ H. z - #include <linux/types.h>' I5 J l: s2 K: n$ C
- #include <linux/interrupt.h>
' b, R4 m: q: u! e$ S/ _( V, c - #include <asm/io.h>8 }9 @/ P( J6 y
- #include <linux/moduleparam.h>
9 r4 Y7 O- z9 T) R% N - #include <linux/sysctl.h>2 T4 c( Z& |; \) [7 i
- #include <linux/mm.h>
* H' C8 u9 B1 L* U% r - #include <linux/dma-mapping.h>
' v% X) s7 |6 Z8 c* Q$ O - 4 _3 a% Q$ o) V; ^
- #include <mach/memory.h>! ^% P6 ~0 Q- x5 b/ @9 }: ]5 i
- #include <mach/hardware.h>/ n1 [9 W- r: E
- #include <mach/irqs.h>
4 I9 t* y0 @- b* n" J - #include <asm/hardware/edma.h>( k& F( }- t& Y, I3 ^" B# b: r
- - H* Q4 m+ t4 I/ r8 x s* `' i/ a
- #undef EDMA3_DEBUG6 @- g s, a( T2 H# w' b5 i6 I
- /*#define EDMA3_DEBUG*/
V0 C- B: b8 w - 6 I" `! X/ H) V) V/ {' n
- #ifdef EDMA3_DEBUG
) H j/ Z$ C; J, K# a( |6 a& v# _ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)4 V* E: l/ v3 i/ i
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)0 k6 B' c- J8 `( f# c% Z1 P
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
. j) \% y$ L, B" A- R - #else
S3 |8 r6 c" w7 x w - #define DMA_PRINTK( x... )- Q4 X* F( V! m# i
- #define DMA_FN_IN3 C6 ]4 N7 @3 f ]9 v; T6 R) @8 }9 y
- #define DMA_FN_OUT
6 Y' W! u1 `" T. o h# C! j7 w6 g3 N - #endif
/ y7 g( M* H& P$ E6 s5 U: i8 x( T. } - $ G* ^+ ^9 G6 _" H" T
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
5 G, B# A* j/ G# f Y: Y2 j' |3 ? - #define STATIC_SHIFT 3
% A# C: d5 O: k; i' _5 _ - #define TCINTEN_SHIFT 20. B2 k( u9 r0 ~' X8 \: N8 s+ z
- #define ITCINTEN_SHIFT 21" L# @9 x, D, K
- #define TCCHEN_SHIFT 22
' u8 _, t- u. S, O# X$ u0 x: B2 R% Y - #define ITCCHEN_SHIFT 236 c: ]1 `) s$ u! I
- 3 b% ^- }- e5 q$ c1 E
- static volatile int irqraised1 = 0;
* @9 ?" O1 o" Z O - static volatile int irqraised2 = 0;
6 C; L4 o' P3 t1 \! B8 n1 c; C - ) I7 F: t$ H& b! g
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ U6 p: u& I. F* X" M/ A- ]* l - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
E: |+ Q* p! v0 J0 |1 t - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 l6 p, S& I; e
- 1 {, Y5 F8 R2 i- V* c
- dma_addr_t dmaphyssrc1 = 0;
- s4 j# k2 h) W* d& I; O* N - dma_addr_t dmaphyssrc2 = 0;/ ~0 ~# B7 J9 P3 C
- dma_addr_t dmaphysdest1 = 0;) m' k6 R5 h& T- C% V1 `5 @
- dma_addr_t dmaphysdest2 = 0;
# T% x" w/ ?. ^ - * g+ O+ p" f0 W0 ?' H3 ]
- char *dmabufsrc1 = NULL;" v" g% B7 P6 c/ E7 @
- char *dmabufsrc2 = NULL;( S# g8 q# z( }* a
- char *dmabufdest1 = NULL;8 }0 S8 T A& v0 U3 ~
- char *dmabufdest2 = NULL;3 x7 T% h* N1 j/ t8 i9 |$ {0 x
- ( `6 z: c5 {$ U9 T' @
- static int acnt = 512;& x* u' m% E/ C% D5 w
- static int bcnt = 8;5 Z% i5 _( ]; l' p
- static int ccnt = 8;' n- [! Z' E' K5 R$ [' \* N
- 9 u- [# o/ p! m3 j0 ^
- module_param(acnt, int, S_IRUGO);
$ S/ Y; l! r# E) E. N: g& @ - module_param(bcnt, int, S_IRUGO);* M9 z0 E( F, Q/ K* H0 v) J, L4 J0 `) {
- module_param(ccnt, int, S_IRUGO);
复制代码 2 {* ^. I y) @3 A
" j# Q2 F# |' v$ h8 r" D& R3 p
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) n" |- o# ~8 n; zarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 m2 R9 _: X# G1 h
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。* i' ]$ ~- w/ w7 h" F
! u' W& X, C ^4 M& |8 C0 L
; a3 G) P n c |
|