|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( W6 U! l8 C" I; }) i B8 w- [code]EDMA sample test application
" G) ]) D3 q* H9 m - /*
+ Z/ r1 ]: P2 [! C2 o6 z7 [& \ - * edma_test.c
# q2 K; s: _$ O+ ~ @ - *
* L7 q# _) Q4 Q8 \2 G9 x - * brief EDMA3 Test Application
' b3 y& L1 b+ A8 S9 R0 ~) E - *& z" _- U! [' B3 F$ r" |
- * This file contains EDMA3 Test code. E$ K5 o$ B4 T; D- \, K
- *4 {2 W/ q5 P5 p( O1 W; F
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
( E0 L0 E1 g- S# G, r - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
! X1 ^1 q. k# q \- Y# U - * TO CHANGE.7 |* B1 [8 G. o9 w
- *
- U5 n. C0 R j/ f - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/1 K) r. Q& U% y! Y
- ** L6 Y( X$ {! X# T& j
- * This program is free software; you can redistribute it and/or
8 {* s2 r( ~( \) V6 j3 h; Y# E - * modify it under the terms of the GNU General Public License as
* y; I; S+ H! n* Q4 a6 { - * published by the Free Software Foundation version 2.
: ^4 f# Y1 h1 I0 s& h% h8 D; e$ q - *& t! g9 a6 H2 U+ p# M# R9 l) B
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- F) V% m- o# z8 l% @ - * kind, whether express or implied; without even the implied warranty; g& K' y0 _: j. t
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 w# v& T6 Q5 ]. {; l) G
- * GNU General Public License for more details.
. h1 b9 c' t9 q* q- {+ j - */
' \- }, M% T" I1 ?4 ?. z# H
$ j8 C$ \. w' w& n( c0 z- #include <linux/module.h>
: }) I$ x9 {0 |( | - #include <linux/init.h>3 B) E( N3 ]9 w( `3 c& d
- #include <linux/errno.h>3 z2 g9 b1 y" W- g
- #include <linux/types.h>9 N7 @) M Z- Z" w
- #include <linux/interrupt.h>; ?8 I# n( S6 A2 R9 H
- #include <asm/io.h>
+ w' I0 w. Z" v5 H3 f# L - #include <linux/moduleparam.h>" l5 I- Q, p; Z; D% I2 m
- #include <linux/sysctl.h>
% e1 H9 k& K; z7 x" a9 R6 h& U T# C - #include <linux/mm.h>; m" }2 Q! i2 ^
- #include <linux/dma-mapping.h>: U* z2 v* B8 N
6 |+ ^$ S4 c. ?1 i4 E+ |- #include <mach/memory.h>
+ A7 P; ` O9 |% K7 N0 y - #include <mach/hardware.h>
5 Q2 v' O* j( D' i, {, x - #include <mach/irqs.h>% h1 `3 b, b# v" `( f+ \1 z
- #include <asm/hardware/edma.h>+ V5 D, W8 C, z& \) `
" A% z8 |. I. i, g/ _) e) ~- #undef EDMA3_DEBUG; ]$ E; p5 p& z$ @8 Y! ?+ @
- /*#define EDMA3_DEBUG*/
: L8 U0 j4 f' R/ m Z - 2 Y; O, n8 m5 {/ z( f" E- w# } G
- #ifdef EDMA3_DEBUG
; F `! D/ s1 G8 [. k ` - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)8 b6 j) X) N( N. i$ ~5 J. m
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)( h! Q3 B. y! _
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__) a- u" D8 d- z- }
- #else
) ~ @* K( |0 e; u - #define DMA_PRINTK( x... )* K: `" A8 A0 T b' M( U
- #define DMA_FN_IN
, ~3 J6 l; E, q+ S/ ?+ }8 I7 x - #define DMA_FN_OUT! }$ Z0 c2 }. F& W. x
- #endif' _, T( z, Y4 k P
9 {9 v& j M! O. l- #define MAX_DMA_TRANSFER_IN_BYTES (32768)( S k; R; U- E8 r# {. K0 S
- #define STATIC_SHIFT 38 J3 _" ^; O6 Y3 O, E7 J" s# J( q$ H
- #define TCINTEN_SHIFT 20
: b; m1 N& b$ T4 v) }0 s - #define ITCINTEN_SHIFT 214 x. g& X" H3 S* b) I
- #define TCCHEN_SHIFT 22
7 H; b+ B% c+ a7 c5 V/ I8 e* t: f - #define ITCCHEN_SHIFT 230 x) J) H! V0 \
% B. U' c7 D7 X5 I- r- static volatile int irqraised1 = 0;
1 v+ J" d4 {8 Q* ~$ \ - static volatile int irqraised2 = 0;, A) F0 [2 s( }/ J. Z4 H1 |
9 |' Y5 {; N& i- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 Z# t9 k) J* y% h
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 O; X/ Q# \* C+ d
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 ?$ s' ]$ M) \* u
# j4 n4 n& j: r. c7 f/ `- `- dma_addr_t dmaphyssrc1 = 0;
6 n( W( b) p- r+ ^% Y) q - dma_addr_t dmaphyssrc2 = 0;* C8 y( e$ a5 u; N7 {
- dma_addr_t dmaphysdest1 = 0;! _ \1 S" U4 i) `: _; u9 E- J
- dma_addr_t dmaphysdest2 = 0;
2 s0 E8 {& B: K& N$ M
& \# l! q, d$ H4 j1 p. |0 H, ~3 E( u- char *dmabufsrc1 = NULL;
4 D! z' M) G9 M - char *dmabufsrc2 = NULL;6 ?6 G/ T* o" m2 @2 W: ^" ~7 o
- char *dmabufdest1 = NULL;+ n8 U; ^) w. D$ Q# L5 U9 j
- char *dmabufdest2 = NULL;4 @5 T/ V' h! L+ d4 j/ \* L2 q% L
- 2 m, J! Q0 n! R
- static int acnt = 512;0 {- s! S4 ?7 X/ m3 _
- static int bcnt = 8;! F8 E* n x A7 G
- static int ccnt = 8;/ a9 q) w8 v, ]# O' W! H; o
- ( i- t/ g9 P6 t8 b8 i9 ^ N
- module_param(acnt, int, S_IRUGO);
" g& V( C8 o) g1 m - module_param(bcnt, int, S_IRUGO);
$ e/ J8 p' w2 p* I e2 O+ e - module_param(ccnt, int, S_IRUGO);
复制代码 ! }# H$ w9 H d- o; k& B2 f
7 h/ z% e& x# y, h: h 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用8 q0 k' d; l$ q3 ^* W' ?
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
0 g) O, u5 g# Q9 i! Q 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。4 r! Z- ^5 J$ Q7 L) i8 e2 G
% y, H4 s; ^9 \" ?% {# g! S+ V( k7 l& b( t2 c7 }3 ~* N4 ]
|
|