|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
$ W4 C3 k# F7 b0 M( Y- [code]EDMA sample test application
3 \- u/ v/ z* v- ?1 U9 `# J5 L; W- [ - /*# i0 f! Y5 w& i4 k' ~2 A
- * edma_test.c6 U& U, e) S& n# C" u
- *
7 b7 ~ n1 t) b# c2 Y - * brief EDMA3 Test Application
" K. w; V1 E! d4 e - *
' p$ p0 l6 D/ z, N$ d6 U5 @ - * This file contains EDMA3 Test code.7 C" R1 ?7 h0 e! \9 ]5 Z$ a
- *
! |8 T4 d- H9 p, g - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE0 X; |+ A2 K& @# g. O) ?5 W l' H
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( ]- V! Z' U7 i: Q* a- ]% g- A - * TO CHANGE.
" E, W3 Z3 F( | - *
: x% j: i" N0 b. E - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/1 |4 ^1 ^$ a- }. \6 g# }
- *
% x' r [0 s6 D3 S - * This program is free software; you can redistribute it and/or$ P0 a/ @; R: I f2 Y
- * modify it under the terms of the GNU General Public License as; A8 |6 u1 S5 H3 y$ { g1 C2 f
- * published by the Free Software Foundation version 2.2 ?5 m* x" C1 g+ z0 H) V7 f6 ~
- *
4 c, I. E! I+ L3 q - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ P" w1 t* {, N$ O& _/ A - * kind, whether express or implied; without even the implied warranty
% z2 y6 Q# w0 p1 y, {" l - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the& _ h; C/ v6 g+ Q! Y# d
- * GNU General Public License for more details.
1 x0 M. a: Z$ X3 q( s) N - */
4 W- c, A, ], L! K8 j0 F3 @ - , h, t2 t. E, q0 F
- #include <linux/module.h>
+ `: ^6 u% B A1 R8 I; G& ]8 f7 b - #include <linux/init.h>
8 H3 @! H# n0 z# c7 q - #include <linux/errno.h>
9 b/ r) P, @7 x. r! N% C& s - #include <linux/types.h>
m0 C( c) s! Q0 t - #include <linux/interrupt.h>
3 O8 H) k8 {5 G K" |6 e - #include <asm/io.h>
9 ^; _+ f) T$ P& g5 l @ z r( y - #include <linux/moduleparam.h>: m$ T% W* q2 u: F. z
- #include <linux/sysctl.h># t& M; ?8 W# r5 `' W. q9 O
- #include <linux/mm.h>3 S% k; m! M# @7 _$ z$ m
- #include <linux/dma-mapping.h>7 x+ c" L. c5 J* r
4 T+ K9 W* s I- #include <mach/memory.h>; z" Y u9 Y* m; g5 F
- #include <mach/hardware.h>
! ^9 Y. C% S7 L# G2 ^5 _8 c% J$ i - #include <mach/irqs.h>! C" @8 X6 h6 x$ F+ j1 C' G
- #include <asm/hardware/edma.h>5 w+ d8 T8 l! Z+ X Q' n( L6 c' b
3 g4 Q6 ]4 x/ Y8 ^7 i* b1 @7 F6 O9 Y1 X- #undef EDMA3_DEBUG
( W. ~2 J) R0 p( Q - /*#define EDMA3_DEBUG*/$ ?) J% d+ ?% h0 n* d
- 5 C9 E8 S4 V, q- k" ?
- #ifdef EDMA3_DEBUG
- K% N6 P4 [; X0 m: Y - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)5 W8 H- g: j1 X) e% M: ~9 Q
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)/ }6 q% a- C# `7 z
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
; i I. U: X( w6 S - #else+ B5 R/ r& E7 L' A9 a# l, I- I. ?) V
- #define DMA_PRINTK( x... )4 q9 ~4 h5 I! }) i) ~7 ~
- #define DMA_FN_IN* }: ] F+ t0 q7 f: g/ y7 |! G7 I
- #define DMA_FN_OUT
. P& m2 u m7 s) c - #endif6 O) F- f9 n& s1 z% _8 Z
' V. ?* Z c$ O& E7 x7 Z% d- #define MAX_DMA_TRANSFER_IN_BYTES (32768)( d9 p+ {/ j% Z7 T
- #define STATIC_SHIFT 34 a' D' Z; q6 R4 p
- #define TCINTEN_SHIFT 20
- N7 ]7 y. Q& C. ?$ a2 f( P/ F - #define ITCINTEN_SHIFT 210 b5 b2 @1 ^! Z1 v
- #define TCCHEN_SHIFT 229 F/ \' E( Q5 _1 F
- #define ITCCHEN_SHIFT 23+ A4 M7 e! ]: B& A }' H9 g/ ?$ H8 S
- , ^6 s4 }* F9 R8 v
- static volatile int irqraised1 = 0;9 F/ Z# o$ x) f- \' Y- J. f
- static volatile int irqraised2 = 0;
: D* ]; r/ r9 |- W3 F
8 U6 G: j1 k0 v4 ~- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% Y/ }2 e3 }' G
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& q: [; w3 S* o0 X
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) F2 n) e: [/ B/ a; ] `; W
- ) Q c# Q# l$ \2 X
- dma_addr_t dmaphyssrc1 = 0;
1 i! P }7 \6 |* m# l% {$ _ - dma_addr_t dmaphyssrc2 = 0;: P2 p* L/ }4 ?3 \
- dma_addr_t dmaphysdest1 = 0;+ N6 q% @& J& R8 Q0 J
- dma_addr_t dmaphysdest2 = 0;
7 j2 U. S9 x$ \- x+ l7 T* K
: Z1 v' M0 D3 v* h/ c& |' d( V7 D- char *dmabufsrc1 = NULL;
- F: Q2 n' ], A3 a% d - char *dmabufsrc2 = NULL;
- r, Q4 p1 U' U- R. b - char *dmabufdest1 = NULL;
3 e! V& v2 t+ j j - char *dmabufdest2 = NULL;( k F/ D9 D( d7 M* I6 S: G
& ^, C$ e# Z6 R4 C9 \, e* H- static int acnt = 512;
" D3 Z0 L5 p) ?1 p1 `3 P$ Y - static int bcnt = 8;
( n2 g c4 l! ~+ ], S8 L/ z - static int ccnt = 8;
- n; V6 S# h' e: ^ - * o( K0 }$ k+ }, C
- module_param(acnt, int, S_IRUGO);5 B; W/ F8 ?& u" h5 C! O" q
- module_param(bcnt, int, S_IRUGO);; F! g* ^9 x% W9 g4 h
- module_param(ccnt, int, S_IRUGO);
复制代码
5 W$ E r0 F3 U8 b9 T( X
7 Z r. K7 S* ^; h 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
% B$ _9 I3 A0 g8 B+ b O2 i1 b3 b. narm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。( ?' [2 o5 v2 C7 _) m$ N* A
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' k. `; x F; \
) Q- ~4 S8 P( ~' g) ?% ?" d& @" U: U) R4 l5 m; o" v$ L; d
|
|