|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 % r$ o+ y( x# E) _) m$ E" C5 M
- [code]EDMA sample test application
0 X) i9 D, H S# k( _, p - /*' s, u, ~# @# {7 B+ V# f
- * edma_test.c6 r5 m, W, N2 Z, t( ?
- *
7 p+ i6 f6 E/ l0 Q m - * brief EDMA3 Test Application+ V$ o& ~* C" T
- *
8 }$ s! n6 p! {' u5 n V - * This file contains EDMA3 Test code.
y3 i/ F5 i5 M5 Y* @( O# r6 _ - *
- ? [ {* L" ^ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
: q7 J* s8 R2 j# `2 I0 Q% M( M3 N - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
: D/ d* @: K. `2 G) g - * TO CHANGE.
& g6 T, \9 c/ a - *: M6 m! |; h% H5 p% j$ \
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# L6 G7 e( B. F! p& Q9 U
- *
) Q' R0 ]- c# g3 E: _; p - * This program is free software; you can redistribute it and/or
# J5 H1 X$ V7 ]/ b+ ]9 h0 A9 s - * modify it under the terms of the GNU General Public License as' d; P* P6 a8 e+ m7 e$ a
- * published by the Free Software Foundation version 2.
# T Y! V; G; m; H; [ - *3 }# }: g" N: [! ~
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any' q, |7 {% l) B: H
- * kind, whether express or implied; without even the implied warranty$ Y, l% I0 N) k& t8 S2 A. E
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 m2 n$ x( c0 m, j- i - * GNU General Public License for more details." Z2 s4 M3 s6 d* `
- */5 i8 d' ~9 G- p* F0 \+ A( T' A/ t; I
- 3 g1 ~& g- V6 e
- #include <linux/module.h>
% t# N/ I3 c6 f- g; S, j - #include <linux/init.h>
& H+ z2 f/ ?" ~ D$ H0 P" T+ r# M - #include <linux/errno.h>. a- J+ e# d! V* |! ~0 y
- #include <linux/types.h>' \! p8 c1 v! z6 ~! Z4 @8 b
- #include <linux/interrupt.h>
1 P: D" {2 l) p - #include <asm/io.h>$ I! q/ p ]8 V' d( V9 `) A+ X0 S& K/ n
- #include <linux/moduleparam.h>
. ~! f! D/ Q7 }" P$ x8 W - #include <linux/sysctl.h>
5 n9 u; ~& C. q; s - #include <linux/mm.h>
' e+ ~- M$ s" p4 i - #include <linux/dma-mapping.h>; ]2 V% W; v) m0 ~0 g3 l
- N6 o/ j+ p+ @0 b) Q) C; _
- #include <mach/memory.h> V9 k9 A ^8 k; c' i& n
- #include <mach/hardware.h>
9 G; [# _$ E) Y3 y( ?. \2 u - #include <mach/irqs.h>
7 z7 b' ^( f. c5 w - #include <asm/hardware/edma.h>0 _0 g% O( W0 p6 D- u: u* y
- : W' F2 J. T0 I3 H
- #undef EDMA3_DEBUG, g) ]; A: e5 ?" e. Z0 s9 y% ?
- /*#define EDMA3_DEBUG*/- v- z/ {& @9 R' L7 i
9 S* s6 Y: g6 {6 ~9 R- K- #ifdef EDMA3_DEBUG2 R( y9 b! Q0 G% o3 h$ S
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
) W2 k' e% ?8 o1 N9 D! Q- E9 U - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
w9 [5 u7 l/ `- j0 T6 S - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)$ G& }, U4 h9 H T1 F
- #else! R. F U4 l8 J0 }
- #define DMA_PRINTK( x... )
/ B2 g. X% Y/ y% _$ l) L - #define DMA_FN_IN2 {0 e! o: h2 x4 k' T8 s
- #define DMA_FN_OUT
1 I; c8 ~# H# O# U1 C% M - #endif7 J% t I0 k5 v. {+ h8 q. F# {
- . `6 n; o" A: b2 J+ H- z8 u
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)# O- O/ D' Z+ P1 G; U% U! z
- #define STATIC_SHIFT 31 T4 G" t6 ] M3 G& \
- #define TCINTEN_SHIFT 20
7 {9 @! C3 n) M/ z' v - #define ITCINTEN_SHIFT 21
c4 _. d! g$ v( E - #define TCCHEN_SHIFT 22' F( T R8 R% Z1 ~7 N
- #define ITCCHEN_SHIFT 23
: z' E! t9 K) e S' T - % L/ ?* F7 r: N x3 b# f
- static volatile int irqraised1 = 0;# n/ N% q: s% O1 ?! B
- static volatile int irqraised2 = 0;
+ N1 R: Q+ U/ | - 3 C; G; G" v6 I5 v+ g
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 g6 g$ S: ~; L0 r
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ j& ^% b; }) {5 j - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 j" w# U" b2 E
- , t& D6 p4 l {% v/ }
- dma_addr_t dmaphyssrc1 = 0;
3 L$ y |3 k O/ g1 i3 Z - dma_addr_t dmaphyssrc2 = 0;
" b; v1 y! l9 E" S) V - dma_addr_t dmaphysdest1 = 0;
4 U0 r" {1 |& I2 v0 {4 [3 l - dma_addr_t dmaphysdest2 = 0;
O: \( G# d$ o" a% d
( D* p6 n9 K7 v9 ?# d/ F- char *dmabufsrc1 = NULL;, ~! E4 f. ?# @/ T
- char *dmabufsrc2 = NULL;
. Y3 Z: Y' f1 P3 ?# d# Z& r$ Z. ?! y& Z - char *dmabufdest1 = NULL;5 |! I$ ]3 |$ @& i" w) @5 D8 M
- char *dmabufdest2 = NULL;/ s3 C% I" z8 }; I+ [& A
; b( f* @' [5 D% L- static int acnt = 512;" E9 @& ~6 {( k7 l& `# N
- static int bcnt = 8;! l/ M9 Y! K4 }6 }0 t3 z
- static int ccnt = 8;7 s* q) Z4 L, X' n* v. m
- ; N1 G! K% F( ^8 I! d6 }
- module_param(acnt, int, S_IRUGO);
- q- ~5 V1 P: U7 l - module_param(bcnt, int, S_IRUGO);8 G0 `4 P" Y" n
- module_param(ccnt, int, S_IRUGO);
复制代码
* \6 y1 ?4 B: `- K! ^0 \8 W5 l- |' a2 p9 `
0 V: k) v! |( K' Z 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用+ }! C8 x6 W: z4 B
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
0 u* Z; X) K0 z9 C$ Y 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。! v% A0 D8 P1 C) f# O/ O# j
1 G" P; j5 u Y
8 u z2 I0 T# ?+ Y5 E; G9 E* }+ b6 k |
|