|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 Y; H9 D% g7 _( g
- [code]EDMA sample test application
* ]9 ~$ x: S1 ~" [7 ^; n - /*
" Z5 \3 k( U1 {/ @' @2 s - * edma_test.c* H' y! x U( s& b9 W
- *# J3 p& S+ R$ ?7 m
- * brief EDMA3 Test Application8 m3 S; Q3 `: h7 O% r* ]
- *
" y+ \- E& w" R8 F; _ - * This file contains EDMA3 Test code.- J1 { \7 x* ?
- ** Y3 ?* p: h7 a5 U8 j5 I ~- g
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE+ R2 K* E9 E7 i8 l; v: k. c W8 _
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT4 Z- |) ^" }9 w
- * TO CHANGE.
6 u- b. D7 V9 }4 A5 d - *
' z, r) W! v1 U8 c% D - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 \5 V2 C/ s/ }- m - *' ?$ A" z( v& {! r! T4 H
- * This program is free software; you can redistribute it and/or
* a9 a6 i+ ?7 m# l0 ] - * modify it under the terms of the GNU General Public License as4 \/ y3 ]4 @+ J7 [0 p
- * published by the Free Software Foundation version 2.- H9 f* N( a" y$ w9 t
- *4 c! Y) E, \9 ^$ m! e
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
' r' p8 ] O1 R/ F; f - * kind, whether express or implied; without even the implied warranty
) w3 i3 \$ T1 P: O1 p) } - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7 @# H1 `- a$ A- g* b& b! R - * GNU General Public License for more details.1 [- s5 O$ `6 }5 [% e6 {+ s2 b
- */
. A" m7 D6 v$ p - , L3 D U/ v2 S/ q: G/ O
- #include <linux/module.h>
: p! N. t& j2 N; M - #include <linux/init.h>
3 Y8 ~, S+ v1 u- o7 i; o4 {. u- W - #include <linux/errno.h>
9 R" P; D; f" j$ ~ ^4 y8 o- ] - #include <linux/types.h>8 c! _3 b/ t, ~
- #include <linux/interrupt.h>
7 U1 r+ @+ [5 @7 {7 I - #include <asm/io.h>
/ D8 p# g& X0 f: l; {) F0 m D2 U( h - #include <linux/moduleparam.h>
# {/ H' ?$ h Z! x - #include <linux/sysctl.h>
6 s* q, u7 R8 O- w7 D - #include <linux/mm.h>- h4 D7 }+ `+ d+ W7 V
- #include <linux/dma-mapping.h>
5 K9 v: m4 \( d9 h2 _. P - 3 t( V7 ?2 a( @. j2 @
- #include <mach/memory.h># l% X4 {* M7 h w
- #include <mach/hardware.h>
: |3 h7 I" T4 o, a/ M8 R! }) |. R0 q7 j - #include <mach/irqs.h>
- ]! d4 @ M( e+ q - #include <asm/hardware/edma.h>
7 ^* K! y" k0 f$ K6 D- _( S
. b3 P5 p7 i8 ?; s- #undef EDMA3_DEBUG* ?7 ?. o$ y3 B8 f) |% U
- /*#define EDMA3_DEBUG*/3 ]. W0 t% q: u! z2 D" l* L
5 C8 T G) R- S' [5 a3 \& F- #ifdef EDMA3_DEBUG9 X5 R% i) x$ D: z7 K+ U! A3 {1 u
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
+ Y) k; f, t. O$ I: b7 n - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)- l) o( J2 f) y: a4 F. h# B
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
2 k g, {) E+ T7 Z* l - #else
! s W/ K% k: o6 B - #define DMA_PRINTK( x... )5 ?' a. m6 W& W& l
- #define DMA_FN_IN
4 ~7 |7 y9 v8 ~' o" v& x0 W* ~ - #define DMA_FN_OUT
' R4 K J0 F' p" I! @) @7 ~ N - #endif. S: a2 W1 `5 O) h- F b* f) v8 _
/ B8 {5 @& ^, T: h0 Q- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
v0 Q) n- j3 @0 v6 R) S - #define STATIC_SHIFT 3
; h4 t7 j6 {/ I+ h" X& |* r0 p. ~7 j - #define TCINTEN_SHIFT 20
/ F4 l) x; l6 h5 k$ t4 h9 [ - #define ITCINTEN_SHIFT 21& m5 \% A7 v7 I' ^6 \- t- C
- #define TCCHEN_SHIFT 22
% V, N3 y7 k3 d7 W0 A, S - #define ITCCHEN_SHIFT 23, X, n9 o3 {9 a" r* W$ t4 x
+ s/ V7 J" K4 G7 g, l5 r$ C6 O; K) M+ f- static volatile int irqraised1 = 0;3 i: z& y: I' j/ |9 v+ `
- static volatile int irqraised2 = 0;% Q- H r, n, v$ L- A
( Q. }3 e% D# f, t- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 t8 i1 y+ v A& }0 m9 _
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. z) O; C2 Q- @* t
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 _; O$ z+ A) u, s
7 R- O" C- r( j1 Y$ R# c- dma_addr_t dmaphyssrc1 = 0;5 {% P% o; c) t' ~
- dma_addr_t dmaphyssrc2 = 0;' a7 x# u2 N# t' i# N3 Q
- dma_addr_t dmaphysdest1 = 0;
8 W7 g1 t4 Z& Y# Y - dma_addr_t dmaphysdest2 = 0;
3 Y& R. n6 ]+ S" I - ! X- Q" S8 v: R* ?
- char *dmabufsrc1 = NULL;
. J; R! E5 H" M% D4 r) c - char *dmabufsrc2 = NULL;
+ W' n$ x, r& l* e - char *dmabufdest1 = NULL;! M4 h! t+ s4 z2 v4 H3 \8 I5 H6 Q1 K
- char *dmabufdest2 = NULL;( I; i' D6 A% S( w$ p" l6 h' z6 U
- - C' R: J1 f6 K
- static int acnt = 512;
7 U% ^2 P2 w: Z8 F5 g) Q5 p( {' f* C - static int bcnt = 8;
' I3 P/ O) |- D% ^& T0 I+ Q P7 _6 h - static int ccnt = 8;+ l7 H+ Q$ y7 `* h) t9 Y
- 0 r; V1 y- M% B8 I$ q, C9 J* M
- module_param(acnt, int, S_IRUGO);: J" r P5 D: A0 k7 j0 t
- module_param(bcnt, int, S_IRUGO);
{. ~5 b8 w# `0 g$ }6 T' h* o - module_param(ccnt, int, S_IRUGO);
复制代码 1 Y& `: s' J3 ~. V1 \5 `5 Y F
+ R: r3 S C5 }, u4 n
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
M$ X7 b/ _; ~: S' z2 L' sarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。: m) W/ w% H0 b" N! ~: j0 L1 S2 h
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。) E/ E+ J" z3 c) C9 r
2 d1 f0 X% J6 O" j
/ I! {' W1 @; Y; C! x |
|