|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) D0 @' `' b6 l! O$ ?0 k$ \- [code]EDMA sample test application
3 K V: W8 p# N' F+ q( {: g# @! ` - /*8 f* A+ | b! s
- * edma_test.c
) G8 Y+ }9 _$ U - *
; ?' Q O: W. z" _9 O9 D# U% U - * brief EDMA3 Test Application
+ p% X+ m, h2 c* E) K3 N- L - *
8 s7 b- f) P' [5 \5 V - * This file contains EDMA3 Test code.
+ ~7 ^+ [& y- Z4 Q& o) W' G - *
: d% J& H; I, V, s$ l - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 @3 S6 v5 ?- z0 L0 V
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
6 z/ n2 ~$ Q3 f ?. ~: M - * TO CHANGE.$ m( s) A1 t& h/ b& p9 Q$ M
- *% `% Q: v' z5 |9 W& v
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/* {$ J# ~6 _; ^3 ^
- *4 [1 s( ^, K! s0 w5 S
- * This program is free software; you can redistribute it and/or
9 A! T! Y m; ]9 [2 G" _( s - * modify it under the terms of the GNU General Public License as9 k" _4 ?8 x- \- t3 `: e* u
- * published by the Free Software Foundation version 2.
0 i# `1 k6 [& C1 g+ | - *' n0 l' d' Y1 {, X* ^
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any! e/ ~6 E6 o' w- C
- * kind, whether express or implied; without even the implied warranty
% t1 d7 J/ `9 B5 R0 n$ s! `& }- m7 Y - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" @, _4 y, z% ]3 Q - * GNU General Public License for more details.
* g7 U8 c8 n% F - */6 z) f1 Q1 P0 i5 i7 ? I/ t
- 3 i$ t. o- K( Y9 x/ V/ b
- #include <linux/module.h>
0 h X, ^% R2 x. { - #include <linux/init.h>
4 S+ i4 E2 S% J# ]( m" Q0 p1 V) P3 R5 O - #include <linux/errno.h>* E4 y3 i) A: [' |
- #include <linux/types.h>& D1 @( n- B- e* s
- #include <linux/interrupt.h>
0 k( N& d% P, ^4 N& D8 \ - #include <asm/io.h>, R0 ?, k+ U; m% u, x7 x4 ?
- #include <linux/moduleparam.h># t+ f* F$ A- G, N; ?" Y8 ~
- #include <linux/sysctl.h>
0 C0 T2 ^. F6 |# M - #include <linux/mm.h>
7 ^7 ^; k+ I8 @& | - #include <linux/dma-mapping.h>7 A$ u& H& A r& @8 T# l
- K. |- q! Q& H' N0 F8 Y# g& P& D
- #include <mach/memory.h>* D, e8 y' J W! A$ X3 ]. m
- #include <mach/hardware.h>
5 R& m( ]; n2 C0 h. w2 Z - #include <mach/irqs.h>1 a! U* D% y2 [5 h% A
- #include <asm/hardware/edma.h>
1 h3 E* a3 K* W, f - / J6 i; q. H6 Y3 x2 ] K
- #undef EDMA3_DEBUG; l( }- t: J5 W+ ~; \
- /*#define EDMA3_DEBUG*/8 K4 r0 G4 W! ^
" ~9 U# j3 D. ]- #ifdef EDMA3_DEBUG
3 S- v# I8 o v! X% Q8 K" X - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
1 x% P9 J/ ]/ a2 P9 X - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)7 [5 z; A& o6 \" O- x
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
; A" i# J5 J1 x5 o - #else/ D1 o4 _9 r( A8 {( V% J c; T4 m/ W
- #define DMA_PRINTK( x... )7 u P8 s, a: Q; J8 y' N
- #define DMA_FN_IN
- Q N9 [# m5 S% V0 P D5 v - #define DMA_FN_OUT- N0 k" g$ Z. ?- _
- #endif
3 H7 O9 r- _0 Z0 f+ S8 l9 M0 D - , x, Z0 Q7 ~9 q$ N
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
3 q- ]: B2 a2 ~: I( c1 f - #define STATIC_SHIFT 3
" N# J- C" g0 q2 _% Z/ r% A - #define TCINTEN_SHIFT 20+ ^" ^# K& ^" J7 V9 L
- #define ITCINTEN_SHIFT 21
( C* W3 z: m3 N2 F - #define TCCHEN_SHIFT 22
1 M0 E% K8 g U4 t# X& P$ V- B - #define ITCCHEN_SHIFT 23. ?# u' }2 @3 @# b, L& D2 b
+ f& n& \4 v. p7 _- static volatile int irqraised1 = 0; Q; C8 C$ J$ G* _0 I$ Y
- static volatile int irqraised2 = 0;# e/ [- n! u7 X5 R% {3 M
6 f) R, Z5 a) X, v, K7 |" K- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, \. `# g8 _! ?! S
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" M4 t: `2 ~0 ~
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! P/ K* Y P/ _% F d" c
" T, C2 Y$ D0 [- dma_addr_t dmaphyssrc1 = 0; @& V$ B8 } g8 U7 }
- dma_addr_t dmaphyssrc2 = 0;
/ Q# M3 T7 n1 l+ j8 M. n0 K. D5 q - dma_addr_t dmaphysdest1 = 0;9 z2 ^$ A5 _! U# t
- dma_addr_t dmaphysdest2 = 0;8 g8 \% H9 i3 K, [& ^0 b
) I# w: D0 q* R4 d- char *dmabufsrc1 = NULL;
q7 ? Z; y W; u - char *dmabufsrc2 = NULL;
* U9 ?, i) o" m; ^ w6 w! ~ - char *dmabufdest1 = NULL;/ @4 V E! c7 R! E9 F
- char *dmabufdest2 = NULL;& V6 P7 s* M& e8 j/ V
. N9 P1 B7 {, T3 q: E- static int acnt = 512;
, f& L |! f5 S/ S- Q! _9 a - static int bcnt = 8;
% G2 P5 d' [* m, D7 g - static int ccnt = 8;
6 U+ q! z1 C5 q7 r* _) i6 g4 z - % v; R7 W6 M2 G5 j( c) B9 h/ _
- module_param(acnt, int, S_IRUGO);
]6 ^; o) ^2 P9 S1 w: {+ s7 b - module_param(bcnt, int, S_IRUGO);# c# T" r- @4 w' w* W$ `" y* i/ v8 O
- module_param(ccnt, int, S_IRUGO);
复制代码 L* O$ q. z! ^ T2 L, }* L
+ R. j0 a# |! M 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
, U4 l5 q' K& @$ g& {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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
2 r, Z8 p: G' h4 T) j5 A 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
( ~$ R0 v% |7 W: \# E' A: H! W! L+ y. j; V, T
# }1 C E1 b# l2 S4 p
|
|