|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 F* m$ m2 w% b% o- [code]EDMA sample test application
) j+ c' W$ I4 }! O' r3 B: ?+ U" S - /*
& X# R, b; w2 K( v - * edma_test.c
1 x1 n) Y i: z( G - *# L; g5 ?0 n7 ?" a" Q. a
- * brief EDMA3 Test Application
8 W6 q' g! V+ H - ** v ]) Y' t. I8 O' _ l& H* e/ n* D
- * This file contains EDMA3 Test code.
* p6 T6 Q& e* z - *
, ]9 K# E% U- \: _! k& D- q2 C7 s - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
1 Q) W5 M% b8 \ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% n* x+ H( r$ p3 e9 l3 a7 n8 Z2 G
- * TO CHANGE.0 p) U5 b- M6 i, m# f9 Z" d2 K3 ^
- *
6 V5 ]: g9 z) h8 |; a/ ^ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/4 R1 F( |5 [: E/ a
- *! E2 x b% l, i# R/ H( m6 }: Z5 ]
- * This program is free software; you can redistribute it and/or; J- M' m+ w5 `) Z4 D7 w
- * modify it under the terms of the GNU General Public License as2 d( w3 b: G) j# R3 D
- * published by the Free Software Foundation version 2.
: `: U: c% t& s! } - *7 I# c7 o% e7 x5 R: @
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
4 E' O. w% b5 Y' s - * kind, whether express or implied; without even the implied warranty* V" w" R, I: N+ L% k# @% m
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6 W7 y1 a) I% b, P' _: i, f* p - * GNU General Public License for more details.
# C+ `6 G0 {% Y+ C7 W - */
& W: F; v- e3 `
; t# e, v* q% ~ I% I- #include <linux/module.h>
1 ^7 Z; T2 h& h, e - #include <linux/init.h>2 [. O, P7 k! I9 _6 l
- #include <linux/errno.h>
+ O0 R6 X) T6 M5 |1 X2 n - #include <linux/types.h>$ I! l5 _* e9 H$ ~
- #include <linux/interrupt.h>
! ?6 Q$ B6 ]2 @: w; p& S - #include <asm/io.h>. }% M# a; K3 {+ ]% [9 u
- #include <linux/moduleparam.h>* Z& u3 p) n1 h
- #include <linux/sysctl.h>
$ {+ S6 K+ ?2 J0 h8 I - #include <linux/mm.h>
* [& e& n n+ l' b/ _6 y - #include <linux/dma-mapping.h>
( y& B7 [( W3 { [5 f5 v - 1 w' s) [! M2 \9 T
- #include <mach/memory.h>- L4 r( k& K( t: ~# l7 A1 |7 k& N) `
- #include <mach/hardware.h>
% W2 k6 z' w. G - #include <mach/irqs.h>! k' S9 ?0 @# G, f
- #include <asm/hardware/edma.h>* W: U! W& E n* A
! y! Y. H; S+ l; E* ^5 P4 i1 y- #undef EDMA3_DEBUG
# } F% n9 T& K: Y" |0 M - /*#define EDMA3_DEBUG*/
$ a t" H9 w5 _: o* h
; a4 U" n( E# {8 q+ S2 h( o- #ifdef EDMA3_DEBUG
9 a$ W; k* M9 _1 O3 L! K5 { - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)3 h; X3 E9 ~( a5 J2 |
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)) Y0 q ]- O5 X% {/ X1 K
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! `' D9 b h; n4 J
- #else
: h) X. n& h8 @% g - #define DMA_PRINTK( x... ): V5 w( a* m7 S" P3 l& F
- #define DMA_FN_IN
, i+ ]1 @7 t$ P5 j - #define DMA_FN_OUT
, h' F- h4 U9 _ - #endif
0 D: y2 H; X4 w1 N% F
' K! w" N' t; o- #define MAX_DMA_TRANSFER_IN_BYTES (32768)2 o, `+ k- x+ Y
- #define STATIC_SHIFT 3
# L1 A- P8 h% d0 r, v - #define TCINTEN_SHIFT 208 ^0 Q& e$ f. k
- #define ITCINTEN_SHIFT 213 p% q! c9 R) d
- #define TCCHEN_SHIFT 22; g) |$ o" F3 r* U
- #define ITCCHEN_SHIFT 23, ? @" j+ r! I' r0 o
- - Q3 m& U& W6 ^1 v9 a. [7 B B
- static volatile int irqraised1 = 0;
; }$ `+ C0 |% L+ ]' c8 ` - static volatile int irqraised2 = 0; D- A6 Y6 b1 h, q; i$ x: A/ L
- z0 b) E) _- k) l# {
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 W5 u) Z; s6 Z" G' [. r
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 k4 d2 K# ]% Q1 n% P - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; J# M6 e4 r- G
- ) Z. K1 c3 ~+ V9 Q+ W* }4 K1 j
- dma_addr_t dmaphyssrc1 = 0;+ |9 Y5 T0 U. F9 p* P: [5 g5 R/ M& Q
- dma_addr_t dmaphyssrc2 = 0;
8 B( \: l L/ {) I - dma_addr_t dmaphysdest1 = 0;
/ q& H. H+ F0 x - dma_addr_t dmaphysdest2 = 0;% o) {4 O& X( o- {
/ t0 Z4 @! J6 i, q& ?9 i& D! O- char *dmabufsrc1 = NULL;5 F3 [$ Y$ f- }. H
- char *dmabufsrc2 = NULL;4 ^, S* y) ^$ @9 V+ ^* P2 _5 ]
- char *dmabufdest1 = NULL;
, B/ c/ X/ Z6 o1 V/ i& d - char *dmabufdest2 = NULL;
- o$ ^5 ]- {( T
- g/ k, c5 V/ e8 b/ K" E- static int acnt = 512;
: \2 e5 H, u/ R- U - static int bcnt = 8;
3 A9 |" c. ]) b8 u1 i) y - static int ccnt = 8;0 n3 f: Z' `& z6 h5 z7 T& f) v
( L& v- q0 G- j' Z% o8 x- module_param(acnt, int, S_IRUGO);
& T% Z! P3 i# s4 ~3 g) j8 I - module_param(bcnt, int, S_IRUGO);8 ~; N3 o" E7 I7 U2 J: h! o9 ]
- module_param(ccnt, int, S_IRUGO);
复制代码
* p# n1 G4 _0 \3 z. W h/ I" X0 b3 | t' c* g; J+ ~
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ P8 C3 {. C: o/ ~; Z1 U- Aarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* C5 h3 Y4 u; F# Y3 U& ~
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
4 I; C; ~$ \. n( y! X+ G! e% N2 [4 P9 y
0 f; R" Z; `/ a* M5 E% [
|
|