|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% `6 P2 k- @' G0 }" f7 @8 ~4 c- [code]EDMA sample test application
0 ~$ M2 L& {3 X6 { - /*
) m% K. P* R# w) K( p5 a4 g% \ - * edma_test.c
- O5 j% x' o! p1 E - *
- p$ W# k' N" p# \ - * brief EDMA3 Test Application
: i4 `- _( f- Z. a; @% q - *8 @; p0 ^. }4 S* {, N
- * This file contains EDMA3 Test code.( F1 ^; c$ |! D1 g, K2 D% _8 T
- *
. ?( `. P# _4 }+ d* m( G - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
+ g6 m& C8 M7 D5 ^" B4 t% V - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
9 B, y* M) b, m- p7 w& V! T - * TO CHANGE./ G, i( g' Q' y5 j( W8 Y1 g( f
- *+ G& d- A$ S& E# e j
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
) S1 n* w* q. |0 k$ M - *
- L! d7 b# h7 f& Z, J - * This program is free software; you can redistribute it and/or0 Q6 w& w, h; n# S f3 Q9 L T9 [9 _1 @
- * modify it under the terms of the GNU General Public License as# a- p8 f1 F7 m# _# j7 q
- * published by the Free Software Foundation version 2.% J1 j3 B4 U' R1 L6 H
- *
% L5 B0 O/ N. b J# n - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
2 E6 o& ^& V8 c - * kind, whether express or implied; without even the implied warranty! n: Y% P" Y( M) P: j
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ g, b) `- E9 N$ n - * GNU General Public License for more details.# A5 {% a- X: N& Q
- */
( J1 d' n' J# k3 r: i8 u2 I - ; u5 o" s2 w; Y, c, _
- #include <linux/module.h>
6 `: ^4 T; K v( K6 @; q2 O - #include <linux/init.h>
( M9 u7 M, s9 |& R - #include <linux/errno.h>: Z2 F% S9 Z/ N/ H/ [
- #include <linux/types.h>; L; w8 l- x, D0 ?5 [: {) y
- #include <linux/interrupt.h>7 y% a4 M; l, H+ u. u
- #include <asm/io.h>7 }4 k3 P! p9 {: H( t b
- #include <linux/moduleparam.h>8 A( v8 e) H* f u3 O( l
- #include <linux/sysctl.h>" u; d W4 z+ ]" n
- #include <linux/mm.h># c" ~ T; i7 G( f: U3 g
- #include <linux/dma-mapping.h>1 C: Y5 N' B) l% H+ Y
' S& r' j1 J6 P+ n: }, `7 I( I- #include <mach/memory.h>1 e9 |$ {: {, ~& P. Z
- #include <mach/hardware.h>5 g: t/ W j7 ^. p, F& r* E
- #include <mach/irqs.h>
& @6 f4 r' P- I7 y+ t - #include <asm/hardware/edma.h>
2 Y" t: Z f8 e - ; t4 \# w; K8 t- o, D4 I
- #undef EDMA3_DEBUG
1 F) m+ ?) u6 m- |* i o - /*#define EDMA3_DEBUG*/& D; q: m7 S' M! S. p
5 B: P( }6 g2 y& P; _- D# b- #ifdef EDMA3_DEBUG: b) J% R; e# r8 N
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS) D6 z, |" P7 `3 R; X( u9 w, X3 D
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
% e% F$ `- N: b - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)% G0 c* |: P6 B4 i: W
- #else3 \, Y3 S) z; {
- #define DMA_PRINTK( x... )+ ?7 I+ L0 \( L/ w( ?7 y8 l# }1 v
- #define DMA_FN_IN
& W6 l: M* R: o, \ - #define DMA_FN_OUT
0 O c5 g$ ?; }6 ^, w - #endif/ F6 A, G1 n8 X: v0 L6 r
9 m' l* F$ ]! y4 x3 d/ j) L* g. H- #define MAX_DMA_TRANSFER_IN_BYTES (32768)9 A2 E& b' t$ W. Z7 z
- #define STATIC_SHIFT 3 \5 u& G$ u, c
- #define TCINTEN_SHIFT 20. y. [& {2 C, u0 ~/ A
- #define ITCINTEN_SHIFT 218 |& m W# R/ b2 F
- #define TCCHEN_SHIFT 22
# k7 Z* P. E8 W. [5 \1 }. ^5 e - #define ITCCHEN_SHIFT 23
9 \: B- q9 t' h6 H( o$ f# b
2 H+ m* k3 f4 l; R" Q! a: g( F- static volatile int irqraised1 = 0;
/ T% v& L/ ~ ^& R9 v% `! L3 l5 M - static volatile int irqraised2 = 0; L. @7 ~9 C$ f& M4 L' r
- ; d- |+ M6 S7 b0 q8 J. K; I
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; }. n6 t# J5 h1 X) C
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" v9 ?% [+ D' d) K4 q0 D# H
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ v N3 Q9 D1 T6 [, `& t( l9 d. w
, t2 x j7 _( E9 f- dma_addr_t dmaphyssrc1 = 0;, V/ c- G: D! s
- dma_addr_t dmaphyssrc2 = 0;: y8 }3 d- m6 f9 i" L6 ~
- dma_addr_t dmaphysdest1 = 0;
8 C* P6 v3 Y4 V! l R+ l: Z! Z' N - dma_addr_t dmaphysdest2 = 0;: t; b3 [ ]5 U W, K7 c$ P
- 7 Y& N: {* [5 Y$ x$ q
- char *dmabufsrc1 = NULL;6 R% `* ^8 f' H% x
- char *dmabufsrc2 = NULL;$ h( X0 h1 ?5 _: y, G
- char *dmabufdest1 = NULL;
1 k7 ?2 d8 _' u, ? - char *dmabufdest2 = NULL;4 h3 U2 ~$ _+ ]
5 Q( u @; O7 F) B1 {. o: G) ~- static int acnt = 512;
+ C2 L9 I9 m9 T8 ]% H$ [1 g - static int bcnt = 8;3 C. i5 ^& O! x" I: O5 [! v
- static int ccnt = 8;
/ M, d' n! `4 m - 0 r5 w% B* t( W0 ^ a
- module_param(acnt, int, S_IRUGO);
/ x+ }# s+ F- K& V2 D0 t' r6 K5 w - module_param(bcnt, int, S_IRUGO);
2 c8 T1 y9 D$ N9 Y2 p0 q8 F8 r - module_param(ccnt, int, S_IRUGO);
复制代码
! r3 N* q0 Z% [9 L$ }6 F- S: r
3 T4 @- L7 w. ]( t, m 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
- ?1 z% f+ m+ j/ K1 J- Sarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
) Y; k7 N4 w, _! ` 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ P) @) `: k6 X3 L" t+ w
1 c; E0 w u: t1 B" b A$ n2 V8 i
8 T8 r! @1 R2 c4 M/ V |
|