|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 I! H6 u# ?% v6 n; x8 B7 U; U
- [code]EDMA sample test application
1 j0 a. |* { {$ I( t) Z7 V: Y% i - /*8 P$ o% }* ^5 f( e/ N& p
- * edma_test.c, u! W! K" z* M( b1 y5 T" V% S
- *
. T5 f+ t) y" y" [6 @( s8 I- i6 f; I - * brief EDMA3 Test Application0 s+ y" {" u: N$ @' K5 U q
- *( R, j E2 w9 x6 t( [9 [
- * This file contains EDMA3 Test code.
, p4 ]; a# Q& x - *
2 j8 n* U! l0 X; M - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 o& i+ W- A; |; ^6 ^% p, v) F" P1 C - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT u) R% {8 w1 W7 G& i3 R2 b7 k
- * TO CHANGE.4 y( [! m4 A D
- *
1 H7 p% M8 V5 V# g' l& b - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ e% W! t$ Z. ?0 { s# N - *8 N4 L$ P/ S/ H5 @ }
- * This program is free software; you can redistribute it and/or- c" i/ q* x' `9 c( Z ~
- * modify it under the terms of the GNU General Public License as
) p. U9 K) Q7 _" Y/ C. e - * published by the Free Software Foundation version 2.' m' }# v# t* c; D' e" O0 F
- *
3 j8 P, g' m) z U: V9 x- e" U - * This program is distributed "as is" WITHOUT ANY WARRANTY of any4 o9 v# f- B! A: N6 U e
- * kind, whether express or implied; without even the implied warranty* b/ v" B4 s% Z* V
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" u) H0 c6 \) P: j2 D! p1 o' G - * GNU General Public License for more details.' Z! n* Q" N2 T0 M' ?
- */
& x u( Z# i5 e5 ^, a - ; F; Q2 {3 `; w. z! g3 Q
- #include <linux/module.h>) x9 B( I% J8 G/ C' q
- #include <linux/init.h>0 e* m* O0 ?) X# E$ ]4 H
- #include <linux/errno.h>
; k+ O i& k5 I8 U, k - #include <linux/types.h>6 T, E- I! Y- K) u
- #include <linux/interrupt.h>
% m) A- U% ? }4 B/ x6 m3 [ - #include <asm/io.h>$ I1 m0 |; @+ X* r9 P) _2 e9 O
- #include <linux/moduleparam.h>
5 E; D; g( h: D' G: O. x - #include <linux/sysctl.h>
y$ E2 w( M. ?2 M* N9 U" V2 \ - #include <linux/mm.h>
5 _' }7 C( Y% e' v' T, l% W - #include <linux/dma-mapping.h>
- C5 g$ P. u( [3 G1 z2 I/ b; \ - ; ~2 d' V5 I7 P# _, Z! X
- #include <mach/memory.h>% W* k" m, E' {) A" U
- #include <mach/hardware.h>$ O, M% d' S* L f( M# N5 F
- #include <mach/irqs.h>
! |4 K# Y Q# O+ d- h) z - #include <asm/hardware/edma.h>
1 r; ^$ l- x/ j# b( }$ f( s- c& @ - 5 N' e, u' L) L
- #undef EDMA3_DEBUG z$ |: r- i$ I- ~0 t
- /*#define EDMA3_DEBUG*/6 ~ o/ j% J* M9 B4 a9 b
' v1 G F1 T, n) o9 g8 o- #ifdef EDMA3_DEBUG9 ]( I" u x' J0 T/ I& N
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
" [ [) \1 s% V0 Z - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
A" y) q) i& q+ B: R - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
2 o: n* J; @# }- A% p6 t. D3 g - #else
/ t" M" d6 W5 K0 Z - #define DMA_PRINTK( x... )1 R! a( t7 d0 A, n/ P0 Z
- #define DMA_FN_IN# k- T. o* W. @/ i8 ^- ]. G# Y
- #define DMA_FN_OUT: I2 S9 u" x# w$ d% F/ Y5 T
- #endif6 w: B: O. o' H% m) i2 X; W, N
) j7 b0 i( O0 ?) \" q- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ R5 h1 L, c8 w& i( y; J c
- #define STATIC_SHIFT 3. {% }2 \* ]4 M' `+ J8 y8 `6 Y
- #define TCINTEN_SHIFT 20
+ j9 S; B$ V2 c8 R' M* o& f: m - #define ITCINTEN_SHIFT 21; n3 o5 [# j% i; g
- #define TCCHEN_SHIFT 22% ?. T5 l4 Q K- D( b) h
- #define ITCCHEN_SHIFT 23% ~( g ~ L( `; h% J9 N
- t) M' v# x! G7 j( N- static volatile int irqraised1 = 0;8 z5 q. D% c7 K5 \& w8 x
- static volatile int irqraised2 = 0;0 _" ?- p1 F4 t. l8 D! ] p
- 9 u2 ~8 I1 u& Y) ?2 \9 a! K
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: L- b1 m2 Y% E - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 k) r/ |# M8 r! c. E8 ?. k
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 g. t1 x% X8 i5 r1 s) B) N - : G/ b3 w6 B w& G6 A0 a T
- dma_addr_t dmaphyssrc1 = 0;# Z1 J* i. k, U2 k
- dma_addr_t dmaphyssrc2 = 0;; }% ^; ^6 p% x, v# k
- dma_addr_t dmaphysdest1 = 0;! G' N" C' a, i6 |2 w3 N' P3 v
- dma_addr_t dmaphysdest2 = 0;
. e j/ d9 t) o. c* l% d( |
9 Q4 x8 A" G- Q8 N) x% _7 R" _- char *dmabufsrc1 = NULL;9 y+ B/ w# Y) B& r2 ]
- char *dmabufsrc2 = NULL;
$ a& q, O1 [: Y# ]' z - char *dmabufdest1 = NULL;
0 ^ f" f' e$ H D+ t0 ~ - char *dmabufdest2 = NULL;
2 o9 a3 O' G$ u3 I - # r7 L2 L! j: z% v9 i; l5 H/ P
- static int acnt = 512;
; I& }( V4 f5 |, I( ~" C - static int bcnt = 8;7 \* V0 w1 w; k/ Z0 I# H) X
- static int ccnt = 8;: U2 z9 c" Z- d t) U
- 8 m* m/ e; B2 g, _+ O
- module_param(acnt, int, S_IRUGO);
3 }- V! p# h- ~ - module_param(bcnt, int, S_IRUGO);8 Q1 i8 i" n& E# B& v. c+ l/ Z
- module_param(ccnt, int, S_IRUGO);
复制代码
$ o5 p3 J6 {. G8 Y9 k0 R* _( w, ^- i; u4 Z" s9 X8 M: b
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用) V+ P: w. l u, p9 {5 ^4 O
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
[# _; B/ k% O% l 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
/ B8 R. g6 D! s$ l- {5 {: p- @/ P( p
! |: s0 ?& \: W8 Y |
|