|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
# P4 Y- M A. A/ y& w0 D C- [code]EDMA sample test application
% g; q. T. i, Z) v6 r! Z - /*
& m9 S, q( f$ ?( ^; L; T T - * edma_test.c4 B0 x* V8 h3 Y! [& M
- *
) Y: C0 p# Z, Z [2 S% J - * brief EDMA3 Test Application/ {8 w/ Z8 ~& H" \
- *- s3 s' t& d8 I9 g* ?( i _
- * This file contains EDMA3 Test code.
( V3 b% O, b! K$ I - *. D4 M* y/ s5 A" f
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE- Q1 c; I. t. N7 q: [' K
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
& N9 B: K$ X% g! C& i9 }' u8 T4 ? - * TO CHANGE.+ v, h8 q$ [- B A
- *
# W) V& m% y0 T - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
/ R) V0 X& D9 R* Z - *1 G4 g8 Q4 O# n) j
- * This program is free software; you can redistribute it and/or
5 F5 H+ |+ M# G* g& H4 y2 [2 R: \( e - * modify it under the terms of the GNU General Public License as
1 \3 B1 Y8 z; J5 ` - * published by the Free Software Foundation version 2.( L& r, C- v4 V$ w5 L
- *9 G3 T7 w( p$ a1 O* A
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- d: B, X& }9 ?( P" \9 g - * kind, whether express or implied; without even the implied warranty: i s! o" x" \% F
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% W5 M, l q+ a L6 q4 u/ [! T - * GNU General Public License for more details.
9 x, F" \5 }! G! X - */; A# N; {# P4 r9 p: m
- , h( }4 p2 {9 G9 `* r
- #include <linux/module.h>
3 l. T, o5 Q: D5 _$ i - #include <linux/init.h>( c; ?9 T! Z# V
- #include <linux/errno.h>, g6 j8 \4 x; O9 |) k) j' P
- #include <linux/types.h>2 ?0 i% b1 L0 {( J: ` E) h
- #include <linux/interrupt.h>+ d; \! N, Q9 i7 n( g# O2 \
- #include <asm/io.h>" r r4 r2 y: F
- #include <linux/moduleparam.h>: E. g2 @' v3 t
- #include <linux/sysctl.h># n3 ?- K5 N0 v. O: r! _
- #include <linux/mm.h>8 g) L* n& T( _" E6 O5 `8 `5 u
- #include <linux/dma-mapping.h># _" b9 a) Z5 X& n2 Z
. L$ y- l, s, c5 E3 e- #include <mach/memory.h>
. @3 w: R' m" W/ ] - #include <mach/hardware.h>
0 J6 L1 D1 ?" K/ _: t$ Z# R, J - #include <mach/irqs.h>4 X/ h/ k" X# n" u; g
- #include <asm/hardware/edma.h>/ A G% E" Q6 F
- / o8 I: ]" [ c8 a+ M9 ]% a
- #undef EDMA3_DEBUG! h+ S/ w8 i: z2 f' |3 @( g
- /*#define EDMA3_DEBUG*/. B! I1 _4 U$ t: w
0 \$ n/ P( g) y; H, E6 m- #ifdef EDMA3_DEBUG }* F5 |0 t1 s3 ], N, m6 Q
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; E' `3 ~0 q; K- E9 r1 f - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
- |) r7 O9 y' Z- ^3 P - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)9 N- |( S1 h' j$ b& G
- #else
2 j. Q7 S: F& H% Z1 b& Z - #define DMA_PRINTK( x... )& o0 @; ]& W6 d1 C: b/ f
- #define DMA_FN_IN* I; T5 `6 P- _% @. \9 O0 z
- #define DMA_FN_OUT
6 b0 c9 i$ L8 K' ^: I: v) g - #endif& X9 q: S& ~, N6 X+ }+ w9 L
- . n# s8 Q4 h# M2 G$ `( w
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
& n# G! C& o( e+ j* Q. J - #define STATIC_SHIFT 3# @% A$ q0 c5 G! l' N$ n
- #define TCINTEN_SHIFT 20
; V$ T, m6 S; u. ?- c% q - #define ITCINTEN_SHIFT 21
& E, n2 X6 ], U& s - #define TCCHEN_SHIFT 22
7 i; v9 O* l; y- ` - #define ITCCHEN_SHIFT 23
3 g* D* c: |+ \' u: r: N - . q) H0 D* p+ `' q. ~6 T
- static volatile int irqraised1 = 0;
/ v; j% s. P6 g: K4 ^ - static volatile int irqraised2 = 0;. H: c9 L( J# y) | l- q
% p. f" q: ~+ G7 j- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 D/ }& |, E4 u% E9 T& d
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' N& b( @: E$ w) c, e- @
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" V9 c2 e- `9 [ E3 n, d - ( ] s: C% y# G6 [8 x3 D
- dma_addr_t dmaphyssrc1 = 0;
( w1 Y' V$ X% x7 X$ D - dma_addr_t dmaphyssrc2 = 0;. `5 Y* [" f" P9 F9 e( c! A; }8 {
- dma_addr_t dmaphysdest1 = 0;
. |; a$ C1 S& h# T - dma_addr_t dmaphysdest2 = 0;
; [9 I& a) G) x# {7 t" R
6 \, m; h7 m/ P$ W% m( Y- char *dmabufsrc1 = NULL;
8 ^+ Q6 S4 F( _# T9 J3 \ - char *dmabufsrc2 = NULL;: ~3 ?- Z1 u3 P3 Y) i
- char *dmabufdest1 = NULL;1 q3 r* m3 }' s5 k9 p' a' V0 _
- char *dmabufdest2 = NULL;
3 c e8 q& F4 [7 [ - 8 j) ^$ r! O4 f4 n/ T
- static int acnt = 512;
3 q9 {( N* g) s, [+ a8 L$ r, s - static int bcnt = 8;2 T! a; W# V: O3 S F
- static int ccnt = 8;1 c: b* @3 d- g4 p5 F4 K
- 8 P5 r8 o# q8 z4 T, _4 E1 F% Z
- module_param(acnt, int, S_IRUGO);
! i/ a/ L7 E, W5 U' T& s: M1 p - module_param(bcnt, int, S_IRUGO);
, O2 W& Y; Z) H2 ^$ y - module_param(ccnt, int, S_IRUGO);
复制代码 " F, ?, b+ D0 {' I: N6 y" I. n
6 z: m, x. Z( U
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
. @" v. O8 J; Y9 u$ ^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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。5 j6 z" V% [! Y4 I* n ?
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# s7 ]4 O1 _9 E0 `! @
) F, t" T6 N- B& j" d8 ^. G! |! F* p7 S
|
|