|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
+ Z' S3 c. G- a, e. P- [code]EDMA sample test application
! _$ X* D! X! I4 B8 ^+ u* C - /*& t; E0 J* T8 M6 r1 _- j$ G
- * edma_test.c
' w ]! t0 T6 V( E4 \6 B B! V - *; N: ? J& W2 o) E' {/ \! U: P
- * brief EDMA3 Test Application
# M% y, q" z1 i0 `/ x5 } - *
, k$ D0 a; R% P9 s7 m9 p! L& _: c - * This file contains EDMA3 Test code.9 i8 X0 C* t/ T! ^* q# c
- *$ ^1 ^2 U6 V7 `
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE3 a$ V( J7 \3 _% ^- r' @3 |! M3 x
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
& @. u/ T% t: y+ `0 q - * TO CHANGE.
) B2 ~9 Y* w! q4 {+ g3 P$ K - *. B% O, B/ N8 H1 A2 q: P# |
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 T" V, b, i6 E3 Z3 A" J3 {
- *
8 W+ J. P4 x( ?; S4 K' @ u - * This program is free software; you can redistribute it and/or
1 j% r$ |4 D. A! I, \ - * modify it under the terms of the GNU General Public License as% ?1 R$ ]3 L; w( x
- * published by the Free Software Foundation version 2.
& ]( K7 `3 m' C( H - *# ]* @- k+ V3 A0 t: j6 f w: `' Z( f
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
( j( X- M8 ?' V4 l. Y+ u7 M9 O - * kind, whether express or implied; without even the implied warranty
/ h" o3 a) d+ M - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 s" L- _1 a5 n8 u$ q R - * GNU General Public License for more details.
6 _$ f8 u. b5 a) ~! h - */" g( s; o. a6 U3 [$ y
4 K- _8 N3 n3 `; @- #include <linux/module.h>
* @5 v+ O% _' J' \! ] - #include <linux/init.h> S4 ~9 i) e. q, M& L) h* n5 {
- #include <linux/errno.h>: t. x3 H* l( |
- #include <linux/types.h>
7 X' D4 q, J: ?3 B2 S4 i8 N - #include <linux/interrupt.h>
& c" \' T- V4 ]( g4 e( A - #include <asm/io.h>3 V& L; D: v' f
- #include <linux/moduleparam.h>+ p- s3 B4 U7 @$ R w
- #include <linux/sysctl.h>
! ~; V' Z* Z4 D( [ @: o - #include <linux/mm.h>3 X1 P# ^' q, l" T: |7 L# l- k
- #include <linux/dma-mapping.h>
$ @! h D; C" }' | - ' Q6 S1 s; i+ H3 [
- #include <mach/memory.h>
; X0 L, ^) g. ]2 e* P5 K - #include <mach/hardware.h>2 q7 a$ z1 B/ |# C R" V; U
- #include <mach/irqs.h>5 ], u" g; y7 T. n0 R
- #include <asm/hardware/edma.h>
2 ^& u8 l( k; `/ A, O- h3 k' K - ( y4 V) o6 R; D6 y& @ M- Q6 G
- #undef EDMA3_DEBUG
0 S8 b& H4 z; G6 D Z3 j: |4 W - /*#define EDMA3_DEBUG*/4 _: ?7 D9 ^9 W+ W' I
- ) L7 H- ]* u9 d# w7 s& N/ C
- #ifdef EDMA3_DEBUG2 c! S6 o2 B& X8 Z
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
9 B! p0 c0 r! b& Q R/ I - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)- n* L) N- t, M( B' c
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# f: O% r2 t; E/ I6 j, ~4 Q - #else( E* N" E; l) V
- #define DMA_PRINTK( x... )" Q; t& o e1 ~9 ^0 C: C
- #define DMA_FN_IN
% ?% w3 _3 e7 g- `: H( W - #define DMA_FN_OUT* c2 d2 n% f, ^" A8 v, E3 @
- #endif' d. b7 C) ~6 H. @ S$ v1 ?: S
- 1 }9 t: d# E$ \/ A1 c
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
' n& M: Q! z, n( [' `' U - #define STATIC_SHIFT 3
% B: x& t, r& Y: R4 K" C4 m - #define TCINTEN_SHIFT 204 P2 H2 d4 m6 [( @) E! b
- #define ITCINTEN_SHIFT 217 N$ c; I/ A4 s# I0 K/ s( W7 q
- #define TCCHEN_SHIFT 22
$ ]1 P8 `3 M! `1 P - #define ITCCHEN_SHIFT 23
& ?% o8 {' _, j) e' x
& b, e4 |( t1 y4 J/ B- static volatile int irqraised1 = 0;; a! b3 G x/ [8 x# C) W q% v
- static volatile int irqraised2 = 0;7 g1 B% N7 P% Z: [- c
. ~& c. I4 z. g& `9 \9 {- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: D% ~; u0 }9 \" C) _
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 b% z5 Q, _- k% D
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: m4 w1 I2 H! g3 L" t- U/ X
5 B* s4 `2 P! P0 v0 e7 ]- I. w8 R: x- dma_addr_t dmaphyssrc1 = 0;7 s6 s" i1 V! u; n. T
- dma_addr_t dmaphyssrc2 = 0;3 {6 Y5 m+ g: V5 x/ ?( {8 u ]% g& @
- dma_addr_t dmaphysdest1 = 0;
: s, c1 K7 Y% V& O& `4 M# m - dma_addr_t dmaphysdest2 = 0;
4 o3 R+ G5 v8 ^2 h% E' r - ; q% Q9 @6 f+ O- z& \) ]# K
- char *dmabufsrc1 = NULL;
* ~1 [" ?7 n9 V8 t' T5 i - char *dmabufsrc2 = NULL;
% x3 c% R- F0 b( V9 m& y7 a - char *dmabufdest1 = NULL;
. ~; |( t' V/ X, N) ]' S- ]9 r - char *dmabufdest2 = NULL;
) c% ]5 E! ?3 b$ x, D
- i' [/ ?5 X- M$ C2 A8 I- static int acnt = 512;
2 X' K/ i" D+ m - static int bcnt = 8;
8 i4 [; d7 F7 f7 w, @ - static int ccnt = 8;
2 y% V( Y. v9 m9 H4 p - ( O: u" v9 [- \3 k7 \% v
- module_param(acnt, int, S_IRUGO);# E, a$ G4 @) Z1 ^% |4 N
- module_param(bcnt, int, S_IRUGO);
* U6 W' ]; P$ L! Q7 {% U. ` - module_param(ccnt, int, S_IRUGO);
复制代码 2 Y, S* }- W( K: L+ m7 h- N
# e" s# V! I2 ]4 @ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) z6 I, f. O1 _( y% P; t$ uarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
( ?; V, E1 u0 h 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. `- h+ i2 F* O; Z$ I! y: M( }/ V$ o
; \7 U, s8 O+ n" ], r% B% ^
0 F. J: m$ b/ Q& P9 e
|
|