|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ) g- |" D$ Q h
- [code]EDMA sample test application
0 ~ x* N* T6 E! z2 b/ @' n - /*
4 X5 c/ h/ A- r, _& O - * edma_test.c
3 K6 c" k* O9 v! }8 L( p. O - *
: K+ K4 m6 g3 a" C - * brief EDMA3 Test Application
0 o7 D% @. R8 C4 b) Y1 y7 ^; }& b [ - *
$ ~, T3 ^: @( I, T! H - * This file contains EDMA3 Test code.% w/ R6 g% Z; m2 p0 K# `$ N
- *
7 j/ `) q2 t9 L( W4 S6 u% t - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE$ I& z! c9 p5 M" G) `* y
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
! s& k; z( G W8 R# g- ] P/ ] - * TO CHANGE.5 v: z3 A+ \7 X3 j
- ** ~0 ^! u# \5 D# q6 [# V+ _
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# Z, n8 K# D- E1 f! q5 k @
- *+ o4 W6 n$ `6 ]6 O" [& Z& Z7 e; g
- * This program is free software; you can redistribute it and/or
, z/ S) k' ^( A: J+ n" N5 V; x - * modify it under the terms of the GNU General Public License as
1 @: Y4 }) k* l1 E- }- b$ ? - * published by the Free Software Foundation version 2.
8 q$ [2 Q8 C* y+ y - *
) ?& r) O; _7 C - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
3 ?; |$ m+ \0 I1 d' @( I - * kind, whether express or implied; without even the implied warranty
# P% [' q% O6 U0 c: v+ ~. _ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& H$ M9 i& l8 N$ z. j - * GNU General Public License for more details.& _3 N* t7 G' G: e0 k
- */. V" a9 ]# Z4 P
# B' F8 [/ N! h! ?1 | @. D3 S- #include <linux/module.h>
$ x( d" j7 I6 J- F$ s) c% M - #include <linux/init.h>
' [1 w8 k1 T; l* E4 J - #include <linux/errno.h>! B) L% M4 C! L; t* ]
- #include <linux/types.h>
, l7 p4 d- r! {* y0 ^0 r4 v - #include <linux/interrupt.h>
, N. }) P0 t$ M! C* o - #include <asm/io.h>
5 U4 v: a' d* y. K. v - #include <linux/moduleparam.h>
8 ^: B# {. v# L+ P) [6 ? - #include <linux/sysctl.h>2 g3 w( r9 H6 u' W( f. G
- #include <linux/mm.h>
1 k Y0 a/ j7 M3 }9 a - #include <linux/dma-mapping.h>
# N; K, w% m4 A7 X - & t. K! r# l) V3 x1 w8 o, q- _
- #include <mach/memory.h>
7 l5 P- Q. B( z8 g& E# U8 U: X - #include <mach/hardware.h>
+ ]0 P9 D9 w. z; e; F - #include <mach/irqs.h>
% R" @2 i$ A5 H# s( P! g% N - #include <asm/hardware/edma.h> ]2 z; j' k8 v ?
- 8 h: E* Z+ Q v' U7 O$ T; M0 @
- #undef EDMA3_DEBUG
3 j ~+ w! O3 A - /*#define EDMA3_DEBUG*/
' p' E4 D: Q( `8 a" X2 l* ^; W
1 v' R' c* H) [6 o2 P+ X; ]- #ifdef EDMA3_DEBUG8 d, y- l* P/ J' a' b) F; M
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
! ]3 A1 y9 z, T& H6 `& ?( n - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)# x: w5 E* _: m- N8 W9 n1 H8 Y1 N
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! @" @, Z9 }# R3 J: `" V
- #else0 ?3 q, p( f. a( v- c6 J
- #define DMA_PRINTK( x... )
. W3 y. V }# a# e' Q: k- N - #define DMA_FN_IN
$ Z5 n" Z* `7 [9 y1 L. ?' K3 Y f& Y - #define DMA_FN_OUT
' ~, N/ }; j- K5 Q- w - #endif
( y1 \, H' }3 n+ q% e T
. L: e7 w& \$ k" t- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
! W6 \% X. ^' R - #define STATIC_SHIFT 35 }" l: F o) D, X5 L, q# `3 h3 K
- #define TCINTEN_SHIFT 20
( U0 T# h6 O4 f - #define ITCINTEN_SHIFT 21
( I# y; W0 p- y" D3 q4 ]% P: @) c - #define TCCHEN_SHIFT 22
! E" n! y( p8 K$ M* E- F - #define ITCCHEN_SHIFT 23
/ h+ I7 n: t$ x* Z - 4 h. [4 e1 ?2 b
- static volatile int irqraised1 = 0;
. w* S$ O$ m' \1 Z0 x" T - static volatile int irqraised2 = 0;, d0 u) Q/ o% t
* f3 r+ \% M* @4 l0 \% H9 c( V! L, ^& j* F- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" n) I/ o! S# A, V9 Y5 \ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. S1 z' B0 P, D; T" G/ p2 N - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" Q1 d) H1 C8 w: [' W
- ' ^2 n$ y0 I: Y- L& @; _" z0 b
- dma_addr_t dmaphyssrc1 = 0;
1 q# ^+ Q% [) @) t- Z i6 S - dma_addr_t dmaphyssrc2 = 0;1 w# `6 u+ g; J2 A
- dma_addr_t dmaphysdest1 = 0;! y- t% M+ B; z5 h
- dma_addr_t dmaphysdest2 = 0;
! Q; @. k" g4 i! O' o# K( E
d9 Q4 a. j% E8 S& X$ |4 d% F- char *dmabufsrc1 = NULL;) M1 _. r* L% V3 z! A/ X2 u
- char *dmabufsrc2 = NULL;
" s1 {' M2 j0 ~' |9 w - char *dmabufdest1 = NULL;+ R0 o8 M) H, s% J4 n
- char *dmabufdest2 = NULL;2 ?, Y+ ?* T8 A4 X
- - ?) @# G; \6 q. S7 K
- static int acnt = 512;
6 F' x7 R7 c* E/ j# f - static int bcnt = 8;" V2 Z1 H; J1 K- A# }
- static int ccnt = 8;
) W5 F# o' K0 ~$ ]" c( C
? l% a: ]5 i# D. T- module_param(acnt, int, S_IRUGO);$ s; c3 g" N5 c$ h; C- X
- module_param(bcnt, int, S_IRUGO);
/ E# C; |! u6 d+ g: E - module_param(ccnt, int, S_IRUGO);
复制代码 , @9 p: R; V% Q- J4 Z) i
5 t" e3 t" ~( r+ ~. \7 ?8 J
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用; E9 u$ N0 P& b _* o1 n
arm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
& V" \; l( [/ N6 A2 M# L 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。9 ^$ i" v$ C# ~: P" V
! y8 ~5 S/ Z0 Z
( |& p6 g9 r0 X7 v! [7 ]; ?! g
|
|