|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 / ^2 u, ?8 q6 V7 ~
- [code]EDMA sample test application
1 ^$ S4 j8 Z6 S% R - /*0 o; G& i8 V& M. E
- * edma_test.c& `+ e$ k( m x4 Q3 R8 [' c
- *
7 Z; L8 Y ?2 N& Y% ]% l - * brief EDMA3 Test Application7 X0 T2 P" G4 U: I; L7 Y
- *' Y- S/ E y0 O2 l% g# E
- * This file contains EDMA3 Test code.
" }' h4 P# v, l7 f! Y( V - *; e7 P3 G+ e8 S
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE I% h% w% j& U" P* }0 M
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 m- ~: r" H6 l0 J- U9 ]
- * TO CHANGE.
0 u, l4 k) ]* ~' o- S - *
! }3 h+ F/ b- U4 [0 b6 O3 n - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/: x5 M% z# l; |* e! |
- */ c8 R5 J r( m( }
- * This program is free software; you can redistribute it and/or
|- o5 R" U; r, R L: i - * modify it under the terms of the GNU General Public License as* d3 y3 b8 C) M
- * published by the Free Software Foundation version 2., a% x2 S* e. c: X0 b- ^6 [5 W
- *
! f. E5 U7 [! z0 I! A6 _' q- Z - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
0 {$ z& L: [8 Z, U& `6 B( i - * kind, whether express or implied; without even the implied warranty& M1 b; N; v' A2 j1 L
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% ~5 V: {% w0 [# A" }# O3 v a) `+ K
- * GNU General Public License for more details.8 x* {& M8 Y8 R I9 s0 }
- */
9 d0 E* M1 p4 b3 H, I$ } - 4 S) c* `1 F2 r2 v( a: b" Y1 r
- #include <linux/module.h>
A+ }' f' w5 ]: w. V/ W - #include <linux/init.h>5 {% L8 K8 A5 D; U* R5 K
- #include <linux/errno.h>
# C- I/ B. n3 k, G/ O5 O - #include <linux/types.h>
. h2 L1 r0 I, D6 R# j - #include <linux/interrupt.h>
2 ^5 W7 o$ ?. o6 L - #include <asm/io.h>
+ a7 n- @( M% {4 r- z0 ?4 Z$ @ - #include <linux/moduleparam.h>
- D# S, D/ f0 ~: Z: V6 K - #include <linux/sysctl.h>3 d/ ^# P6 Q' ^" {, ~
- #include <linux/mm.h>
7 g! @3 i9 V2 ]/ }! K - #include <linux/dma-mapping.h>
, j# x& T- a& Y9 b( n
% s" w: _# _5 N. W! i' G/ |- #include <mach/memory.h>
% f2 E3 C+ d- U! G+ \# [ - #include <mach/hardware.h>
6 n, J& d& a4 @1 L9 b - #include <mach/irqs.h>
' n. O. u0 n4 g7 e1 g) q - #include <asm/hardware/edma.h>, c$ k& g+ G# s; X
6 @4 S% u, f: R6 b$ I- #undef EDMA3_DEBUG6 d" \/ X ]8 f- U9 F! Y& v
- /*#define EDMA3_DEBUG*/0 F7 s3 n& D$ X0 Z+ B% d1 k, w& N
/ Q5 B1 r) t3 b, _- #ifdef EDMA3_DEBUG
& |% p) K- ?1 o! r' W - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
# V. n9 @' i' r5 X$ J8 G - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
0 Z$ ]6 w C# o& C+ m* X; Q - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
9 ~4 C" d! _! B& a7 n: k2 @( v - #else
/ |. v" M$ g/ S6 `, V - #define DMA_PRINTK( x... )
& C& b' ~4 W! s - #define DMA_FN_IN
- x# S ?, p8 `( e7 l5 q - #define DMA_FN_OUT# \* m3 _, u( e7 U- R
- #endif/ g( m6 f) T7 v( H( p/ r# b
% A/ [1 s0 u& G9 P$ A$ f- #define MAX_DMA_TRANSFER_IN_BYTES (32768)8 G" z' M) Y) Z& T2 W
- #define STATIC_SHIFT 3* v' q" B' _( R* H" L Z; K7 d! W
- #define TCINTEN_SHIFT 20
! r- e2 p: |6 B% ~$ K - #define ITCINTEN_SHIFT 219 y: g/ D6 u, c, `8 C
- #define TCCHEN_SHIFT 22+ H2 E8 s3 S. }4 {, t
- #define ITCCHEN_SHIFT 23
# k, n/ G' D J. S
( _; [( r! ]4 R- static volatile int irqraised1 = 0;
/ _& n# j( k8 ~& N* W7 u - static volatile int irqraised2 = 0;: w: D; n0 y4 _! d1 c; V+ W8 {9 n
- ) ^) l9 {4 m1 s# n, w5 x4 }
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" K, n) h% B/ }. X; c - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 v4 U: x+ o( B2 k - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ [. ?# G& m; N0 H! @
8 c0 b/ D' R* T, Y+ k8 l0 Z+ T- dma_addr_t dmaphyssrc1 = 0;) c: ]( b$ B/ k2 S) w% ~/ N [; W# K
- dma_addr_t dmaphyssrc2 = 0;( f/ Z, p/ O5 \/ C6 y; x, {
- dma_addr_t dmaphysdest1 = 0;5 ]1 t/ }" c9 x4 ~- m$ e
- dma_addr_t dmaphysdest2 = 0;+ g2 W- n! R# A3 M. g1 L6 a
- 5 a& Q# B+ W5 T- S! h
- char *dmabufsrc1 = NULL;
) D) F- S+ r7 s# ^1 {( h - char *dmabufsrc2 = NULL;
+ {: ` g6 `: n - char *dmabufdest1 = NULL;
/ c1 j+ r: g- K. M5 V( a- ^ - char *dmabufdest2 = NULL;0 P( t: e: N9 v8 ?' u
- # @/ d6 X3 T) j9 W# C
- static int acnt = 512;
z2 N1 M0 J5 H( g - static int bcnt = 8;2 p6 X( A; p9 a& d' p% W
- static int ccnt = 8;
3 W# M3 H/ t) x$ H+ j5 }# B+ R# A6 \7 {
/ M ]' V% e- d+ v- module_param(acnt, int, S_IRUGO);* e6 j% m: _, g2 v. l* }
- module_param(bcnt, int, S_IRUGO);
9 `& L. ~% K s& F6 e - module_param(ccnt, int, S_IRUGO);
复制代码
8 W% \ U& I" u) P2 D. p) `8 @6 \
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
* J S0 v/ w0 `) Iarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" t2 Z- n. v# j. S5 Y' O0 P
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。$ d8 A' c# P6 W9 F
" f8 x: O% K9 R* J
, u6 w# Q0 E5 O, n7 t* k
|
|