|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 p! g- x4 T& f% Q6 {) D0 u
- [code]EDMA sample test application
( d. p6 o0 t& |! k I/ B# ]1 U - /*
8 N2 B7 M4 m& v - * edma_test.c
7 Y0 \0 k) O0 L' ]2 ]; _5 P1 e& o; F# k - *
- F; Z2 w' X4 N; o7 B( V - * brief EDMA3 Test Application |( h" z8 `0 b* O
- *
; i) W" P( K% H* T; w) ^ - * This file contains EDMA3 Test code.
4 I8 i# ^3 r& k4 {% B/ S* \6 H - *
1 B1 d7 t A/ J - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
o8 |2 g3 O E- D' u# U - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT( ?* y! {2 w6 A3 l
- * TO CHANGE.
" A( |, U' U- Q+ g8 o D) x4 u$ s - *
- t; _* g* M: q8 d U# n+ H - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
& K& E& K, U9 a0 \, @2 i - *- i+ E. ]$ S' o' |7 J, @4 g: X1 F
- * This program is free software; you can redistribute it and/or5 i. [7 ~3 b9 c" ~' G
- * modify it under the terms of the GNU General Public License as' S6 Z! G b5 M9 k5 `
- * published by the Free Software Foundation version 2.
/ k/ l. u/ D4 x' |8 j9 J - *
, {! U% |; I9 d& N - * This program is distributed "as is" WITHOUT ANY WARRANTY of any" q/ s( b; ~* F$ L8 r
- * kind, whether express or implied; without even the implied warranty7 O( o/ U5 F e9 O" N
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) W4 `& U* C6 J: g# k9 U D
- * GNU General Public License for more details.3 d) k" N% o) x" v
- */: n; w a* Y) [ m3 Y* [
4 [# K+ V' P) {! L" X* ^, t- #include <linux/module.h>- v- t) X/ U+ f
- #include <linux/init.h>- x% q2 Q$ C E/ l- r& f/ D
- #include <linux/errno.h> Q7 L$ o$ c& O$ A2 q
- #include <linux/types.h>
( t' Z6 O% D6 U8 H7 L& g - #include <linux/interrupt.h>
5 U* h$ z3 d4 F3 x$ h z# R" D - #include <asm/io.h>
* F7 N( p: J2 [4 Z0 l# b5 j$ u8 \/ J - #include <linux/moduleparam.h>7 i7 V) _7 e8 q3 k2 A
- #include <linux/sysctl.h>) k2 \/ w" e4 j( d% e3 P
- #include <linux/mm.h>. o6 K3 C7 _. k9 g; ^) T' A, H4 j! j' ?
- #include <linux/dma-mapping.h>
R8 o( n$ H) p0 l - ) C& ` x& n( Z: z8 q/ k
- #include <mach/memory.h>' c% _. E4 n2 N; m! h: q1 v
- #include <mach/hardware.h>7 P. p- p. Z: U6 o
- #include <mach/irqs.h>
L! ]- k8 t! D" f0 ^$ l4 R3 [8 S8 d - #include <asm/hardware/edma.h>
7 u+ u; h: X. @3 G. r! \4 ~ - 1 |3 c; y, o/ I; `" ?* p' [
- #undef EDMA3_DEBUG
1 g) A: D: J9 X - /*#define EDMA3_DEBUG*/
: f) s# N$ v% q! j3 U0 D
; Y' p( ^3 w1 \7 W9 }- #ifdef EDMA3_DEBUG7 r. }4 q& U+ _0 X/ ~8 J5 Y
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)9 G1 e9 I0 D0 }% V% p9 y$ i
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)4 a, V4 P) ~- H) e! }
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
2 H" F, P7 D3 ?1 u1 A# z! u - #else6 B$ r* g: {" r4 F/ F5 F
- #define DMA_PRINTK( x... )
7 {# d$ R$ u/ ~/ y. i/ ^0 w% P - #define DMA_FN_IN( v; \: K, e( `/ q
- #define DMA_FN_OUT
8 s3 K3 S0 u7 } - #endif; |0 I; [- Y8 ^
7 ^& S% G+ j9 ]# F- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: |. a1 {! I, S2 F - #define STATIC_SHIFT 3# J" p9 G( [$ k+ J# q% u
- #define TCINTEN_SHIFT 20- G# `- h0 Q9 X9 b3 W* u
- #define ITCINTEN_SHIFT 21
3 J4 W4 L( k' `/ k( | - #define TCCHEN_SHIFT 22
& m& L) T0 C- I# f) G0 {7 q - #define ITCCHEN_SHIFT 23" f6 j) i2 t" V: {, q3 k
) i7 ^2 }: \: f. A- static volatile int irqraised1 = 0;
# @ D0 a& u. o2 F1 R1 I - static volatile int irqraised2 = 0;2 q9 w a6 ?" G$ Y7 S
- 4 E; d9 B4 S9 L6 u: Z3 F
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 i1 `. P2 h2 h
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 B% H. t8 R3 Y8 b
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. a9 g' m) X8 ^
- |' k2 T7 {) S! T/ H3 R- dma_addr_t dmaphyssrc1 = 0;2 B$ a& R6 Z* b- y8 k' ]! S# t
- dma_addr_t dmaphyssrc2 = 0;- A! }# K, `. s7 H, D+ z' n V1 p
- dma_addr_t dmaphysdest1 = 0;
) J: ]/ {) s! q s - dma_addr_t dmaphysdest2 = 0;
& |/ C# b+ O$ y9 }. E: C! v - + c& Y; [* G/ S7 V
- char *dmabufsrc1 = NULL;: D' L% k9 H2 D+ m: d4 L; ^
- char *dmabufsrc2 = NULL;( W+ N: J A1 f
- char *dmabufdest1 = NULL;. f' P7 O" W% v. A& h
- char *dmabufdest2 = NULL;
5 A/ ^* H- k4 n6 L: k) E+ k2 V
7 h" W( ~- q& x. G/ G9 M2 e7 f6 h3 Z- static int acnt = 512;4 f1 x5 h# W( K# E6 s; h2 k i
- static int bcnt = 8;
' D; L6 Z# F' C$ H. _" m - static int ccnt = 8;
% i$ |3 e2 A& z# p, v. t) X - 0 g" R5 ?* X; Z1 L* j
- module_param(acnt, int, S_IRUGO);) k. q& |5 E! f* _: f
- module_param(bcnt, int, S_IRUGO);2 A" o4 P2 I5 H7 ^2 v' P' O
- module_param(ccnt, int, S_IRUGO);
复制代码 2 N8 D! w9 z* A7 C B
0 X! e4 ?( @( y: l
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用+ J! }+ a+ w) c5 d& m7 M
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。) I, f2 O6 L) ?1 g0 ^; f# C6 u
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
- i4 _ R& g! D+ {, g# H# B2 }/ X k& t& Y4 U
- @6 U% H! @! A' X& w9 Y' m6 A
|
|