|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 1 Z4 b3 K' z: v$ ]1 c
- [code]EDMA sample test application
% b9 ]% _5 D: w5 b5 F! k6 G% p$ U - /*( g% h8 l4 f8 l/ a
- * edma_test.c
& x: ^+ }4 S' \3 i& Q - *
F6 ]8 y6 b$ W! w' |+ Z2 V! X - * brief EDMA3 Test Application
0 \9 f- x4 {$ t' j7 I5 j+ n7 x6 r - *+ ~6 {- @1 a: [; R2 c3 \: T: s
- * This file contains EDMA3 Test code.8 U5 \3 y7 f" e' T
- *7 I" h! _/ O3 l6 K/ D" w4 ^
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( N8 Q" i) b- z
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT0 A0 k$ ]( M; L$ t: W
- * TO CHANGE.
" V: s( E2 `* f, h( \ - *
+ ?( A' O E- H1 X - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* V7 Y$ F7 |% t$ _5 n - *
% |4 A- f. W2 G/ n C$ e - * This program is free software; you can redistribute it and/or; v( U1 v* S, M- s- C0 t
- * modify it under the terms of the GNU General Public License as
9 D& ?3 b& { w c8 E - * published by the Free Software Foundation version 2.
( m8 h$ R8 \" U$ l% [9 m, h - *
1 ~# o& b# m4 t, R! a& f - * This program is distributed "as is" WITHOUT ANY WARRANTY of any! |/ E9 M+ B+ }+ E
- * kind, whether express or implied; without even the implied warranty& x& i! N q5 W. d) w
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
O) B% L/ j) a - * GNU General Public License for more details.
& H3 n# i( T: A" Y8 E- { - */
3 s5 ~3 d% f5 Z6 F6 x# X" h - - d" E* x% Z2 z9 E5 T& |1 \
- #include <linux/module.h>! J5 {" U ?# P: J% l1 d6 F
- #include <linux/init.h>
+ n' \$ G; j& R+ }+ ?. o - #include <linux/errno.h>
& h/ [( @% w# X. j - #include <linux/types.h>
' g6 u2 ?7 e) g- k- [* t4 A - #include <linux/interrupt.h>8 Z3 T3 p4 W9 v7 ?! U8 o
- #include <asm/io.h> K2 {& T* A4 |# K8 `/ V
- #include <linux/moduleparam.h>, a+ X1 W! I( |+ A. U1 b
- #include <linux/sysctl.h>% m+ N) S1 i2 `2 C1 R# M8 T
- #include <linux/mm.h>6 p$ K9 v0 d8 M. v9 W- S7 X
- #include <linux/dma-mapping.h>( i. o" P+ K) B$ x. J
& m* i% c! |2 g4 l$ u/ j. p: r" d- #include <mach/memory.h>( y/ b/ H7 H% U) s* ~# t
- #include <mach/hardware.h>
9 ]. n& s9 k9 \4 Y, ? c: N - #include <mach/irqs.h>1 Z `& V: H8 U- y8 l: C' Z8 e' v
- #include <asm/hardware/edma.h>
# C! U" O' f9 ?1 w$ v/ \+ N - ' M) Z b0 v' b
- #undef EDMA3_DEBUG
w% d8 {- l, _$ F2 J! O h1 ^+ p - /*#define EDMA3_DEBUG*/
( x/ D/ L% I' h - : x8 t6 Q6 l9 B, A! N2 x
- #ifdef EDMA3_DEBUG1 o+ {. O/ X: X# r( h' D
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)1 y& `: r/ r3 l Q) }
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
' A3 u9 n; z* j2 r: \- v - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)6 L! J- N; @# x8 Z" K$ }7 ?+ Y6 d
- #else
1 V, X3 ^5 g5 N8 { - #define DMA_PRINTK( x... )
+ \# @, L+ V8 u9 B( l" g% y - #define DMA_FN_IN
I; ?* I9 p% }" d# U/ _3 v - #define DMA_FN_OUT
) Y. F; `; o! l& S# k4 d# C! [8 z- ? - #endif
& s: |7 P1 H( d/ W
2 g. g# x, M1 k- #define MAX_DMA_TRANSFER_IN_BYTES (32768)2 t, S- Y9 K% ~; L% ]' q3 ]; ?$ u
- #define STATIC_SHIFT 3
, z# Z; U2 n! G' d" @) z - #define TCINTEN_SHIFT 20
p) U& M5 @ S$ k' R+ R0 x3 ] - #define ITCINTEN_SHIFT 21
x# w+ s& v5 u4 v - #define TCCHEN_SHIFT 22) X s4 ^" L( T0 w2 L
- #define ITCCHEN_SHIFT 232 k4 `) @5 C( n, [' u6 Z; a# O
0 g. E! j) J7 l5 z* ]- static volatile int irqraised1 = 0;" _2 Q# z# w; V% j
- static volatile int irqraised2 = 0;
% I" L. F+ Q: Y) H' `2 H y! x
" z8 }$ r: S) ?3 i/ `( e- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- g1 h5 y. A" U. s+ i) z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 H& P8 a, Q' D
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; b7 b7 _% j# u* D - 1 w+ ]1 B" t; R/ h/ w
- dma_addr_t dmaphyssrc1 = 0;
5 k) d* l$ p7 i4 X& y: e - dma_addr_t dmaphyssrc2 = 0;
' n2 f6 y% t& q - dma_addr_t dmaphysdest1 = 0;
# k5 A0 e( Z' j% `) _5 ^ - dma_addr_t dmaphysdest2 = 0;
7 j* A+ M$ M5 j7 s! D: h
, U6 O5 M) r. C) Y- char *dmabufsrc1 = NULL;
* H, P4 k8 {5 M - char *dmabufsrc2 = NULL;
+ S# u4 K5 h" f4 }0 u - char *dmabufdest1 = NULL;
4 T6 W; Y. p5 n - char *dmabufdest2 = NULL;. W1 r2 ^' c8 C& M
" S! M+ U6 s! N- static int acnt = 512;) d1 s% B9 k- A) U5 n+ j3 Z# u
- static int bcnt = 8;
( W- f( k5 \9 Y$ c+ r) | - static int ccnt = 8;
, Z. y8 U& U6 \( P% y( t4 U
( E/ U' ~5 ?( J5 I2 H6 y- module_param(acnt, int, S_IRUGO);
: |) m8 V; }, k; l" J+ ^5 M - module_param(bcnt, int, S_IRUGO);
, N/ V. y7 m! \- | E - module_param(ccnt, int, S_IRUGO);
复制代码 ) P3 f J. d m6 I+ I; @
4 v# r( F3 c! Z L! [ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! l9 h2 c% @" ] i3 ~+ Zarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
/ D9 S, q/ I5 ~) z" H) u ?& V" S5 p 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
0 y0 J# [. h7 A; f7 D" ]
1 y3 T0 x v4 V0 ~; f p+ e1 Y: Z- ]8 o# c7 c
|
|