|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
0 @/ H. b: M% Q; l- [code]EDMA sample test application6 W8 P- Q* e5 i8 o# y
- /*6 G! W6 I! j) U, A2 ^3 v
- * edma_test.c
* _( Z! U& t* C/ n) x - *
/ i; s. [' x7 J' t" \. a# z - * brief EDMA3 Test Application. I, z3 b" R3 W) k; q
- *6 } a9 t9 H6 |! c
- * This file contains EDMA3 Test code.
; Z; `" y n4 p - ** ~- C5 A. n4 Y' ^- O" B N8 o0 N
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
+ e3 G( U0 l* Y5 `0 I0 {+ ]; }8 G+ \ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
3 T$ y9 l5 h% M f - * TO CHANGE.
# {; T8 |: o2 I" R1 D$ l; ] - *
7 O& ?/ ?3 d- ?3 L - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
h8 y/ d$ O ?+ @- F) i; Q# R" v - *+ m2 }' K( k0 S8 s
- * This program is free software; you can redistribute it and/or! M E( W8 A+ u* o7 ^/ @
- * modify it under the terms of the GNU General Public License as
4 H: A3 l4 `& g7 n" G - * published by the Free Software Foundation version 2.+ E5 Y" Z) G5 G- x' T$ s/ A
- *8 a: V# T7 P( F! O w
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any( a" u% i2 }: c; x5 Q, J
- * kind, whether express or implied; without even the implied warranty
% v% ~* ]# M Y# h4 p1 s7 x - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ x( _ O& g! S g- u# t; S7 c9 o - * GNU General Public License for more details.
0 b, B' `5 f5 w+ ] - */
1 Y9 x3 R" q& ?1 J5 [2 ~
% R9 s' P; y& A( K0 ^: ~- #include <linux/module.h>$ j# J% X7 @+ I
- #include <linux/init.h>
6 k! C% E4 D1 w9 e" @" f - #include <linux/errno.h>
# f& z+ | O4 B - #include <linux/types.h>
: e. U* J& I: \; v3 [! p7 v - #include <linux/interrupt.h>
, s9 I: C* D. h& @ - #include <asm/io.h>& u( h) J9 U- |0 g& l
- #include <linux/moduleparam.h>
& [! H! E% U& s5 J1 { - #include <linux/sysctl.h>" |+ K! Z( ]) s
- #include <linux/mm.h>9 x; j4 u7 A9 X5 s+ q
- #include <linux/dma-mapping.h>
$ W, R; ?% [& v+ `( k5 ~! q
8 b3 j) I9 n* U5 p. M9 |# D- #include <mach/memory.h>
. D2 C- X, h5 n0 y* H) q8 } - #include <mach/hardware.h>, I# n8 R1 S; ~# T
- #include <mach/irqs.h>& V' O5 \7 t" W9 R
- #include <asm/hardware/edma.h>
/ U% g3 ~" r* D# h2 } - " s0 S+ n0 `! f2 ]4 L
- #undef EDMA3_DEBUG* ^" X2 l2 ]- }1 u1 |0 v
- /*#define EDMA3_DEBUG*/- D ^ _1 K* t$ O
9 G. O: m h; Q- #ifdef EDMA3_DEBUG7 a$ j( a2 ]0 L8 }8 }8 P) k8 `) V
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
$ u- [) `' ]3 a7 N3 f/ j! m; j7 y - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
, M7 c6 q2 G* l2 ?* | - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 B m3 ]) q; z8 Q - #else0 h: S' N1 e+ m& I" l1 ? ^5 X
- #define DMA_PRINTK( x... )
5 a2 [/ S0 N. X' C - #define DMA_FN_IN
/ O. R$ N S& \' P - #define DMA_FN_OUT
9 h9 `# z6 r/ e& L3 r* L! ?& P# e - #endif
! d$ n4 p- S% K5 T2 `( q( g$ M - * n; T6 I5 v( H0 }2 F- x) {
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)# b7 x% T Y: x( ^1 Z
- #define STATIC_SHIFT 3
2 ^* M9 H! M4 P# K" D/ X - #define TCINTEN_SHIFT 20
: S; u& k: R! C4 {/ J' U - #define ITCINTEN_SHIFT 217 z+ a) N" d f
- #define TCCHEN_SHIFT 22
6 O) A) s2 j% p) v, z! l' _3 s - #define ITCCHEN_SHIFT 23
- A( ]- n: X1 A5 W h) p
8 |% u, \: E/ O4 D- static volatile int irqraised1 = 0;
! L6 P, X2 ~3 z' X5 }3 s - static volatile int irqraised2 = 0;) Z+ I6 y" G' k# s6 z
- ; L% T7 n7 B4 |/ A3 i* f0 f' M
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
y' G* O: K4 g ^/ w0 { - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, _( s, U) y7 W4 R - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* _, J: S: E9 f/ u) v
7 b0 x- N8 ^! u) b+ ?( K- dma_addr_t dmaphyssrc1 = 0;
6 r6 n" k4 d0 F- R& d- G" n - dma_addr_t dmaphyssrc2 = 0;
3 \% O, G7 ~9 }; D' V1 K - dma_addr_t dmaphysdest1 = 0;/ k, o# C- T! n6 U9 T& a8 w% t3 T- q
- dma_addr_t dmaphysdest2 = 0;7 N, w8 K9 q0 \
- 0 B! W: L) p# g X
- char *dmabufsrc1 = NULL;
& f3 [. G3 E8 f3 B4 r) S4 q - char *dmabufsrc2 = NULL;( z4 U9 U- Q# D# j$ }
- char *dmabufdest1 = NULL;
4 z+ s2 l' v0 t6 y# \0 \ - char *dmabufdest2 = NULL;! k8 \5 k/ P6 H. {
- 3 n2 @# a, c5 g4 ^$ p
- static int acnt = 512;
, B+ N6 |! \% R3 i H/ D/ Y# G; I - static int bcnt = 8;
# j0 m \4 @3 O7 Z; T r* b - static int ccnt = 8;4 }- [; I$ H$ K7 O
% |* l( V4 \2 O! b! Y& \$ l: E4 X+ _- module_param(acnt, int, S_IRUGO);
& a" |) A# Y5 T6 c0 N3 A% R* t - module_param(bcnt, int, S_IRUGO);
. `- x* @# N, V/ U( K- l6 a7 C - module_param(ccnt, int, S_IRUGO);
复制代码 # w6 _+ s& ~1 M" q" ^9 c% _" ]
/ v( ]! q B3 Z* Q! ]& S, q7 V
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
}2 M9 _6 n& D: `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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# D. J2 j. P2 o. W3 a8 N" C. I
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。4 x1 [0 E& u, e- p; W+ r
% t; P% f% y, \7 Y
1 `% q8 V+ u- ?8 M7 K' K8 m
|
|