|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
E& D* ?% Z) u. T- N, J- [code]EDMA sample test application
$ M7 B$ _9 Q+ d - /*4 B" V0 w: m* ~- A' s" e
- * edma_test.c
! z5 I8 p/ k6 g! z* w5 ^$ f( m- \ - *
' D. s! G$ P$ J* u - * brief EDMA3 Test Application8 W3 D* b3 S$ H" N
- *
; r s; P4 M8 q0 h: h- W s - * This file contains EDMA3 Test code.5 F) K$ ~8 s; X T3 @
- *
% N! Y6 R( n4 J - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
. N1 P. J5 t- \# D% n/ q - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" B) g) u$ r0 o7 r( f
- * TO CHANGE.
9 W7 s9 Z+ k1 J% _7 X - *
, S! `" I. J: _: @ I1 S8 n4 I4 g - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
$ C5 ]) M V) d# o6 s% s - *
! q; ]' _* U' K& V4 c1 F8 F8 \ - * This program is free software; you can redistribute it and/or
0 p1 Z5 U7 _4 J) r% f# G/ P2 I - * modify it under the terms of the GNU General Public License as
& Z; f5 R6 ]0 ^; \- Z0 `" Z - * published by the Free Software Foundation version 2.
9 F* P3 I# L2 [' i# | - *
; @' H3 y$ y7 U - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
' Q! C G0 y) O! t" k7 I# x - * kind, whether express or implied; without even the implied warranty1 @6 u8 @3 Q+ H3 Q3 O3 e% j, |+ I
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the; _# i$ p1 v3 e% }8 D
- * GNU General Public License for more details.( D" T0 v( M2 [# ^9 y
- */. f$ y+ r7 F, t& H0 x
- + h, M; s& e8 K" x! {; ^( c0 K
- #include <linux/module.h>" L3 o1 I* _ h1 v) `% t; ]: ~
- #include <linux/init.h>
! H- N: C+ e% f0 X - #include <linux/errno.h>
+ ]8 C) m6 o% A5 H2 J) l8 k! T - #include <linux/types.h>
0 ]: W2 f; K; h, O - #include <linux/interrupt.h>! ^ W) R1 R7 k5 k) h
- #include <asm/io.h>
/ `! v- r1 b/ B/ r h - #include <linux/moduleparam.h>/ g% J4 H+ }, c9 d% c
- #include <linux/sysctl.h>8 y9 A; }: ?7 q" d* l' U) f8 P
- #include <linux/mm.h>$ ^/ V+ o# x/ ^5 o: V( z
- #include <linux/dma-mapping.h>6 ?9 `4 r3 p, P
- ) k7 M- L) ^# I7 q3 t Q8 F
- #include <mach/memory.h>' I2 a4 {# U8 J7 p
- #include <mach/hardware.h>2 B; O. i2 U- G5 ~
- #include <mach/irqs.h>
# b) s+ p% W9 s2 f - #include <asm/hardware/edma.h>
4 ?; b& r, ~+ L C" u% J q+ x - " T- o3 p; o1 s: U4 s( A6 s- T
- #undef EDMA3_DEBUG
+ }, g5 y$ p) O5 P- B5 g - /*#define EDMA3_DEBUG*/
$ Y5 Q5 Y8 z9 v# q) b# r6 M; R
- Y" f* [& S7 g1 l2 l3 t- #ifdef EDMA3_DEBUG- k8 i" {0 [1 b8 G% _1 t
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
F# `: o# i$ h7 W' m - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)! Z% Z1 X; [2 E! ~+ a6 ~1 d
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
e: L- q3 R! w1 M8 h2 N - #else! f0 ]$ o$ |# }+ I# y. p
- #define DMA_PRINTK( x... )
* \, H7 f, G4 V! V+ U+ v1 X - #define DMA_FN_IN
) M7 [- ]" B6 ?& b - #define DMA_FN_OUT
/ v& f9 ?5 p$ l- B6 r% a - #endif8 K. @$ ]/ w9 n4 |7 p/ Y, z
- `0 M- h; C& _& A( G8 Z6 H
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ q4 w: Q3 {: U2 ]
- #define STATIC_SHIFT 34 Q% U& V& V4 c5 v5 j
- #define TCINTEN_SHIFT 20( N# t$ k0 g9 k
- #define ITCINTEN_SHIFT 215 e5 g3 v$ a5 A% m& V: m
- #define TCCHEN_SHIFT 22
4 y9 `4 j* c# z8 l - #define ITCCHEN_SHIFT 23( f: I+ g- c) u5 t
+ }" U; i; ? o2 X0 S! s, F- static volatile int irqraised1 = 0;/ X# L1 r( l3 w7 k
- static volatile int irqraised2 = 0;
$ N X8 Y& S. ] d+ d- x4 v) _
: x5 [# V0 v4 O4 t, j% w- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' u; W" k: Z6 [/ \+ t4 ~0 u8 {9 h - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) ~" m C, K# a3 V - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); `4 x) I' N# H9 E' N6 A
: N. w5 y0 R+ p5 C6 z- dma_addr_t dmaphyssrc1 = 0;! z" c; ~- |' X' X
- dma_addr_t dmaphyssrc2 = 0;) T2 I7 e! t; `# v/ S' [& D3 Z: s
- dma_addr_t dmaphysdest1 = 0;
2 _+ Z A" N# D( G - dma_addr_t dmaphysdest2 = 0;
+ n$ q6 J$ G4 N2 v: d' ^5 w5 a4 }3 V
; k/ y$ X/ F* q; K7 _* ^# P- char *dmabufsrc1 = NULL;
- O* p* i: A4 ^, ]) r - char *dmabufsrc2 = NULL;
8 V; Z, M" K% [3 j - char *dmabufdest1 = NULL;
# z6 d) D% [% m' ~ g! r* F - char *dmabufdest2 = NULL;7 T8 E/ h4 y6 Z: f& Q3 p3 X
" t& A8 \. W8 Q. X$ y- static int acnt = 512;
$ Y! I0 s4 z( @- z' F' S5 l; p - static int bcnt = 8;& A+ {) M) t# C1 }; b4 I% i- O
- static int ccnt = 8;, c( u5 D1 u2 }# ?
- 4 C! @1 e* y4 T; n
- module_param(acnt, int, S_IRUGO);; b6 s9 `$ q, b. f( N2 |
- module_param(bcnt, int, S_IRUGO);. c3 d/ A0 L" x+ o! @' z
- module_param(ccnt, int, S_IRUGO);
复制代码 8 m+ j) q, Q) K7 m: n# v; D7 g
3 {7 p0 K; n2 Y
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用! ]1 L; L4 j! h4 p6 W7 F L
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。+ }4 V* o: T; W; R
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
3 }3 i! u2 W( M3 ]# m* S, x
* L2 ^, }7 A4 [, ]8 F
2 f, \. B Z) q |
|