|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 i, y! I/ |* ?; X' W. c6 W- [code]EDMA sample test application
, D9 Z! T/ R) b - /*. h5 r0 K& r" k2 _, h* J) X& F! c
- * edma_test.c1 F3 q+ h3 W1 G y* x
- *1 M' Z# z, ^9 H' }- j; ]
- * brief EDMA3 Test Application
' V8 A" [5 C5 g/ z - *& V) b6 K; B, Q3 o" T1 b& ^
- * This file contains EDMA3 Test code.
: z5 A0 X& w8 h8 J - *. g1 M8 `' `4 w* v t- b$ g" ~
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% x* }; Y0 B3 z! [# X2 P - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT, o% A8 I8 s0 N' @! Q0 y$ p- W
- * TO CHANGE.
5 T# o) K: Q) s5 J! T4 m9 J9 y+ X- ~ - *. a( }( F% @- M: v- d. `6 m
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; x7 h3 I& B; ? - *9 B/ m8 g7 L) e: |1 ^4 w. {
- * This program is free software; you can redistribute it and/or
7 v, Z' E0 }3 ?' c - * modify it under the terms of the GNU General Public License as
+ }6 k0 ?/ |9 M' z c$ s - * published by the Free Software Foundation version 2./ l8 @4 x5 l8 v. `+ @
- *
% M |9 t) S7 W% X. } - * This program is distributed "as is" WITHOUT ANY WARRANTY of any; E6 {" Q4 t2 f/ g
- * kind, whether express or implied; without even the implied warranty
% S% d1 M% @% b' w - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 C; ~" }) h; [
- * GNU General Public License for more details.
! [# T6 G& W2 m1 k: t: {" }1 U5 P0 v - */
7 W- F. ?9 b o5 C3 [ - & o2 X/ G4 R* ?* H
- #include <linux/module.h>
' x% P$ p8 {6 b# ~9 O* m0 x- B ? - #include <linux/init.h>9 i& L" ^$ o# U1 u2 A
- #include <linux/errno.h>
( @/ J+ X( }2 l# t1 f$ n! @0 x1 i - #include <linux/types.h>% g k0 r2 a) S+ i3 D- v6 M7 G
- #include <linux/interrupt.h>1 Q& c1 R: \+ J
- #include <asm/io.h>4 O; J* X4 C- o3 a& | N# F7 z
- #include <linux/moduleparam.h>- U b7 T) f" w
- #include <linux/sysctl.h>5 i2 l O7 @. z) ~
- #include <linux/mm.h>
9 a1 a9 X* r6 p! v, L - #include <linux/dma-mapping.h>
: _- |$ f- Y( E, B - ( V. L1 J( J7 b* s2 W
- #include <mach/memory.h>
1 E5 y* U9 W9 D" \" e - #include <mach/hardware.h>
' h {( c# p/ X' \4 w- E - #include <mach/irqs.h>$ {% j" ]+ } m: v4 f' ^% q
- #include <asm/hardware/edma.h>
- v" V5 Q3 R! a6 |3 f
/ P& M0 p. G, I/ B2 @8 w# i& r( L/ f- #undef EDMA3_DEBUG
6 @8 T4 G( A0 o% C5 q1 I2 }4 U - /*#define EDMA3_DEBUG*/
# J) @! E! v. Y" u. Y! q, { - 6 a( _7 V; J& g& v! F1 ]
- #ifdef EDMA3_DEBUG
2 `% m- t9 i6 d2 e; |9 m - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS); I4 S2 G9 b# f, |& ]5 m
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)' W! g) W+ |9 E) h
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__); Q& }3 w) P. `$ P& Z
- #else
% }" a( q0 U% { - #define DMA_PRINTK( x... )& ?' d s/ e7 b8 W! n( R
- #define DMA_FN_IN
+ J2 l' U; I0 r. L - #define DMA_FN_OUT. B9 n( j0 X1 `8 I
- #endif4 F) H/ E6 \; c3 A8 u8 d; L8 O' T
y% f# L! g8 I- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
3 }/ k4 y$ y7 s. F2 ~8 m( d" j - #define STATIC_SHIFT 3
: I3 S9 d5 b) o D - #define TCINTEN_SHIFT 20
6 T0 m7 c# f L - #define ITCINTEN_SHIFT 21, b8 z4 L0 |5 e/ I2 ~& J
- #define TCCHEN_SHIFT 22! P, S+ I8 V. m
- #define ITCCHEN_SHIFT 23 c2 N6 M( R3 G/ l1 ~3 l
- 5 Z6 O3 Y, M q; E
- static volatile int irqraised1 = 0;
0 c' C' U4 S: B7 y N - static volatile int irqraised2 = 0;
* `7 T9 [$ l. P% R; f
0 ~! L- G$ [! G1 m- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) D& Q0 B7 C+ P8 p! Y
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' I. ^: c, S( Q9 h8 y' U
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ c6 U! T, i( T+ J7 f
; X1 ~7 a$ s) U6 J7 O2 j( ^! M# {- dma_addr_t dmaphyssrc1 = 0;" w" Z4 ?& E g L: Z" D5 B, L
- dma_addr_t dmaphyssrc2 = 0;
' _0 ]8 x' M$ n( b - dma_addr_t dmaphysdest1 = 0;
) L7 d4 k" |2 E, q - dma_addr_t dmaphysdest2 = 0;
0 y4 D8 ^4 B, g
% H3 D+ E: G! z- char *dmabufsrc1 = NULL;
# p9 V6 C' k( ^9 ]0 v& { - char *dmabufsrc2 = NULL;4 @- n4 ]8 J* Q* J9 p# Z
- char *dmabufdest1 = NULL;
; i! l7 \3 e' B* \# ~) I% U$ g - char *dmabufdest2 = NULL;) |' z6 `& y$ W. j- N8 ~ t; o
7 p; v6 `7 \) O H g, X- static int acnt = 512;0 s F8 K* @3 {/ Y) g
- static int bcnt = 8;0 q( {' w9 b, |5 y$ I# X
- static int ccnt = 8;
" N! a. ~+ J, O+ w y% I
# i0 w& z" {% ?% m9 ~( e4 W& f- module_param(acnt, int, S_IRUGO);
3 ]1 t6 S* p6 X7 _0 M1 S - module_param(bcnt, int, S_IRUGO);
" M6 o" |" R" q0 a - module_param(ccnt, int, S_IRUGO);
复制代码
0 v' n" j/ `6 K, p' x$ j* q
; U& S# n7 |5 F# U8 l3 X 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 d+ [' z# b2 n: C9 L) [ s% [, aarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。$ f9 H% Q( m; Q+ Z* D
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。( q; }5 @6 J3 _1 k ~! S0 b, p
: F3 J' s8 s& q+ S0 e( { @
' l9 U; w( r# J |
|