|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 - q' m& w' l7 _1 G4 E# J
- [code]EDMA sample test application! c1 M( j& }1 _3 {
- /*, g. I2 c! j! Z; }. J
- * edma_test.c
$ J+ g4 s. E* I9 m) P0 k - *# n/ Q3 B6 u" u) `7 i5 p) b
- * brief EDMA3 Test Application
; c$ ?& Y5 s4 W | - *; [. [* Q! |$ t& R( E
- * This file contains EDMA3 Test code.
6 R. ]; g& z+ k6 q - *7 l* f0 G' b7 t [
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
1 x: k- ]9 [: g! \, m9 q8 \6 l( V - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
2 W( _# w, |- u3 }9 g - * TO CHANGE.
7 S% Y& j7 b' y - *
+ M) B: p5 ^$ U( M0 h - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# ~! @" P: C% [- ^
- *# C# r6 d, I. ~+ {
- * This program is free software; you can redistribute it and/or
5 @# U8 r& L* P+ D x - * modify it under the terms of the GNU General Public License as1 v0 O, `" g |" G e
- * published by the Free Software Foundation version 2.3 E& F W6 ^* C& l' w2 o# ?
- *
: U7 }: u( s, Z1 d& k3 e4 W6 | - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
# x4 e6 j2 s7 |# I9 l! Z3 Y - * kind, whether express or implied; without even the implied warranty
3 a+ C* Y* U' @5 J5 j% Z2 g# X - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the5 _6 W2 L& J! M* ?$ f
- * GNU General Public License for more details.; J8 d) ]) A$ I7 O
- */
v0 Z* S( y4 |
" e% x+ j4 y- d- k1 a2 a- #include <linux/module.h>
9 Y- D1 a1 e7 e - #include <linux/init.h>
# A- K& \# `: E& n/ S; e& }* j6 k - #include <linux/errno.h>/ _, T9 q, w4 P$ M' X! T
- #include <linux/types.h># @' D# z9 n/ J, m# n: Z% l
- #include <linux/interrupt.h>
' e- w$ I n% A - #include <asm/io.h>' t$ C& }! X; r3 H4 E
- #include <linux/moduleparam.h>
# c8 x0 |! @" z, A' g: @$ k - #include <linux/sysctl.h>
0 {1 i" {: n$ N - #include <linux/mm.h>
, `% V" o' j/ F" {8 ` - #include <linux/dma-mapping.h>
- y7 p' @" {* ^. ^: B3 B/ |! _ - - ?$ i0 y! U; B1 x' _( {1 I( G
- #include <mach/memory.h>% s' M/ L2 \- e0 A B
- #include <mach/hardware.h>( y0 Z% M8 m1 d( B# E: \. F, w
- #include <mach/irqs.h>
* D" s6 C I/ {0 _8 W - #include <asm/hardware/edma.h>8 i1 h/ F1 h2 C9 Y) U! R
- + b+ C0 R( Q" s6 y
- #undef EDMA3_DEBUG# N& N: v# m. f) P7 M
- /*#define EDMA3_DEBUG*// A& o: H: U2 A( f
- ' X( t) _ L, y1 {' g" j
- #ifdef EDMA3_DEBUG
) K. Q4 P8 M2 v. e( Y: k5 S - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS): T c2 E6 b# I t, t/ ]- R
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
H- J) P0 O$ E& i9 O, `- ?! s1 P: S - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
- d& q" y3 m- {' K - #else
( Z c9 P j R; W - #define DMA_PRINTK( x... ): I0 J8 f2 {+ s/ v5 Q% K
- #define DMA_FN_IN& Y2 Z& I) R0 U
- #define DMA_FN_OUT# N4 R8 v5 z6 p
- #endif) m1 t' V+ q3 H
- $ _" m- ~5 b% m3 N) l" |/ ?# F6 j9 |
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 z8 D" r* C2 Q2 i5 L4 i& z, F, _ - #define STATIC_SHIFT 3) }$ E1 X, l. q! C$ w, @
- #define TCINTEN_SHIFT 20: K. b" C# P1 X; r
- #define ITCINTEN_SHIFT 21! Y) _' k+ ]5 x6 o' L" D
- #define TCCHEN_SHIFT 22& u8 ~( G, ^& i2 C. {* ] j
- #define ITCCHEN_SHIFT 23
- R! o) P3 w7 ~- j! A: f2 P - : H$ K+ D* @ ?: P0 m1 h2 }
- static volatile int irqraised1 = 0;+ Q' {1 r5 u/ _: Y' K& G! K
- static volatile int irqraised2 = 0;
* |0 n0 o1 o. F3 p5 d, d - $ Z! s$ [: [& E6 ]
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 a7 s% v% Y+ ?$ y- m* d
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. I, v, q2 V' s' N a4 L - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
f5 b0 y# i6 z - 8 r! m- Q$ d' G( r" y; ?5 X
- dma_addr_t dmaphyssrc1 = 0;
, l8 E9 l+ P- \1 Q - dma_addr_t dmaphyssrc2 = 0;
( r4 E; Y/ s2 }' q: d' ?2 o9 G: x - dma_addr_t dmaphysdest1 = 0;
8 s6 y" J- k/ p, D - dma_addr_t dmaphysdest2 = 0;
3 k* H: m" ^. b* R0 w
% S" F6 q8 y. Y8 C" |- char *dmabufsrc1 = NULL;9 E ?2 p( Y9 s" A+ b0 m3 @
- char *dmabufsrc2 = NULL;( g `2 d+ _2 ~8 T+ ?
- char *dmabufdest1 = NULL;
0 S! P$ Y4 @+ o$ U6 J9 t - char *dmabufdest2 = NULL;
- A0 v6 H+ p. _, \
1 y& ?( ~9 V( @9 H- static int acnt = 512;
6 S( d6 _( y7 \9 C+ e* x" Q - static int bcnt = 8;+ z: m( y5 V7 a* D- h- c* s
- static int ccnt = 8;
: F# \) K9 N7 j4 |# |1 k8 Y - 8 ]5 s! W6 n9 l
- module_param(acnt, int, S_IRUGO);' p& P8 `1 {0 N: P, D& r$ I7 F
- module_param(bcnt, int, S_IRUGO);* \, ]; C! D* v e2 _+ g, E0 e2 a
- module_param(ccnt, int, S_IRUGO);
复制代码
3 A5 q* t: _9 ?* j( R% l3 i! j: F0 ^' A# P1 U: v) W
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用$ K- d2 @/ P4 \% V$ m
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
6 Z7 k2 L( i- p7 ? P( u 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' G8 L! h* t( P: r* S: o
+ ^. e1 u; e$ {( B' z4 w: g) H
( Q, i# Q% Z; j( t( R/ ~3 V8 J1 R$ v" O |
|