|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 * q/ W# h0 f7 U* I; X. f6 y+ u7 N. R- J
- [code]EDMA sample test application
$ ]% O- t' W0 V - /*
( Y9 E1 S$ e, E - * edma_test.c5 ^! ~3 B8 u# c# B+ c7 p
- *' Z+ x2 r! r7 ^8 t7 ~
- * brief EDMA3 Test Application
{# a+ J) m6 ~& b0 `6 m- Z - *
: z. n/ ]3 `" p6 w - * This file contains EDMA3 Test code.) Z8 Z7 L. ?$ R9 e1 d6 M) r3 p$ u6 j ^- ?
- *0 x' x- R1 f* d5 e$ \7 e S: G
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE! M- s# h2 }& c Z( p
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" A- i- M! W- c - * TO CHANGE.
7 t; E/ Q+ }$ X2 ` - *
# b% r& r7 f! M$ Q- s- c0 ] - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
v7 }2 Y+ @" I+ T# N3 n - *6 N* ~# ^3 O7 R1 S! |6 n1 A5 Z
- * This program is free software; you can redistribute it and/or' @4 ]8 v6 Y" M
- * modify it under the terms of the GNU General Public License as; u. Z/ F2 t; i% X2 l
- * published by the Free Software Foundation version 2.
5 [3 l) m: C p1 V w! ]7 j# s - *
, g( o" x: \+ _; W7 s+ [- n - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
1 |3 ], Q6 t4 d0 F - * kind, whether express or implied; without even the implied warranty
3 |+ O+ w3 a2 k6 i - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ h& U- X: j' O6 i1 L
- * GNU General Public License for more details.: ^2 B. O. q1 t$ u0 F/ I
- */. p6 d8 V5 r4 d c* u
- # F: K. _4 J, a
- #include <linux/module.h>
& m# b) c& s; w& N! ?% s* q/ S - #include <linux/init.h>
/ ^' T$ T; N$ m! ]3 { - #include <linux/errno.h>
$ u- N9 q1 Q/ Q; H% n+ P6 ?$ L! @" R - #include <linux/types.h>5 r7 E4 ?. q0 u. `) U- D
- #include <linux/interrupt.h>9 M% } N) k1 j7 @/ s) {6 q
- #include <asm/io.h>
+ P1 m; v1 @2 [) r7 u6 s - #include <linux/moduleparam.h>
% }. X8 E( i/ v" P; k* O* x - #include <linux/sysctl.h>
# ~. y1 L2 x( y+ b0 | - #include <linux/mm.h>
7 J k3 t% @* ?$ D9 u - #include <linux/dma-mapping.h>, ~& }9 e7 [/ p. I9 m! G
- - d5 ?; t2 O' R8 a; O( `5 ~
- #include <mach/memory.h>
+ o$ ^6 V1 U. q6 U+ ^ - #include <mach/hardware.h>
/ |2 r0 o( I6 f8 o% b& Z% V - #include <mach/irqs.h>
: v7 K: @3 \9 x/ C - #include <asm/hardware/edma.h>6 k( Q0 D, i ~! `$ Z
- ) t5 t7 Q: P2 }" H7 X: f$ j
- #undef EDMA3_DEBUG
3 O' P" S# _$ c7 Z/ Q4 Z d - /*#define EDMA3_DEBUG*/
! y1 y6 E& n- `% P: @0 X - ' ?5 l" V! f. ~ ^: t' |
- #ifdef EDMA3_DEBUG7 v- `; |2 r3 S3 y" e
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
# I- K+ @) O+ o3 H+ A - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
0 Z6 g/ B2 b5 M/ M2 K - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) w& b5 r% ?; ?7 [3 N' Q$ Z - #else
7 w2 j3 s( O* i - #define DMA_PRINTK( x... )5 G# j- z: |% R
- #define DMA_FN_IN5 L" o: Q# L3 t O* G. S) S
- #define DMA_FN_OUT
. e* C4 S0 [# }+ V# n - #endif
: G" Z9 x C( t: E$ h/ h7 x
e" y# J: L* w- #define MAX_DMA_TRANSFER_IN_BYTES (32768). r! l: }1 E9 b9 n
- #define STATIC_SHIFT 37 @$ v) g8 @( z- D# a
- #define TCINTEN_SHIFT 207 E- W/ B8 l% ]8 I- e0 X- [1 W# e
- #define ITCINTEN_SHIFT 21# q+ c4 s2 L0 ]! H. |, x
- #define TCCHEN_SHIFT 22
/ v5 g. W& j. ?) B - #define ITCCHEN_SHIFT 230 ]) j! S6 a L, u$ J5 I+ e2 n9 B& @2 r
2 \) }0 `3 m, [* t8 h p6 y+ w) g- static volatile int irqraised1 = 0;9 R" F0 M% c+ j# n
- static volatile int irqraised2 = 0;, O6 e/ u4 N- O: J7 j
: A% w5 [6 M5 O8 F. Z& a- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); ~: S1 b# C8 a
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' |( \; v" C* W: w. e7 ?* k; l
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ K8 v. F7 ~& f3 Z: y
- $ i1 W. I: n; X; P! [) |% E
- dma_addr_t dmaphyssrc1 = 0;6 |7 }' i% D/ N
- dma_addr_t dmaphyssrc2 = 0;. }1 v, h6 e' Y( O& C
- dma_addr_t dmaphysdest1 = 0;
+ [, M) y* }" b9 x1 v# \. b$ E - dma_addr_t dmaphysdest2 = 0;
7 l s* J/ b# _ L3 Z
/ d! e" H: \% f1 M* j2 }- char *dmabufsrc1 = NULL;
% u' Z u% [# \; M - char *dmabufsrc2 = NULL;
" V) ^; [! [. P$ W; `7 H% U9 s - char *dmabufdest1 = NULL;& N) e* K3 ~& V. c, D t
- char *dmabufdest2 = NULL;
$ o ~+ A4 _. K1 H$ o - / R# l% C4 D3 Z( Y! B
- static int acnt = 512;0 A1 R( `* Z0 c
- static int bcnt = 8;
! w6 H9 m5 p) T - static int ccnt = 8;* E4 c( s$ J4 h% A
1 B& k; ^ @+ R0 D1 z5 R- module_param(acnt, int, S_IRUGO);
/ R/ m( k- y) J - module_param(bcnt, int, S_IRUGO); i, K3 J, X/ }: l/ ^
- module_param(ccnt, int, S_IRUGO);
复制代码 9 Y( |3 h1 r( I6 U% q: I9 g- O
2 }6 Z* V! r% c0 |. Y4 B/ Z
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用; Z9 A' n; C9 c+ o. C. z+ k& s" |) }
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。/ ]; C2 A; n1 h2 H6 l
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。9 W* P& m+ G' X3 a$ a+ x! t
' @; y: F0 m. f3 N
3 t5 G/ S V, x6 N+ N/ y
|
|