|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 Y( `, Y2 t8 v) U- [code]EDMA sample test application
1 H8 J B; ]4 [- L; o - /*6 W. T- U& M8 L. e3 y
- * edma_test.c
) D+ p2 A& x, |; Z: Q; k - *
I, I! e% j% K' d# R6 B8 K1 k) r) M - * brief EDMA3 Test Application2 m3 K0 `, ^ @7 R+ h% b
- *
- q. W% `1 g: S0 P* q - * This file contains EDMA3 Test code.) V6 ^. l9 ]& @* r+ z
- *
1 O( R& v% K; ^% y7 W - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE- l: u }0 K8 p6 O8 j
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT+ ^' ?, U$ z, D [) z* P
- * TO CHANGE.6 l F- ~$ P5 H! ?; j, g
- *
s* E5 ~0 I. b1 j - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/: ]9 O a! a& o9 N
- *
: i8 H, Z6 a) O9 b - * This program is free software; you can redistribute it and/or
* f9 B, w9 H6 ^$ G+ l* X5 T - * modify it under the terms of the GNU General Public License as
( |# |# ~8 Y: S- ?+ Q - * published by the Free Software Foundation version 2.4 `- q+ D) v g3 u u+ I
- */ @7 W5 {6 S5 P1 E6 d! c+ r
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; h/ m9 |0 `$ S# F - * kind, whether express or implied; without even the implied warranty. ]2 M- |7 J* q
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the; G+ w ?" s7 A5 x
- * GNU General Public License for more details.
5 J% w- `% A" R3 f - */
. R6 R+ J- T4 w* Y
2 u0 k# q7 k* g1 K- #include <linux/module.h>2 g' I- D. [- q$ r: y( Y- x* E
- #include <linux/init.h>8 p5 q1 p) z; z( u! f. G% x7 }3 m
- #include <linux/errno.h>
! D* A* p$ M# z! v4 H0 |* }: l - #include <linux/types.h>
3 I" J. u5 H3 O - #include <linux/interrupt.h>
' C$ }/ N- v Z( n, i0 F - #include <asm/io.h>* a: V' R. S5 C7 F, d3 |) C! o, f
- #include <linux/moduleparam.h>
3 A" D _* q0 ] - #include <linux/sysctl.h>
3 y! j" z. K+ \) f4 X! _ - #include <linux/mm.h>
1 X1 d# m4 ^, | - #include <linux/dma-mapping.h>
3 _- {, K% v1 f
1 n; k7 M0 t, H* u- v0 l( S; Y- #include <mach/memory.h>
, l- |( l3 }3 i j/ T - #include <mach/hardware.h>3 w$ Y8 o3 i, s# F
- #include <mach/irqs.h>
4 c" y% H& M3 Y6 ?/ J6 r+ V - #include <asm/hardware/edma.h>' w( z9 @4 B& s: y f% I: r
# A: Z6 r# s0 I ^: ` d- #undef EDMA3_DEBUG
8 b2 H, R7 N$ y# o - /*#define EDMA3_DEBUG*/
8 k. ~9 t& F8 Q/ D2 q; W* @, u - ( L" Z; ]6 B, W( N( e2 p; a& F5 ]
- #ifdef EDMA3_DEBUG
/ ?. {0 ]3 g4 m2 J1 \- f" \! S' K - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
, |% B6 P$ l+ o$ q1 K& P' e/ Y0 A - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
3 ]! p5 D9 q; K' W; A U6 Q& e' l - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* B! b# T! |) I% ` Z0 J
- #else; o3 g% P' ~8 q# h# q9 A0 K$ \) O, C
- #define DMA_PRINTK( x... )
+ J, P+ S7 ]7 d - #define DMA_FN_IN% p: `5 k8 k1 z1 ~' E9 m
- #define DMA_FN_OUT
' g; R. _2 k' G+ v+ m# F4 E2 { - #endif+ n. X0 W$ F1 H" { Q
- ' B8 v% j; [5 s7 `- ^) }* ]
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)( \/ b+ ]% p2 L5 E% d* o
- #define STATIC_SHIFT 3) T; }# K5 m5 S R. I
- #define TCINTEN_SHIFT 206 t3 j" z4 W: M. k+ r/ p
- #define ITCINTEN_SHIFT 21
1 S- P1 A3 z' _5 z7 I# } - #define TCCHEN_SHIFT 225 A# S' b. z8 T
- #define ITCCHEN_SHIFT 23
6 y; x( F% E. f2 o8 c1 Y Y, q' ~/ M
4 O7 E# I7 ?' u. m/ n- static volatile int irqraised1 = 0;) E4 d/ n& ^1 N" O
- static volatile int irqraised2 = 0;
$ s. F2 u, @5 x% _$ R+ i5 Q
2 e; p# _/ m0 t5 I2 n- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% _) t q9 z" d) C - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 w& M) J8 C. y1 B) L7 ~: A
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; Z/ g: ?! ^5 t% H - ; ?+ y x/ a! L' a
- dma_addr_t dmaphyssrc1 = 0;
6 s" o" \# Y, d6 {; O6 V; f& O - dma_addr_t dmaphyssrc2 = 0;$ `: Y# C( ~; R$ S) Z# `
- dma_addr_t dmaphysdest1 = 0;1 m6 |/ r9 Y! B% n
- dma_addr_t dmaphysdest2 = 0;. Z, g3 n% ^& @3 r4 g9 R) [1 z
4 i9 O- o* e0 ` k- char *dmabufsrc1 = NULL;( x* [8 U, m9 p- ?/ x1 A
- char *dmabufsrc2 = NULL;
% S7 M$ U2 x* w8 G E3 l' X8 B5 j7 P - char *dmabufdest1 = NULL;
5 V- _5 q9 t9 r& N - char *dmabufdest2 = NULL;
, P7 I% }, f2 a& u: b) r" g
5 _3 ^$ l* Z; S e) c( J9 b- static int acnt = 512;, B- x# W3 I/ A& J) R0 N' V
- static int bcnt = 8;
6 q& D/ y# |3 q' t* T - static int ccnt = 8;
0 v6 O& w9 g) j/ O/ G1 T - & ~0 C2 a. i3 c3 `
- module_param(acnt, int, S_IRUGO);
3 h" z2 N( w, r0 \" ~# U - module_param(bcnt, int, S_IRUGO);) }% v7 b) j1 o: Z' T8 H" R( N
- module_param(ccnt, int, S_IRUGO);
复制代码 9 O2 e8 `3 z# p* s, z
9 d" ]- X: ^" c1 V3 F7 E* k 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用9 i/ x6 _0 y2 s
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。1 w4 i! v+ E: u8 T, G
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
5 y# t' ?2 ~+ ~- l% s7 _, l7 A$ t: r3 M$ y4 Q, D( k
" e5 w3 Y# [) H
|
|