|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ( \# l! n4 S" C! F( y
- [code]EDMA sample test application! Z, q+ ^- @* O3 T* W; w, g' S
- /*% l5 J" S) n# m
- * edma_test.c3 m% I5 o" o9 h: F1 _7 E
- *" n6 o* @* J3 `
- * brief EDMA3 Test Application# f. X( P- A1 Q" p; n- ~
- *- c: A9 U9 v$ J4 B0 ^# x/ Q1 }/ v
- * This file contains EDMA3 Test code.
% Z! T- ^/ u$ p - *' O& `, u2 r: P1 n) ~
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
6 a- ~$ f; s$ U - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
1 i6 A' ?5 f* Q7 H" h+ ^ - * TO CHANGE.
1 ?6 t6 u3 ^+ v( U) U* ` - *
( N$ O8 |! o! y9 v - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 q( d$ Q8 K, Q7 Y9 n* |: U2 V* ~
- *
' R1 r/ H0 j) ?6 d9 w0 E - * This program is free software; you can redistribute it and/or
9 R% o# M; C6 x+ Z - * modify it under the terms of the GNU General Public License as8 ~* M5 [8 Z8 r% Q4 ?2 B1 G
- * published by the Free Software Foundation version 2.1 u; i, X) Y( U: L. ]" K( U
- *9 C- O- m' p) n0 f' @- ~' y. b3 G# M
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 P$ t4 I; }) ^. a0 k; B
- * kind, whether express or implied; without even the implied warranty
P. N* Q, w6 e' E) Q. |& Y - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the& x$ [7 A( {* u& p6 U2 `
- * GNU General Public License for more details. |* I8 o, C3 J! p
- */7 J; G" _. z& G! t* F7 J
( H! O# H# e0 T5 F- #include <linux/module.h> e6 u4 J& v0 G
- #include <linux/init.h>
. p1 J0 g7 D9 W7 e5 F9 q - #include <linux/errno.h>
# i: f1 c. D3 M: H6 ?- K* v+ V) ^ - #include <linux/types.h>
9 M8 o& z1 ?$ ?0 H# v - #include <linux/interrupt.h>. `, H d9 |$ ?1 m2 O$ [: r
- #include <asm/io.h>; G; m. }- C, L/ S- j) R+ A& ~% T
- #include <linux/moduleparam.h> j6 G, P# h$ o: F1 H) {
- #include <linux/sysctl.h>
" Z' a- X$ j( D; m: w - #include <linux/mm.h>) \# z) T3 e/ j2 y
- #include <linux/dma-mapping.h>1 A. S4 F h) A& C; U& Y% e
4 p8 N9 \, A7 m: A' x: y5 ]- #include <mach/memory.h>2 y. V: W& X+ F$ m3 h" r
- #include <mach/hardware.h>
& q5 G z6 x7 U1 |* i- q C - #include <mach/irqs.h>
8 b2 I( d' c3 t9 ]/ a8 |, U+ } - #include <asm/hardware/edma.h>0 E4 c6 ^3 O2 r# G2 y
! [3 x4 T. |* P7 I6 j7 a- #undef EDMA3_DEBUG
' l9 s. I. [9 Z. z1 k% w - /*#define EDMA3_DEBUG*/# v6 F! H1 u- ]+ x$ x
- ! [/ ?2 i% m, t6 z
- #ifdef EDMA3_DEBUG6 H' j0 S0 c \% Q% y
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; K( k1 t- Z! a) X" L* D - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)9 \+ w W m9 v0 G
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
7 a; I) @. W2 P* L1 T4 r" h - #else$ h7 d, ^$ I( P# L. b
- #define DMA_PRINTK( x... )& @; G: b4 n- b
- #define DMA_FN_IN
$ s( A* Y0 L3 m$ Y3 c! N. {) X - #define DMA_FN_OUT
/ C7 m" o- @; B - #endif4 F8 D, w, {( ~# \
8 o4 v$ B& @ e }6 [& _* g0 r0 S! S1 ~- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
m) v9 j, a" X3 e4 W- n _ - #define STATIC_SHIFT 3
+ {- e i8 Q: X- I0 d9 f - #define TCINTEN_SHIFT 20% v" }7 i x0 j! i' k6 Z9 j1 R
- #define ITCINTEN_SHIFT 21
2 Q7 o' t5 K# C6 c& \; K5 F - #define TCCHEN_SHIFT 220 U+ R4 X& B5 X8 w1 Y7 t; s0 F
- #define ITCCHEN_SHIFT 23
5 O& a+ P. O. n" r3 d
" _- N7 i# L3 w4 x. x4 y- }- static volatile int irqraised1 = 0;6 M+ |9 ~+ e, w
- static volatile int irqraised2 = 0;" W5 P i- B4 O: l- w
8 T6 \3 j x) u' p( Q. p- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 I: m( f- K! ^4 W
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 G) u! Q! m% R) U: V: n, N) g# t) B - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 \8 o) k; k) r8 q6 | - % ], k9 Z6 t5 V) N+ l1 n" b
- dma_addr_t dmaphyssrc1 = 0;/ T6 } f$ t- g: i% p3 ~) h
- dma_addr_t dmaphyssrc2 = 0;4 y1 a5 \/ m2 o& G: m) F/ y
- dma_addr_t dmaphysdest1 = 0;: t E7 G; U/ R4 ]6 N
- dma_addr_t dmaphysdest2 = 0;5 W5 S( D$ g+ p/ P
U8 P4 r! n! c2 S: E9 z: o- char *dmabufsrc1 = NULL;7 W V: ?3 p% [ s/ L: Z. U
- char *dmabufsrc2 = NULL;
V. b6 n: R3 O x% j/ F. \& g& H - char *dmabufdest1 = NULL;
: i. g, [: p' r) W - char *dmabufdest2 = NULL;3 H+ V. U# C, u1 L, S7 C
- 3 j0 y: E9 A, B. [. v1 l
- static int acnt = 512;
2 i* _# e6 s" N. a4 ~ - static int bcnt = 8;) ~ n* r! n3 s6 Y. `
- static int ccnt = 8;' S5 o1 N- P9 k! t
- ; M# o8 g9 j$ \
- module_param(acnt, int, S_IRUGO);% J* @/ O( s, X. M/ G
- module_param(bcnt, int, S_IRUGO);
* p8 O5 V4 r' @ - module_param(ccnt, int, S_IRUGO);
复制代码
# C/ \$ d' C9 |* G; S" |8 K# b: n
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
- v) N0 q# H$ Xarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。1 k8 f# k3 G( R7 ~, B
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
3 a. d) J: W& ^6 o: J6 X5 V6 d% q' W- \
/ m) H% o0 [$ M( C
|
|