|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
* p# F) U3 t9 I; R, H- [code]EDMA sample test application
0 B7 C t z. W) S - /*' ~/ b; M7 ~& `/ i3 A' w
- * edma_test.c
8 Y- {" o# y! e5 c6 z: M6 T - *
; Q" B) J9 O# z2 V; ^ f! w - * brief EDMA3 Test Application7 J p+ D1 k& K9 t- f2 e
- *) k6 x& w( u) }) D
- * This file contains EDMA3 Test code., U; J3 ]0 R" X8 g. R3 S2 I
- *' h# i. m4 D+ R9 d
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE0 J ?/ `$ n o1 r5 @9 U
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
' K2 i0 p2 A ]! x - * TO CHANGE.
1 y5 X9 Y1 d1 U( B - *# D7 Y2 ~7 ]& `' E- F, y" c, D
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- ]! u$ n" C- \( T, b9 ] - *
1 h3 n; n# V7 M9 Q E' ` - * This program is free software; you can redistribute it and/or- A8 ~& m3 ?' [. m8 ], q
- * modify it under the terms of the GNU General Public License as
/ |9 w/ P& f, Q7 y# s d( P - * published by the Free Software Foundation version 2.
. ^7 [- H6 b1 C: w3 |" s - *
, D6 w4 n: V: p& [5 o - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- o9 @" S7 W' I* u - * kind, whether express or implied; without even the implied warranty9 T3 J" `+ v2 P; |
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4 u% O9 F) M6 R7 Q' K: ^ - * GNU General Public License for more details.
, ]# R. K' w9 }( Y6 d* \/ W" K' d - */
7 J/ X2 N0 v: a; s/ P0 q) G
0 F: {+ ^ t c. {+ |- #include <linux/module.h>
j! q; ?! m- s; H5 U8 N. ?, r( S - #include <linux/init.h>
5 ` F8 G# |# @! ^4 w5 w: @8 l9 z - #include <linux/errno.h>( |+ ^9 Z& x! @& m @% L; q
- #include <linux/types.h>
2 U, h9 Q" l; W* `, t9 F2 M - #include <linux/interrupt.h>, ?6 n9 J0 {4 I( a
- #include <asm/io.h>
+ m: l; d, d3 u' W6 b9 v/ A" ?0 W k - #include <linux/moduleparam.h>7 D8 W8 r! t7 E! v( N& g+ b4 C2 H
- #include <linux/sysctl.h>; ]' Y! |$ i8 P
- #include <linux/mm.h>* T0 Z( Z# e4 ?/ S' o! K
- #include <linux/dma-mapping.h>5 `; J& i+ ]: B
& ^, g% i. T9 i) O4 V- #include <mach/memory.h>: @7 U& @6 e, s+ a( L) U
- #include <mach/hardware.h>0 Z! a3 f; w2 P# l7 X
- #include <mach/irqs.h>
/ r% { S4 p# [5 R- Q - #include <asm/hardware/edma.h>
9 W* X7 U' n& Q8 @ S& w4 v+ Z8 S - : o+ k/ }- F# p' q% X8 _
- #undef EDMA3_DEBUG, D* u4 E5 y6 y w) _ ?" _
- /*#define EDMA3_DEBUG*/
5 m, Q! `: m% a7 t- p/ U+ ]
2 A! o3 H) Y3 C- #ifdef EDMA3_DEBUG
6 k$ D, S: l8 U! k) r3 \ R - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)/ F2 V7 `' \/ F8 d [2 r1 R, t
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
4 Q. k) K0 e3 t0 J, B5 u2 w- ^$ e) ~ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! F+ d% l5 _8 n6 R1 j
- #else4 t! s$ \" r8 t! q2 t
- #define DMA_PRINTK( x... )
# d- N% e2 f8 w* b8 h f8 q4 ` - #define DMA_FN_IN
+ q0 D& i% g! V: O+ F8 ]% Y - #define DMA_FN_OUT/ R2 f+ `. q' u/ X1 K
- #endif/ l" \+ R9 }6 H! {. L4 k: H/ A
# R2 y! a; v* Z+ u/ x- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
1 w# y# m' m. S" B# A; ^* b - #define STATIC_SHIFT 3
; ?2 e2 U2 [, g8 F/ p: a - #define TCINTEN_SHIFT 202 Q# t) j+ z/ N! f* q Z1 k
- #define ITCINTEN_SHIFT 21! _0 Y2 {/ S- t
- #define TCCHEN_SHIFT 22
9 r% u0 {+ @& p. f) a7 U# v4 r - #define ITCCHEN_SHIFT 230 Z* r6 f$ a" }
- ; P& x9 R; G' {; X
- static volatile int irqraised1 = 0;
- Y. t3 h" h, I! } - static volatile int irqraised2 = 0;/ O; z5 q+ _2 p6 @5 `
- 5 }. u7 i+ P9 p$ h" `$ a
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); C! E: I# i4 {0 Z+ r# K( a
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. h, j* u$ ] N - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( [$ O; N. e+ j2 W: R# { - 8 f8 P" E2 N, E0 J- s, l' t) k
- dma_addr_t dmaphyssrc1 = 0;0 M7 |$ H; D; Z$ j, j9 n* @
- dma_addr_t dmaphyssrc2 = 0;( ^0 w7 ~, y2 U/ w, K# @, C
- dma_addr_t dmaphysdest1 = 0;3 t6 v# h6 b0 T9 p# h8 A" V' } x, X
- dma_addr_t dmaphysdest2 = 0;- y+ k- `" B" P) ^
- & p+ y$ p- a$ ], I9 w, \
- char *dmabufsrc1 = NULL;
5 W0 Y2 a# g- I; ?5 s- J - char *dmabufsrc2 = NULL;
' x1 V: q) l$ j - char *dmabufdest1 = NULL;
4 H# ?( o6 r, u+ u- Q) W; a, ~( a - char *dmabufdest2 = NULL;% A) y2 r" K1 b
2 m" _" Y( O) ]5 [9 L- static int acnt = 512;8 ]; C2 ^& N- h% m; S; I# o/ m" f
- static int bcnt = 8;$ @; l$ O- _: p6 q
- static int ccnt = 8;
, P* {' @6 ]) s( m1 f - ! y T5 p. q4 t, ]
- module_param(acnt, int, S_IRUGO);' F2 y ~3 Z& t/ u
- module_param(bcnt, int, S_IRUGO);: H4 Q; R& q! P
- module_param(ccnt, int, S_IRUGO);
复制代码
+ A; T3 l; {, B$ V5 ?" j: e$ S5 j% d; u: B/ }6 E) u6 G+ m& P" {
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
0 L6 R8 h7 n" V$ t$ X- Varm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# j2 [& N6 C" M- I
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。0 S& s! D9 B, D( i) e \2 }
2 a& L' \( S( s8 @. s
$ {3 f8 A8 ]! j( T- q" r& u |
|