|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 " y8 N8 S% [% G7 D% y
- [code]EDMA sample test application
6 d. J9 Z5 s: l& ?9 J+ A" W8 w: T - /*4 u- ]2 H4 p0 x) W8 W5 S
- * edma_test.c- P' ]" L! r3 f0 r) g4 d
- *
, l" v/ Y7 \' { T) k, J - * brief EDMA3 Test Application
2 r5 f m4 y4 X: ?/ q - *
% G3 {: ~, S% j/ A3 E - * This file contains EDMA3 Test code.4 t/ q, _8 i, g" W
- *
5 k5 N; Q, z5 t# x- b3 [ Y - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE2 j% p' W5 g& l1 e1 S9 V) U
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
! {# l5 ^+ Q* G0 a- P1 H8 f# R% U- i - * TO CHANGE.5 i" h }' w2 g4 x% E( F1 I, C
- *) i+ i- O7 ~8 R9 R n: Q7 D0 n0 ?
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/& J7 z; E# h/ }% ?1 Q
- *$ Q/ t {7 c( n$ i, |7 B2 n
- * This program is free software; you can redistribute it and/or
; P* V6 L# P) v. h* @& @# [* A - * modify it under the terms of the GNU General Public License as
, R* w1 r0 V' k; H' F- @ - * published by the Free Software Foundation version 2.) Z) a$ ^# F; z* z' F% [7 E
- *: t b( J+ z( H8 Q# K8 i5 p
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 X- ^. y( a4 L0 I$ |8 F; _( ~
- * kind, whether express or implied; without even the implied warranty6 g5 ?, O6 c. M: Z7 U# G1 L5 t
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the4 R }! g- i# b; Q4 I& v W2 q
- * GNU General Public License for more details.9 g3 U, `/ k4 j c
- */ U2 t, y/ {3 J6 i- p0 z/ H
- 8 g# {9 ?3 E, B2 w( i; h' d
- #include <linux/module.h>7 W* z2 p% @: D0 D8 q
- #include <linux/init.h>3 C% e/ r& \5 d
- #include <linux/errno.h>
: y4 e1 O4 |( L - #include <linux/types.h>
' c8 W+ W; |3 y0 [0 ]5 _+ R2 b - #include <linux/interrupt.h>& e( V O( _8 k9 e: @
- #include <asm/io.h>
+ x7 @! w# a5 E, M& x2 N/ I - #include <linux/moduleparam.h>, e- d+ {0 x5 ?1 e
- #include <linux/sysctl.h>
/ Y7 t6 ?; n# M - #include <linux/mm.h>
7 i, o$ X% Q& d, C - #include <linux/dma-mapping.h>
9 Q( u) V( d5 m - $ m! e0 {1 {0 S$ u8 z; _% o
- #include <mach/memory.h>; k0 d' h7 k6 ^: q- M
- #include <mach/hardware.h>7 E# H V& T, V, n/ E7 _
- #include <mach/irqs.h>1 ^( g1 r# \' X5 L" s
- #include <asm/hardware/edma.h>: f! h0 r' C1 L0 _- n$ b3 v
* c$ @, Z4 g* J8 ], a- #undef EDMA3_DEBUG: m) k2 ^; s9 @5 X: A% u7 e
- /*#define EDMA3_DEBUG*/
( ]/ D3 r& C' o& J
- U7 p) f5 u& O6 J, F2 G" S/ `- #ifdef EDMA3_DEBUG
" D: e8 B! R8 M9 x& T8 W3 O# `7 e; v - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS); b8 } E- n$ ?# [: {' t! i
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)% L9 W+ X6 T6 J$ W* C- Y
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)$ ~% Z% m7 @) {6 F' }! Y
- #else
$ D/ M8 C5 K5 x5 C, V4 j - #define DMA_PRINTK( x... ); ^4 [4 C* |7 R+ {$ D. D' l0 G: d
- #define DMA_FN_IN
+ {, ]0 D X/ w9 y# n5 W: ~ - #define DMA_FN_OUT
. C$ t" ^; q! S& R$ e4 G - #endif
. g- d% t/ @4 r7 C! |/ D( _ - 4 Q% k; m2 ~" v; Y! X
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 A: O7 T* l; R* m0 F% y# Y% K - #define STATIC_SHIFT 3
& x8 _4 Q7 j/ ~ o - #define TCINTEN_SHIFT 20
/ B5 J5 p+ Q' U0 E) l2 y) T" [ - #define ITCINTEN_SHIFT 210 U* J* N' v# X8 P* N5 r1 J
- #define TCCHEN_SHIFT 22! A5 g! w4 Q8 w! M. ^$ n3 y: R; d
- #define ITCCHEN_SHIFT 23
6 @) S3 w' d: { - - i7 D, K. b* Z& |( j, M( u; |# l8 v+ o
- static volatile int irqraised1 = 0;* q. d( I$ Q0 |
- static volatile int irqraised2 = 0;
! `) X5 t( r* D X3 u! r- A2 g - 7 ]! C3 M- I/ I2 b: z4 U
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 f7 ]; Q: O6 l$ ~' @2 F8 w
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 m% N' a. D1 w: f - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 q# T2 x- }2 }4 ^( _
- & f/ f3 g# t# O2 Q6 w/ A: M! _
- dma_addr_t dmaphyssrc1 = 0;
8 Z! s- |' k# u4 z - dma_addr_t dmaphyssrc2 = 0;
! {5 w K4 i L# z' H - dma_addr_t dmaphysdest1 = 0;6 W2 @6 p3 ^+ s1 T4 \4 J) h9 w' [
- dma_addr_t dmaphysdest2 = 0;
/ m! L" i1 Y9 s0 Y5 z - : A1 a+ N5 p: e9 i9 {9 t
- char *dmabufsrc1 = NULL;! R/ H/ S) y, P. b- `, l3 c
- char *dmabufsrc2 = NULL;
- Y. M$ O6 z- X- ?0 E - char *dmabufdest1 = NULL;/ V1 f1 l) ~% h1 x* D6 [
- char *dmabufdest2 = NULL;
v9 n9 ]2 `6 |# z# P, Q9 V
+ K) V, a7 w$ s0 h* ~$ b* k5 `' u* \- static int acnt = 512;
1 T0 l7 j+ y1 y - static int bcnt = 8;
+ D& O7 W/ K6 Z, e+ o7 N - static int ccnt = 8;
6 @2 ^. Q" L2 o3 `8 Z2 P - m2 M' C+ R5 @
- module_param(acnt, int, S_IRUGO);: j! \, z2 r! v: F2 v$ j+ u9 b: J
- module_param(bcnt, int, S_IRUGO);
d$ z, b- x3 k2 f+ I8 s - module_param(ccnt, int, S_IRUGO);
复制代码 ' b2 h7 q) ~6 ]$ X/ _, }
) _. J/ Z; n9 {2 O9 O( z6 h 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 }4 v9 {8 ~8 H8 y. jarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。& N+ }" [0 S+ R* I+ T6 o8 \ E
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
1 O1 ^+ \" F& D& }5 z6 B3 b% F; @" ^2 ~7 c8 m0 }
& ]/ S% R2 q6 p0 f |
|