|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 " Z0 R- p9 n! z, {
- [code]EDMA sample test application1 x. o3 s# K k- ]9 v% m
- /*
8 y: X3 F2 n6 C4 N- F5 e' w - * edma_test.c9 M& K5 B+ m4 k5 {7 ?
- *
/ R2 ?* e: o- b4 {2 N - * brief EDMA3 Test Application+ n+ V! T! w- T& J& q' b: u! f) c
- *
( v( L% _8 M: a1 E) P# m, w2 a& x - * This file contains EDMA3 Test code.
5 g% `5 G! N/ k) P4 t' [ - *5 U* c0 i$ D; W7 l* A8 e& ~
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
8 E6 k3 B# U( `' C5 O - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT$ n9 `( g0 p8 c! @/ H7 y9 G
- * TO CHANGE.
' y& H* J. a6 A3 f* E; o9 | - *
; O: a6 |+ X% X6 z2 i9 q( y! H8 n- K - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 q1 r$ I& ^: M5 J c; H - *3 U( J2 s2 F* K' `7 `: w _* g0 @2 R. j
- * This program is free software; you can redistribute it and/or+ W3 S5 m0 _+ d$ W3 }
- * modify it under the terms of the GNU General Public License as
& p+ f# H+ v! [; q' L/ C+ ] - * published by the Free Software Foundation version 2.7 ^& e" j5 M4 p, Y
- *) u+ l) Z- h* T" U+ \' `- e" T& V
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any- P0 m1 D! t! P. g
- * kind, whether express or implied; without even the implied warranty! Q" d8 Z( {5 M& p! T. }# ^, I
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4 I. O& x3 \* T! x - * GNU General Public License for more details.: y# q# h: V6 ~5 o) S+ T2 P
- */
3 @- m; X; V; X6 A% p" ?4 ]
. F+ m' Q- R8 v% A4 |( |( f- #include <linux/module.h>
4 k6 e @& r% m. V - #include <linux/init.h>! @7 [3 v/ I0 D3 n
- #include <linux/errno.h>
1 i1 I6 b8 T& U% T* z5 V3 j - #include <linux/types.h>: w1 y3 l0 p! O: f- h; s
- #include <linux/interrupt.h>; i, Q8 H* X, k
- #include <asm/io.h>; K6 ?$ W* ]: s* T
- #include <linux/moduleparam.h>) b. M8 y. W3 _) J8 y/ l
- #include <linux/sysctl.h>
?9 v% d' {! w3 L7 H/ y - #include <linux/mm.h>
) i# c4 e! g7 v) m* _, n2 t - #include <linux/dma-mapping.h>& o* u7 k4 N- U4 g) T/ C& {
3 V1 {4 H- [2 y/ |; ]; d/ N% \- #include <mach/memory.h>
/ f# x% g' ?: B. e/ S; L: Y6 ^ - #include <mach/hardware.h>
9 N9 n6 |1 [+ G6 o& I6 g - #include <mach/irqs.h>) }2 j+ C6 n2 i& b! z3 H: j5 K2 q
- #include <asm/hardware/edma.h>
: P, ]' `* p% K6 ]
. [& m% S4 @7 w( c* z- r- #undef EDMA3_DEBUG# }" A( P: E: K4 F o( @1 I
- /*#define EDMA3_DEBUG*/
, z- X( L+ t5 Y8 k& h. X- W
2 w' ^4 W. c' R9 ^3 |- #ifdef EDMA3_DEBUG& R& z3 j4 E# ^4 _5 V- v5 p
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)+ D9 W" d+ j! Q) u+ X& e$ O4 F5 U
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
: ?" Y% _9 B% ~ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)5 D$ k. y# V1 {2 ?
- #else
! i2 J' r0 c& s# X; i- n0 ?' A - #define DMA_PRINTK( x... ); a q: R: h: f8 o. O9 x# D# X) E
- #define DMA_FN_IN3 q( T) I/ Q/ N5 ?# c& d' K
- #define DMA_FN_OUT
5 O0 Z" K# u- G, d9 V% n - #endif7 R: T% m) |0 j8 J- r8 i/ E. `7 R6 C
- b: F- O$ Q6 [( V7 K
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
% F/ Q. g. Z9 N* n6 D2 \ - #define STATIC_SHIFT 36 Y2 A/ B; }" [9 T- a' f
- #define TCINTEN_SHIFT 20+ C4 [- f; U$ d7 O4 o7 h' w
- #define ITCINTEN_SHIFT 21
1 x3 q" L- c2 T6 [; G3 A - #define TCCHEN_SHIFT 224 _& v. f' }: n8 ]4 N7 m
- #define ITCCHEN_SHIFT 23
9 Z9 i/ K8 o- @9 y
* {: Q+ e* w L& E! j/ b8 B @- static volatile int irqraised1 = 0;
; F; q5 U0 X& f' i& @1 r' D - static volatile int irqraised2 = 0;2 o' m- f$ X) }- O
8 t% x9 [. }6 i- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 e! `, T, l6 L, Z% u* h - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- N6 {! ^3 x( Z - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 {9 g# V6 Q% ?8 g% g' s
8 x) X% r% m7 R, F( N- dma_addr_t dmaphyssrc1 = 0;
4 h6 F6 _, ~# {" w3 }7 g2 I0 j, @ - dma_addr_t dmaphyssrc2 = 0;' j+ R: m2 |" E5 N8 H4 m* \; `
- dma_addr_t dmaphysdest1 = 0;
J0 A+ z- L7 Y# \: J8 G - dma_addr_t dmaphysdest2 = 0;9 o" ~ k: X8 r
: R" i A a5 }7 v; q& V5 R- char *dmabufsrc1 = NULL;* E. [" X3 `# F3 L7 A
- char *dmabufsrc2 = NULL;) Y! ~9 C4 c( @7 _" E! K: w% v5 a
- char *dmabufdest1 = NULL;
6 k2 {! |( d8 [- |! F) ?/ ?2 p1 y m - char *dmabufdest2 = NULL;* }. @* c2 N- p( S/ J; d
- 4 L' G/ u! N8 c
- static int acnt = 512;) |7 Y% y' Z2 m2 f/ b5 y4 S& d" ]
- static int bcnt = 8;7 G! P; t! Y8 W, b2 U' K
- static int ccnt = 8;* n' G8 e2 { X& V
y) O& f% Q- o+ _- module_param(acnt, int, S_IRUGO);5 P: q' k" J& S% F0 V0 W o
- module_param(bcnt, int, S_IRUGO);0 b$ s/ x: U3 F* |: z: P7 \
- module_param(ccnt, int, S_IRUGO);
复制代码 - Q4 ^) w- H; R4 u5 q& i
2 z2 J- _) U2 {# ]' Q
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
7 Y; h" H& t2 }% i: narm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
' B" d0 a5 p( y/ b' M+ z# W 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。 }' d l# |# y' W' {! c6 c
0 h' W3 a# Q) ?" r3 C' C
* ]% v- c2 k6 c) U0 Y5 T) O1 ` |
|