|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 O7 U6 N7 E& t% Z# f4 s, G- [code]EDMA sample test application
7 j/ }1 s; K8 H, X8 c - /*
8 n) U+ q; k* A# v6 z1 ]! f - * edma_test.c: l) j: x# r4 S9 Q! Z
- *! S1 x8 ?; S9 C9 g1 t1 O4 y& G
- * brief EDMA3 Test Application
/ ]% E- v4 t; D9 B1 j6 [# D - *
) r. W: W2 A8 _2 Q# ` - * This file contains EDMA3 Test code.1 D$ Q, l8 L, G- |5 Z2 F$ X, S
- *
5 Y5 V5 w5 C+ D, Z+ B7 d - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE4 y6 X" f; ]2 y& A. |3 y7 I5 h& q0 ^
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
+ L& T/ H5 J% S* q$ n - * TO CHANGE.
8 Y l @/ F. | S1 {2 [" \4 G" V - *& { d `; v6 V5 g! r" r
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 a9 x2 g1 Q, ]1 \# r - *3 X6 _3 n- |7 }. B l, T; k3 |
- * This program is free software; you can redistribute it and/or
2 t8 c9 c, D/ Q$ v% S& o6 p9 `+ I9 z - * modify it under the terms of the GNU General Public License as
" o/ _; P; Y( v3 G - * published by the Free Software Foundation version 2.
: C. r4 b0 D7 Z - *
! B' w' g( t X- m: t4 l' c - * This program is distributed "as is" WITHOUT ANY WARRANTY of any) J1 [9 |# B: `0 S
- * kind, whether express or implied; without even the implied warranty2 B2 p; `# F# P9 Z
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the6 I9 K8 g! y2 I: ` P
- * GNU General Public License for more details.4 z/ Z: w9 R( H" E
- */
+ N0 l& D/ O( w$ @# a* d" ^
7 a q: X) Q5 _9 A& R ~- #include <linux/module.h>% G% n' ?3 P$ y& ^6 i- @9 x
- #include <linux/init.h>
5 S5 k: b# E1 o! ^9 g, `4 Q8 P; A - #include <linux/errno.h>
% h$ }4 D- }' k, O n - #include <linux/types.h>5 {6 Y6 X2 H) H) ]: R! f' O
- #include <linux/interrupt.h>, Q4 F8 q9 i& P
- #include <asm/io.h>3 F, w8 f, z! _+ i7 I
- #include <linux/moduleparam.h>! T' n, n# ]* _4 o4 c
- #include <linux/sysctl.h>
% I; ?; U0 U: q9 { L( Y( d - #include <linux/mm.h>
6 L, T) w* w. ^ - #include <linux/dma-mapping.h>% N1 K7 |9 Y$ D% ?' I& @$ O0 n+ p7 [8 \1 x
5 ^+ a- B$ |2 X" g( k- #include <mach/memory.h>
9 v- O: P/ m9 {# z - #include <mach/hardware.h>2 ?8 A! K2 ?' Y' g
- #include <mach/irqs.h>( U' @7 Q! y7 D2 z8 r0 x4 v
- #include <asm/hardware/edma.h>
9 v+ i0 D; I! B0 m3 S& w! G
6 l) K% _3 I" @& D- #undef EDMA3_DEBUG
5 Q; n) i6 F B% }$ {$ n5 ` - /*#define EDMA3_DEBUG*/3 K V, ?2 G1 l9 ?
- 9 N6 q8 R+ z# P/ Y( M, P \2 A! q
- #ifdef EDMA3_DEBUG- a6 }0 G) U4 p: T
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
4 t: N1 F: t4 ^2 H. \ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__) B2 Y9 c+ o5 Q) W
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
, K3 @* w( G7 {# Z - #else
! X! T( H8 Y: q* E5 L - #define DMA_PRINTK( x... )' X8 X, _, c) X) L0 R
- #define DMA_FN_IN
N# Z( Z' [7 ~% _' E. i" _ - #define DMA_FN_OUT( K9 y7 W3 z8 s; ]5 J" ]+ p$ g
- #endif
7 f: U2 z, L5 f* j" V
7 _: Z4 i8 X1 L- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- k* g) }& m; K! e! O4 L - #define STATIC_SHIFT 3
( R6 q7 z) l& a+ U& ]5 B - #define TCINTEN_SHIFT 202 [1 L" P4 R7 v7 H
- #define ITCINTEN_SHIFT 213 j: G1 C! h5 D, {: p$ u v- i
- #define TCCHEN_SHIFT 22
$ e% b7 H4 g. L# u9 ]2 b - #define ITCCHEN_SHIFT 23& |# D8 `5 D' F; j; |' R
8 C$ c# ]: ^! @3 d8 S- w- static volatile int irqraised1 = 0;; W: w6 f9 R+ n0 a" v0 T8 u7 X
- static volatile int irqraised2 = 0;
Y( P7 p- ?- Y0 ]- L4 h: m$ z
- @" b" f6 H% B1 u3 Q/ f- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 d1 j2 Y! c- z% p+ \
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 L& ~6 A8 h8 @1 w0 Y' Z - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ m* ?( K) r2 [! o
3 V ?& y, L, {# d- dma_addr_t dmaphyssrc1 = 0;
7 p/ R# A5 w. `- S: Q9 U - dma_addr_t dmaphyssrc2 = 0; K! m- _* l7 N% R6 K
- dma_addr_t dmaphysdest1 = 0;8 ?0 }4 W2 F9 I/ y4 t& h
- dma_addr_t dmaphysdest2 = 0;4 L2 J: `. M' u% H; ^
$ ^, Z$ j2 D8 r+ t3 O1 I/ N- char *dmabufsrc1 = NULL;: J7 L* p0 ?( m/ K
- char *dmabufsrc2 = NULL;
& H' l* }/ |- x+ ~6 k - char *dmabufdest1 = NULL;; _ L) ~, p. l
- char *dmabufdest2 = NULL;
) F: v. `2 q" l! v2 \9 u3 L - - d7 `3 l/ w5 H' U5 H
- static int acnt = 512;
$ T. j% ^' A8 @- Y* C+ j$ h - static int bcnt = 8;) @6 Q% p0 t* b6 k. ?6 c$ L
- static int ccnt = 8;
0 ~; h5 Q) W- ?5 N - 6 A8 z4 d8 j) c
- module_param(acnt, int, S_IRUGO);$ P9 F& i1 U7 T9 D% E3 G
- module_param(bcnt, int, S_IRUGO);3 j$ e q$ q. f6 }: |
- module_param(ccnt, int, S_IRUGO);
复制代码
2 N9 M3 Z. ?! }& k: F( Q& X% ~6 U9 O" C1 P9 t
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用) p; V9 N2 Q/ Y0 ~- v, s% b$ |% 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 i3 p; X3 w$ K9 u
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% O$ W& g& t7 Y& a/ ^% m8 }& D7 a9 ?) P! G; e% ~! P% ?( e7 R/ f
* c* L8 v* G6 T% H& [! W |
|