|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 7 v: {; t3 U! h- r( T
- [code]EDMA sample test application
) C" ]% W- q0 V; ]0 _# S - /*
$ B& S. U* | B. P0 q7 ?- w - * edma_test.c
( o5 T/ e8 I ]4 R - *& }1 w# f X8 O0 U
- * brief EDMA3 Test Application
! B; k$ G/ r K5 }, u - *, I0 _. r& `; J% m7 C6 H* Y) Q
- * This file contains EDMA3 Test code.
4 ~% r9 G2 @) A- G9 K- j1 m( Z - *1 U% j) Y7 `4 e5 Z0 J( k# b
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE7 t R \1 q B! j2 T
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT) c. {$ A5 k+ o* F( d
- * TO CHANGE.: E9 D W$ E" O( t/ _# s
- *
- k& E7 E* {" t7 x# d# _* h - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* i' a8 Y5 G( a& X+ B# b- W - *
$ A8 M: u% T0 y" i9 [( [2 i& a" J - * This program is free software; you can redistribute it and/or1 e6 R: U1 R* S1 U7 |" f6 s
- * modify it under the terms of the GNU General Public License as. M1 Z8 t& h3 @3 H( L* G7 r0 L
- * published by the Free Software Foundation version 2.3 R, B5 t9 L/ c* N1 {
- *6 J1 f( k# C5 m. z
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any0 @- ?2 y* C* N# W$ h
- * kind, whether express or implied; without even the implied warranty* q( b; P) Q. p
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the4 c. P* K8 B* u2 V1 n8 q- w
- * GNU General Public License for more details. |% y* f [$ M7 g# ~7 R7 w* m2 [2 [
- */& V8 g0 F: ^1 r( l+ t1 I9 ~
1 P$ p, C" S0 i9 _) E- #include <linux/module.h>
( w/ N" s5 ]# Q, t% z. h) b2 o& g - #include <linux/init.h>1 W8 ~5 q2 d7 p! v
- #include <linux/errno.h>
5 y/ K& D& `4 X1 @! S- r - #include <linux/types.h>: m7 A: @" O* F" ?! j
- #include <linux/interrupt.h>( y& z9 a3 |, T1 e
- #include <asm/io.h>, I( C+ \, V* U# T# n& M; R Y
- #include <linux/moduleparam.h>
0 D- s- W6 R) G- p2 h u7 o - #include <linux/sysctl.h>
! _3 g: _% @$ i) J+ y - #include <linux/mm.h>
1 v7 w& ^0 K) u& ]) U. n - #include <linux/dma-mapping.h>
$ l' z( s+ s# X+ u X' t/ C - 7 c# M5 w" ?0 T6 u8 l7 _+ ~
- #include <mach/memory.h>, ?) _: G0 W' ?; e3 Y, x1 }
- #include <mach/hardware.h>) d* y" t# P. g- ]; i$ i/ P
- #include <mach/irqs.h>
8 [, B5 [& H2 \ O" L - #include <asm/hardware/edma.h>
: r m$ D7 p* [+ g) ?. e - ) ~* P" ^. t. m0 `
- #undef EDMA3_DEBUG
, h( A$ W, y# d; y" ] u - /*#define EDMA3_DEBUG*/
* C: t7 N5 a) k! ~% B
- z" \$ Q" H1 H) [* r6 k# g- #ifdef EDMA3_DEBUG
% G+ V8 x: V% l, u: x. ? }% h2 P. m - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)# I0 _& z% a% Z3 X5 `
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)+ O( Q9 Q% _1 P; A8 c
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
" P: x( c# N* o- H9 ]: } - #else
7 D1 A% }+ D3 Y1 }* Y - #define DMA_PRINTK( x... ); C4 l% n" ]) x5 v" k( b& w9 u1 [
- #define DMA_FN_IN( h5 f5 r& i* T0 I2 k& A/ b
- #define DMA_FN_OUT2 v; ?1 T3 I; r+ G& k. c
- #endif
" T4 d1 t8 Z4 _3 m/ T' d* E
+ A4 u6 l) }* p' w3 R* ~" t- #define MAX_DMA_TRANSFER_IN_BYTES (32768). G H$ u0 q3 m# C' D: t C
- #define STATIC_SHIFT 35 v3 o( G, G) n8 D
- #define TCINTEN_SHIFT 20* _) O+ ? k5 ?. Q6 T( ~0 `: p
- #define ITCINTEN_SHIFT 21' L! u l8 w- V6 P1 V
- #define TCCHEN_SHIFT 22; x9 d7 r3 g! o4 }% s
- #define ITCCHEN_SHIFT 23) `2 o d) [7 J$ W2 i, u' Z- f$ o
4 t- P! v( b7 V% r( o! u- static volatile int irqraised1 = 0;
4 _5 M% H4 ~3 l) A1 z - static volatile int irqraised2 = 0;: R' `7 |/ O6 Q
$ ^7 W3 ]& z9 C- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" S7 T1 g0 d8 t B% z3 i
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ S7 \9 T7 I/ Z) G4 W
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, B* W0 X7 U1 W6 a
0 Y n) B' X7 m! ~; @+ V- dma_addr_t dmaphyssrc1 = 0;' h: u. F z N( \0 N' x
- dma_addr_t dmaphyssrc2 = 0;
4 F/ [' @8 h! ^+ r - dma_addr_t dmaphysdest1 = 0;
! P' j- R2 y/ s$ T - dma_addr_t dmaphysdest2 = 0;# `5 g: t! E: Y( J g
- 1 [3 r9 @8 ^% {7 i5 Q
- char *dmabufsrc1 = NULL;
* R8 X0 k2 W5 `# X - char *dmabufsrc2 = NULL;
$ l# L' V. k) L# L# j - char *dmabufdest1 = NULL;& u4 f, V# E0 }, T' a" p
- char *dmabufdest2 = NULL;# t, T, ~! d1 h, |8 G! ?' E4 ~, p
- N/ W, P7 A/ a. ?( D- static int acnt = 512;( K# x2 l$ Z7 j2 _
- static int bcnt = 8;
4 N# S8 F" ]5 E1 T6 ~: @( ^; A4 J6 R) n - static int ccnt = 8;8 t! N! M- M! S& g/ }2 }7 P
- 7 s3 @% E/ n6 ]0 i
- module_param(acnt, int, S_IRUGO);4 C1 K# F7 A6 D* T# d0 M: F
- module_param(bcnt, int, S_IRUGO);
: B" c2 |+ G+ C/ v' ]6 H/ r( `3 x - module_param(ccnt, int, S_IRUGO);
复制代码 7 B; t* ^7 M& G
2 S8 s% P2 Z# \
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用8 ^) @8 o1 D; p1 [
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
" w+ p2 r5 C9 c2 ~7 X# I0 W 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
; V {% ?+ s% p
' |$ x* N7 b/ f
/ v8 B7 ]; Q& S ]' p: L |
|