|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
1 I" k$ j& O9 l. f$ S0 [& L- [code]EDMA sample test application
' c6 |4 p+ Q$ n _1 G - /*
) j' W' @( H$ P8 O8 f - * edma_test.c
. A8 y/ m6 Y. y - *- w, t" W2 z" k4 f; U" \
- * brief EDMA3 Test Application( \8 `- B @) U7 U' U: H
- *) T+ o( x. x$ f
- * This file contains EDMA3 Test code.4 B- | d5 L, c( W0 }/ o
- *
. A4 j- g1 O1 ?2 _ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
2 Z5 l9 C1 _( h. ]6 ^ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
c/ w R/ L ]$ u7 t& z7 h. u% I& V( K2 j - * TO CHANGE./ ~1 y) ]& S) X: F0 l7 i
- *- u8 H, ~ C- K$ q$ F( C9 \
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/( ~$ t, e3 u8 J
- *. }* o) @7 ]. U Z
- * This program is free software; you can redistribute it and/or
1 L8 @8 |) b) p* T! r - * modify it under the terms of the GNU General Public License as+ V4 N( U) t- C2 `) K' Q
- * published by the Free Software Foundation version 2.
; ]8 g5 A( g' `8 }" J2 f1 } - *7 }5 k/ q/ l7 E. @: \$ z7 Q8 D
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any, X, ?" V2 E, r. H1 B& Q4 c+ q5 i
- * kind, whether express or implied; without even the implied warranty6 n; h9 ?; a( l, N1 u8 D6 L+ R( @
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# B+ `2 K5 n* ?9 t( G
- * GNU General Public License for more details.7 k3 P F! ^9 ], T
- */% X i& A* ?- E8 F6 I7 j
- 4 _! ^8 B8 C- m. x* A
- #include <linux/module.h>
) B7 m/ Q* o9 t* S- H - #include <linux/init.h>
( s8 M% m a7 k3 ~2 |" o6 ~ - #include <linux/errno.h>
- ^2 o; g" l1 B3 r: Q: a - #include <linux/types.h>. D7 H! E) ~- n/ x/ m# Q0 D
- #include <linux/interrupt.h>0 J+ ?% y# m3 F/ o5 U; |' z3 C
- #include <asm/io.h>2 V9 B$ w3 D- g8 l
- #include <linux/moduleparam.h>3 U" ], W: m4 X8 j( j% J5 T2 [# J; M
- #include <linux/sysctl.h>9 q- f( }- _/ j# [! \; n; u
- #include <linux/mm.h>% g1 Z$ B2 t+ j" d( N
- #include <linux/dma-mapping.h>( |3 ~; x5 f# N; L8 X
/ b- T1 n) R% @- b ~- #include <mach/memory.h>+ P3 H0 X3 r( q! e
- #include <mach/hardware.h>6 n# I2 T- j. p
- #include <mach/irqs.h>$ B) }; q- m' ?! ~3 W4 o- M
- #include <asm/hardware/edma.h>2 T: d: S+ k! l* i1 V- [- `
- % E0 I; h1 y+ n$ B( Q% ~! a w
- #undef EDMA3_DEBUG' \, i! t3 {( e4 Q- k0 p- T$ m9 A
- /*#define EDMA3_DEBUG*/
4 K, T7 n$ W1 u3 H1 f {
! ~2 `2 X2 z, e: V7 _# x/ H- #ifdef EDMA3_DEBUG. W, U0 w5 m: H, X2 L! y
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
% l+ H1 c' \0 G1 |5 X& Q* a' U9 K/ [ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
) J" v5 J9 f; d - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)- ^$ e! t Y4 X0 _% w' T8 }- a
- #else% U- [" T. U9 Q1 u( B& U
- #define DMA_PRINTK( x... )) u* v3 E) a; {; L7 g9 t
- #define DMA_FN_IN6 @! k) p# W% t' r- b# w
- #define DMA_FN_OUT
/ z/ S4 X0 m, o# I8 U. {: q9 W - #endif
/ Z6 Y+ y( I1 y" F
' ~% R$ c5 T. M9 F' l8 g- #define MAX_DMA_TRANSFER_IN_BYTES (32768)- } f& f/ m% N8 E0 K, z" w' l
- #define STATIC_SHIFT 3
2 K+ _* F+ P# z" d - #define TCINTEN_SHIFT 20; @, h7 N) s+ q: I: X
- #define ITCINTEN_SHIFT 21
/ A9 n4 I7 N. y, F! D% x& ~ - #define TCCHEN_SHIFT 22- A0 T$ g/ a& x" {
- #define ITCCHEN_SHIFT 23& F1 y" k' ~, I% `/ i# k& _
$ ?1 m+ l5 B7 d3 }- static volatile int irqraised1 = 0;
; Y% l; ?. P' G# f2 _# M - static volatile int irqraised2 = 0;
& Q4 G; g7 u/ o, ]3 b - " \6 B {+ H5 \- ~
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& w, ]6 W8 L! c- V - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 D9 w4 c g* i9 W- A
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" ^8 `/ A3 e9 p/ B1 a" ` - 8 X( `4 h" S4 F0 d8 i5 o) L
- dma_addr_t dmaphyssrc1 = 0;
9 ]8 z& N+ L; u, n2 L8 D - dma_addr_t dmaphyssrc2 = 0;
( ^8 H: P7 l2 |0 v& c4 G; M& R - dma_addr_t dmaphysdest1 = 0;& F# ^4 b" P% ^$ @5 A
- dma_addr_t dmaphysdest2 = 0;
[: p: ~+ ~! b5 g& k) p - ]% e- T8 k- l) K- ]& R
- char *dmabufsrc1 = NULL;
: h( H# P) O& J( ?% P - char *dmabufsrc2 = NULL;
; } \4 r) _7 O/ x; Q4 d8 y - char *dmabufdest1 = NULL;$ V: W( c7 ^, }& g; s+ }
- char *dmabufdest2 = NULL;
% i- r1 `8 Q% @7 S% O - 1 w$ r a/ q* o1 {. j
- static int acnt = 512;0 F- W0 z, A1 _1 J1 o0 K
- static int bcnt = 8;4 G" F' g9 O% B2 G* [4 x; o
- static int ccnt = 8;" x) b7 K! ~& ^/ _9 ] R" ~
: ~* W6 t' g# b4 f N, t- module_param(acnt, int, S_IRUGO);' C% c" P0 j" X, V+ M2 o, R
- module_param(bcnt, int, S_IRUGO);
5 n1 d5 @& `. K% @# w3 s - module_param(ccnt, int, S_IRUGO);
复制代码 $ o3 n% L: _. m2 D0 ]7 K1 r g$ b1 j
% e, J4 z+ r8 T- ^) h 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用: h2 o& J9 y' a0 n* T
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
3 h$ M# R# w3 _! A/ I2 \* D- g9 H 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ p- J8 L f6 N* h M% |8 U
& A0 `' ]# a& X' ~# s; {
% s; _5 F" d$ ~, P0 y/ L
|
|