|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; C" g6 K* M/ q' u0 D0 A- [code]EDMA sample test application
- W0 U& I6 Q' _ - /*
/ a! `" p. C2 M - * edma_test.c2 k2 j8 R5 c, o; J- C8 @" y
- *$ w+ |3 m. [% r: w0 x8 d* \8 q
- * brief EDMA3 Test Application; D# z. q. v A! s' g+ I0 N
- *
v5 u' Z* N; i- W, O0 g - * This file contains EDMA3 Test code.
. E2 W+ i, n9 l8 ~1 y& s - *6 m! B# d8 ]5 u. p7 b
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE* d! v" K8 @7 Q- L. F1 l! N
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT/ L% u! z9 s9 I" m7 Z1 b
- * TO CHANGE.
9 P' }( u; k# I' S1 O1 l - *; v. p' O* R8 R& T" N
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com// J- _( o" W$ \
- *
5 S) f* i( J, N( y - * This program is free software; you can redistribute it and/or3 \0 r% e$ O( q( a! n
- * modify it under the terms of the GNU General Public License as1 X: f9 g. @" R
- * published by the Free Software Foundation version 2.' e4 k7 J. L O: b
- *
1 p. N! H$ c6 l. J - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, s: [6 m. f# Q: F - * kind, whether express or implied; without even the implied warranty
9 \( F9 [% N8 L0 N) ^' O - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the6 u, e# `1 N4 Y$ b0 G1 ^1 L, O! }
- * GNU General Public License for more details.* ]# M% L4 |$ O! _
- */
/ s5 j0 \( D! r7 R! p - ; T; s) R+ U2 C- M
- #include <linux/module.h>
, v$ ]* ]8 e/ N* z2 k6 `7 P9 [ - #include <linux/init.h>+ N, N, N% X0 B/ [/ W# a
- #include <linux/errno.h>
6 E! g6 }$ d' Z( x - #include <linux/types.h>" C7 C X$ M: O# Q9 D4 @7 J7 ?
- #include <linux/interrupt.h>( \- ` ~8 ~! A+ H* Z& H
- #include <asm/io.h>
) r9 `% l3 j4 l* R4 | - #include <linux/moduleparam.h>6 D' m' Q" ]* u8 ~- t5 I2 g7 l6 o
- #include <linux/sysctl.h>' @4 I/ `4 i* P& x+ M8 e1 y! y
- #include <linux/mm.h>
6 v# u9 `5 S- }5 d0 m - #include <linux/dma-mapping.h>" B0 Z1 s9 |6 P
~3 ~+ t) I1 u- #include <mach/memory.h>
) L, C* k+ |4 Q - #include <mach/hardware.h>
+ O4 m% J& y2 L) _( F' ~ - #include <mach/irqs.h>) J6 U6 x( z' n
- #include <asm/hardware/edma.h>
8 E+ @! H" @1 ?) K* y5 u, @
' g; a% R; B, o- M2 R, f7 R; W- #undef EDMA3_DEBUG
2 q1 `' }1 Z7 u- I& F& p9 N0 h1 M6 i - /*#define EDMA3_DEBUG*/
/ C9 w# w5 w9 [7 d3 ` - $ h6 k% H" I. M8 n0 L8 K# j
- #ifdef EDMA3_DEBUG( w: b( K7 h; f4 _( U
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- L7 x" R$ E' {) P7 l5 D/ A. | - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)9 }$ g( q" l$ B" ^8 z* @: z7 j5 Q
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)' p, ]# d+ v; F6 z
- #else
6 v' o0 M' M0 r% E/ ^ - #define DMA_PRINTK( x... )
, A6 w1 o" Y3 W1 w9 i - #define DMA_FN_IN
; w% X- \7 ~ d( K - #define DMA_FN_OUT
( w; {5 h2 \+ Q; H: u# `" H( O - #endif! l' q6 W" N5 c4 Q/ m/ z3 L* j3 }$ h
5 j/ L2 D: O) ^! N5 f/ z' |4 l- #define MAX_DMA_TRANSFER_IN_BYTES (32768)4 O* D- K, w& z* s! V: h% Y- `9 l
- #define STATIC_SHIFT 3& P7 F4 k& _1 e2 J+ X
- #define TCINTEN_SHIFT 20) O7 E* A4 H8 B! R% r
- #define ITCINTEN_SHIFT 21
# U2 E0 I$ r$ _4 D8 O0 M; y- I4 D: N - #define TCCHEN_SHIFT 22
7 L2 P4 I3 A+ E0 Z! C/ o# {* h - #define ITCCHEN_SHIFT 23
+ h4 p- v1 X; b) F
( w0 b& i! q+ Z K& s+ S* V3 p) b/ w% v- static volatile int irqraised1 = 0;
& u& W2 Q- R: k2 S( r2 N1 Z3 Z - static volatile int irqraised2 = 0;9 f8 i) j- q, j; H
- ( [7 R& B( u* |; B& i/ o5 w
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ _& J1 T) V& o- o) q3 L6 C - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# j) P/ @/ [! f5 @2 S1 {5 a0 _
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& `5 D% S. L, f7 j! F - " G' ~' B+ |/ X6 p$ A1 G: y) g
- dma_addr_t dmaphyssrc1 = 0;% Z2 \; [7 }- v
- dma_addr_t dmaphyssrc2 = 0;
3 ]4 c% g |: q4 }7 }0 q, o! B+ I - dma_addr_t dmaphysdest1 = 0;! o% \8 b$ P5 a2 c; t. \
- dma_addr_t dmaphysdest2 = 0;
' ?& n) |3 G5 t( k, X: T8 j
; V' O+ I8 q2 m* S- char *dmabufsrc1 = NULL;
* ? b3 n. ?# V3 d* C - char *dmabufsrc2 = NULL;) x l1 Z# g" c! G. E
- char *dmabufdest1 = NULL;' X3 a; g5 b( a" k9 T$ L. u
- char *dmabufdest2 = NULL;5 I! G* A& e1 H: _
- , ]; _+ { a7 w$ E& V
- static int acnt = 512;* r7 s" q8 e4 t* g' C, O
- static int bcnt = 8;
" G7 I/ \- D3 w; P1 f3 T - static int ccnt = 8;
! v, J; Q% \* [7 E% ?$ Z
! Z' {; m" Y1 z- module_param(acnt, int, S_IRUGO);$ k! J. v ^* h8 `/ k+ \( M
- module_param(bcnt, int, S_IRUGO);
0 x' o0 H) U N3 a9 g& g - module_param(ccnt, int, S_IRUGO);
复制代码 6 q' k; Y! [4 W5 j
& v) r! o# }- h0 f" { 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! X. T! s) g: z& E7 w1 a- I7 Xarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
+ c \9 i' X; o 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: H7 W) I/ V! l& H9 o. ~# u
8 A( [' B+ w& s9 }: R, o
$ I) o0 q, F: U, W L |
|