|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
$ c' d; a2 T n9 k, c3 c, W) O. b+ R- [code]EDMA sample test application
, m' _8 z6 F- c3 O8 l; @ u+ D - /*$ K/ y* E% W( Z* r J/ v
- * edma_test.c% y5 Q/ M* a2 B( g6 r& Q
- *' k3 ^0 @0 a3 {
- * brief EDMA3 Test Application' _8 M) K) m1 m+ L. B3 G
- *: U; n2 }! h* D, F$ D* H
- * This file contains EDMA3 Test code.
@! x1 V/ _% J. m - *
* z$ v2 x# [) e7 [: M - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" ~% I2 f" w$ \
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
8 y* p$ B( [" Y - * TO CHANGE.' G, X. L a2 f- f7 `
- *% s9 h* _) D$ }3 G8 t' ]7 N4 I
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com// r5 s; G" |+ ?
- *
8 p6 b" J6 S. {$ v7 P - * This program is free software; you can redistribute it and/or
/ }6 _/ b+ K+ i4 a$ L+ k - * modify it under the terms of the GNU General Public License as' Z# ?: l9 A3 u& t# Y& l# z
- * published by the Free Software Foundation version 2.; m/ `5 }5 p5 g* g0 k) H
- *; R! k' @7 s1 h
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any0 E$ k. e$ u3 [) W1 Y
- * kind, whether express or implied; without even the implied warranty( @, [) L: X! G# B6 B+ V3 f, z. F
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% _7 M: t) N; o6 B - * GNU General Public License for more details.
0 `; K& r/ d- g% ?5 ~9 j$ h - */3 Z$ E+ P3 b- f3 U( V; h D
6 M* a4 r0 [9 @9 ]6 [- #include <linux/module.h>) u' R X' x: O) M
- #include <linux/init.h>3 i9 o$ G! v! X; ]2 p7 J& i
- #include <linux/errno.h>. a& G! d0 j2 w5 M. e; G
- #include <linux/types.h>1 i& |8 j; j$ m2 m& \* d. p8 `
- #include <linux/interrupt.h># ]2 [2 z; z1 m* x2 k
- #include <asm/io.h>2 Z- z( m4 D& ^6 [1 v! n
- #include <linux/moduleparam.h>/ G7 [$ ]* x1 e, q# m
- #include <linux/sysctl.h>& L( e' S& M) @
- #include <linux/mm.h>5 @, ^4 W; r: |
- #include <linux/dma-mapping.h>
+ }: [8 L H7 Z6 ?1 x
0 J" s. \& b9 A, V) ?. Q- #include <mach/memory.h>/ R8 E9 H/ s& A1 M4 w" x
- #include <mach/hardware.h>4 ?" S: w3 r& D7 p9 S+ }
- #include <mach/irqs.h>
( C& o( Q/ V' ?& s8 ]9 y - #include <asm/hardware/edma.h>
$ q; P( \2 L% ]! l/ |8 I - # I3 H3 }* x$ ^1 h* `
- #undef EDMA3_DEBUG+ M5 p* N3 n7 t; h; U, n+ h
- /*#define EDMA3_DEBUG*/; a, U4 q/ t, i" j, H
- 7 t- S9 L) K# U
- #ifdef EDMA3_DEBUG' Q/ g. Z7 j: L8 m( ^( O7 [
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)6 L; u1 L! L5 i+ S3 M
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): ^7 q! [* Y( i4 G+ H' w3 O7 C8 I# n
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)) B& _7 H5 r- n
- #else+ w' E- S7 i1 i) C; O- K5 H) U
- #define DMA_PRINTK( x... )" p1 d. A. h5 ^) z: X1 ?# G5 ]
- #define DMA_FN_IN# R* B: t+ h* Q2 G2 _, S7 q
- #define DMA_FN_OUT
8 K2 I4 T, q2 J8 @) p - #endif
) L1 l, C8 g3 i- |
8 a" ~8 o# C& J8 O- K- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: {9 D9 l" R- x" S* V, W. i# l - #define STATIC_SHIFT 3& G* o+ ^6 E0 t; z. `& X6 X
- #define TCINTEN_SHIFT 203 R h6 \& a$ ?1 ^( d Z: v7 i
- #define ITCINTEN_SHIFT 21+ Q+ W1 Q1 R% e7 h8 P
- #define TCCHEN_SHIFT 22% o# z" A# M6 A& w
- #define ITCCHEN_SHIFT 23
) R5 i3 S% w A% J - 6 D* `: Q: n: u; Z6 y# d
- static volatile int irqraised1 = 0;1 K& _2 I$ ?& c. `/ D) `& T
- static volatile int irqraised2 = 0;
* j& W, q0 n7 e' q - 5 Z/ f, E9 ]3 e. N6 z7 `% k
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( `! p. q* I! U- w1 g
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) b4 p8 @9 ^. _' _
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 ~2 w5 `3 @/ e& Y9 f
; F; i8 t7 O" r9 E. a- ~' }/ B3 W- dma_addr_t dmaphyssrc1 = 0;
3 M9 g) k9 }. e - dma_addr_t dmaphyssrc2 = 0;' [5 G0 Q' v1 O5 }4 O8 Y' }" e9 v
- dma_addr_t dmaphysdest1 = 0;
" m5 J( z: ~) K } - dma_addr_t dmaphysdest2 = 0;' a5 |2 m+ R6 ?8 l7 C$ F
4 p: V) e9 N/ L+ I! b" I3 _8 O. j4 s- char *dmabufsrc1 = NULL;
. t8 d$ t# s. U$ M, z% D - char *dmabufsrc2 = NULL;
6 B+ c9 q* r7 [& v - char *dmabufdest1 = NULL;
1 z. y P3 k4 ] - char *dmabufdest2 = NULL;' k. e# L/ D+ n) r4 j% [( v
- 7 X8 P/ Q& Z3 i d7 H% o
- static int acnt = 512;
2 `! S1 R& L' Z9 p6 y - static int bcnt = 8;
& f5 ]' A( Q/ r; D5 o - static int ccnt = 8;
- s+ m" D4 r* ?' [# Q. ^ - 1 V+ r0 m- {/ w! B( }
- module_param(acnt, int, S_IRUGO);
+ E1 G# R0 z' w0 | - module_param(bcnt, int, S_IRUGO);
; S0 Y4 W% H6 B* F) x1 P& [4 I: o - module_param(ccnt, int, S_IRUGO);
复制代码
5 }0 a, e2 w; S" V$ S- f6 C( J& T5 K+ W
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 L! M' f/ {. \ E/ a6 darm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
" k* W4 L+ g4 ?: o r 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
7 ?' P+ i4 @3 j& X+ U: j& e0 l2 ~" ~2 e$ G5 j- }& R* t& ?, n; ~0 L: D
; g+ t* P+ }! v# t+ Z9 m |
|