|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
- o1 V! m. ]# N E8 ~- [code]EDMA sample test application
, W. `( v! x% U3 ?+ [ - /*
3 R+ X- |$ M1 L1 M - * edma_test.c
! m$ ^8 J5 S# V8 Z7 w2 E - *
/ r: ]* Z2 W f0 D0 p - * brief EDMA3 Test Application3 g2 p$ l( U B; l; V/ R
- *) |5 L3 C3 w, F8 w4 j# E! \
- * This file contains EDMA3 Test code.6 B P+ [2 M' _
- *
" R& F3 g# V# A: O/ a b$ k - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
: J! Z x$ d X, j/ U4 A - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT r% L2 b! k' w! s" z: R5 Y. O
- * TO CHANGE.7 T) h% e3 i. o }
- *( B' I1 R! F3 ?9 n
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com// ^. h: X9 x- r" q7 e w' d
- *7 U2 ? a- `# L1 Q( x! `& W
- * This program is free software; you can redistribute it and/or
6 H3 r0 d& _: D% ?* l/ }9 f8 O - * modify it under the terms of the GNU General Public License as' ]+ U: H. ^2 E, l
- * published by the Free Software Foundation version 2.
$ W) T, \% h. X: K) ^% s4 P - */ Q |1 T! w) r6 Y. S* u. W
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any3 A' _+ T) U' w) j% O) e
- * kind, whether express or implied; without even the implied warranty& D0 S" g9 O1 U7 c' W
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ y) Y. l6 P. j2 C2 W - * GNU General Public License for more details.: f, x% H0 Y/ M) r9 r/ j5 w
- */
& V& l$ a! L, u* U. J! M - & N: Q' E- r4 _* [# ~- g2 A3 Q
- #include <linux/module.h>
: R2 A: N( p- m2 B k9 B - #include <linux/init.h>2 H9 k2 g3 u! d1 w5 ^, } @
- #include <linux/errno.h>2 U$ s N3 H. C0 t* _' D
- #include <linux/types.h>
+ V3 @9 e. f, n/ R& N - #include <linux/interrupt.h>! E. _' E% p! m7 L N, t6 v
- #include <asm/io.h>
8 e n& b' @4 ^: ?1 b5 m# H2 G - #include <linux/moduleparam.h>
4 {! h b2 v3 ]: v1 `, [" \ - #include <linux/sysctl.h>4 ^ d& P$ {( Q, r J' ?
- #include <linux/mm.h>& Y# n" U& t2 c3 }. x
- #include <linux/dma-mapping.h>
& |& o- y1 M$ R' ^2 e6 V
7 o- s! V1 j$ }, N& Q) C6 `7 l- #include <mach/memory.h>
, b" Y R8 T" V% o! {' t - #include <mach/hardware.h>
/ q6 ~2 l( U1 ~6 \0 `: s - #include <mach/irqs.h>' p& p+ x5 p* e1 ~3 t: [9 d. c
- #include <asm/hardware/edma.h>
& g1 I: d4 S9 [8 N. }/ m
/ o2 j5 P" ?2 D8 k5 t3 m) o+ \- #undef EDMA3_DEBUG
8 S0 a: J _5 c. E( @" s - /*#define EDMA3_DEBUG*/
4 Z2 ~0 L7 o& j( Q5 f5 z3 \! y - 8 r7 V, ^( a4 d5 g: O
- #ifdef EDMA3_DEBUG3 ]3 o. `6 P9 g+ G! A/ r
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
! {7 m% I; E3 k$ b3 g - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 O9 e% |, i9 B/ n/ i2 P& v - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
% ]* z) n. _4 Z" P- X) U - #else
3 n" f6 d q1 Z$ q9 V( U - #define DMA_PRINTK( x... )
% F4 f# [$ _5 I0 T5 l) j/ c0 y* w! R - #define DMA_FN_IN! N1 `4 A) J1 {* ^3 C Y
- #define DMA_FN_OUT
) J* R* c9 v) I4 }5 O3 u* E - #endif" S2 J! j8 a$ ?6 e2 |* Z0 G" P' Q
- ; O% [& o. i$ \( ?9 z9 f' L
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 j+ p! h7 d0 ~8 J) R V - #define STATIC_SHIFT 3
) }0 R5 l% Q# s: N - #define TCINTEN_SHIFT 20
, R0 y$ W7 g, Y8 C; J8 H# o; W - #define ITCINTEN_SHIFT 21
7 ^- X0 e5 a/ p+ n+ \ - #define TCCHEN_SHIFT 22
2 _0 n( Z( o0 ?5 G& e$ H3 q) q - #define ITCCHEN_SHIFT 23& Z7 A; p1 ]' f& T4 m
4 W2 ~( T9 m! t' S0 t/ |- static volatile int irqraised1 = 0;
( _' g! `, {7 m/ R' _ - static volatile int irqraised2 = 0;$ H3 }- d9 f1 G) V
- 2 _) W9 v# x9 p- y8 D$ `1 ~* i/ c
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. d$ `3 ^. b! O8 y d
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 p. e0 D$ i9 t) n" Q - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# f' Q+ s6 b9 W, y' c- k, w/ n
5 @1 e) n7 _0 Z+ x6 a+ i& J7 ^$ }- dma_addr_t dmaphyssrc1 = 0;
; U9 {8 U, {, P2 Y0 Q - dma_addr_t dmaphyssrc2 = 0;
, j& N8 g, X+ w# k& @9 U; y - dma_addr_t dmaphysdest1 = 0;: i5 D5 e! [ \3 m B; x
- dma_addr_t dmaphysdest2 = 0;5 w6 u# e3 S' v* x
5 |* _$ {- _+ i1 M- Y$ K: S- char *dmabufsrc1 = NULL;
6 q3 n- J; Y \! y - char *dmabufsrc2 = NULL;% O$ h* F9 o8 K& S: B- K1 t
- char *dmabufdest1 = NULL;
8 S7 w, t7 |5 P) X9 w3 Z2 V- c - char *dmabufdest2 = NULL; Q7 T' {0 y, J5 |
% e! ?% X, P! f( Q0 S1 D- static int acnt = 512;
" W, q& T" S: Z! q - static int bcnt = 8;8 o) [( t9 |1 n$ e6 x
- static int ccnt = 8;
: [, h3 W& N+ A! I/ o# I4 s0 ]: P - , E6 ~# I% B( L" C1 u$ e! j
- module_param(acnt, int, S_IRUGO);
. z0 f% Q4 A8 \ G! ] - module_param(bcnt, int, S_IRUGO);/ b0 [2 l% ]) r7 F
- module_param(ccnt, int, S_IRUGO);
复制代码 ; s/ e/ T% D4 E7 ?1 j" V- C" S% l
) j9 p# N9 h; o1 Y. L) u
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
7 e6 l! W5 _! I# D. V6 O7 X# Barm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。0 O5 C' c5 j1 x- D' R! V3 l& U
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。* [" e5 @, V9 Y: u% m0 z. K" z' Z
, P \( D2 ]9 T0 f' ^- w. M p7 W% l1 {
, ` |3 b* X; ^ E" D |
|