|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
- h8 B6 Q1 b1 y6 c- [code]EDMA sample test application
0 A* |1 R m: S, U9 g - /*8 n& w& c, k/ N7 h7 @) @3 b9 N
- * edma_test.c
$ ?6 m" M+ h1 _* i& @1 ?0 F" V D - *% ^( T' @, s; S; i
- * brief EDMA3 Test Application$ ]- {; p* V( `) b0 P, F
- *' s' s& }8 ~" e9 C; _$ B5 ]1 s. B$ I
- * This file contains EDMA3 Test code.
& T9 A. U' a1 b3 |( ~3 l- v - *
* I t& B* Z9 c Y8 }! t. S7 r% h - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( ^( Z2 o- d# c9 l8 ^) |
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT4 G' a) _$ H0 N) q
- * TO CHANGE.
& G9 |( w% F. U4 C - *, a! Z4 G! I( z; g! K) v2 R& @
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
6 Y; s0 f4 F7 Y - *5 |# s8 m. R S( U( p* y
- * This program is free software; you can redistribute it and/or
) f5 z# K( H2 v4 o+ A - * modify it under the terms of the GNU General Public License as
/ @- Y5 v5 ]) Q6 c4 @4 e% D W - * published by the Free Software Foundation version 2.6 s" d1 v+ n& ]( f! E8 k
- *
3 {7 _& x% A6 Q" N! W - * This program is distributed "as is" WITHOUT ANY WARRANTY of any1 F' Y! ^$ N- d2 v0 [
- * kind, whether express or implied; without even the implied warranty/ m4 R0 a1 B: G0 i
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
( t# \- B% ~! i0 u7 R - * GNU General Public License for more details.) T' f7 ], l# {6 p' |
- */
9 o; [$ U6 o' i3 o - 6 [- R N8 D6 L# K y: y
- #include <linux/module.h>( z, O; \, U4 O/ Y! I- H l! f
- #include <linux/init.h>7 M2 O6 n: l8 Q; B+ O, K2 q
- #include <linux/errno.h>8 `6 k8 K1 `) M% @5 w3 O
- #include <linux/types.h>
! I9 j7 L _8 f: a - #include <linux/interrupt.h>, q8 e* b9 c, M; ]* M
- #include <asm/io.h>
7 ^% O# Y6 S9 T& P; Z8 f2 ^# U' P - #include <linux/moduleparam.h>
$ a- g+ T% I+ W& k - #include <linux/sysctl.h>5 G! O( @/ q$ ?1 y8 J
- #include <linux/mm.h>% \1 j& I- r. [3 V! l( N2 L' f' A
- #include <linux/dma-mapping.h>
2 e( e: b! F$ y+ G) A: d- G - 5 X& k& m) H6 j; O2 z% x
- #include <mach/memory.h>% ?6 N: |4 |6 G8 ~/ Y$ |" U
- #include <mach/hardware.h>! K+ u7 b* Q* M6 e& |2 D
- #include <mach/irqs.h>, _* |, @& i1 l' ]
- #include <asm/hardware/edma.h>
8 I/ W" Z: o9 y$ `
9 N0 x" x# W9 A# D4 f% d- q- #undef EDMA3_DEBUG
3 q i" T: i8 Z8 P Y$ ]; S - /*#define EDMA3_DEBUG*/& Z: @1 X2 u5 D2 c9 c8 r% i
- p9 D4 T. W" I6 ~& j" Y
- #ifdef EDMA3_DEBUG9 j0 c5 g$ t" `; `
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
1 C. s E4 o* \ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
% Z. i5 E! ?, S8 l - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__). M- T |) e, m+ {7 w/ a
- #else3 s& L6 E4 Y4 A- h) ?$ T+ x
- #define DMA_PRINTK( x... )
# J. y! Z- F: `6 L - #define DMA_FN_IN
. M6 v# ~4 i; a1 S6 @" [2 @ - #define DMA_FN_OUT( V* i$ |+ `' c) P a
- #endif
9 Y3 R+ |5 ?) ?( Q
, B6 D( f! q0 _ T$ j6 E- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- `1 ^) @* r2 V - #define STATIC_SHIFT 3& D5 M5 z- y7 m8 q
- #define TCINTEN_SHIFT 20
! R4 m1 c9 n7 ~2 n - #define ITCINTEN_SHIFT 21
' L$ ]& u, {! y' o) Y - #define TCCHEN_SHIFT 22% T& H! A9 @+ u# c+ p- W1 U0 V
- #define ITCCHEN_SHIFT 236 q6 J5 y$ M3 S, q
- & @* u7 M! c4 }' C5 Z
- static volatile int irqraised1 = 0;
9 C( i$ _3 }1 n) f! x - static volatile int irqraised2 = 0;
- D# [9 f E2 p9 a
4 V6 P+ |9 O; a- ]. A, ^- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" M: I) [+ ?# I0 ~; ]! J8 [: D - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 d& a3 k: D( ?2 u9 t* k1 }3 k4 J - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- V3 b8 ^6 S. Q3 E; X
% P7 H1 x" B( g6 E' n- dma_addr_t dmaphyssrc1 = 0;
) R- {0 ]' o9 t6 ]6 R- D2 N - dma_addr_t dmaphyssrc2 = 0;
( I' D. X: t% ~3 |* _, h0 ~7 L+ a, L - dma_addr_t dmaphysdest1 = 0;
! F* L( R4 \/ x - dma_addr_t dmaphysdest2 = 0;7 W2 V3 L4 Z e$ p' K3 J
- ! I: I% S# N1 p
- char *dmabufsrc1 = NULL;' ~; d: Y$ C: b8 L
- char *dmabufsrc2 = NULL;
5 b3 T+ Z. `, |8 d- ]5 W; Z - char *dmabufdest1 = NULL;0 I9 ]8 A0 M9 s% a$ g8 ~; V5 L
- char *dmabufdest2 = NULL;7 f; ^, q4 O+ y1 @
! E2 a! Y; \6 f5 F6 A- static int acnt = 512;
* k$ t/ c) U. }0 Q - static int bcnt = 8;
$ [" _! g' k1 F, Z, }) Q+ [3 y N - static int ccnt = 8;6 w# o# Z# K: J f; y
- 2 s: g* @! z1 q& @* Q) W( d
- module_param(acnt, int, S_IRUGO);
5 p% G+ m& A7 ]# H$ s$ a - module_param(bcnt, int, S_IRUGO);
) o8 k. l' y6 v j/ j7 h9 ^ - module_param(ccnt, int, S_IRUGO);
复制代码 n/ O0 H% D" a/ E& D
4 l6 L" s0 Y+ H( A 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
; e, K" U* t8 B# b' rarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
( `8 R6 k7 }! N8 G 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
. v- v/ @! l- K, b. ^! U
8 v( a3 S. t( E5 Y# `( n( L
: ~; g* e/ b( ^" K; g% W8 j7 [ |
|