|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
q& a1 p" {% q7 x7 n; j& a+ P- [code]EDMA sample test application
% {$ E/ H; J8 e9 l/ | - /*
, Z( L5 t2 O$ w2 @& \ - * edma_test.c
b. N+ Z3 x' x& R1 A - *# n2 ^; @7 _0 R# Y M
- * brief EDMA3 Test Application
* l& S( q* y- p H9 Q' r; i - *8 v9 I6 B9 S4 ^+ p% F
- * This file contains EDMA3 Test code.- k7 n7 q5 u: Q' _
- *
7 `6 v& R' I1 J - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% {* C- Y, A4 s$ h6 g+ ~ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
) O6 J- z& U* R - * TO CHANGE.$ q, J8 A$ P& [- W: q" `: M
- *
% X! p7 U( m$ d9 S - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/( Q/ h5 G& a6 m
- *7 E" e4 y. @- b4 R* I; i! O1 g
- * This program is free software; you can redistribute it and/or) {8 ~3 N/ s+ C
- * modify it under the terms of the GNU General Public License as
: m& Q+ Q2 H; q- {, ] - * published by the Free Software Foundation version 2.
5 p8 Q7 g: X- z( s7 z6 X - *
* k0 A; e3 e# G. y# t8 _$ h - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, L' Y; }) ^# w0 Y" o - * kind, whether express or implied; without even the implied warranty
0 i) N9 D2 J8 s6 C: Q - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4 N# W0 n g# g8 B9 p. o% ]; | - * GNU General Public License for more details.
0 Z3 s- g2 z' Q; Z2 L - */
6 U: `( n* ^* ~0 t- X: T* Y% A - ( z6 m6 n# d; J0 I$ v, `: a
- #include <linux/module.h>/ R% Y" ~; K7 l0 g
- #include <linux/init.h>
! A' X, j6 g2 l' s0 L - #include <linux/errno.h>
) m$ J! P! a/ c+ [7 ?5 P - #include <linux/types.h>
8 k, s' O/ ?. a, T- w7 D4 S - #include <linux/interrupt.h>
7 a6 Z6 C0 p, H9 |8 x) ~9 t0 v$ U - #include <asm/io.h>
4 P6 U3 x( m# D) Q3 I - #include <linux/moduleparam.h>
3 x8 f2 f3 h% L- |+ k - #include <linux/sysctl.h>' `3 E2 H4 p- ~: j" ~3 W
- #include <linux/mm.h>
2 e8 z6 I+ N- \% u2 G$ m" j - #include <linux/dma-mapping.h>
/ e7 S/ c& Y- |4 Z2 G2 S9 u9 l
2 S% p& n$ g0 A- #include <mach/memory.h>
1 ^' d5 b# v" @/ { - #include <mach/hardware.h>
! @: O' }4 h7 [2 E$ Z# R - #include <mach/irqs.h>1 {# V! ]5 g( E7 a1 i/ B! K) G2 H& P/ v. U
- #include <asm/hardware/edma.h>: o# ~6 n0 J: Q1 r5 }' x
- 9 K$ }% m: G/ R/ b$ ]
- #undef EDMA3_DEBUG3 t, |5 v5 f+ B' F, c1 E7 ]
- /*#define EDMA3_DEBUG*/
6 g+ [2 k0 |: \2 `5 G) w+ _
6 m: }7 A' g$ H' S5 ^, X; _- #ifdef EDMA3_DEBUG: m/ ^( G' J/ j
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS); P8 w; J7 M5 j* l
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
, [! w: Q" {; A/ P. ^6 l3 u - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
+ [. {/ w+ c. l7 B" x" q - #else
9 d% M! o! X- J - #define DMA_PRINTK( x... )4 y0 r: E D& @1 n+ c5 z/ w! c
- #define DMA_FN_IN! i; t6 G6 R- R
- #define DMA_FN_OUT
+ w# E, ~9 K$ [ - #endif- i7 f) f7 t* n" C9 [
0 W" Y5 J3 S# Y4 p( V- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
5 q4 {: O5 a1 f$ \# N; E! Z - #define STATIC_SHIFT 3
( U9 T) ] `% g/ U) w- ^7 p8 }6 i - #define TCINTEN_SHIFT 20/ B" `! {' J9 r( a
- #define ITCINTEN_SHIFT 21
$ J) R: @5 Y- Z2 c$ D - #define TCCHEN_SHIFT 22
7 }9 I `) n; P) L4 H0 n1 P - #define ITCCHEN_SHIFT 23, h, h9 j2 ^- P4 U
- 2 t# g* ?: r0 b5 t9 t+ e' d0 C0 W
- static volatile int irqraised1 = 0;$ t5 }& p; y+ L% l
- static volatile int irqraised2 = 0;0 f/ O$ @8 Z7 d1 b4 r- ?- @
- _6 M, d% e9 d( s" k# W# n/ f& Y
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 k, C- p( H, N3 L, A5 F - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! y: h' \" ^5 K% T' T- J. {. g0 Q - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& s9 p/ O" h9 e& h
" a( ` c" Z! Q- dma_addr_t dmaphyssrc1 = 0;
3 Y( x. v; {4 a# O - dma_addr_t dmaphyssrc2 = 0;$ C: E* E1 O; L" [1 Y2 p
- dma_addr_t dmaphysdest1 = 0;8 d, U8 L5 @/ Q$ I- Y: S) ~
- dma_addr_t dmaphysdest2 = 0;
8 m. w0 f. Y! K, Y4 t - R- @5 `; v, ]3 P! p8 W
- char *dmabufsrc1 = NULL;
! |9 s& [3 j( z1 v - char *dmabufsrc2 = NULL;
0 \+ p: S. ` e4 m h* ^) y Z4 i - char *dmabufdest1 = NULL;3 K1 l8 f* c6 ~ m9 V
- char *dmabufdest2 = NULL;
5 F9 b* {* c; f9 B3 X7 a" A - ' t3 O; Q+ ], ]& J5 E4 j
- static int acnt = 512;% }( q1 Y" S( P2 z) n2 z" j3 r
- static int bcnt = 8;
/ R x% J" b- \ - static int ccnt = 8;
0 X6 D( k& r, w2 s; i' G8 ?; i# f
+ D# p7 x: V& d9 z/ r0 s- module_param(acnt, int, S_IRUGO);- |& c% B" Q$ ?% a
- module_param(bcnt, int, S_IRUGO);+ p6 Z/ J! t" C9 C+ M- r& A5 _
- module_param(ccnt, int, S_IRUGO);
复制代码 + g6 w- \. b! Q8 d
; B! H8 s% T& d' K, J7 ]" Z" | 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用3 z( T3 r6 A" T# f' v
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。4 o- _& B. I( F. j4 h. {3 K* w F& j
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。% Z* f! V* R8 N9 g z
( y& o) E8 Z& y9 d7 A
I5 ?& m# g1 a4 L
|
|