|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : }5 Q- O0 g2 n1 w- s
- [code]EDMA sample test application
6 ?, q! `5 U: @ - /*
; d5 b4 W6 X% O k8 x' O5 N" A - * edma_test.c
2 b' s, m8 }+ f - *) F+ S1 T$ q% M, }
- * brief EDMA3 Test Application0 u$ J, `1 c- d' ]. _
- *
7 z" X! ]+ c$ f4 v2 c* E/ _ - * This file contains EDMA3 Test code.
) }7 m) p$ @. l& W& t - *& d3 |8 ?; f* n: q
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
1 \/ q: K; }& s7 ` - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT2 s" P* ]& J. y8 t0 i9 E1 j" Y
- * TO CHANGE.
8 C8 ]1 k: s! @$ Q# P1 s - *9 y+ I( q# J9 O# v6 ^5 {4 T/ {
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
# q. q; v* q% X: ]# G+ _ - *
( F# a9 j" {9 W" q, V1 A - * This program is free software; you can redistribute it and/or& b" b$ o- `" @
- * modify it under the terms of the GNU General Public License as9 I" g7 s/ a( x1 K( P) n9 G
- * published by the Free Software Foundation version 2.. w% @1 Q1 e' w5 t4 T
- *6 X' }: y r [& |: a( F, Z
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
% C( c( z: d' s p3 Y. Y% | - * kind, whether express or implied; without even the implied warranty6 T L4 j. a; h+ d7 r
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the' Y* e2 V ]4 V$ |
- * GNU General Public License for more details.
! p* D( Q% ?6 N% I$ ^: a - */! u! {) E! C3 V+ R
- : z" {2 U/ y' p
- #include <linux/module.h>0 G5 i. k& X. ^1 A+ b1 z/ J
- #include <linux/init.h>6 h) }; \: U0 U
- #include <linux/errno.h>- _9 }3 |+ B! [: S3 @+ c
- #include <linux/types.h>
4 G4 F G i, P* L* F - #include <linux/interrupt.h>
# E1 P9 z4 F2 ^; P# d6 s% o5 a - #include <asm/io.h>
5 J0 c" y, j2 Y( N4 H - #include <linux/moduleparam.h>
4 V8 g" h' E. y! q$ p; w - #include <linux/sysctl.h>3 R. E# v9 Z- g9 r1 }
- #include <linux/mm.h>1 i, j; w/ |" w1 S
- #include <linux/dma-mapping.h>, |3 [3 f2 e7 C& B
( z# I& @! u$ n3 Q0 H. A- #include <mach/memory.h>* T: A3 ?, }, W* I/ k8 h
- #include <mach/hardware.h>- f1 j; E: {9 R
- #include <mach/irqs.h>2 O8 ]: Z4 f8 @4 g" C, n' u! V3 ~+ V
- #include <asm/hardware/edma.h>: `2 l: k4 H4 A( W- f% Y
- 6 l9 p1 M* {! I9 t$ ]
- #undef EDMA3_DEBUG
. L5 f$ z8 Y; S U4 o - /*#define EDMA3_DEBUG*/1 }4 ~- z/ n3 Z+ g# I: j% W
- & K- @ j7 l8 t- i/ s' r. l
- #ifdef EDMA3_DEBUG8 A* Q3 I5 {0 W- L7 ]7 Z
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)7 C6 |# f2 {+ c6 N- ^
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)( X% C& i( k) c' h) b; ^
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)4 B, t$ D2 J: _& \6 K
- #else, j+ ^4 c! [6 b
- #define DMA_PRINTK( x... )
. l/ |7 q! |& q - #define DMA_FN_IN8 h' V# k; @+ n/ ~
- #define DMA_FN_OUT V0 I5 U4 o: L# |: G
- #endif% o& ~+ U8 ]: ]% T/ ?
- k7 `3 t& U: q8 R' W+ {) b" f- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
H' f# E" T; B - #define STATIC_SHIFT 3
7 ~ x6 g5 \3 p - #define TCINTEN_SHIFT 20
2 y% _% y8 Y r1 m/ q; o8 h) N - #define ITCINTEN_SHIFT 21
+ K) T* J9 ^8 d7 V - #define TCCHEN_SHIFT 22* V% z- X+ S$ A* u1 \; y' l( \
- #define ITCCHEN_SHIFT 237 n4 I* o, Z; w
) _; W/ m1 L. `, [8 [- static volatile int irqraised1 = 0;$ H! N2 D( X2 w0 i ^# j& T3 N9 i
- static volatile int irqraised2 = 0;( _! O) [# I4 \; K$ _
7 U, a& M! W4 ?( X' y- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, l: B; t* G& w0 f7 ~. y: G
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 I& w& b# [$ F, [4 l
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; d, H- P8 ` [- w
8 h& ?" r0 v6 m! Q8 ^! \3 Z; |+ A4 W- dma_addr_t dmaphyssrc1 = 0;+ Z# R8 V4 ?; `" a2 l* z$ j& B
- dma_addr_t dmaphyssrc2 = 0;
) f: r0 ~9 X7 h - dma_addr_t dmaphysdest1 = 0;
$ H5 `1 M( \2 Q" ?1 Y; x& m' j- R - dma_addr_t dmaphysdest2 = 0;
1 @1 Z2 G: `; z. A- x/ \# w1 K - 7 k, E. q1 M5 E0 J3 A/ a
- char *dmabufsrc1 = NULL;# C. e( v1 ^9 p! R( U8 {3 q
- char *dmabufsrc2 = NULL;: @! P/ p2 ~/ n
- char *dmabufdest1 = NULL;( a! |. O7 h/ x/ `# h5 U4 H5 l- Y" ]1 V
- char *dmabufdest2 = NULL;
( ^# H$ H2 v& Z- A( t6 _/ E# {
0 o1 J: D, @* [ R$ g- static int acnt = 512;
' @1 A5 L- V* @: E - static int bcnt = 8;
& C9 y# d: g4 N7 j; D4 {2 I - static int ccnt = 8;
8 B, b/ c0 J1 }+ O3 k% ]
) X( J& }$ G5 D" C( w- module_param(acnt, int, S_IRUGO);5 A" a2 V; G- A' H- j" u
- module_param(bcnt, int, S_IRUGO);% ~/ ?1 U+ t- Q* Z; b1 h# H8 I
- module_param(ccnt, int, S_IRUGO);
复制代码 / b( d6 u9 c9 T
: x0 A( E2 g' _, _
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
3 w7 |( Z9 p; p# @- N3 r) ~" Iarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。- `* Z1 |6 k! C) G7 _1 T8 ^. W3 |) H
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# b% J8 L' \& K# T: p* ]1 D- d; }: `% {/ u
/ P' r- [6 U) _: b3 P" e, ~/ `& v |
|