|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 5 {* T: P5 _# [( M% ]; t5 X5 X; o
- [code]EDMA sample test application
f; k6 p6 B( C6 v% z3 m6 @0 W - /*
$ t+ k$ \, U' f( B) ?1 Q - * edma_test.c+ y4 v& f* Q; n+ U; I' `
- *
3 Y" D2 s5 e( I' E. u, u - * brief EDMA3 Test Application& \. g, J% v% E5 }- \6 q! g
- *
0 m& [* T# y ^$ J* q - * This file contains EDMA3 Test code.
0 j7 O& V/ U; v! I1 `; M - *
! V$ K( |) s7 h0 o' Q6 t - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
! |$ b1 f; w2 @* B7 ^- \ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT! _/ y0 T7 J; w" u
- * TO CHANGE.
# H! o9 E3 o. y - *9 y$ J4 h* C& f
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
9 w" i2 _. o5 R* L1 ~" ? - *
6 K; D6 [0 V8 m& w, g - * This program is free software; you can redistribute it and/or7 R4 h' `. W7 [: b
- * modify it under the terms of the GNU General Public License as
) y# I7 h( ? {& W - * published by the Free Software Foundation version 2.1 R7 u( Z! N" V K1 P8 F7 [- [ s
- */ E: v6 p& j3 _3 \/ i
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, [+ j' P3 p; ~( F. O( l, H& q - * kind, whether express or implied; without even the implied warranty
6 O7 M$ n9 J: V - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
. e6 F/ Y4 u, p3 m+ N+ o( j9 D1 M! c - * GNU General Public License for more details./ {: a; b( q0 a$ G( K% R
- */
/ `" V- `+ j% ^' _' M4 `# }
3 u) k! w! f% W- o" Y/ @' E; A- #include <linux/module.h># a7 u2 x. `3 v& g9 ^( i
- #include <linux/init.h>! g, O8 R X j" q
- #include <linux/errno.h>
8 [, j2 w& X! f1 U2 W3 U& C - #include <linux/types.h>; M/ P S% C: C3 H k( k- K9 G2 W
- #include <linux/interrupt.h>
: @0 g2 @: z4 S0 U - #include <asm/io.h>/ f9 D5 v+ J1 u- }
- #include <linux/moduleparam.h>! x/ a6 I0 S S( j
- #include <linux/sysctl.h>! v2 L! v. b' b5 A( s' Y; N
- #include <linux/mm.h>& h! |# t6 F& N3 g
- #include <linux/dma-mapping.h>- |; H$ T* @* r* M1 A5 Q& j( j
- 0 J9 y: Z* g6 k2 H
- #include <mach/memory.h>
( ?' x6 o0 V. V - #include <mach/hardware.h>1 c- S, [; Y' B, `# B, q# _
- #include <mach/irqs.h>, I: K# K* l2 }) ^7 G
- #include <asm/hardware/edma.h>
6 b& l! v" Q" E$ c) d3 t - / k$ \' [' T- z- I6 Q' U
- #undef EDMA3_DEBUG
R: G3 H1 Z: x& A u1 J- S - /*#define EDMA3_DEBUG*/
1 |/ A! V+ z9 ]) m/ R' M% S9 g- [0 j - . [/ w j* I' _: ?1 V
- #ifdef EDMA3_DEBUG
+ N4 g8 `1 R3 G5 I4 [2 C9 d9 P8 r - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)9 A e, {0 @. r. J
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)& y _0 P# L: x$ L5 ]4 a( \
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
! X* d; `( X1 V2 R+ f6 h - #else8 o! u/ _' q9 K2 O8 k! G; o# d
- #define DMA_PRINTK( x... )
0 z+ F& K3 \9 k9 j - #define DMA_FN_IN: Q' k- `6 j+ I/ o- n( X
- #define DMA_FN_OUT
! i& f p! b0 W4 z - #endif
7 P; ~" T; b/ T! e' A' [ - : Y1 k$ M% d# F: {; h
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
* ]/ ?5 ]5 S* |; o1 ^. @( f( P - #define STATIC_SHIFT 3 h4 D. \" y6 v+ A
- #define TCINTEN_SHIFT 20
- L2 F" `" ?8 L! G5 g- P- G6 h - #define ITCINTEN_SHIFT 21) C# Z# R& n* K8 _; P3 l) P8 V
- #define TCCHEN_SHIFT 22
5 W* k ]1 C7 m1 w5 Q* m8 g( L - #define ITCCHEN_SHIFT 230 L2 P- o& d m" k- g
- ( T. w* J/ r0 R
- static volatile int irqraised1 = 0;
3 N+ H3 g. w) ?8 ^4 F) g8 f; l - static volatile int irqraised2 = 0; T* Z6 S4 V- E8 |. W1 s
6 O3 g. y& L# X( @1 d/ {7 I7 q- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 b; `$ B: k6 L2 h$ D u7 N9 C
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ }# a# e! F! i. S7 T w8 k - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& o* ]! v/ v% r; r7 {
9 Q N4 P9 D j. V8 {+ h- dma_addr_t dmaphyssrc1 = 0;6 B) G6 Z% c/ M9 t8 X% }/ \/ B& p5 t
- dma_addr_t dmaphyssrc2 = 0;
& s- t. f. ~$ u5 b+ S - dma_addr_t dmaphysdest1 = 0;! E+ m) ^ \0 h+ {# E8 N2 e
- dma_addr_t dmaphysdest2 = 0;
7 S- i% v0 k! `3 c8 P& ? - ! Q3 G0 J( R0 n, i- k9 U4 y
- char *dmabufsrc1 = NULL;3 @& R) o% L8 |' I! R0 f5 z' r
- char *dmabufsrc2 = NULL;/ O5 p3 ^1 z: b m4 V. d8 j
- char *dmabufdest1 = NULL;* m# \( s% N7 t! y5 Z9 p
- char *dmabufdest2 = NULL;% h2 n8 `* F3 e% e4 m) ]; z/ q
- ! Z" ~* B/ h0 u! o9 O
- static int acnt = 512;
0 b/ n) F [% J7 w1 K - static int bcnt = 8;
2 S# }% U' Y2 a# G) L# x - static int ccnt = 8;% S; N& h$ c+ m
- 7 t$ V5 F/ L, b( v
- module_param(acnt, int, S_IRUGO);7 p' _, D6 e M) B, X. i- [7 K1 k1 y9 n
- module_param(bcnt, int, S_IRUGO);
% m" w+ S1 S5 D; X' s7 k - module_param(ccnt, int, S_IRUGO);
复制代码 . @5 o3 t8 F. ^$ J7 t/ ]
3 e9 ?6 }3 K% r$ D9 |7 N 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 K9 i6 f: {7 v" F) Tarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 H# M# x) [$ S' ^% B& Z
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。9 C1 X( c- q9 o! g9 Q
* ?0 c4 g' n& ?, [& n' i
- B% _* r+ t# d3 P |
|