|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 4 V9 k5 y% a* W( d! Y7 B. G
- [code]EDMA sample test application- O6 l/ I7 o. o+ k7 N
- /*
! S2 X, U* t# \) W t9 @: K/ N - * edma_test.c
/ J) g! c" \4 R- h - *
# o! M7 T9 m, E- S - * brief EDMA3 Test Application) ?( c }. c. f3 ]% I, z9 q4 A7 C7 q- h
- *
0 n; j) d2 S! i1 d1 v8 ?* D - * This file contains EDMA3 Test code.- X9 O, s0 z3 j- Z
- *
2 t& v, D$ S8 V$ k - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE. N7 K& ?0 D' h: O/ Y% B
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
, F3 Q& Y, h0 N7 u5 M - * TO CHANGE.; l- Q ^! w- n. P
- *
& D* S+ y) }" s - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 [6 y) q3 s1 |* Q! q4 P1 R
- *' D4 ~' l% j% ?8 u- b4 S
- * This program is free software; you can redistribute it and/or( J% w! o7 o6 I/ Q3 e
- * modify it under the terms of the GNU General Public License as
1 ?0 o" }% U+ m+ v9 @5 M" D - * published by the Free Software Foundation version 2.
0 s" l `1 K0 u* P* L4 c' ` - *+ A+ N. ?$ v3 ^' p9 `+ v$ E1 e
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
3 \4 N1 k) d2 N! J6 a) X - * kind, whether express or implied; without even the implied warranty
! M; c( c% P; \: [, f1 L8 R - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- N: d( A" X7 r7 _$ @. ^ - * GNU General Public License for more details.
1 F+ i+ F% G4 }" z. B! E6 E1 W; g3 d) i - */: w' S" r/ A/ l0 t
- ) ~; m1 \0 q/ x6 l
- #include <linux/module.h>
, j4 D f7 x. e# B' Q, `7 { - #include <linux/init.h>- d l/ M8 c. y$ T
- #include <linux/errno.h>7 |% W% N) u5 W
- #include <linux/types.h>3 u+ n6 V+ D0 J; O# P5 l
- #include <linux/interrupt.h>6 Q: c$ b5 `* b# G
- #include <asm/io.h>2 Z: U) H7 \! z( U! k
- #include <linux/moduleparam.h>
5 \$ A' s$ P ]- a - #include <linux/sysctl.h>
8 T) |5 p8 Q4 L# @" ]: c! Z - #include <linux/mm.h>
( v& j- O% k& v+ } - #include <linux/dma-mapping.h>
4 b$ j1 k0 w/ d( x2 `, ~ - 8 T0 _+ |' h2 ~
- #include <mach/memory.h>4 } V" Q4 g9 A) A$ v8 @
- #include <mach/hardware.h># d) ?. H! A; A5 Y, @2 M7 b
- #include <mach/irqs.h> o p3 X) [. n) ~
- #include <asm/hardware/edma.h>
- w; b4 e. N% x k - - b6 O% K9 Q& u- ~. a
- #undef EDMA3_DEBUG9 o& w$ w* ]# {( ^: N$ {3 m
- /*#define EDMA3_DEBUG*/' w7 A( |5 ?7 F* [9 u3 S4 b
: [- ]2 A$ _+ X* s; Z- #ifdef EDMA3_DEBUG
/ M- f* Q0 O5 f+ f3 T+ Q1 g. @ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)7 ]5 }' b8 l# [
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)2 l* \" z! O. W/ p; [6 Y
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
: x9 ~! {4 o* G* x q, @6 w9 q - #else! B0 V: ]7 C8 @: H, |
- #define DMA_PRINTK( x... )" R# ?6 H& n( k) }) w/ Y( L, Y9 ^
- #define DMA_FN_IN5 K @% ?" a/ L$ Q1 U. ?/ |8 G5 h
- #define DMA_FN_OUT
; H* i: t' X- @8 f% }) D. O - #endif
$ H( {4 \' l5 l( _7 E
4 d/ R$ _9 o7 e- V: `6 a9 p# J' _- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
) R, e7 y8 J8 {" z6 O4 j. [* W - #define STATIC_SHIFT 3
% k' S! K3 A2 q1 I) ~ T - #define TCINTEN_SHIFT 20
- s5 {; E7 X; J - #define ITCINTEN_SHIFT 212 t+ B, x' } U+ r+ T" n l7 S2 G
- #define TCCHEN_SHIFT 22
2 d3 q8 }; _. D - #define ITCCHEN_SHIFT 23" V% j# M) `! F0 a, L
- 0 z ^7 o5 H U1 @) c, w! ^4 r& n
- static volatile int irqraised1 = 0;
! p1 g# q1 T9 c/ v6 ?/ n - static volatile int irqraised2 = 0;
! T: b" O1 G' P8 I - , m$ r+ t0 u/ {) E
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 _) U* P) d, T7 `, N: t. v& Y - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* J Y* F6 H% Y, n! X W8 P$ `
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
A+ y" K2 j/ c& u- Z. N - 4 s& d* A: Z' W" e9 ?9 D: v9 d
- dma_addr_t dmaphyssrc1 = 0;) k) k+ e8 e( B* d3 N
- dma_addr_t dmaphyssrc2 = 0;
0 t% |5 @" G2 N5 b/ x - dma_addr_t dmaphysdest1 = 0;
# A+ f& M0 q3 }- U; J - dma_addr_t dmaphysdest2 = 0;
9 x. `3 | Y" _; o7 w6 t& s - $ Q: G- o: Y+ @$ U$ t
- char *dmabufsrc1 = NULL;4 W/ i3 q9 D% ]: g4 L
- char *dmabufsrc2 = NULL;
R8 j1 a7 C$ X, i% z - char *dmabufdest1 = NULL;
- ?' {( c' `/ X - char *dmabufdest2 = NULL;+ r2 N6 u; Y. S
; {( J+ J9 n1 Y* G/ ]3 n8 j5 H0 ^- static int acnt = 512;0 c( T( K3 z E3 D' J" N3 X
- static int bcnt = 8;7 i2 Q% v" A' Z4 q% y, r
- static int ccnt = 8;6 M1 W6 `6 P# A" @, ^
) A' |, Y" r' }& l- module_param(acnt, int, S_IRUGO);
: @" S' f0 O- Q# B - module_param(bcnt, int, S_IRUGO);
8 X: N; s1 r- C5 H' k - module_param(ccnt, int, S_IRUGO);
复制代码 ( S& ~7 s0 z; |# \
; z/ \* ~( T& ^ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! |8 D' n7 ^/ F" d$ X" \! ^9 y \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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; j, |. {+ A* H9 _ ]: R
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。9 x, r+ Z4 R/ t; F9 o- |
* m+ ]( _0 Z/ Y. Z" F* f
7 X; r3 q2 v9 `* N# L$ l) q |
|