|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 7 ^& c! r, L& l. O
- [code]EDMA sample test application
4 l' Z& }2 v q# c4 N. W - /*5 h8 f( p/ a& R9 I% [" j0 h( Q
- * edma_test.c
7 K+ F+ H/ Z3 v6 [) F; B9 { - *
9 E* F. H Q: q. ~, J - * brief EDMA3 Test Application
8 [- Z D! u5 H6 U/ E; F+ f - *
; T! Z6 ^5 H& h8 E( ]4 l - * This file contains EDMA3 Test code.
9 f' F9 F- M, a; R' q+ F7 h - *
4 E) k- o+ V+ o+ o - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE+ N. G0 L0 [$ r0 k# r
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT( S1 L3 J" o. F. B3 ~7 U
- * TO CHANGE.
2 V, R) F E# Q% r+ `, \2 N - *8 B2 b! N! e4 E: w2 m0 G. w/ U/ Q
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- o j8 n2 v+ ] P O
- *
1 {) s0 N+ j s$ | - * This program is free software; you can redistribute it and/or, Y; w& P% f7 [# {' G, |+ J
- * modify it under the terms of the GNU General Public License as
! @8 O4 T3 U1 Z - * published by the Free Software Foundation version 2.
. f0 l9 a- p' B - *
) b+ F. Y* P0 t; x& w; U& E - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
/ T: p5 x5 b/ i4 `; |+ } - * kind, whether express or implied; without even the implied warranty
: [ j3 N7 f- U6 X - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" o0 x) j h1 _' I - * GNU General Public License for more details.
9 w, i6 n- i: ?1 @. @9 U - */6 y- w6 Q: n8 x5 K
- * J3 U1 n! _; H$ M; U
- #include <linux/module.h>8 X0 w* C; b& }- Y( A0 h) @: h
- #include <linux/init.h>7 [! L3 j1 d/ ~1 E5 z6 P
- #include <linux/errno.h>
8 A3 m2 C+ o0 ]+ L - #include <linux/types.h>3 x3 {2 [0 x& w) N/ l& l! A
- #include <linux/interrupt.h>
, F. d, A7 r8 ~; N2 g8 Z - #include <asm/io.h>
( q! f$ g4 \ b+ t; B: a. G4 \7 Q - #include <linux/moduleparam.h>; p" B3 [% {( G0 j7 Z4 N' Q
- #include <linux/sysctl.h>
/ G3 S& p' ^" R. B/ ?4 j7 T, P9 u! r - #include <linux/mm.h>
7 ~/ Q9 a; H1 C7 U0 j3 H$ }- i - #include <linux/dma-mapping.h>
+ L+ v9 y# B0 B* B" }7 P+ p - 6 c8 X( v6 L( t% _
- #include <mach/memory.h>
; y: l/ w4 H; i7 z - #include <mach/hardware.h>1 Z* q' S& q6 L: Y2 ^, k
- #include <mach/irqs.h>/ z: v. x. Z* K, I/ f9 G
- #include <asm/hardware/edma.h>3 m" h1 a* Y a2 A
; k: b, n8 k7 O! V- r2 v- #undef EDMA3_DEBUG
+ P* k$ E, t, B6 ?( D - /*#define EDMA3_DEBUG*/% B2 t8 x" Q- N' B7 G) |/ q
- ) Y& I- s- ?4 m7 s- n, a
- #ifdef EDMA3_DEBUG
7 i9 A+ t; s- }: V% L) z% ]: {& A - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)5 f k# b4 t. r+ X
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
' b0 Q- Q1 j3 p. I3 C7 E1 v2 U - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
- S( ^. M7 k k6 t - #else) W% C1 y! k( k( }
- #define DMA_PRINTK( x... )5 l6 W4 V) {0 a/ v! @1 W
- #define DMA_FN_IN
1 Z5 @2 ^+ E" G. u - #define DMA_FN_OUT
& l1 P7 r- A4 _* p - #endif
' l3 m/ B- w! a& Y. P: y - ' f) Z% ` u6 E, u) \6 G" P
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
8 f5 J& G( {' S - #define STATIC_SHIFT 3" B4 u( Y! e6 |+ {! R; g
- #define TCINTEN_SHIFT 209 Y: [7 a$ \( I: v5 }
- #define ITCINTEN_SHIFT 21
/ O3 {' t% J: l2 Z - #define TCCHEN_SHIFT 22
5 g' P/ ^( k" A: V3 v: ?* T - #define ITCCHEN_SHIFT 23' H5 Q) q; [* w2 ?, U- x; J! L, R
+ Z# A* `( ]9 B! B' T9 W! y- static volatile int irqraised1 = 0;! g3 ?8 Z* E2 _. q/ E1 D, ^
- static volatile int irqraised2 = 0;
( [9 {5 n) x8 i, Z$ Z8 f& o; h p% `3 W
8 t" j o, I" u- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 ?7 g% ^/ W0 @' Q* `
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); D- k3 l. p( O
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 f+ O$ a% [6 M3 o
- 6 Z, C+ ~9 ~2 k; l; K! O+ e
- dma_addr_t dmaphyssrc1 = 0;
! S! D& p, D* l* }4 l - dma_addr_t dmaphyssrc2 = 0;
+ }2 K! p- \/ {4 ~) ]2 K4 k# ?$ f - dma_addr_t dmaphysdest1 = 0;
1 ]' d) [. f" F$ X0 u/ g3 l - dma_addr_t dmaphysdest2 = 0;& K+ [4 e$ A) X# u2 K4 z' P
" f6 A' a2 i$ ^( y4 y- char *dmabufsrc1 = NULL;
% L7 ]- ]4 b8 r G8 b3 W' Z2 v - char *dmabufsrc2 = NULL;- Y" ~ {$ }) c) ~
- char *dmabufdest1 = NULL;/ d' k8 q9 }( N; x) e
- char *dmabufdest2 = NULL;
% w8 L) p7 N5 |+ X; O; q) p* T - + |$ |' X0 X9 W/ }2 t7 Q
- static int acnt = 512;2 } R' R5 e7 b* Q# J
- static int bcnt = 8;. y. K! |/ j6 E, F9 A2 s1 _
- static int ccnt = 8;
4 B" k8 n1 S! K' E U - 1 g* ~( \' n* F, w$ @
- module_param(acnt, int, S_IRUGO);# _" Z, ] z$ {% O9 \
- module_param(bcnt, int, S_IRUGO);
0 ?# q: J" B# @( _1 Z7 y" @! P - module_param(ccnt, int, S_IRUGO);
复制代码 ; O9 e" E' [3 I8 H) Z
0 V1 w* I' c. `4 p8 y 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ _5 a' I" e0 f9 h1 W: N6 Tarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* b: Z, K! ?7 h0 ~7 w6 |
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
1 b/ Z& v7 Y1 q4 H. ?( P
4 L; |+ s/ |) D' Y0 ]' V8 u& ]9 J
/ [2 Y0 p" B' ~9 h7 ~ |
|