|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 o/ d5 t2 T/ Y3 f* I- [code]EDMA sample test application
7 k! n- m5 A6 ?- J( u' a h - /*
0 U( g# k3 K! J9 P& t! ` - * edma_test.c& ^- n/ b: K$ ^/ D' J% A
- *
9 ]0 K, g- l% @* M$ U! N - * brief EDMA3 Test Application
$ j# v! _; x3 d" D( F, t: A7 X - *
9 W! z- z' k2 P0 d - * This file contains EDMA3 Test code.- `* m H5 q B2 F% }3 W
- *! q) F, \/ |- o' ?7 d( u- a5 A
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE$ y5 o; I- G3 O3 k8 `
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT, u& }8 b6 W C( o. r' r9 O
- * TO CHANGE.
% |8 \8 e' ^* H$ Q9 x6 s - *3 P$ w# E( T) C& E8 A/ F* H
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/1 U" f& s4 \& c6 _# w4 V
- *, Z" I! a( N2 A. p
- * This program is free software; you can redistribute it and/or
% T. H5 b! N6 m& w. a. d - * modify it under the terms of the GNU General Public License as1 c* ~+ X9 U% w, |
- * published by the Free Software Foundation version 2.
. Y$ `6 H1 k+ O( L5 ]! u [ - *
0 y5 A" T/ u; O0 n - * This program is distributed "as is" WITHOUT ANY WARRANTY of any& L1 k7 G5 Z) O, I1 ~8 \
- * kind, whether express or implied; without even the implied warranty( v. z' I! m$ k" i V
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' I0 T6 ?) u# m* | - * GNU General Public License for more details.1 L3 D2 i' s8 p' l* E" j
- */- ^+ b9 M# F$ ^3 `
- ' {' T- h' c! P0 S5 V* y
- #include <linux/module.h>% ?" g+ D* d/ N$ f! D) j- X# i! N
- #include <linux/init.h>& |4 J3 {0 i/ |6 r* O8 e7 O
- #include <linux/errno.h>
# d0 ^/ x v k H) ~. U - #include <linux/types.h>
- w8 I3 @5 G6 ^: z - #include <linux/interrupt.h>
9 D2 S; E3 e+ E1 i7 j4 g - #include <asm/io.h>
" v. ^5 c. m$ C) G - #include <linux/moduleparam.h>! p* A9 k' f3 t; V1 u% U
- #include <linux/sysctl.h>
b/ H X, h2 A, x% Y - #include <linux/mm.h>3 g% ~, L4 H1 Q5 W2 [& \% F
- #include <linux/dma-mapping.h>' ]- V, P/ v! [4 c: g
& n( t6 `) i- d' Q/ P# y- #include <mach/memory.h> U4 a6 |2 j5 G# q9 u) p% z
- #include <mach/hardware.h>) i- I7 s# @; |; J" |" N$ S x
- #include <mach/irqs.h>9 ~2 i7 Y! D' |' P9 q0 Z
- #include <asm/hardware/edma.h>
, m6 X$ Q5 ]0 r) o! S& K - Z$ I) r3 }' |5 y6 O
- #undef EDMA3_DEBUG
2 x; @- @7 F5 s2 v) e - /*#define EDMA3_DEBUG*/6 n4 P% p& ?( d0 L) Z- J
- h8 C2 r+ F; `, Y. ?8 K& y1 S
- #ifdef EDMA3_DEBUG b0 x! c! t$ T$ o
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS), E8 I- A5 c A
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)9 {& W1 G3 l% n9 o
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
4 M6 _- K6 B @, a$ Y - #else
t4 f( W- C+ L$ X1 Q - #define DMA_PRINTK( x... )
. R1 _% m1 Z0 G4 y/ ] - #define DMA_FN_IN
1 \- H9 Z5 I7 s' ~ - #define DMA_FN_OUT7 k4 Q6 A( w3 _/ e
- #endif
, Q, b5 b; s/ Y6 [: k
2 ~5 ^8 f5 D2 R# @% O5 ?1 m0 O$ h- t- #define MAX_DMA_TRANSFER_IN_BYTES (32768); ~0 |" m* C6 O
- #define STATIC_SHIFT 3
) Y. c) ~) p- N' G) [: I - #define TCINTEN_SHIFT 20
4 t' J) v1 W% N+ L - #define ITCINTEN_SHIFT 21
/ F: Z- L( S4 W1 Z: a4 m, L s - #define TCCHEN_SHIFT 22
9 o1 u( K# [# e! m' O6 u - #define ITCCHEN_SHIFT 23
) D) i2 u! c# U! g" T2 p
" G+ E3 B5 ^: l3 K4 O- static volatile int irqraised1 = 0;+ ~- e; f0 l5 G7 R0 ^
- static volatile int irqraised2 = 0;9 f$ M3 Y/ f) K: i4 U: G/ s; t7 N
- 2 M% \% S2 p& A2 ?" y& H
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) F( \0 o4 H# K& E5 ]- N4 U - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" P. [: m# `/ P3 w - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. U. s) Y5 E% q& ?& F
; ^8 I$ l6 R" L0 d5 j- dma_addr_t dmaphyssrc1 = 0;
8 M( q8 u+ |1 n, f - dma_addr_t dmaphyssrc2 = 0;
: l* C) P, u- j% Q% h - dma_addr_t dmaphysdest1 = 0;# V5 c& W: g" }
- dma_addr_t dmaphysdest2 = 0;
1 ~+ ~2 X1 @7 |* x1 T
+ y, ]) }" M- s! j3 ?- char *dmabufsrc1 = NULL;
$ h6 ]( |0 ^8 @5 R& x9 f+ {* V - char *dmabufsrc2 = NULL;6 E8 c- ^# L# x3 ]1 X. a
- char *dmabufdest1 = NULL;
; w3 s. Q6 A, D. \. b& B' h% `% t, K - char *dmabufdest2 = NULL;% ^! _ K, x9 m
" p7 }! S X- |7 j1 }" c5 d- static int acnt = 512;. `6 k( D& S: B$ J' _
- static int bcnt = 8;
' A' {2 R: C! U1 B1 F# w9 Y - static int ccnt = 8;
# y( B" f; |. J( B" W" ^
' ], ?/ u+ s- ?2 P- module_param(acnt, int, S_IRUGO);& b! |# b* Z* n* n
- module_param(bcnt, int, S_IRUGO);" D( `- F' o0 v& Q3 i+ Y
- module_param(ccnt, int, S_IRUGO);
复制代码
0 V6 f! \( a; M# Z
6 v$ O, Y# H! q, r2 i! M" m* x 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用) i) g7 V6 Y: p/ L7 |. l
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
" N8 G6 `5 v; e& Z$ J- d 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
7 R# d, l; [% n% X9 s3 ~7 O% }" K) s: Z) L7 }3 X c( c& i0 ^
& I3 P& h7 \3 {( c' z8 v4 o* w0 z |
|