|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 L" ]' K* Z& ^# Z- [code]EDMA sample test application
) d9 k2 L0 ?+ T) A4 L' A - /*$ B( f: `, J9 u
- * edma_test.c4 s9 ~* f; X1 Y
- *, f" Y; X) B# w0 l
- * brief EDMA3 Test Application+ W2 C1 j6 {) I, P/ |9 U7 S
- *6 L" q- p7 ^1 E! T
- * This file contains EDMA3 Test code.
# U$ U$ j, f5 ]7 @+ j, G - *
6 X& K" n6 D& T# E% P - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- @$ ]; { `) F3 R9 x, X' h: T - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 r _! j; U- o$ ]
- * TO CHANGE.
& g; D0 {- Q( D: @2 U - *$ r9 h. E" T& S) ?4 x. M$ X3 M
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/0 z% Q, l4 ], I! |
- *
& F4 A+ d8 _: y6 w [+ K; R" Z1 ` - * This program is free software; you can redistribute it and/or
! d4 h0 }1 B3 J6 n& _1 k( b p3 q1 B - * modify it under the terms of the GNU General Public License as
0 A9 g3 V9 m$ q) ^5 X% `+ w% j0 Q - * published by the Free Software Foundation version 2.
9 Y4 u( m: N$ u8 {9 H - *
( u& G$ V) q" X7 y- N( Q - * This program is distributed "as is" WITHOUT ANY WARRANTY of any% i! z- ~" N5 X0 q( q: x9 x' Z
- * kind, whether express or implied; without even the implied warranty
$ m' E& V/ v( D% O' T - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 M, Q. M% G2 @! N
- * GNU General Public License for more details.
' U; g0 w# P& Y/ ]' _5 d1 M& m - */
. b( ?/ h$ h+ `) ]; t. y, H) F; | - / h. j* L8 _* Z2 `- @" B
- #include <linux/module.h>2 k* K4 o2 k; l* W' W; ?# O
- #include <linux/init.h>. T7 j8 u& g; s- B$ ?7 ?: s
- #include <linux/errno.h>. f4 I' e$ c0 I8 v& Z/ F7 @) N/ H6 d# p
- #include <linux/types.h>+ l5 `, Z3 z. l7 M6 P% V) ]2 m
- #include <linux/interrupt.h>
. \- A1 ]$ o. n! E - #include <asm/io.h>% M+ @# d% A9 q- P
- #include <linux/moduleparam.h>
. Q* T; T0 E4 [ - #include <linux/sysctl.h>
7 N! c! T _0 ]! R/ G! b - #include <linux/mm.h>: N0 W( k- r2 ?" L. y/ l! W* ?2 e
- #include <linux/dma-mapping.h> p3 ?' o8 m5 W, B4 I
- 1 o% ~8 i4 l! h; C
- #include <mach/memory.h>
7 X4 |3 L/ \2 {+ H - #include <mach/hardware.h>
7 U) k7 p1 T1 X- a, D - #include <mach/irqs.h>
|# |3 {6 v& H - #include <asm/hardware/edma.h>4 N: @/ |& W! O. r4 N1 Q) R3 y6 F3 D
- 7 ]' i* r/ Z; u+ Q1 y: c+ N* `
- #undef EDMA3_DEBUG
0 e9 a- D% r) W+ J0 J" n - /*#define EDMA3_DEBUG*/
0 O8 x! Y. y% a ]# _
+ w# J( P0 }! t2 w3 z- #ifdef EDMA3_DEBUG
: a b" W9 l) F( ^& G" ^ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)5 n/ e, u& o5 Y8 L
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
( ]: N8 n) Y8 V* ] - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
% Y* t, _8 J0 t2 K - #else
8 {" a/ K5 g/ M$ f( i- S% K: w- z - #define DMA_PRINTK( x... ); F5 q( ]4 V* Y& {2 X/ E
- #define DMA_FN_IN/ X. x y+ A# t# @, a2 B9 }
- #define DMA_FN_OUT
# x1 @: l8 { W0 M3 q - #endif
0 Q3 ^7 N( F% }0 D7 i9 E! x
3 k# ^. W$ X, w& X! c. {* O0 G/ {' ~- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- ^/ v* ^7 W& J3 v- [) j( S& j - #define STATIC_SHIFT 3" [4 R9 l4 J8 Q, l' H
- #define TCINTEN_SHIFT 208 }( G4 ^6 [: v: a1 y# h$ }
- #define ITCINTEN_SHIFT 218 L) L1 }7 }' ~' w8 l8 h. f) d
- #define TCCHEN_SHIFT 22
, I; d/ t u5 }6 }0 o - #define ITCCHEN_SHIFT 23
7 l6 }, | A$ q* V, O' u, {* O
. s; e% q( L# I3 @% ?4 ^* L- static volatile int irqraised1 = 0;
$ L! i" Y3 L$ D- z2 w - static volatile int irqraised2 = 0;
) V" E/ H. } ] - ( m. |" v, o- F* P& L4 n
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. o& d; n! e7 ~8 K8 g
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% V6 P3 N4 n p7 H" G, R% W
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 A6 g% C/ ^; Q9 K; Z1 E
- * W* J9 Y: G5 ~& Z7 {% Q2 k
- dma_addr_t dmaphyssrc1 = 0;
g$ m: {2 s. Q/ z - dma_addr_t dmaphyssrc2 = 0;; T9 W5 D. y( o' I9 a- k5 a4 m
- dma_addr_t dmaphysdest1 = 0;. A! K) ?) \$ k* Y2 s X M
- dma_addr_t dmaphysdest2 = 0;) O/ _& q5 Y, m3 L) ~* r
% M+ |1 z2 B6 \. B- char *dmabufsrc1 = NULL;3 T+ a b& Z' i+ F# b
- char *dmabufsrc2 = NULL;/ ?; E. H C6 K5 k- Q# s
- char *dmabufdest1 = NULL;
8 U" j+ Y+ w: j3 t! g - char *dmabufdest2 = NULL;* b+ i$ B. d8 g$ Q/ T
- 0 b5 M% s0 p Q
- static int acnt = 512;3 c- Q, ^* D, f$ T& s% @+ H) m Q% e: Z
- static int bcnt = 8;
( ~5 ?4 N5 p, [ - static int ccnt = 8;- d/ j( T8 e( m
, ]7 U _0 L L5 \- _$ ~( X- module_param(acnt, int, S_IRUGO);
) E, D h+ R1 W$ F+ r# Y W - module_param(bcnt, int, S_IRUGO);! D# ~; `. t5 x% u: |+ `1 A& m
- module_param(ccnt, int, S_IRUGO);
复制代码 - f/ I+ I* y' z1 |/ u( P& X
; l; m. L& i% B
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用# _6 h# X& B* U5 t9 q
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。( y, K" j8 C, g# X3 A
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。4 d5 {* I6 b6 [; d C- l% O
2 W+ }6 O8 R& l1 n0 T, g! Y6 \ p3 U8 x# ~3 E {! [7 [4 X7 ?
|
|