|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 u3 @( u% r/ J" O- E
- [code]EDMA sample test application/ y1 M+ N" L6 K+ w$ e! ]% C, L
- /*
/ G3 Y$ ]) I2 {9 w! @* H2 q - * edma_test.c
3 H) z$ }' k5 i; L7 j& ^) o$ N - *1 h% C8 [3 l0 J0 W" W7 c* O$ S
- * brief EDMA3 Test Application
- H: a# Z9 v0 N! E+ b- n n - *9 q0 ^# m% ]0 c1 s
- * This file contains EDMA3 Test code.$ e( G/ K) E$ u0 {
- *
. [, R1 @+ O) i! _3 k: j - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 b" z% R+ S* E/ K0 |- J1 i
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 g: Q$ t7 T+ U3 ?7 B
- * TO CHANGE.
0 H- ]" E& ~2 t9 u9 u- v - *) W7 X Z6 `/ W5 A5 f. ?+ t
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/' y+ x+ j8 A1 e2 f. ~ K
- *
: ]- v1 [; @ g/ U4 S/ H - * This program is free software; you can redistribute it and/or6 d. v; K0 P: T! U
- * modify it under the terms of the GNU General Public License as- e, w! D0 C! |: F1 z4 d
- * published by the Free Software Foundation version 2.+ Q0 D. a6 e9 p* F+ e$ v' U9 S0 t% M
- *
- y: Z F; R; T9 T5 n" A) C - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
8 k+ n0 J9 u& ?6 I0 n" b - * kind, whether express or implied; without even the implied warranty$ g5 l7 S( I3 S o8 w6 m
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the& o8 [7 x3 O/ n3 N2 t
- * GNU General Public License for more details.& R' r) `0 Q; |5 @# o1 f
- */9 f9 C M' z1 W
+ t0 Z2 B9 f D+ B6 n$ A- #include <linux/module.h>
7 ^0 A0 H+ [& N X8 k5 I1 I5 x - #include <linux/init.h>. R4 B3 S3 I4 S4 \& V
- #include <linux/errno.h>2 I# X1 M' M- W. v5 f
- #include <linux/types.h># p* r, x/ Y* x& q9 E3 h( M
- #include <linux/interrupt.h>: c& e7 M$ c# b$ v* g: C
- #include <asm/io.h>
4 a0 a3 n, W3 K7 [9 n# S" Z5 z+ C - #include <linux/moduleparam.h>
6 ]3 [3 S0 h* ~9 s - #include <linux/sysctl.h>0 f# i# {* s X$ c8 E- c
- #include <linux/mm.h>: [& h4 K7 u+ p- B
- #include <linux/dma-mapping.h>
9 T0 Q/ ?7 J) Y# w; \# e6 l& Q
) U; c, F' o( b' d) G- #include <mach/memory.h>
" s; e1 e1 G" J$ h. U( g- ] - #include <mach/hardware.h>
~' N! Q0 B% r) ? - #include <mach/irqs.h>
+ ?% i) [0 ` O/ z9 @ - #include <asm/hardware/edma.h>% X; h4 N: ?- x$ [6 t' X
! i5 p9 u, q3 z+ t" x- #undef EDMA3_DEBUG% y2 _7 H! {4 |+ I/ r
- /*#define EDMA3_DEBUG*/
. u& _7 b1 D1 Z# ~4 h: g& n1 o - M+ p& D* U! S
- #ifdef EDMA3_DEBUG5 Y$ }. X- Y8 P/ F+ e
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)' H1 E# F4 Y! E! s" @! D
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
6 Y0 P5 m% q7 i+ b - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__). ?5 ? [6 c/ X3 l2 w4 Q. l1 x8 g+ P# B( F
- #else
' d/ G! Z2 h. D - #define DMA_PRINTK( x... )/ t4 S2 K- o; ~4 X' h. f
- #define DMA_FN_IN
" \/ l/ ]+ @' I2 G; q9 Z( ? - #define DMA_FN_OUT9 D; I! S3 }/ X# O1 X- V
- #endif9 X; Z h) W4 C' {
' W7 R- Q9 E! C& b- #define MAX_DMA_TRANSFER_IN_BYTES (32768)3 h6 F/ R' x7 `2 i. d
- #define STATIC_SHIFT 3
9 o3 W! b( J) t& Q3 `! n6 R6 a2 i - #define TCINTEN_SHIFT 20
) e+ J" r' a. `+ k: y: b; n& S - #define ITCINTEN_SHIFT 21
B$ r8 b! O$ \) J - #define TCCHEN_SHIFT 22& g. h% w+ a- H' }) T/ _
- #define ITCCHEN_SHIFT 23
+ v0 C' h% y9 @& W2 p - " d4 V# d; F! [: G
- static volatile int irqraised1 = 0;
8 ?# i9 \0 q& {$ `# S1 K( a - static volatile int irqraised2 = 0;
$ y- c6 f: y3 Q( l& P* I - , o' \4 U( Y2 S" g# B# J
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# l3 k7 {+ E4 O/ S - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ J" Q0 y% D- P* X6 |7 F1 g7 O
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& L3 Q1 ~$ v6 P! T$ D
& C; [0 |0 t7 c- dma_addr_t dmaphyssrc1 = 0;4 s# J& [' K2 {
- dma_addr_t dmaphyssrc2 = 0;
+ [9 r/ {! T. S0 G7 j0 x0 S/ l0 W - dma_addr_t dmaphysdest1 = 0;
: `/ k* {( g" p - dma_addr_t dmaphysdest2 = 0;! o6 e8 M* s) U4 r0 Z
- * e; E5 z! D# J" [. l/ _: h" i
- char *dmabufsrc1 = NULL;. D2 j4 e; m+ R0 c# a4 u
- char *dmabufsrc2 = NULL;
# z4 e/ X7 H" i, h7 P - char *dmabufdest1 = NULL;
2 f. ?# b. n/ h. V - char *dmabufdest2 = NULL;
# @+ a! e1 g5 H/ }* j7 i1 |# N
( U: E* e8 m( Z5 H- S- static int acnt = 512;- F# y! z5 m2 Y# W& H+ x
- static int bcnt = 8;
/ |( R3 y0 \# d' B+ {, U - static int ccnt = 8;; }9 K* T6 S* A% ?
, w7 ^1 c6 n: @. k- module_param(acnt, int, S_IRUGO);
5 J4 R2 o+ S' D4 W- S - module_param(bcnt, int, S_IRUGO);
; X& E% F8 E. D2 ?* b* M( W7 @& B! E - module_param(ccnt, int, S_IRUGO);
复制代码
) _/ P& K+ ]7 Z/ z9 \# u3 n4 x; |- B
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
3 Y! X3 I" e# v! marm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
* P4 ^: r2 O6 X- C S 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
) [% k- j8 m; q& Y3 S
+ o8 M, G, [! { f9 _
& ?' W) z( @3 S4 o4 q1 g2 o |
|