|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 # j5 q( j/ i' w! @: O+ k! c, m
- [code]EDMA sample test application
. J; z. L7 w# O- a0 N" Q! Z }7 W - /*
$ l; P1 o5 `' N5 M. \* f$ l7 c& H3 { - * edma_test.c
^, F3 K- {, A2 u3 o6 d9 h, a$ n - *
; O. B1 L: P; b1 O7 u. t - * brief EDMA3 Test Application
+ P$ C9 ]: M; y( \3 H1 W. W - *
! L: n* M9 ]% n8 D* h+ k+ B2 R3 H/ O I - * This file contains EDMA3 Test code.' k2 z1 h7 Y2 m
- *) j: e2 B# L4 q7 B, s: ]
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE7 H! |5 T3 I! I! }
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT- T7 Y# f; u e
- * TO CHANGE. j/ N- }1 u+ ~) r
- *) X( D' S) E0 r$ ]
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' E& ~+ N8 \/ r0 e) e# U; a( P - *5 y7 a W+ N! e: R3 q+ c
- * This program is free software; you can redistribute it and/or9 C3 c! y1 L5 e( l7 U E
- * modify it under the terms of the GNU General Public License as9 B" R; {3 [9 W3 D1 k% N
- * published by the Free Software Foundation version 2.4 W; q$ A n s) \% U' k/ ]8 ]
- *' _/ S d! I( y' M2 ~0 q
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
6 R) F) M2 u1 p- U - * kind, whether express or implied; without even the implied warranty6 C: W$ M. D" Y* I7 B
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the; ^7 F! @+ v+ z8 Y; \ a
- * GNU General Public License for more details.
0 W: s! M/ d( K( l' q6 D5 t* g0 t - */4 }# Z; u) p5 ~# m, H
$ w2 T+ D& j" b& h5 h- #include <linux/module.h>
, u: g( W- x5 l" k$ h3 M1 H7 } - #include <linux/init.h>& o$ T2 b7 S5 }. H
- #include <linux/errno.h>
! I2 @& ]; H' O# X) N6 Y - #include <linux/types.h>8 Y6 S4 _7 _* q, Y/ H, N5 h/ c/ Y
- #include <linux/interrupt.h>
5 U+ h9 i8 _' W$ K& B" H& n - #include <asm/io.h>
$ A- M5 Z$ G1 z4 r - #include <linux/moduleparam.h>
. k ]' B9 U X" N! G. E - #include <linux/sysctl.h>
" R8 v" W- J9 i8 u/ T, R - #include <linux/mm.h>& s3 L4 ^% q2 L3 ^8 D4 p% _; _& J
- #include <linux/dma-mapping.h>2 ?, M$ i- D! ~7 J# {
- , g4 P# A. S2 Z& t+ g5 N
- #include <mach/memory.h>) h% g' v# R9 F9 T+ @+ Y' d- q
- #include <mach/hardware.h>
2 {2 g) }. ^$ t' d$ m - #include <mach/irqs.h>: {- U1 s) A k
- #include <asm/hardware/edma.h>9 {, l% b% T: Z* j1 k
) E2 {! i2 c! u* B, h( ^- #undef EDMA3_DEBUG9 o S0 C1 j% v9 F+ V2 C" B, ]
- /*#define EDMA3_DEBUG*/$ t6 q! F r% _) Y0 t
- " |% J" }: S6 K$ v/ q5 c
- #ifdef EDMA3_DEBUG
) C- z, s/ ?2 s% }* y* e7 i - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)0 j+ i) h6 S. v& b0 s, d/ I, J
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
0 B: i5 t+ y9 r1 Q Q O' p - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__); a% W }, W/ d
- #else
6 u. @" u9 D$ q% a9 q+ s - #define DMA_PRINTK( x... ). H" U- `% \, n: C5 n& G
- #define DMA_FN_IN. D: J- Q5 o4 R& f* W+ ^1 U
- #define DMA_FN_OUT
! T6 ]2 ^8 h0 I, r$ M, F. J* p - #endif
! D) b& e( u: t& v2 t$ q# p - - g4 ]: A% {( r! g" m
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)2 r: I' \* [. x/ \; o& ?/ v
- #define STATIC_SHIFT 3
; [0 Z8 x1 g0 B" J+ J - #define TCINTEN_SHIFT 20& u4 x" {# K; x {6 K& y, I
- #define ITCINTEN_SHIFT 217 R6 h$ m# t t. I/ y: K
- #define TCCHEN_SHIFT 22
9 o# H' u/ }) `8 h6 @) B" t+ @ - #define ITCCHEN_SHIFT 23
: n+ a9 j6 o* G - 0 c; S, E* B' {% U
- static volatile int irqraised1 = 0;3 j. C# y5 X0 u
- static volatile int irqraised2 = 0;
1 T4 H1 Y0 Z6 {' x% I7 T( c - 7 P: a, ~. ^$ ?! N' y/ v2 [" ?
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* r/ o/ ] R/ ?% O3 N- `. q+ q - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 v/ x% W: D2 t8 J. w - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 @+ [4 A* }* e* p, C# C
- 4 C! g1 ] o. b5 P7 c" J3 g
- dma_addr_t dmaphyssrc1 = 0;
' X2 C- ~* n& c( D; K) M - dma_addr_t dmaphyssrc2 = 0;
& r% e8 \7 K2 A# b9 @& M - dma_addr_t dmaphysdest1 = 0;
% g; D. Y1 \6 c - dma_addr_t dmaphysdest2 = 0;5 O: h: g# K d5 \% c
2 V- o) N: E0 ^6 f9 t9 c$ ~" @/ q( l/ X- char *dmabufsrc1 = NULL;# v/ X4 Y- ~, T3 b, l$ v
- char *dmabufsrc2 = NULL;) @& P% l2 G0 @- F
- char *dmabufdest1 = NULL;
: Z! }! I' O4 ~9 [$ l - char *dmabufdest2 = NULL; i8 e6 U4 g& M; n
- 8 A v# u4 C" H! _
- static int acnt = 512;
" @; G7 c+ {; x7 x - static int bcnt = 8;" V# A% D* h5 ^4 ?' O
- static int ccnt = 8;
) }3 v1 X3 I0 d- _
3 e( ~8 f0 l7 f. q: _- module_param(acnt, int, S_IRUGO);$ x) n2 |( C( o, C& f0 Z% r' h8 D( _" E
- module_param(bcnt, int, S_IRUGO);7 p7 E+ l1 f# X$ ?9 a
- module_param(ccnt, int, S_IRUGO);
复制代码
/ g0 G$ T0 l6 @% G; `7 ~" g1 x# k. ~/ }
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: e( _$ V2 F1 A- d" 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* ?: C( x9 _3 @- s3 \" @) h$ U
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
. N/ L1 t) {5 ]9 b% c0 f0 W: _) n T2 T) u. c: ?' D) ^
+ ~2 p/ I1 [& f0 v* i
|
|