|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ; ^; C1 m' g5 i7 [& ?# K
- [code]EDMA sample test application2 S, t S6 a* J0 ~0 k' S: x* S6 G
- /*6 u. x* H9 K3 ] y) L% x
- * edma_test.c
( e8 p" l" \0 R% {8 J9 i9 b T - *
% v' k* y `6 m - * brief EDMA3 Test Application
# U$ @; U- [9 Q* B - *) x8 w6 m/ X* m" Y: u
- * This file contains EDMA3 Test code.
/ I q0 h( T9 {9 T; I, v4 r - *
M W# P- `9 x - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE5 \& _, G+ B% n6 h
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT/ t$ f2 F& e5 R! T* p" t' m1 p7 X
- * TO CHANGE.. m* `" V1 P8 ^4 C
- *
# P- [4 e2 g2 y$ }5 Q - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/) T+ C; g6 g. m' h+ Z" d6 x
- *
2 f8 x% ~9 I- U$ W* R - * This program is free software; you can redistribute it and/or. m% {, v- b) h1 z( E% R! D
- * modify it under the terms of the GNU General Public License as& X5 d2 P+ E3 ^2 Y2 U: o
- * published by the Free Software Foundation version 2.
L! _8 i, v; G! w. H; o - *' k2 o* H9 c- f* H+ p
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
/ Y0 H8 {0 c1 G- v3 a: l! P5 W: l - * kind, whether express or implied; without even the implied warranty0 ~' d& r; o8 _) l1 k
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
, Y8 Z; b: F0 n5 L8 ` o - * GNU General Public License for more details.
8 u+ C$ C3 J' ^ - */$ ^0 L1 S- G2 u. Y5 V# \: |
6 R4 }% P4 T$ H+ i7 D- #include <linux/module.h>
|7 r1 C3 m% Y( M* y" C - #include <linux/init.h>/ h& J1 s9 F& {/ I' `' K
- #include <linux/errno.h>
8 \- J8 A# @3 P( H - #include <linux/types.h>
7 o- a/ Y8 E) N- v - #include <linux/interrupt.h>
& j% f+ P# h$ r3 n5 t - #include <asm/io.h>
6 u5 v r c; Y1 A& z - #include <linux/moduleparam.h>. w- Y& Y% A; j2 ?. I( Z
- #include <linux/sysctl.h>
/ j% n, c5 A1 [2 C - #include <linux/mm.h>
& P& a- S0 w5 x! D" ~3 ] - #include <linux/dma-mapping.h>
( H3 i& n, U" Q* Y5 L - $ p& }8 }1 [1 R( w
- #include <mach/memory.h>
+ Q# W. Y8 [3 [6 V! q - #include <mach/hardware.h>
2 S8 `* i! k$ | j3 c3 t4 s3 C/ {* f - #include <mach/irqs.h>
0 A0 L" b8 e, z4 r! r2 U - #include <asm/hardware/edma.h>
3 Z' c* _# y3 Q - / W" R$ _8 c- ]6 H" Q1 k4 F
- #undef EDMA3_DEBUG% j9 f: u, K. m; ]
- /*#define EDMA3_DEBUG*/
- G# [4 ~, L: B* v - * `: }/ F' O G' I. Y
- #ifdef EDMA3_DEBUG1 M: Q' Z, L% A B
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ p/ _# b& D: Y* d" x - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)3 A, f) O, q' b
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
: _- ?" m( h% V$ o - #else* u9 L9 k( i# N" s h/ }% m. w
- #define DMA_PRINTK( x... )) l; H* `' E) n |/ V
- #define DMA_FN_IN8 D: t; P ]; N# ~4 s
- #define DMA_FN_OUT
Q) S' A! m: P& ]: D - #endif& M# i6 n, D5 @1 J! {, \0 Q5 [% C& a
; `5 n* |0 x5 f, Z7 L- |) }" g- #define MAX_DMA_TRANSFER_IN_BYTES (32768)% S. {* @9 x7 }: A W! I
- #define STATIC_SHIFT 3, A W3 w6 V/ t" y0 e
- #define TCINTEN_SHIFT 20 G2 H- Y x7 H: w4 n
- #define ITCINTEN_SHIFT 211 \+ ^5 X. ~1 B; s5 g J
- #define TCCHEN_SHIFT 22
& @, x |" [6 C4 A& s - #define ITCCHEN_SHIFT 23
$ k$ |! b9 ]% r: r) A4 ? - 0 B4 E( S9 s9 y9 g) `; c0 o) s
- static volatile int irqraised1 = 0;
" S4 Z3 i, f( }* Y - static volatile int irqraised2 = 0;9 N7 r, U0 ^" K; c$ ?9 x' j [7 Q
) q+ f; A* b+ Z& P2 P# Y6 c3 M4 W Q- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% D8 x1 u3 I! x) D% @9 a8 ]
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 t7 _( h' B/ z, u; r! C1 r7 z - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- N4 a2 A7 e( P( ~
- / V9 K# X7 E. M3 \) t* ^
- dma_addr_t dmaphyssrc1 = 0;
6 V" h& R A6 o* ^9 H7 u - dma_addr_t dmaphyssrc2 = 0; t5 ~7 B4 \ b6 |1 G/ K
- dma_addr_t dmaphysdest1 = 0; D% \* o9 E# R! C7 I. k8 m! w
- dma_addr_t dmaphysdest2 = 0;
! ?. i4 L/ B- h# D' N8 e; I/ r - 0 w1 D/ R0 O) z: h
- char *dmabufsrc1 = NULL;9 X1 d6 u" O8 L2 V- P) l# ]7 D
- char *dmabufsrc2 = NULL;
n% W7 b' P5 E& z* F* d- \ - char *dmabufdest1 = NULL;3 h1 @. v$ v4 i# ?
- char *dmabufdest2 = NULL;# _6 g& Y2 v+ F; H$ f6 W) V# Q& S
6 k* S& P1 f7 M" @) h- static int acnt = 512; X4 |1 [! T1 ^) w2 i: ?0 A
- static int bcnt = 8;
1 k! Z9 R3 M$ u: t: T( y - static int ccnt = 8;
& b3 N, b% K$ Q) v2 b
; E7 z1 H8 H" l5 E- module_param(acnt, int, S_IRUGO);8 g, z3 S5 O# m
- module_param(bcnt, int, S_IRUGO);+ [, d P c l U$ y
- module_param(ccnt, int, S_IRUGO);
复制代码 + s3 T+ ~0 Z% r5 r, F8 O+ e! Y9 B8 z
" C: h0 n/ h5 M# M4 h8 S 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用8 W& i; y8 d5 _
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。1 ^: g2 J" p+ O- w: `* a+ t9 j# |
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 O) m5 S% l, K5 S3 k5 @6 K' v6 N
4 `; K2 e& q& _$ C$ V: b* y2 e
7 s }( |1 e4 {6 F2 g% c" d5 B4 \1 ~ |
|