|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
* }2 X6 W: C- o* F9 Y- [code]EDMA sample test application# Z, R, q+ @4 x( l* W2 B
- /*
8 P) `4 M( C0 Z3 V - * edma_test.c
. V& T7 S4 U4 p1 ?1 g7 ? - *
/ t. Q* S2 P# C: }/ V+ T - * brief EDMA3 Test Application% E) I. @2 \6 i2 `6 @) t1 O* L! d7 b
- *
2 C, q u6 g" I& j- N" b - * This file contains EDMA3 Test code.5 X; S8 p3 e! ?( p3 g, z
- *
' O6 p: H9 R. `. ` - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE% n! N: C- t. L
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; }; ?4 @6 `7 P. D: ^
- * TO CHANGE.
: n+ Q- V3 z0 P0 Y4 V3 Z% f: x: a - *
0 v% S" F) \' b/ a - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
9 ~4 l% N0 T# z8 W6 h - *% j6 ^! R* \3 W) s9 z6 ?' ?
- * This program is free software; you can redistribute it and/or$ Q. T4 n. U# T& e `# [
- * modify it under the terms of the GNU General Public License as
) W H& Q0 X: }7 d: A - * published by the Free Software Foundation version 2.
- g5 \2 g, n- |! M2 J7 M0 f9 P - *
$ _- O2 M( E2 g' X9 d - * This program is distributed "as is" WITHOUT ANY WARRANTY of any1 N* R$ B9 D# s4 x4 A5 M! O
- * kind, whether express or implied; without even the implied warranty
) R( r& }9 E" x& W( \ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* e$ }9 _+ E* _
- * GNU General Public License for more details.1 Z. S R e# p) }2 m
- */# t5 }$ V' V) C$ h+ |7 [+ b( J) [
- 3 k6 v3 t, l! y
- #include <linux/module.h>! n; E% O( N) |! j" S7 n
- #include <linux/init.h>
4 |$ Y9 j H7 e; ? - #include <linux/errno.h>3 ?' N- c7 C5 I( z: F
- #include <linux/types.h>
4 J. y3 k0 u) o0 N - #include <linux/interrupt.h>2 j5 I2 W9 P; L1 _# `5 P/ \# M7 E% S
- #include <asm/io.h>
- S/ }0 w9 h2 @, h7 y U7 ?" x - #include <linux/moduleparam.h>& i N& Z l& z- } `' e' H
- #include <linux/sysctl.h>
: s6 x8 z% ~4 {5 B - #include <linux/mm.h>8 C5 ^& @! N5 f; C R3 ~1 H2 J4 j
- #include <linux/dma-mapping.h>7 L5 m8 q) r. y: g4 o
% B s6 j0 t+ P- #include <mach/memory.h>
1 w9 y1 R# z% y - #include <mach/hardware.h>- t. O( ?5 B) W7 ]1 z3 P0 r
- #include <mach/irqs.h>
0 K/ u& t5 k6 K/ N: D# B - #include <asm/hardware/edma.h>
$ k6 U# j8 n& ~9 R5 ]
& h) `) F+ H5 y2 M$ Z8 x- #undef EDMA3_DEBUG
. ~! h4 d v, O! w# n. n! Y - /*#define EDMA3_DEBUG*/$ r" z5 b( Q. v: v6 @
- 7 K- ^% h( q( a; s
- #ifdef EDMA3_DEBUG
3 D! R5 E% k7 o3 U7 u, N - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)& E4 x) Z/ T V9 q
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
/ ^6 Q- L n; e% ~, ]4 K - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)6 e4 a+ J, h# V) l( K7 k( F4 L, S! X
- #else
P+ W* f' A% @2 f1 b# ] - #define DMA_PRINTK( x... )3 B. z. O% d# g, r6 g4 R
- #define DMA_FN_IN/ r' K. O4 f; c! d/ M1 G) T Y) R3 o
- #define DMA_FN_OUT
* [4 c( C5 r5 ^/ v+ e8 A; G) G) p7 @' ` - #endif
- O4 b$ f1 H a( ~
+ E# d& V1 _) N4 [8 y6 O! \- #define MAX_DMA_TRANSFER_IN_BYTES (32768)& e9 v' v2 |) J9 D, T) L- N9 k6 i& D
- #define STATIC_SHIFT 3) G% Z' R+ I5 X x T
- #define TCINTEN_SHIFT 20* a, }1 D8 ^) V: P5 f
- #define ITCINTEN_SHIFT 21
' `! a' u: [+ e& e# {1 l - #define TCCHEN_SHIFT 22
1 x2 m1 L0 k6 c4 a# y# y - #define ITCCHEN_SHIFT 23# v; v7 v" G6 J! T" _; Q' x
- / D/ _5 G, [( b" j
- static volatile int irqraised1 = 0;
1 H6 O) R6 Q, Z: H0 v6 S. z - static volatile int irqraised2 = 0;! c4 g8 \5 Z% K; V- I# k+ X6 ]+ x
5 W3 g/ \% o: Z" C. ~- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 w* w' U0 k. P# {9 W! s$ |
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* q% b! L" m/ }) g. B - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- B9 g# v9 S Z2 b7 T& K5 s6 D
- @4 [; |+ c$ \ o& s) t! q- dma_addr_t dmaphyssrc1 = 0;
) Q6 Y. c2 T! Z" T - dma_addr_t dmaphyssrc2 = 0;
0 `7 Q% e! B1 o8 O f$ Q - dma_addr_t dmaphysdest1 = 0;
6 b5 U5 L- s: @/ M - dma_addr_t dmaphysdest2 = 0;) z* p) ~" K# v3 |- y: ]; @
7 |3 f5 B! I7 m7 y5 G! I- d* Q- char *dmabufsrc1 = NULL;
6 e1 y/ h6 f/ K6 X J6 p - char *dmabufsrc2 = NULL;
1 y, P D/ U5 F# b$ e - char *dmabufdest1 = NULL;- z* h+ p9 g( b3 X9 I
- char *dmabufdest2 = NULL;% T* J3 c/ W1 F+ ?9 _
, _( _: f9 z8 e& n+ j- ]- static int acnt = 512;; Y* b2 M" o! E) u
- static int bcnt = 8; C/ T% F `. Z6 P0 V. q$ G
- static int ccnt = 8;! s. V" j% }8 n- l4 X
- ) I$ k3 c; y1 [# g! `% i6 m$ @
- module_param(acnt, int, S_IRUGO);0 T$ p( _) }: R/ @
- module_param(bcnt, int, S_IRUGO);+ i. G" [' o: F% X {1 z
- module_param(ccnt, int, S_IRUGO);
复制代码
& W. T. x( e8 R. [8 A
7 ?( Y* e Z3 i: g `; x G 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用" ?' I: p, L% j
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
" L% v! F. X, f! I6 f/ f 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。! n0 ]9 ~, l; P7 g' o
( m% r( `5 k& ]' Q
4 K9 \5 @7 E- o) Y) s/ f4 Q8 s |
|