|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 & B1 k' S" Z g* q2 I" O# Y* h" k
- [code]EDMA sample test application
- r% c) ?6 ]; u) w - /*
. F3 T: @. M$ i6 }( x - * edma_test.c3 t+ _+ l/ n' ~$ T
- *
0 p( P" a0 v) r4 g5 S5 Q0 U' U - * brief EDMA3 Test Application
5 d$ u. [) c: u4 b( k+ U4 x - *- M0 t2 ?' `6 z- _' I+ E0 p$ Q# o
- * This file contains EDMA3 Test code.
6 g5 v- k- i! M* I! D, r - *" L" m4 ]5 {8 L: l
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
5 n7 f1 j- Q) }/ C4 r - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 e, H: A. Y' a- c0 A- g
- * TO CHANGE.
5 m* [- p) I# b3 ~% x - *
; e9 Y& g9 K( {3 V$ F3 ]7 m - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/2 A8 e! H1 d5 E9 X1 T
- *1 c" N( t/ I& [$ I; Q9 Y/ o% e, j+ D
- * This program is free software; you can redistribute it and/or+ r7 @) A! \. I
- * modify it under the terms of the GNU General Public License as0 j* _* j! g3 R N5 U* a8 ^
- * published by the Free Software Foundation version 2.3 P V2 {8 h: c, o
- *
7 \; y8 e) v+ E; N - * This program is distributed "as is" WITHOUT ANY WARRANTY of any2 k2 y# K& W4 ~9 h7 b
- * kind, whether express or implied; without even the implied warranty% B& Z) n1 H3 ~
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! v: V, E2 R* S" G. O# t - * GNU General Public License for more details.5 Z8 n6 L! \' T2 w$ ]% B# _0 z
- */9 x% {+ e" P; M/ ^, B
- # l! M) B" z, P
- #include <linux/module.h>% T2 _7 r1 Y% G: U/ I, v. x; w T
- #include <linux/init.h>. t1 S. z1 g! n5 D5 B: ^5 J
- #include <linux/errno.h>
% Z6 I7 Q; U6 M3 t7 J - #include <linux/types.h>; k2 p- i1 J5 ?8 h* _' Y2 K
- #include <linux/interrupt.h>' o9 S2 P% y u6 U) X
- #include <asm/io.h>2 e* ^- A# g/ O5 u6 k2 @$ w( A
- #include <linux/moduleparam.h># w2 G5 j1 Y4 j
- #include <linux/sysctl.h>
* a1 G4 h0 g [( O6 V! b6 Y - #include <linux/mm.h>
: x( Y. Q! U& r' @$ | - #include <linux/dma-mapping.h>" i- V8 T& _8 [% N! M( B5 y
- ( a( ^ Q& O' a1 N" g
- #include <mach/memory.h>6 \. B2 E' h5 d; b2 k1 b$ p
- #include <mach/hardware.h>
0 s0 s# c# X; f: g7 g" U - #include <mach/irqs.h>
3 [/ K3 o- b1 x) N" N( b1 D9 Q - #include <asm/hardware/edma.h>
* V6 _) D+ f8 u6 O# M( ` - - ?4 z4 ]" H$ P4 u
- #undef EDMA3_DEBUG) R# T/ x- \/ p) P3 }* ^0 i- C
- /*#define EDMA3_DEBUG*/2 r9 t" P: O | L$ v! t( l
- ) o* Y8 t; b) a0 M, |6 {. ?
- #ifdef EDMA3_DEBUG$ {# G8 U0 Z) h8 K
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
# T! x0 ]% g/ p3 u% T2 ~ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
+ V& r2 |) ], ] - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
8 U* m3 C" K6 [5 x - #else
+ ^1 H5 A7 {! ~( x - #define DMA_PRINTK( x... )
5 Z. L( Z2 }: T6 w R - #define DMA_FN_IN3 C5 s7 a2 Q$ G' L
- #define DMA_FN_OUT
8 L0 ^5 i- M: ?3 K+ Y* K$ T: T% ~ - #endif
$ M& Z8 p7 Z) F4 {$ g! `
' x& Z# ^% l3 \" A v" e$ f+ O- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ @! y; ]* I& @ | - #define STATIC_SHIFT 3
/ m, {! J' Y7 V4 f% P3 I0 p7 C: ?$ B - #define TCINTEN_SHIFT 20
& S+ V! h/ I$ i - #define ITCINTEN_SHIFT 21
' ?. L/ V( s/ U& C" [ - #define TCCHEN_SHIFT 22
. e( Q2 _9 L0 X7 c3 ? - #define ITCCHEN_SHIFT 23
. p( N8 @. y; E5 q) I0 m
. b' d1 `" D6 w, B( y& Y7 c- static volatile int irqraised1 = 0;5 d1 ]* \3 I3 p. u
- static volatile int irqraised2 = 0;
! P( [/ T5 G5 L+ Y- q" G
' T# x" G8 W. a- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" r. C' m1 R4 M - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* r/ A! v/ U: N5 g: V# |
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 i1 A5 w. G5 J1 n& f
" L0 Z" u, Z' G' ~" X0 r. O( @- dma_addr_t dmaphyssrc1 = 0;) b! g. p! H7 }! K
- dma_addr_t dmaphyssrc2 = 0;8 Q0 k6 u$ `% ^$ s# i
- dma_addr_t dmaphysdest1 = 0;
2 c8 H7 O. ^ w3 h8 a. q - dma_addr_t dmaphysdest2 = 0;
* _% |! e' P0 `. y7 z9 k1 D6 p( ? - 9 F, l1 W/ x6 e* ~ S6 r: d
- char *dmabufsrc1 = NULL;
- Q) Y( I) e: ~8 X+ e - char *dmabufsrc2 = NULL;& }8 e: Z$ a# Y: P. N7 w3 ?- [
- char *dmabufdest1 = NULL;6 B! w6 K7 h4 k) T! x1 X4 ?1 R
- char *dmabufdest2 = NULL;! N" {8 ?, O, p1 z+ \# ]8 u
- 7 B6 U7 Z& j; Q' S5 _* e8 M1 h: Z
- static int acnt = 512;
7 i/ D8 a* p E1 y5 e# K: |/ P - static int bcnt = 8;
- j4 J9 _9 G# D* R - static int ccnt = 8;( ^+ F. Z% t0 ~% N+ {
- 5 s5 `# n7 d6 M q& j% r. [
- module_param(acnt, int, S_IRUGO);
; P; |6 @7 e! L - module_param(bcnt, int, S_IRUGO);
+ }- {. Y1 C0 \* o - module_param(ccnt, int, S_IRUGO);
复制代码 4 m- G& ~3 T* X+ U
$ x" T" k4 H w- d; e9 Q
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
7 {# @3 `& L8 Marm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。7 Y! {7 W" T- N2 B9 p
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。4 C8 X+ W: `! r ?; C
2 h6 @# k& B$ Y4 P, e/ g
! m" T. Z. f) r G7 }" A p
|
|