|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) H4 m2 U# W) V4 r1 I' L3 a' |- [code]EDMA sample test application
% L6 y; P7 V7 O0 A* |) T% b& e7 [ - /*
% A* U" Y0 J. p3 H$ z - * edma_test.c
, R1 ?5 R) A" R. u - *
$ A$ f/ c) o. e7 b2 e' E8 ?; K - * brief EDMA3 Test Application/ l: L- q! ?4 Y7 }3 [3 ~- S) w
- *
# v2 ?/ r4 d. L; T, D% y3 k) d0 d. w - * This file contains EDMA3 Test code.6 y6 p% E$ Z$ D" d g1 K
- *
1 a/ E8 Z7 a4 B# k& x - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" P5 A* b: M% a) X
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT: \. V3 L" S7 T7 S) N9 z
- * TO CHANGE.8 q! ]% ^3 T* A5 w9 F
- *
1 }: t0 a$ T# h - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
2 j: T. t- L' s, U4 j; B. W5 s0 L7 w - *0 }8 X# Q1 a2 ~$ V
- * This program is free software; you can redistribute it and/or& ]$ M2 T& @: m
- * modify it under the terms of the GNU General Public License as$ O5 h* _ @. T: V1 {0 v0 ~' y- W
- * published by the Free Software Foundation version 2.% u$ ^# d; G& ?: u: G: Z
- *5 k. t. q3 D& c* C- ~1 F
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
) V) ]# H+ M; O8 Z3 f" u - * kind, whether express or implied; without even the implied warranty
+ N: l0 Q. V" C& a+ D - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the' i3 Y3 G$ g) c" t) }
- * GNU General Public License for more details.
/ Z* z' z( J$ i/ y( j5 U0 H - */
/ G- } r: r' g% ^' N
7 I, ^! O5 h# R' ]# F- #include <linux/module.h>9 G3 r E$ W2 w8 E5 E- N2 c- h* ^
- #include <linux/init.h>
8 r" @# q: G7 X) j( f- G0 _ - #include <linux/errno.h>
^8 ]$ w B- S& ^; j- p+ e0 |9 R - #include <linux/types.h>/ n+ V3 r/ T0 L& Y# N# \. B
- #include <linux/interrupt.h>
. Q3 J7 [' a% k8 r. i3 L# b) s j1 c - #include <asm/io.h>
" ?1 t t& T% e! B: o - #include <linux/moduleparam.h>
. Y% ^6 O9 |! {: Q4 S - #include <linux/sysctl.h>
% |- M1 u: ~4 p/ i - #include <linux/mm.h>$ E9 M1 l, { ?7 G: o. Q8 A
- #include <linux/dma-mapping.h>& _* z- l+ Q& P# Q* Z
2 x u+ }- S9 U( Q- v o% D# s- #include <mach/memory.h>; U- r+ s. S/ V! _2 }+ q( Y
- #include <mach/hardware.h>
6 u9 ]' U8 r2 J( @ - #include <mach/irqs.h>
" o. b( R- {8 L. E - #include <asm/hardware/edma.h>/ D L2 e$ f0 ?4 y" L+ C& |0 |; l0 P
) @( d7 {) M" |2 @6 l- #undef EDMA3_DEBUG
6 v& U9 m+ I/ p6 r; B, _ - /*#define EDMA3_DEBUG*/
6 `# s% t& o) r3 F7 [& d2 I u
! o' Y1 [* Y+ H7 w- #ifdef EDMA3_DEBUG7 ^$ x# n8 F" ^) I
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
4 D2 W! A% Q( b1 p7 z) d g - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)6 O7 g6 ^1 V( m7 O8 @
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)$ b0 e8 B7 `7 d# {$ W& Y
- #else% u( o8 Z% U# b$ o9 @) ~' x$ m
- #define DMA_PRINTK( x... )
7 u( n: n) ^' x) i& Q - #define DMA_FN_IN4 `1 s, T0 L1 J+ i: j1 o5 o
- #define DMA_FN_OUT
( f: f7 q1 `2 D: j3 n - #endif2 n/ \" u! r$ D* C
! F8 F% A" J* ^ w& e) o) c- #define MAX_DMA_TRANSFER_IN_BYTES (32768)1 d& ^5 ^* B- I- t: A
- #define STATIC_SHIFT 3/ v7 Q9 N0 v, I% C' J6 T$ j
- #define TCINTEN_SHIFT 20/ e1 ~: a4 q% U5 Y" l# B. t
- #define ITCINTEN_SHIFT 21- q% U& B7 G c
- #define TCCHEN_SHIFT 229 k. ~% _* @1 q0 f
- #define ITCCHEN_SHIFT 238 u. }/ }1 Z9 j, T9 e5 R# S7 B; z
8 \# a) [! ?$ J9 ]. o- static volatile int irqraised1 = 0;5 L# L5 `; J5 r+ P) A: A6 u
- static volatile int irqraised2 = 0;
- q) A% {, T# J/ b) [& a - 7 J, L/ o; e' [1 \3 @3 M" p& F
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ }* p! Z+ F0 a N& f# D& P' W* y
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ t. j0 X% a: [. t; S& x& j - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ [, q9 s/ b* }! e' v5 D- M - , T3 y2 e! |! d8 |0 I/ I, e
- dma_addr_t dmaphyssrc1 = 0;
" u- H' v0 b. l# } - dma_addr_t dmaphyssrc2 = 0;2 g" N. w" D$ q2 B
- dma_addr_t dmaphysdest1 = 0;
\* F) _$ F* _; A - dma_addr_t dmaphysdest2 = 0;
h5 w6 z( t+ w/ F* ]$ q ~. m: Q! H3 g
& a+ \- V$ t& a6 o6 M- char *dmabufsrc1 = NULL;
) r$ `; x# y( r; R* e' w - char *dmabufsrc2 = NULL;1 Q0 Q: v8 m- F* n7 [
- char *dmabufdest1 = NULL;/ }% b( x* r1 k0 ~$ }
- char *dmabufdest2 = NULL;2 T5 j h8 V9 N5 r/ ~4 o) g% s
1 U7 E# E- v: m7 v6 l- static int acnt = 512;
; t! X" S2 w O% B# l, @- F - static int bcnt = 8;) O) I0 ]6 s! I1 ]& K
- static int ccnt = 8;7 ]- v# A3 A# j6 r) [/ v
3 K( x. O' d6 z- module_param(acnt, int, S_IRUGO);
{, u- @ Q. y1 Z1 U$ f - module_param(bcnt, int, S_IRUGO);" O2 a: E `, L8 ~ q# b
- module_param(ccnt, int, S_IRUGO);
复制代码 X7 `: ]8 T4 `5 c$ d' g. }% z
4 K) h6 A. B+ N$ \: E
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用; C8 ^$ ^3 X2 ^* ^: D
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 I) c1 l, n2 W+ c4 L+ ^1 @4 [
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 `/ n L# C. n- R9 W
, i( `) t( ?( v$ W: t$ [
: ~2 T* M. Y3 y) ]+ T7 N |
|