|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% q$ S; u7 E. j% z- [code]EDMA sample test application
. g6 N* d8 t/ y: V3 V5 r. R - /*
& d% m2 S7 ]% w. x; k/ X - * edma_test.c
9 I0 Q; k. X7 H) m* q. _% X - *5 Z; G# J% R0 ~! X; \0 j
- * brief EDMA3 Test Application
' @# ] i9 F$ P. _ - *) V0 R( J# l5 U; r& C
- * This file contains EDMA3 Test code.1 X7 c& V% V- @! I$ m# e
- *
4 E% w, d& z$ m$ _) ~8 { G9 x5 ^0 V - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 L2 V8 c" _: H3 I - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT# R& V- y4 M3 w* {9 N0 M3 @
- * TO CHANGE.
8 V7 ]' B+ }7 B# l5 ]8 Y - *, V& x; r# @% B: v' F
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/4 o. ~' Q- h8 I( z6 b0 [9 \1 [
- *3 E$ B- |6 d5 x( {9 s4 N
- * This program is free software; you can redistribute it and/or
0 |+ V' @( H9 f/ ~" g8 f - * modify it under the terms of the GNU General Public License as
s2 f$ g. V( H; W r - * published by the Free Software Foundation version 2.
- H+ B0 p) x3 \ - *
+ S- s; L" s9 D% k - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
' Z6 Z! W$ R# v. O# ^( @ - * kind, whether express or implied; without even the implied warranty) `! v) d2 [) I( |* m6 J; {* Z
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4 [) u! }$ G9 x# y! B& [6 O# B+ s - * GNU General Public License for more details.) `% \' X P, l( d2 k* p
- */' P' Y0 X/ o/ Y1 p, I
( }7 p/ g# Q2 Q6 R- #include <linux/module.h>
" S1 N" N( h, U( L$ i - #include <linux/init.h>- c7 z/ b+ x" w
- #include <linux/errno.h>
/ ?7 }+ L1 J% D$ z9 a - #include <linux/types.h>
6 }; E/ j0 e N8 R Z+ P# M - #include <linux/interrupt.h>" t8 F4 l4 w4 C7 j( |7 U
- #include <asm/io.h>) `; I& H! {9 `
- #include <linux/moduleparam.h>- J- c8 G$ |8 p2 T) P/ s
- #include <linux/sysctl.h>
9 L4 B& [- x: }- a* Z" y$ @/ p0 | - #include <linux/mm.h>
7 i2 Z7 u( M# B2 h3 o0 ?- p - #include <linux/dma-mapping.h> l! B& A5 T+ N( }% H
6 ~5 |( G& v7 t9 s: M% C: ?7 C' L- #include <mach/memory.h>! X1 h; s. l1 u4 i# K
- #include <mach/hardware.h>
( n' j! H2 w' B$ u - #include <mach/irqs.h>
w% d5 U3 ], {7 b+ ^ Y7 F# R - #include <asm/hardware/edma.h>
5 I* e5 V* n7 f# B$ _7 y l - # l3 t. n0 J2 F7 w! s7 K
- #undef EDMA3_DEBUG
7 c8 e6 l; e% [2 U( M - /*#define EDMA3_DEBUG*/& K0 D6 S1 K8 W8 \# i. d+ g0 O- \ u
- 5 [! x. g" J" G0 L4 d0 t
- #ifdef EDMA3_DEBUG
; d* N' Z) R; h6 ~, s( ^ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
& ^/ { s2 G! ]& K6 e# g3 X - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 T5 F' E7 A1 R' k3 C& Q) k - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! A: _& E8 O7 ^4 T, r
- #else
2 P2 J/ {2 F. M8 I/ ~ - #define DMA_PRINTK( x... ): {8 W! @4 `, n- J# i' ?
- #define DMA_FN_IN
% y8 _0 ^. {' D - #define DMA_FN_OUT/ J7 v# m* g/ x, Q$ Z
- #endif4 g5 `, \( r+ V O5 F9 y! H
* h3 p! x* U- n. g( T- k/ m) n- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
) w8 Y* h- B) g0 v. ^( M2 G9 X8 Z - #define STATIC_SHIFT 3+ z0 N/ \3 K6 ]5 y S0 U; i+ L
- #define TCINTEN_SHIFT 20
" q* U" K3 |0 w# I! S; z - #define ITCINTEN_SHIFT 21
( }! |+ B/ B9 p, q' f+ v - #define TCCHEN_SHIFT 22% E% h" \3 {5 }8 Z$ A. k% T: y2 m
- #define ITCCHEN_SHIFT 23
2 |/ o6 z N& a i7 M- _
, B* u2 A8 Y% X$ ?% u9 p; A- static volatile int irqraised1 = 0;% H7 Q6 [; A6 [, U- }
- static volatile int irqraised2 = 0;8 j2 J0 u+ K- K+ e3 G3 Y
- , P! K( O& j* D( `
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% _% J* y' I( y0 R1 b- K8 D! K
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; |$ U' J9 P8 z$ f8 j7 z: { i
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: d. B$ t; O, B6 P2 e
5 @+ @6 ~. z: J- U( H5 I( K- dma_addr_t dmaphyssrc1 = 0;
, q/ g: d: r* q4 y$ i, h5 Q- D - dma_addr_t dmaphyssrc2 = 0;9 L: s6 l6 S$ T* Y5 o
- dma_addr_t dmaphysdest1 = 0;) p$ T) u! e# A2 a# N8 r1 k
- dma_addr_t dmaphysdest2 = 0;
' p$ g7 ~9 z* Y0 e - 4 U& s* n. i( }
- char *dmabufsrc1 = NULL;/ `) x( e5 V/ T& K3 g g7 u
- char *dmabufsrc2 = NULL;
+ @& V3 C! c" [ - char *dmabufdest1 = NULL;
+ V$ Z" F6 [! Q - char *dmabufdest2 = NULL;, w, p) d0 y1 r6 V6 o
- # m/ j ]( h$ l! x* Z+ W
- static int acnt = 512;
3 y% z6 E1 }" c0 ?* N! ^# T - static int bcnt = 8;- {& W2 N. {' C
- static int ccnt = 8;
' F A( ?' `* ]! e/ b1 w% v- p: N% y - * p5 t! z6 d& A9 t# `4 I& K
- module_param(acnt, int, S_IRUGO);) \# O# `7 A2 S
- module_param(bcnt, int, S_IRUGO);
0 Y" r }9 u7 C& C6 L1 q - module_param(ccnt, int, S_IRUGO);
复制代码
/ k M$ e# ~, M. g
# e# k& v' ~0 J2 \" K( R' w 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
' x6 b& I6 K) @% Z' [arm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
) M( B. K) [- z/ I& ^0 {; A; ? 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。/ l3 r+ J. A9 O# } P0 i7 [
0 @( j: H$ r9 _( K
9 J' k# L: T& x' |
|
|