|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 H- w8 G5 G7 ~) a) w( ^- q* o- [code]EDMA sample test application* O2 `" U. ?$ w8 P
- /*$ B8 K" g/ Q% V1 c& j+ j. n
- * edma_test.c
# A. G2 D9 e$ t2 E. j - *
) d S9 d, q) K: a# V% z4 X - * brief EDMA3 Test Application
( q/ k0 ^- S0 m% a - *; g+ W; M. n& x0 l9 I
- * This file contains EDMA3 Test code.
$ K5 z% d3 K* ?$ Q$ G. a$ X* i& A1 k - *0 {+ C$ @; J+ h. ~! g
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
) i/ S5 v$ W. `& ] - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT- i. s4 y! S! z% m
- * TO CHANGE.# w1 W$ d3 w$ `
- *2 J8 ]- Y% s. O, n5 X+ w! I
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# U. R0 i9 c! E9 U2 g; c* D* Z
- *
, m6 k i. Q+ H h) h+ l } - * This program is free software; you can redistribute it and/or3 ~5 P _- s2 G2 `- C
- * modify it under the terms of the GNU General Public License as
% P' @% f6 b; C; F! O - * published by the Free Software Foundation version 2./ q Q( f6 t0 R& C0 D
- *% \0 y& M- I, k1 e" S% p0 i
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any* L `* k$ w, |; C
- * kind, whether express or implied; without even the implied warranty7 d( l7 k& J7 {+ W/ S' _! X
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the! w) v) {& v% ^" u4 z# G0 |
- * GNU General Public License for more details.# A z+ r( ^4 `( m! H
- */9 h+ W' `( D0 h0 E" S4 }) E) p
- ! |% R& I& b9 p% i5 _
- #include <linux/module.h>
2 Z! s' E$ k; `- ~% C - #include <linux/init.h>7 E0 y9 z/ U, n: s1 A3 w* B* a2 a V
- #include <linux/errno.h>
5 V! \! v6 R, L3 E3 A - #include <linux/types.h>! E2 f# Y+ v z. W0 X. T
- #include <linux/interrupt.h>) W% q ~+ \; q. z; |$ X
- #include <asm/io.h>( x0 o; }! @ S' ]/ m" Q
- #include <linux/moduleparam.h>& B. r8 r( _# J0 c! q2 s/ }- j
- #include <linux/sysctl.h>
( M; g& e" i* c$ p! J. b1 q - #include <linux/mm.h>6 ~. B% `& u, s3 Q' M" x1 `
- #include <linux/dma-mapping.h>0 w+ E- h5 ^- |0 V
! d8 e1 K' n/ u+ L8 Y7 [: n- #include <mach/memory.h>6 m8 Y! }5 ^+ Z. e* V
- #include <mach/hardware.h>( }& l1 Y, o, z; h2 q
- #include <mach/irqs.h>
7 R: T4 p$ J& i* y7 f - #include <asm/hardware/edma.h>
. Y# G' _9 I7 Q - 6 p; `5 ^0 i$ w! a
- #undef EDMA3_DEBUG
X6 t% x' S7 r/ n - /*#define EDMA3_DEBUG*/ `; v9 u+ u4 Y; _" d
7 `' d. ~5 a: H6 [- #ifdef EDMA3_DEBUG9 t1 y. u- ^5 O8 _( }& h
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
( c; F- p5 r) @3 L1 }6 D - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 }' H: o; l( j) P - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# f, r" A2 t7 E/ y0 |+ X - #else
3 V2 V$ w8 W8 P! F. X: b - #define DMA_PRINTK( x... )
% z2 I* I* N K8 R: @2 s - #define DMA_FN_IN
( X$ d( \9 h D" w/ N# v - #define DMA_FN_OUT6 ~4 H4 k- s0 J! L$ n, v" Q, e0 X
- #endif
7 a I; n* c+ F' m! A- U! C
; o. ]3 z6 \! G# n! m- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
% x: y' d( ?1 F. r( } - #define STATIC_SHIFT 3
8 p0 o4 }2 @5 Q' P$ w: e; a0 t/ @ - #define TCINTEN_SHIFT 20! Z9 ~3 H# U& n' X
- #define ITCINTEN_SHIFT 21$ v5 X2 Z. Z1 T# O) P
- #define TCCHEN_SHIFT 22, Y0 v5 O* i1 }7 I% t
- #define ITCCHEN_SHIFT 23
5 d( E" q- X7 O) O - 4 n6 K( c8 ~; ?9 o
- static volatile int irqraised1 = 0;, F% y" G4 Q3 q" L% m6 e
- static volatile int irqraised2 = 0;
/ O2 n; S+ B( b! w - ; v' w% Y9 @1 L) O* p3 D+ r
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; I$ q. D% F. B2 H; D - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 T6 h2 p+ N. c, M" { - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 l% e7 k! {1 {" y5 L6 e - - S' h$ e# V9 N
- dma_addr_t dmaphyssrc1 = 0;# R+ N! B3 u$ b! Q1 f3 E
- dma_addr_t dmaphyssrc2 = 0;
' p9 j4 \3 k; H - dma_addr_t dmaphysdest1 = 0;- f9 z& R$ I. e+ F$ p9 I& E
- dma_addr_t dmaphysdest2 = 0;1 X& D/ w# x7 Y$ ^7 ^! C _
- 1 p8 E( [' j) }3 l3 i" L4 Y
- char *dmabufsrc1 = NULL;
7 H" h8 ?5 ~4 t9 C# S - char *dmabufsrc2 = NULL;
0 m8 s; R6 M! [* j+ n* r - char *dmabufdest1 = NULL;
3 H& c5 g' z* {" F& Q - char *dmabufdest2 = NULL;
" P$ v7 h: F; s1 k/ @ - + a R+ J6 M- e; c1 s3 Q3 z
- static int acnt = 512;
3 D' @9 q$ V1 W% z - static int bcnt = 8;' f, |! s- U8 h# p2 ?
- static int ccnt = 8;# i L$ V/ @: Y }4 u
% p# Z' R- T3 \; i! Q. H, J- module_param(acnt, int, S_IRUGO);
* A* ^5 F0 k. v( M - module_param(bcnt, int, S_IRUGO);8 {; P! ^% d' j, p/ ]: N. @
- module_param(ccnt, int, S_IRUGO);
复制代码
8 V* t# i$ | ]" Y6 p# _! H( f- ^
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
# G) w1 D" p& g1 K/ uarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
$ e) {0 f$ Q1 x, v 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。& }" ?, Q6 H, K, h3 A! ^
( u/ F" `. D) O. u9 d% a
3 d. b3 `, o6 W1 c
|
|