|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
# V D5 }# f. v, p& v# l. L$ O- [code]EDMA sample test application1 k5 W( X* S( i$ u! f z( W. R1 W
- /*/ Z. S. t' e9 w% B5 P% v( M9 \
- * edma_test.c
% N/ ~/ s- Y9 v5 R* S - *
5 F; k- \8 S" T# B. E1 D+ L - * brief EDMA3 Test Application& ]! {" `5 i' C% R" {3 H. ?
- *3 `( P8 w3 y" k! V/ |, k
- * This file contains EDMA3 Test code.
" Q9 v4 w* J0 M3 @+ Q! n9 }- i( W - *6 z. I X% u& w1 l
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE! F5 h3 h5 D0 e1 I9 u. N
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% C9 f6 f4 |! i' \3 S
- * TO CHANGE.( X# s6 G E* U! a3 o; f" F# e
- *
- q+ m7 i' O& z U( n6 Y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
j9 z0 \) a m2 y8 M2 V: Y4 w - *
+ Z Z( O6 V- v' b+ a - * This program is free software; you can redistribute it and/or& Y% f( n6 x% C- u: m0 l
- * modify it under the terms of the GNU General Public License as3 y$ r/ V; G. }3 ^0 i
- * published by the Free Software Foundation version 2.
, F1 A# d) {8 \ b3 S - *
* K* u: z* K$ o - * This program is distributed "as is" WITHOUT ANY WARRANTY of any, ^$ d4 T3 O& }+ a; e
- * kind, whether express or implied; without even the implied warranty
! O( _* k8 q( X# F( f' J- Y - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the& i# [* J. F- i
- * GNU General Public License for more details.* f" Z, B1 N& g5 l+ N
- *// V2 ~" g0 R) ~* }# K1 m; `0 P
5 v2 q1 i# [" H# \& w, G, @: J6 }$ v- #include <linux/module.h>. o* v# g2 t7 C, d
- #include <linux/init.h>( l& U% S& r$ g6 N; ?) E
- #include <linux/errno.h>0 J, o' t- K7 `& \7 J
- #include <linux/types.h>
; K- E) F' O2 s T9 y$ o - #include <linux/interrupt.h>' U1 {# d- s& D" L: w
- #include <asm/io.h>
1 c- C; p- R" O: G- I5 B - #include <linux/moduleparam.h>* a7 [: ]& C; l+ w
- #include <linux/sysctl.h>
! W- h t% X: r' f3 _ - #include <linux/mm.h>
% N; C' G% D% I, w9 {4 C - #include <linux/dma-mapping.h>
+ i5 R$ U* u# J7 F - 0 g2 }3 X2 i9 _! X( x! A
- #include <mach/memory.h>9 I4 o; p0 p0 q
- #include <mach/hardware.h>
/ n" V3 N1 U8 f' \! I - #include <mach/irqs.h>2 c! G" T; M6 I1 [, r
- #include <asm/hardware/edma.h># y$ _9 k% Q6 U1 I0 r
- & i2 u% F v1 E/ O) H
- #undef EDMA3_DEBUG8 ?; |+ K# J' X) T
- /*#define EDMA3_DEBUG*/4 \: f& b+ |+ h# P. C2 a2 [
: d$ |! Z6 }8 L8 Z3 T) K" x) u- #ifdef EDMA3_DEBUG
& x' m+ M6 G: R% y( u - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)8 o3 m! c9 H4 o$ x- l+ }/ t
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 G$ Z4 j/ m* X5 N, l2 j* t - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
, z/ U: ?0 k# t! s0 ~8 R - #else1 K; y5 j, }7 ~* O7 c, G1 ]! E) C
- #define DMA_PRINTK( x... )
% G8 K( t- ?$ y1 o - #define DMA_FN_IN. g/ h6 ^. j% u8 x5 A" p
- #define DMA_FN_OUT
; W3 S* d' t6 W: D8 l' @# `/ }: e4 f0 t - #endif/ E* ^7 u/ \! ~
- . _. E! q$ s. Z, o% t* r
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 l% M6 n$ N7 B' U$ B: b1 G2 p* r! K - #define STATIC_SHIFT 3; P- f' U* O/ J
- #define TCINTEN_SHIFT 20
* r0 o7 @9 I _2 s$ j - #define ITCINTEN_SHIFT 213 Z* d- G& _( H# H/ Y/ @5 j' U9 L( P
- #define TCCHEN_SHIFT 22 x' z. p: l& F+ x3 d6 x" Y$ T
- #define ITCCHEN_SHIFT 23
- _9 A+ R, x, a, w - ! c- j5 i& m, P& b' P
- static volatile int irqraised1 = 0;
2 `. {+ V8 [& ?3 G - static volatile int irqraised2 = 0;4 P8 J7 M, f. B. w
- - q. _- s6 ^$ S# `1 H0 f
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: e9 k d% L. `0 n' n
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" F; p+ X1 @1 S* j) b - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( T# d; V: _5 r$ n7 x: M- p+ I+ F
- * E+ ^9 U R- Z6 K0 t4 x9 A
- dma_addr_t dmaphyssrc1 = 0;
, x4 t* n# ~! R& {- y8 q. Z - dma_addr_t dmaphyssrc2 = 0;
, q( h5 ?2 M, H( ~& R1 X# q- M - dma_addr_t dmaphysdest1 = 0;
, ]% [# c# u5 c3 A$ [( U/ J - dma_addr_t dmaphysdest2 = 0;/ }; b& M% M: Q' L
& L( A! k2 k& I, }+ D) M- char *dmabufsrc1 = NULL;$ f5 P! Y0 s; E4 l6 k ~
- char *dmabufsrc2 = NULL;9 f+ Z: }1 J$ l6 R0 t/ R+ u$ `" ^
- char *dmabufdest1 = NULL;
# S/ ^+ v4 M) `5 j u$ C! W. Z - char *dmabufdest2 = NULL;( G7 |# n- ]/ M1 G0 j- n
) q/ t" |' s' B2 A- static int acnt = 512;- B3 {+ U1 Z& a4 x& S
- static int bcnt = 8;. K0 P4 F/ w% T$ o
- static int ccnt = 8;5 M' I9 u: ?6 {+ n; n! M- W0 K$ M
- 1 F [+ Z0 p( u8 a4 ~3 d8 R
- module_param(acnt, int, S_IRUGO);
+ T. G( D8 q1 N9 T0 O3 o" O( s i - module_param(bcnt, int, S_IRUGO);' d5 @2 T5 |* ?8 n# V; A
- module_param(ccnt, int, S_IRUGO);
复制代码
, `6 w8 e" ?' j4 v- j& Q" s x
9 ]& i& ~3 h" b7 t- Z9 F' K( X 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用6 L7 N7 c5 o$ s4 v8 X
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
8 G0 B0 q. x: c1 m5 m6 B* v) E0 E 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
1 ^ y+ o% @: [, X) ?& C# p4 k+ [/ L! ]9 P- L( O
% v e) O; I% `' \/ K2 _- a
|
|