|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 # b' h! V2 A* s b
- [code]EDMA sample test application) e) |+ N. j$ t8 x
- /*
( k" r! n, k2 \% Q. s2 B0 m' z0 T - * edma_test.c
: |4 c- I. e% k6 I1 S U - *; k3 N# G8 z& y; e5 p6 M3 c, H
- * brief EDMA3 Test Application1 S! t& M/ A6 t, R) m6 T- J! G3 ]
- *
0 `! {4 W5 s m* p ]1 `! S7 |/ C' y - * This file contains EDMA3 Test code.1 c: o& v7 L% e2 ~+ T t& a5 z
- *
9 L! ^4 P% f2 {' |. M T - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE4 E; m" T' Y+ {# N1 H; J( Q( U
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
+ d# X' G) h3 v - * TO CHANGE.2 m% G$ a5 v! i( ^7 I
- *
8 b1 r' S$ v4 M* b5 m i - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
. N9 l0 [. a( S6 [# n - *
$ A# @, R3 O. d; o2 R% \4 x: C) { - * This program is free software; you can redistribute it and/or
; a! X: F9 c f8 H - * modify it under the terms of the GNU General Public License as% \' U+ \% Z: \/ R0 z+ D; f' l6 ]* _
- * published by the Free Software Foundation version 2.
& N, a6 U$ Q6 I: u. Q# d - *9 L) |9 e8 ?$ e" w3 Q) j
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any4 K. P! }" Q; \& R' [; o
- * kind, whether express or implied; without even the implied warranty) C6 f( \1 n1 P( P' n( z7 k
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* s' h: r* r( E6 T: b! s- m* z
- * GNU General Public License for more details.4 Z3 a( Q& p4 |( ?4 j
- */1 [5 u; Y, p: O
- ! |3 ]( ]( } g* ~
- #include <linux/module.h>
4 V2 e" k' z H1 \ - #include <linux/init.h>
+ L+ O# `$ n2 {! r/ K+ ^; [2 D - #include <linux/errno.h>
t7 Q; y/ n7 J( F - #include <linux/types.h>9 ]. U5 _- w( K# ?, L0 h
- #include <linux/interrupt.h>2 E9 k$ ] T6 F! @# T2 Y7 }2 l
- #include <asm/io.h>
0 F4 |* N! R/ ~; U - #include <linux/moduleparam.h>
( s4 I3 O: L' n0 i - #include <linux/sysctl.h>( k" m' ]* ~" `; H; I- X, `
- #include <linux/mm.h>6 S! g$ `& u" E2 A/ Z
- #include <linux/dma-mapping.h>9 a; M4 K8 }8 f z
- + g% c! I4 p+ p, [
- #include <mach/memory.h># L* M4 a% d5 B% ~3 P
- #include <mach/hardware.h>- p. N7 i" j* Z( H% y0 k
- #include <mach/irqs.h>$ l1 {2 i% v7 h
- #include <asm/hardware/edma.h>5 ~' m) {) r9 O }8 e0 A, w
+ I0 d6 ~/ D4 W; g! T( N) u+ t$ z9 ^- #undef EDMA3_DEBUG/ i' s1 ? U. R
- /*#define EDMA3_DEBUG*/- x9 p$ B& x# _% n: G$ z
$ l3 x& T+ @7 _- #ifdef EDMA3_DEBUG3 Y d; ^) b i" Y9 T" D
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)+ s% C) {5 P: Z9 v9 Q
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
/ ]2 L# D+ N' K$ E! T: }+ t - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# O+ C8 |& `- c6 ^$ r2 ] - #else
; p# ?" {& l6 ]. \# n& H - #define DMA_PRINTK( x... )
' l' ~9 g+ a- X$ L. z - #define DMA_FN_IN' ?4 c7 W% t1 g
- #define DMA_FN_OUT
' X* @( T& G" s9 ?2 t' Z, J - #endif2 d0 T6 g$ r j2 i( Q- y4 q! m
, e. Y/ l: H4 x& T$ y& J4 V" S- e- #define MAX_DMA_TRANSFER_IN_BYTES (32768), @4 L) c% E# f2 q, `8 |: S; u6 L
- #define STATIC_SHIFT 3 V. |1 ~& R% l5 \ s& p
- #define TCINTEN_SHIFT 20; {1 Q% O0 c0 Q$ }, {& e) h
- #define ITCINTEN_SHIFT 21& B! y f7 q" G9 W. x% v; S K+ F
- #define TCCHEN_SHIFT 22( ^8 z$ Q" [( u. \
- #define ITCCHEN_SHIFT 23, w" q0 y& y0 ^$ e4 {0 T/ z
- : e ^) }7 }( k# `3 _8 N2 P# R
- static volatile int irqraised1 = 0;0 b- d$ U6 _% F* A7 ]
- static volatile int irqraised2 = 0;
' b2 s, k( |% f7 S
t+ g9 x: ?* Y- r& ?# I7 J6 m2 H3 ^- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 O9 \. E, o% V
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; ~, R' V+ ~, a7 [) V - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# F/ a" t, {/ g1 n$ I0 A# `% ~ - / o% w1 y. z2 ~2 j
- dma_addr_t dmaphyssrc1 = 0;* L' S q1 b1 R/ b/ Z7 z; k2 G+ s
- dma_addr_t dmaphyssrc2 = 0;
: ~1 f& C) Q& y2 Q$ W - dma_addr_t dmaphysdest1 = 0;
& m1 j( s, T; Y; w* p. M1 F% _ - dma_addr_t dmaphysdest2 = 0;
6 p1 S" R, X3 ]- Y3 r
. {' g+ i! g/ Y6 A. G% \- char *dmabufsrc1 = NULL;& G$ z% O: ]) M! C3 T3 f
- char *dmabufsrc2 = NULL;
/ Z5 s1 N1 B0 y. M. F/ D - char *dmabufdest1 = NULL;
/ Z8 R- k2 J/ u, |. u - char *dmabufdest2 = NULL;" l5 y+ m; c' v+ G, ~
6 U% R- C# @$ L1 E- static int acnt = 512;: o; G( t7 b7 b# ?
- static int bcnt = 8;- n; g! e+ a+ Y' F
- static int ccnt = 8;# e, v' E- u3 A$ ^2 B
- 8 T/ h( T" V3 L6 [: l7 f6 K+ X; S
- module_param(acnt, int, S_IRUGO);
8 c J/ y- u8 [: [ - module_param(bcnt, int, S_IRUGO);' d D" z' A4 M2 j
- module_param(ccnt, int, S_IRUGO);
复制代码
3 h# t* H% N" S/ Q* M1 F: i3 p/ {! i% t; r9 ]9 s
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) I0 z9 S9 E) ?6 g( Larm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" C" w3 `- k, b0 h n! j
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。" Q$ q8 }) p O9 [, Q3 K
* q0 ]1 p; D* W1 W" W6 c( T+ C
0 L: t1 {2 S3 a6 j9 S |
|