|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! O: u* Z/ Q# g8 `- [code]EDMA sample test application, P5 n) z' f3 T' l; e) x
- /*
0 f0 ]0 X R# S) C) @% ? - * edma_test.c
6 P5 `$ z9 \ r6 E - *( b, W0 I- m9 p/ k
- * brief EDMA3 Test Application
4 i0 B1 D, y; G0 N8 d1 j6 { - *
; h% x& u9 ]: W - * This file contains EDMA3 Test code.
% e$ X) L2 ?3 K+ r5 p6 `' a - *& F) l- z$ D! W m7 H; e& j" Q& R9 R
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
3 \+ l- M) M. k5 K1 K3 U - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT& ^- J9 t! O, q
- * TO CHANGE.( ?! e- j( [0 |( \' \. \
- *
+ _# b1 B8 I, h' k$ e$ J7 W, u - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* U& C' E! M4 i - *
' M4 Y7 a2 R& Y* H6 A! `3 c4 q - * This program is free software; you can redistribute it and/or
~) }: J! R" l `2 k0 [ - * modify it under the terms of the GNU General Public License as
# Z$ c, X, {4 n0 t- m G - * published by the Free Software Foundation version 2.
8 \% \& K/ S5 O% i9 w - */ ^+ j- r7 f5 m: C" O1 r1 V0 P
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any) z0 O; o% ~ Q$ W5 X: T9 T
- * kind, whether express or implied; without even the implied warranty: J9 e( d7 m0 e0 I* H
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3 ]* ~' j. [# Y - * GNU General Public License for more details.
s$ m- L- y' \& H" Q - */& p: q2 d6 } m$ ]) I" h! M
- 6 r* T: X- u9 ]1 k
- #include <linux/module.h>
7 h, @2 m) O. D9 s5 x+ K0 S" b - #include <linux/init.h>
" u. Z8 @: g# h5 M9 Z+ a - #include <linux/errno.h>
9 T" p( [! o7 @ - #include <linux/types.h>( ?3 t9 i, H3 G a, Z# B+ b
- #include <linux/interrupt.h>
# L: a; ]# L1 G/ Z9 H - #include <asm/io.h>
4 P2 o8 v9 C4 g% d. E5 H: s - #include <linux/moduleparam.h>9 P" R9 I$ ?; m( O$ C0 Z9 ~
- #include <linux/sysctl.h>
, c7 c3 v! m# M! P$ z0 Y - #include <linux/mm.h>
9 P& ]# n. ^# y+ l3 A) T - #include <linux/dma-mapping.h> U! _/ C* B4 t, b: E
- & F. a# U$ b3 ?) R* k! W
- #include <mach/memory.h>
& A4 Z' k$ k/ N, M5 X1 @ - #include <mach/hardware.h>
3 k; J$ u; ?5 ^5 \- q& {+ Z x, I4 | - #include <mach/irqs.h>, n4 ^( \- X, ~# ^1 W
- #include <asm/hardware/edma.h>
# O, v N5 ? L# `5 m
5 P6 V3 E9 w$ V& ?- #undef EDMA3_DEBUG
- v' Y5 q" [: d: J - /*#define EDMA3_DEBUG*/
: Z1 m' ]. ?& @" M - ) t' u' c5 S' ^9 D' B, o6 Q/ z% v; a
- #ifdef EDMA3_DEBUG
% Y5 I6 E- z) h3 b* Q4 f - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
' x3 q3 U! @( a - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
9 t q6 z/ x4 \9 B - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
1 M W+ `$ s6 S - #else
- w) E9 c# y; E" F9 y0 F m - #define DMA_PRINTK( x... )1 Q% i! j' b. W5 {- L
- #define DMA_FN_IN
2 r8 M5 E' R. T" C6 R' \9 }' O - #define DMA_FN_OUT
8 @2 \! Q( V' c - #endif% H8 b! t- P! z
- 0 ~! W# [7 s* ^3 h* H: M9 B) H
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
# v; t% C. n9 k8 P - #define STATIC_SHIFT 3/ ~, g. a7 C6 C& C) ^. {0 M5 R
- #define TCINTEN_SHIFT 20
, i+ {3 ^) Z5 W `% v( F5 T8 v4 @ - #define ITCINTEN_SHIFT 21
1 F8 M; A5 S' ~3 I+ g8 z" p& Q - #define TCCHEN_SHIFT 224 p" n* M) U9 B8 y! q* c/ \5 d0 \
- #define ITCCHEN_SHIFT 23& O' [1 @3 T( k
* |' b8 e, x0 O9 A& L0 t: j- static volatile int irqraised1 = 0;
, B0 [, u1 |1 S; U - static volatile int irqraised2 = 0;
" s9 h# z7 k% i1 h
9 I8 F# u( l {0 v u- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 V. z- ]7 S) N7 f5 o
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 k4 s9 O) q* |- }+ X3 w2 k( f* } - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 ~5 b7 ?% j% F! {& C# N, d
9 B7 H F X! b! y- dma_addr_t dmaphyssrc1 = 0;
* h4 @ p- z8 r/ b n' w9 F& V - dma_addr_t dmaphyssrc2 = 0;" |1 n4 c$ z2 t2 ? Z, L" M
- dma_addr_t dmaphysdest1 = 0;6 U" e6 E: ~) J3 L; W2 s
- dma_addr_t dmaphysdest2 = 0;3 I5 w- s: F& u a1 |/ Z! }
0 n* Y1 R1 E' b3 O6 m+ Z h0 {- char *dmabufsrc1 = NULL; J9 E# j+ r! z8 V# I
- char *dmabufsrc2 = NULL;
' A9 n4 l# d% P5 D8 ]# f3 t0 |: @ - char *dmabufdest1 = NULL;
: K+ b. s5 Z' B# s9 M2 d) i, ] - char *dmabufdest2 = NULL;
2 y# J) D# U. [. z9 l - ; I( A' N9 u3 a# i; t
- static int acnt = 512;
% l# y4 I/ p5 r - static int bcnt = 8;
- G0 i3 Y1 M/ C) H, Z* P - static int ccnt = 8;
4 J( d/ @$ O8 C$ u: Y
( j5 ]% m+ v: J- module_param(acnt, int, S_IRUGO);1 V7 k- i, q/ v1 c
- module_param(bcnt, int, S_IRUGO);
/ b9 T& O9 g( H: F% y - module_param(ccnt, int, S_IRUGO);
复制代码 7 E& p8 u, ~+ W, |) l5 Z2 E+ z2 C
5 I5 b- q- K( t/ B' m, Z8 f
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
0 @7 C. a* M) 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* S% a* ^1 Q g% `( A) a
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 J1 T( W# F) z+ g; `; [, X* @' ~9 h
# H7 O+ R( ~* y" q
* y' W' i l* V9 c; |* g; q9 q |
|