|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
$ V/ h o, W' \* \# Q/ t- [code]EDMA sample test application; y/ u; Q% e. T- X
- /*5 ]3 o& D) n4 h3 E$ o2 ^
- * edma_test.c
9 w* r1 ]* r% q- C - *
$ M C" L7 R. A/ \. M( X- X - * brief EDMA3 Test Application' L' ~( P$ m! o; M) N
- *% [- b( l( Q: {4 I4 L# O/ Q
- * This file contains EDMA3 Test code.: ?4 Z& h, W% y9 i4 ]( k
- *
( f! O2 H+ K2 t$ ?! t - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE. X' c8 c. N8 B& Z* S" n
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
8 B/ V( P2 X2 J: h: ~! D/ f' k% l* j - * TO CHANGE.
8 ~* ]+ a: B% X2 i - *$ v7 f4 N. }6 L$ C2 H* ?
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/* U0 X$ P( h: r
- *. Z2 o! ^8 \# z, u# _
- * This program is free software; you can redistribute it and/or
. k; d X2 O. A - * modify it under the terms of the GNU General Public License as8 Y! O& R7 t. D/ A# z
- * published by the Free Software Foundation version 2.2 A2 M0 T0 g9 G) j* G( V. i: Q
- */ L9 j |6 X- u$ Q+ w. x: K
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 J0 `3 @$ y( ^ |7 S: O - * kind, whether express or implied; without even the implied warranty! U' q$ ~8 O, r" P7 i
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ k7 o5 T$ k8 c+ W' p' u - * GNU General Public License for more details.4 ?( F0 J4 d% I
- */. D! E) b5 a1 f
7 w8 V1 _0 z6 O1 R- a: m- #include <linux/module.h>
5 s6 Z, v& b N' e- i h5 f - #include <linux/init.h>2 V! r0 X# A7 z6 d9 g$ T6 }
- #include <linux/errno.h>
" I1 R8 g1 ~/ O5 y - #include <linux/types.h>
8 P2 b7 d/ ~' `. F: F - #include <linux/interrupt.h>) \4 D1 R1 t! v/ c. A5 B1 R
- #include <asm/io.h>5 {2 q/ ]9 h! ]
- #include <linux/moduleparam.h>, [ R) Y% U( ]/ B; V
- #include <linux/sysctl.h>
! t+ v6 [' Q$ G1 F* r - #include <linux/mm.h>
3 D4 |: `1 V. x - #include <linux/dma-mapping.h>! Z, r. U- X4 z" W
- X9 P! y( O) B) ^0 |
- #include <mach/memory.h>$ H" l& U2 n9 l5 V! ~
- #include <mach/hardware.h>, _% U% G3 X- x; ]
- #include <mach/irqs.h>
* u" Y% u5 P8 d6 }. l0 P0 d - #include <asm/hardware/edma.h>
5 r9 C* v6 ?" T% {& I3 u - & e% |- h D7 ]& p5 W
- #undef EDMA3_DEBUG
; \6 G6 \7 ^$ g9 l9 A1 I - /*#define EDMA3_DEBUG*/4 C1 P& _4 T6 c
- " ?5 d: p" D* T4 m
- #ifdef EDMA3_DEBUG
3 z, P0 a6 r8 a4 {. G! D - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
+ q! f: F9 I6 A2 n9 v0 X7 ] - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 N, w1 E* ~7 m, Y1 x - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
, ]- ^# o- |- k( ?. T7 M d - #else" T8 e) H0 o# k1 W% M$ z2 u
- #define DMA_PRINTK( x... )
& Q4 r7 t6 P2 }& B& ^" g - #define DMA_FN_IN
$ ]+ T2 m0 T: Q. ^* g - #define DMA_FN_OUT
4 U2 h) Y7 E) R$ A+ u0 \ - #endif9 a$ M' i* L7 X" E% I; f8 f
- 5 }: E9 F5 j1 ?, W. A+ A3 Q
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 P( k, ~- h& B/ I! Z" H - #define STATIC_SHIFT 3
) q( S3 l f) n( X! d - #define TCINTEN_SHIFT 20
8 X V3 Z+ t% H& W- S1 C - #define ITCINTEN_SHIFT 213 F. q' C' {+ F/ |5 I- { C
- #define TCCHEN_SHIFT 22
1 S7 r& b) ]3 v+ ~: G - #define ITCCHEN_SHIFT 23" f C+ M+ B) h4 u& M$ c
- : b0 w" r3 z- K/ y1 _1 @2 d" m
- static volatile int irqraised1 = 0;2 j9 ?7 m, p& s( H, G$ G: E6 ^, }- {
- static volatile int irqraised2 = 0;
: T: r* s4 u& w9 W+ Z3 {. s2 N - 8 U" q; x$ V. O8 r1 x9 {6 B7 j; X
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; l6 a# z1 r! i; Y! P0 k
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 l2 ]" U2 p |* c
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" J& I, m# ?+ z: x7 A0 S5 R - ' {; \: w% j& ~ Z8 |8 M
- dma_addr_t dmaphyssrc1 = 0;+ m' }$ X9 n1 K! L! j2 B
- dma_addr_t dmaphyssrc2 = 0;+ } r! ?1 [2 U
- dma_addr_t dmaphysdest1 = 0;2 v, Z% w& ?9 g+ d. u
- dma_addr_t dmaphysdest2 = 0;
/ y* D9 @. o' }. W - - f& J( Z# J3 R
- char *dmabufsrc1 = NULL;
+ ?) f, \( T! D- f; S. a5 \2 |* V - char *dmabufsrc2 = NULL;
* |( }2 A# y; x - char *dmabufdest1 = NULL;
" ?) ^" h: z# X8 j! e. k; c - char *dmabufdest2 = NULL; d @3 e% u D9 i
- 6 v8 x d) a% I! K* V* G7 q4 f
- static int acnt = 512;# F% y9 N' a# `% @* D
- static int bcnt = 8;
* H" a0 d$ }" Q - static int ccnt = 8;; ]/ l' b7 r( W! T& L0 ? P- n4 I
* A" R9 F7 H- G( B. ]: C- module_param(acnt, int, S_IRUGO);
8 E/ D7 ?* @# K% r, | - module_param(bcnt, int, S_IRUGO);
- P' z$ w" J j$ ] - module_param(ccnt, int, S_IRUGO);
复制代码 7 h: ?3 R; Q' M+ A2 C* N
' c( i& O- v2 s" p0 c( ]
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
' b6 q, m3 @6 W2 ~- D: v( J1 j6 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
& h" Z2 ]5 n; s" q3 s8 Z 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 d: w% i5 K' J' x6 ?/ P
, C0 ~# r5 o8 I2 w/ n8 l
8 `( Z0 e R# b2 ?- \ |
|