|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
0 W- R1 B4 N# Q1 {- [code]EDMA sample test application. B2 W7 |3 u& D$ k' S
- /*
7 {7 X! d. ]- O, @8 D - * edma_test.c
4 c4 x1 @) h( t$ j; e - *
) g$ P; [" O( {% j P3 s - * brief EDMA3 Test Application4 ?# G: T- y- h% [* T' S9 x3 q
- *
, s- P# i9 T+ b/ m: D2 C) Z - * This file contains EDMA3 Test code.0 {0 O* _& @, K. y+ U$ B
- *8 a. e6 x" c- N! L$ W! F+ K; A
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
6 ]- Q. T8 G8 ?) n& A' D - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
, w \# K. E: W$ e4 [1 E - * TO CHANGE.
8 M5 ~+ V+ Z1 {- S6 Q - *- z/ O) O1 m" q
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
: r t% y2 D. t, h8 g6 K5 g+ F - *
/ ~. V6 F' T+ b; x6 ^$ C- ] - * This program is free software; you can redistribute it and/or
! u4 A6 z. P" T* _: p& q - * modify it under the terms of the GNU General Public License as: e- Q, G7 D3 E4 m& L9 k$ v
- * published by the Free Software Foundation version 2.( d3 \$ i& I4 b7 M2 t, ~! B" Y: u* ` h
- *
; f& I; [6 B7 A+ R3 I - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
8 v$ z# q2 N2 l7 c+ t - * kind, whether express or implied; without even the implied warranty8 _- g. G) ^* Y1 w: \0 ?. Z- @; Q7 z2 q
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 j4 {, t6 `9 V g8 c - * GNU General Public License for more details.
$ d" X- T4 @' ]) k0 y& f$ t - */+ ~% v% s6 X$ `2 r6 e) R3 R* t
- 6 g6 g9 o' w. W( R5 |
- #include <linux/module.h>) o! r" j# |4 L3 H. N4 v3 R7 _( X
- #include <linux/init.h>
( l$ q( q: c5 x" e$ L - #include <linux/errno.h>5 ~, v% I6 t3 E% I u9 [) r5 @2 K
- #include <linux/types.h>$ Y6 }, r3 J3 Z1 \7 n
- #include <linux/interrupt.h>4 _: t C4 W3 h" ?( O: k4 g
- #include <asm/io.h>
8 {" l9 c. H$ v$ a5 D3 z( [ - #include <linux/moduleparam.h>. Y+ {- b9 w& ?! J/ b. i
- #include <linux/sysctl.h>* ]: `5 a7 E* d( S4 U
- #include <linux/mm.h>2 K0 w+ ~) J. l: G# g
- #include <linux/dma-mapping.h>9 d5 _. p$ B z1 o0 j9 h
- / ~- o- V. v1 f" q
- #include <mach/memory.h>
* x4 U" g) y9 {) M% {; u - #include <mach/hardware.h>6 o& y. i; k* @( G
- #include <mach/irqs.h>
/ D, ]: h( T7 M* _ - #include <asm/hardware/edma.h>; V) l0 ]9 y1 y# L
- b! b# t; W! s& ?: ]3 r/ o, f" A
- #undef EDMA3_DEBUG
' _9 B* V& }% s6 G9 a - /*#define EDMA3_DEBUG*/. V7 h- _( Q% r1 Z9 o" J, ~. ~0 ?8 k: ^
- . w% `& s1 W8 Y/ g" Y& |! U9 e
- #ifdef EDMA3_DEBUG
8 [9 H, i; \% W6 q, c& d - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 t8 m, C; e/ j# L - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). ~' m! I' Q& r0 q o
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
5 _. b3 d( P% ? - #else
, R3 b" U1 ^+ D' g+ N! n/ A - #define DMA_PRINTK( x... )& O+ r* V5 m: T: u9 i
- #define DMA_FN_IN
3 r7 [1 D. W) Q( y! [ - #define DMA_FN_OUT
% g6 D, W6 ? K* Q7 V: m6 x8 w - #endif& ]; y. ~, c6 Y9 @& o
- 7 V; u A6 b: x; K0 z
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, e, @4 z. H3 k9 X6 T - #define STATIC_SHIFT 3
0 e3 L% {- T; z+ l. \% b+ Y3 } - #define TCINTEN_SHIFT 20$ b9 a; P5 |5 L% v5 z6 Z8 p/ O
- #define ITCINTEN_SHIFT 21) v4 s. X5 [( f" k# v d
- #define TCCHEN_SHIFT 22
! W1 N! l* c4 `' |1 D - #define ITCCHEN_SHIFT 23
$ s, e: r/ l3 K - , k) M& l% f6 v
- static volatile int irqraised1 = 0;" q H9 w( ^! |; q" O/ k' `' L
- static volatile int irqraised2 = 0;) b3 E1 N& ^% \, R( q7 X
) ?0 `( [( ~0 y! C. X( c- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 @" m. B: O% t! j% s' Y. t - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 {- u% ], s3 z9 F* P: Q) f/ ^
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 R5 y8 W2 A* y3 B R o5 G% C4 d' Y
! S4 s3 A. B3 j. w! ^! G- dma_addr_t dmaphyssrc1 = 0;- f% z) |9 `4 l9 `5 p$ D! c4 p
- dma_addr_t dmaphyssrc2 = 0;* @! S: {% s/ I9 P* z, g8 \1 ]
- dma_addr_t dmaphysdest1 = 0;
4 j% Z+ ]) C3 p9 \; F5 l9 C @ - dma_addr_t dmaphysdest2 = 0;
+ u% \* V0 `5 g0 A1 y
( e* X, j Q* Y' y3 F4 T3 l8 V- char *dmabufsrc1 = NULL;
. j0 f7 z2 e: f, x( ?2 ? - char *dmabufsrc2 = NULL;
1 O& E- M! Q- c- [8 E2 @: X - char *dmabufdest1 = NULL;
- w/ r: W1 g( h* G9 y4 A - char *dmabufdest2 = NULL;' t5 J: k3 q, ^# X6 v2 G
/ E$ b) A# \7 N; L' }6 b$ J- static int acnt = 512;
! A: E: r' F7 p' p: r - static int bcnt = 8;* u5 [+ j# X9 c' E6 E9 ^; K8 b N
- static int ccnt = 8;
. _- m4 s+ r, |, R( D% R
0 y9 Q; A- c3 ]' p5 R" _/ Y- module_param(acnt, int, S_IRUGO);
) p0 A0 D, B! E& w' Q% F- D/ E# x - module_param(bcnt, int, S_IRUGO);
6 L+ J! {$ B4 g' v- h1 \. r - module_param(ccnt, int, S_IRUGO);
复制代码
4 o# u4 D& Q; b! G- g, j5 |0 g g0 N) D7 m) O
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
% Q, ^9 ^- c+ oarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
4 K/ Z7 f; G: l3 M9 k6 { 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
& l( l2 d1 \) M9 [" d, k# [& s) l) R' X4 l- n; S4 {# V5 g
3 r/ t+ h- w) F0 r( r" W/ u- a- t |
|