|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, {$ z; }$ f6 z$ I+ g0 F. a5 u6 S. b- [code]EDMA sample test application5 n W1 I8 x8 R0 G7 W
- /*
; {& Y% |# D9 v - * edma_test.c4 \1 Q4 D8 @( `. P
- *0 D( C3 |) x' G) x
- * brief EDMA3 Test Application) ?# i% Q; [8 y( b
- *
. _4 J6 t* K, o2 [! E - * This file contains EDMA3 Test code.( j8 j; N3 F0 B# X
- *. J& S" y- Y/ m+ e& m! m( p! F
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
' J O& {( F% L5 m# ~ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 B J' f& B; N7 I* t1 M8 Y - * TO CHANGE. S& I) s9 ~; C$ n9 M
- *" m7 ], i5 V( G, ]
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/1 m7 z; O# \( R+ J/ `
- *& n/ L8 {0 Y2 x
- * This program is free software; you can redistribute it and/or
. U9 h6 R2 t+ [, z/ F - * modify it under the terms of the GNU General Public License as
9 o% L$ ~( \3 w5 Y: y; b - * published by the Free Software Foundation version 2. |/ S1 X0 o! A* ]
- *
X0 r' H& n% ^% u, k - * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 @# o2 n! V, y w
- * kind, whether express or implied; without even the implied warranty
% I" h% c! V+ ^. u4 _& p - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the7 G2 \& q6 @/ [! B1 Y( Q+ f
- * GNU General Public License for more details.
) n9 Q5 y3 R% H5 s B6 H/ X - */
( Q) V, A% a [0 @% u9 ~ - 2 k' X: X! I# G. k
- #include <linux/module.h>! n. j& ?4 v2 \
- #include <linux/init.h>- s, [4 W l1 f" Z& b: \4 x
- #include <linux/errno.h>
5 l5 E# `8 m, d, J6 @ - #include <linux/types.h>& k" ^% k! X" k8 Z) R, J
- #include <linux/interrupt.h>
8 [0 t- g) P: E& X - #include <asm/io.h>: B& r# h* {7 k+ N+ U; I$ [
- #include <linux/moduleparam.h>6 L( l% D, q4 E
- #include <linux/sysctl.h>$ g0 v( t7 B, Q2 K% h1 P
- #include <linux/mm.h>8 [0 w4 I4 f, k9 j3 q$ F! s6 K4 O
- #include <linux/dma-mapping.h>
3 ?( r7 L" x4 V; M9 C0 c
5 Z v4 |# }2 B% Y- #include <mach/memory.h>3 t& {( N3 y& y$ B
- #include <mach/hardware.h>
( x; c* |' I; G - #include <mach/irqs.h>
1 b0 R+ d' f* a9 p/ u" S* @: M1 S - #include <asm/hardware/edma.h>' x/ H. X8 a- g. p$ G/ T
6 r0 m$ T' m2 H* K# ?- #undef EDMA3_DEBUG
0 T; k Q- d4 t6 L$ M - /*#define EDMA3_DEBUG*/! s( B7 x5 d4 w4 O% b& m
- 4 K6 k" [* x8 V* z" v8 ~
- #ifdef EDMA3_DEBUG% ^0 K2 _4 v! U
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
% T# {4 u6 [3 c - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
+ G% b' H- c$ t - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 [7 }% u$ c* e* r
- #else
* n. c7 N( f# ]& A1 |0 w - #define DMA_PRINTK( x... )+ z6 N p6 }0 l% B
- #define DMA_FN_IN8 Z7 H# s4 o0 r, i2 |% [7 C; Y8 ~
- #define DMA_FN_OUT% d% Y& e( ?4 M7 V4 k
- #endif- h3 Y7 T5 s; l. x
. I: q' ]( x& ~0 }; I- #define MAX_DMA_TRANSFER_IN_BYTES (32768)2 G" z2 y' M3 m7 S4 a6 v4 t- I
- #define STATIC_SHIFT 3
1 w3 k: C8 D; J* v - #define TCINTEN_SHIFT 204 }; m( U% y0 _4 Z2 U
- #define ITCINTEN_SHIFT 21
% A/ t# ]# o* G! N: z5 u - #define TCCHEN_SHIFT 22+ p0 Y) r. t# K d; ^; P+ U' h
- #define ITCCHEN_SHIFT 231 r C9 x2 y1 i5 H
: a0 K" L2 w5 _" ]- static volatile int irqraised1 = 0;
; P6 U' r; k. h* W3 [' F1 Y - static volatile int irqraised2 = 0;+ o+ X! T- E1 K/ i" ~9 X8 G
- N$ E0 E1 B7 F- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 A8 M4 M6 }) Y5 x! E
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, [, J# n3 [; p+ `- D( K - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" I0 k! [: Q/ a# X" h' R
* X, I3 Q7 P9 ^% @8 p, o- dma_addr_t dmaphyssrc1 = 0;
6 G0 ^1 Y6 \1 X- [0 I4 }4 ]0 Y - dma_addr_t dmaphyssrc2 = 0;- g0 S% u s, V8 c' F2 @; z
- dma_addr_t dmaphysdest1 = 0;
7 \4 i$ x8 m F/ Q5 P8 v2 \ - dma_addr_t dmaphysdest2 = 0;8 O8 n% D4 \' J
- 2 P' f& J8 m5 O
- char *dmabufsrc1 = NULL;
9 G( f( q) m0 n - char *dmabufsrc2 = NULL;( |' c- ~2 {" m0 M- Y2 `1 A
- char *dmabufdest1 = NULL;
; R5 S6 l3 q) u" W7 e - char *dmabufdest2 = NULL;* l; ?) B5 C1 q9 Z$ w( ]9 h% A: {
* _5 t8 j2 x" o" ]3 a* V1 f- static int acnt = 512;2 M" u3 C, o+ y: z" c h7 b1 Y
- static int bcnt = 8;
. E3 v5 o1 }/ Y) d5 E - static int ccnt = 8;7 K/ u) U+ ?! S$ x7 H; @. S
- 7 |) j2 J/ w, |) R/ g T" O
- module_param(acnt, int, S_IRUGO);
" d' } w" G7 t3 d - module_param(bcnt, int, S_IRUGO);2 c0 d/ w2 Z! Y! M7 v+ @, B J# N
- module_param(ccnt, int, S_IRUGO);
复制代码
" k4 U) ]. T/ v& r" V1 G7 E5 W6 f* D1 G
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& c R V- V# J( `1 L) varm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
4 G& r# w/ c, p0 Y, I6 x9 |8 p6 n 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
8 l, y& }- A$ m& C4 s* v6 p, R. ~8 ^
6 G& K- a' w7 f- r8 `% q
|
|