|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 6 L$ \ H& x1 B9 w
- [code]EDMA sample test application
3 B( ]9 _. F6 w# ^* C: ~( M5 u3 G - /*
$ S b) W# }3 `) m7 w9 ~ - * edma_test.c
- P8 g7 h1 r1 h3 l k* }% i/ a9 u - *
1 T0 v+ d/ I7 C# K S" ?7 Q. K - * brief EDMA3 Test Application
0 I$ L" h8 G# n9 @; B( d2 X" d# U - *
9 f* Y- }3 @% A7 w5 { r - * This file contains EDMA3 Test code.
+ u. I( c" p- n - *
: \1 E2 V4 H- I# T+ N, n - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE; i% @. h' _3 v6 y
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT( P: e5 @* G0 Z8 w4 R) f1 G
- * TO CHANGE.
4 ]% J2 m( ~6 w: ^ - *
. S7 m- z+ H5 K; j( L - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; }3 ~" J9 a3 R, q - *
) w/ c4 [; |8 g1 L$ N( N3 ~ - * This program is free software; you can redistribute it and/or
" k- G2 o. c& y5 n% M - * modify it under the terms of the GNU General Public License as& O5 z/ R7 z/ { R, d% a: K7 |
- * published by the Free Software Foundation version 2.0 @$ ?& c# F; y5 u M* A5 Q0 `& y
- *6 A) [. Z/ ^; g3 H
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
7 u3 O. j- A% q! y - * kind, whether express or implied; without even the implied warranty
# L0 W% Z% ~& K - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 B, H& k, J! Q* {% o# ^5 V - * GNU General Public License for more details.
; n7 q" `2 D' @1 F - */$ U: q: Y5 a7 C, g. f) N
- - D$ Q4 y4 }* P a/ {
- #include <linux/module.h>7 ?0 G" s: k: M' C4 @7 Z, [) E
- #include <linux/init.h>
; ]( U6 K1 g: G) A - #include <linux/errno.h>" _! s- j! E5 x' D5 ~" J' X: Y6 |
- #include <linux/types.h>
: _ s' u5 L( p) G- }* G$ Q - #include <linux/interrupt.h>; _3 g- M6 F& N ?7 r2 N, Z$ B
- #include <asm/io.h>
" s+ H: H* V4 f( b$ } - #include <linux/moduleparam.h>
6 G% T. i7 J( {# ~) A& J0 r9 E - #include <linux/sysctl.h>
& m, F* F. o( I6 G - #include <linux/mm.h>2 X" L2 C0 r7 b7 a$ F! O
- #include <linux/dma-mapping.h>8 F Z' ~' N, G5 a8 h. ]
- + P! U$ m3 H# N6 D- y" Y" j! l
- #include <mach/memory.h>9 D* B$ i! o) {# l) R
- #include <mach/hardware.h>% t N: M1 Q6 L* l- H/ t
- #include <mach/irqs.h>) @5 i/ J) X3 N$ u+ s! y" v% J& R; Q
- #include <asm/hardware/edma.h>$ G9 J {) w0 o- m5 m! r1 t5 M
r1 I$ D1 H$ v+ z x- #undef EDMA3_DEBUG1 X" B7 O- d, D0 a! E
- /*#define EDMA3_DEBUG*/
& e2 A9 a! Y3 o2 y1 r4 R
. l6 I2 r( ~* x3 t0 p" g0 x1 h- #ifdef EDMA3_DEBUG
/ a- l% o7 j3 \9 a - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)* W8 F, r5 C9 d* K* C" y
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
! a" a" t- ]: d- w - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
9 l$ o9 V4 R5 M9 E! o - #else
9 ]8 m; \" j* [! m/ p6 O; x - #define DMA_PRINTK( x... )( c2 a0 a Q% b; K3 B1 b
- #define DMA_FN_IN
( K# U7 a: e6 h6 V - #define DMA_FN_OUT
& O* Q6 N5 H7 U - #endif
4 }/ h7 q0 s% U' C7 o
, J; R$ t( ?* a. W! ]' {+ {6 _- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
/ v# ]+ t# I8 @' m% ^3 { - #define STATIC_SHIFT 3
, C* e: {4 c" v( R; p8 N. N - #define TCINTEN_SHIFT 20- |+ `+ r* e# `' v. d$ T) }" r
- #define ITCINTEN_SHIFT 21. [1 ^( m/ Y. L4 s [
- #define TCCHEN_SHIFT 226 z! ]$ g, i7 V! y/ Z b
- #define ITCCHEN_SHIFT 23
) b( A5 _% S+ a" D( N
+ H! u+ }3 g/ u2 h- static volatile int irqraised1 = 0;
# E$ d- a$ d$ e' F* | - static volatile int irqraised2 = 0;% q& O( ?# J; ~
- , y' b" f- Q2 Z( Z
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ n5 y! G, o( {" ? - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ n% x: d' g: }0 |* P2 X. ?
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 l: q8 e: I( d7 e3 Y
6 t" Q' u" O1 ]- _7 O' \# T( }- dma_addr_t dmaphyssrc1 = 0;
0 i0 T+ V* |- b - dma_addr_t dmaphyssrc2 = 0; t* U2 p" D9 j+ j/ r, g
- dma_addr_t dmaphysdest1 = 0;
/ i8 X0 A& p; _# ]6 t - dma_addr_t dmaphysdest2 = 0;
% L. k* L @3 I; `* [
: ?4 e$ X7 `5 O7 x8 _. h' @% M- char *dmabufsrc1 = NULL; U) p0 b4 Y2 \& c
- char *dmabufsrc2 = NULL;
! ]6 g% U. w B0 n( T - char *dmabufdest1 = NULL;
+ \! Q* d5 |: o' A - char *dmabufdest2 = NULL;& X8 ]# o1 M9 {+ N- k5 ]& e0 { M% o
- 8 a& p: n1 G1 h7 |4 G
- static int acnt = 512;
; H4 ^9 A, G# {# T8 m7 w - static int bcnt = 8;
5 z2 F$ X N& C - static int ccnt = 8;4 Q6 p' l3 n" o3 S* O; @6 s
- 9 L) G1 n, i2 D5 p
- module_param(acnt, int, S_IRUGO);
( o: a" P% {' ^1 K - module_param(bcnt, int, S_IRUGO);
! j% _4 X! f U# c4 G8 w4 B - module_param(ccnt, int, S_IRUGO);
复制代码 % H5 W' f' X7 ^4 f
4 P! R1 s+ r: g1 g/ A: N W, t
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用4 Q" c1 |4 H! A, ^6 D
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。) q& }& }6 Y0 G
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
/ k( V1 ?2 ?( F( b3 D& d! P. W6 p! q1 t9 i
$ I8 n: \ z" J |
|