|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 b* M/ ~& ^+ O0 w, d- [code]EDMA sample test application
4 h. R& P# F0 {9 u1 X4 f7 g - /*
4 m) V: B/ h4 F( _; ? - * edma_test.c
; o9 Z$ d( z: H; q3 E0 e - *, Q5 r9 P8 p+ v. `) _ c
- * brief EDMA3 Test Application; I% _ u* X( }- ]; ?! J/ W# t
- *
6 C% Q. `, n9 ~) a- h - * This file contains EDMA3 Test code.
2 u7 ?% \- s. ^, |$ h+ U* g1 e - *- i7 ?5 F1 F5 z- G) S7 ?2 c
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE, a, x- I. e6 C9 h' ^9 F
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
, p% S I4 F. |# ~ - * TO CHANGE.
5 S4 ^6 b" w+ N2 z) }3 ? - *
" ^! r/ u% {& j' a - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/( Q4 O- V9 x1 n& u9 v# {9 f
- *& x/ O* Q) E6 Q) |0 m. O8 A
- * This program is free software; you can redistribute it and/or
6 S6 A- \3 R* M0 M% X4 H# I - * modify it under the terms of the GNU General Public License as% |; A- u; f1 x" a3 ^( Q
- * published by the Free Software Foundation version 2.: k6 _% g8 P5 Z, \
- *
. f( P* ^; M8 f' ~" q0 B - * This program is distributed "as is" WITHOUT ANY WARRANTY of any. E! Z+ E: A7 s% t8 r# y2 i
- * kind, whether express or implied; without even the implied warranty; U6 e$ i: K f, Z# v
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
. q* t+ v7 C- b" b$ K - * GNU General Public License for more details./ k$ p* ] }9 ]9 A! d' M" |
- */
" Y$ b# k( a5 S* u' k: A8 I8 m
, K2 ?( Y! E3 O) m' Q- #include <linux/module.h>
. T/ g* {2 ]/ Y" S - #include <linux/init.h>
7 {% K* Z0 M) g1 ^ - #include <linux/errno.h>
4 M, J& U$ {2 @) k - #include <linux/types.h>9 c; O: s# Y9 Y2 n) N' [3 r
- #include <linux/interrupt.h>
4 k5 l4 R E; |7 f! A$ x& E1 T - #include <asm/io.h>0 {, m' J: ^: f* X2 `2 Z5 x0 ]' _
- #include <linux/moduleparam.h>
# \9 d& [. \( Y2 I8 q" V$ \1 y - #include <linux/sysctl.h>8 ^0 I; r7 [) A: u- o: @
- #include <linux/mm.h>& O) e6 U3 [. w8 H
- #include <linux/dma-mapping.h>8 _ c# l9 b/ K8 ]2 f$ f
- Z* y) V2 e* a8 Z8 F7 O- #include <mach/memory.h>2 @" o1 v1 ~, Q2 B' t
- #include <mach/hardware.h>
- j* U. Z2 F. R' }; V5 t9 ` - #include <mach/irqs.h>" d1 `7 p6 d/ M; ^9 |8 Y
- #include <asm/hardware/edma.h>5 g# e: T* n" J: V) w( \+ a
- 3 H; L. [, \% A& W/ [
- #undef EDMA3_DEBUG
/ x' F4 J% Q- `7 D - /*#define EDMA3_DEBUG*/
' b5 d+ n/ `' m' @, i% `
. n0 S' `0 t% x, M8 N+ Y- #ifdef EDMA3_DEBUG9 H; a% N# y" Y6 v
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
8 r9 M m2 @9 ^: j; T/ s9 B - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__), q6 k$ k6 V1 N, d/ a5 K) V7 {. @
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
: c% k/ }1 m" ~! C/ Q - #else
0 M6 l) v9 A& y6 x }8 m5 N L - #define DMA_PRINTK( x... ) q% L# w' d' @
- #define DMA_FN_IN0 n4 r+ h7 `$ d! R+ ]
- #define DMA_FN_OUT5 @ }! i) J/ ?/ n. r2 w# f
- #endif
' `! x' I. R' s% d B: K7 c
1 D8 Y; \/ M7 J1 C: R- #define MAX_DMA_TRANSFER_IN_BYTES (32768)0 |* }0 C/ ]7 z4 v$ Z
- #define STATIC_SHIFT 3
: ` l! r+ G/ } I/ N - #define TCINTEN_SHIFT 20
6 ~) m5 ?) o G- v' A5 D! B - #define ITCINTEN_SHIFT 21
# C% y6 ~: \7 o: ?* t - #define TCCHEN_SHIFT 22
+ L5 R; Z. u s) Z0 t5 Q0 `2 o; M3 e Z+ L - #define ITCCHEN_SHIFT 23& C0 T" U4 Q4 E
- 9 a! h& r8 S* C! r
- static volatile int irqraised1 = 0;' _- Q* ]: h2 m5 }# D' w
- static volatile int irqraised2 = 0;% ]0 z9 y9 I3 X. y
: B6 \, j) E: J( F- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, d) }( K# K$ p6 \$ X# I" s: ? - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( j) H# Z0 P" Q& d - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) X& Q) ]9 Z9 h8 e& |
% i) h) l( C9 ?9 Y3 s. A- f' W- dma_addr_t dmaphyssrc1 = 0;
, Y$ G) S( @; t# ?: D9 T- p0 f - dma_addr_t dmaphyssrc2 = 0;
6 @; M0 c+ t2 a/ s* f - dma_addr_t dmaphysdest1 = 0;
; M0 N8 X0 y# K' Z' P$ c - dma_addr_t dmaphysdest2 = 0;
' y! [" n/ k6 x q) r - ; x2 u! E. H- R7 F; k9 |* h# M2 D8 ^% ?
- char *dmabufsrc1 = NULL;( K& Y. p/ V8 ^
- char *dmabufsrc2 = NULL;. t3 w& c: T$ ^8 W
- char *dmabufdest1 = NULL;
: y; Q2 w. m( w" T, \% A - char *dmabufdest2 = NULL;
7 Q$ T) f* Z& N8 A
" X1 o- n) J8 W# k1 I- static int acnt = 512;7 }: l& o* b+ _4 I
- static int bcnt = 8;, z* \$ m3 T& T% {* o9 Z2 X8 c
- static int ccnt = 8;5 z0 y# z' }" G. B' b" x
- ' R: D! S/ A8 z; M6 @! A
- module_param(acnt, int, S_IRUGO);. n$ S& q, |: X+ z# t# u: @8 L* \1 a
- module_param(bcnt, int, S_IRUGO);
9 [8 x7 k: [! ?2 |5 ?7 j - module_param(ccnt, int, S_IRUGO);
复制代码 $ N" `7 e. ~$ m' h3 o' p
0 ^$ B+ E S# B z4 t) z5 [* V- p% {- _ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ o0 J) _2 e8 X- g1 Q2 |7 `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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。& w+ q; l% f& H* q0 \3 U7 ^
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。* `9 P6 L& u6 h) ?: U& J
! ~" k# K$ U: Q; N- w1 |; X
# b' b8 V/ y' L( L) E |
|