|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 \2 A, N! N) \" I1 v) g" I9 q- [code]EDMA sample test application
! ]# \/ f& ~5 R8 d% d - /*
2 m) E: \# y$ T* ^ - * edma_test.c c$ s) }( e) }
- *- j2 L* l1 o* a5 Q! b
- * brief EDMA3 Test Application
/ m6 ` x! J _- V - *" j+ c6 _& w" C2 ?0 S
- * This file contains EDMA3 Test code.
0 b4 N# @! k+ Z& n" N: x; D6 k( v$ N - *
4 K G0 ^5 U8 {0 \$ G w+ ^ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE0 H6 T( D" j* |# I7 |
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 P! W/ Y* J! ?' X, r
- * TO CHANGE.$ _4 O& v2 F0 x. G9 N
- *
% \2 p/ `, {0 l" l5 P4 ^ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
( L1 k' o V9 t# a/ W - *
6 m% k1 b* u* E - * This program is free software; you can redistribute it and/or
. A7 [+ M) Z. l+ G - * modify it under the terms of the GNU General Public License as" ?1 p" V( R3 d8 [7 |
- * published by the Free Software Foundation version 2.
' h6 D: ?9 N8 Y4 E2 v - *; @- J* q/ `$ n" J( B3 i* L
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any6 d! K& B7 @. x6 _4 D
- * kind, whether express or implied; without even the implied warranty
0 p" h: ?$ n/ d - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
: {4 q4 o5 g) U8 } - * GNU General Public License for more details.5 j8 h- w4 q1 Y
- */# U! ]# _0 m0 q- b
% y% _1 e2 i( d4 M# }- #include <linux/module.h>
% Q! `' J( N1 j; u1 x6 k5 N: V5 X, q - #include <linux/init.h>
r& ?2 g, q0 G5 _0 I: K# F - #include <linux/errno.h>6 M6 `2 ~+ Z/ S- l. m' b
- #include <linux/types.h>
8 c0 o% v8 f7 M - #include <linux/interrupt.h>
9 ^# {# j6 Y; O+ ^5 N! X - #include <asm/io.h>
9 v: z8 d a6 Q# G - #include <linux/moduleparam.h>
% E; l& m+ h! I, Z+ o - #include <linux/sysctl.h>: x( y9 M' @4 i: O, a3 Q* U9 l
- #include <linux/mm.h>3 G3 o9 I0 e2 j4 R1 j
- #include <linux/dma-mapping.h>3 w# b7 P' ?% O9 H! f' M% V
- $ _# q0 g- t l! z. y9 F+ O7 A
- #include <mach/memory.h>! @! x$ A \* L3 l$ [, x0 r# z1 I; s
- #include <mach/hardware.h>
3 a b3 g0 `# e3 x9 s7 o" I: v$ U" s - #include <mach/irqs.h>( |2 O& k* i. B3 e. N: M0 L( L6 j
- #include <asm/hardware/edma.h>
7 I5 x- M& ?& g& b7 v - & @" ^, a2 K9 o$ m1 Y5 x
- #undef EDMA3_DEBUG
" ^! n6 @/ K0 x& ~! Y. E - /*#define EDMA3_DEBUG*/% Q8 W+ H" s8 f: x# D
0 i5 u O3 S7 {8 {, v; y) B- #ifdef EDMA3_DEBUG0 j9 ]4 @1 V+ C
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ T% ]" u" z6 `+ W# R - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 x7 |+ D+ t0 C7 w6 D - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
4 {" h. q; |& @/ P( g - #else
1 p) G" D$ `1 c - #define DMA_PRINTK( x... )' ?' d& k, m7 b" {! ~
- #define DMA_FN_IN
" Z& D) G& B! G, a l6 @6 ~ - #define DMA_FN_OUT% E2 n3 R- Z2 J
- #endif
) w+ ^1 X. h4 Z. ]. _$ Z2 h
0 F. c" p# P' _- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: g: K* T2 D, ^- J) p: w - #define STATIC_SHIFT 38 F& e# f- _9 w, y8 i5 Y8 h1 M
- #define TCINTEN_SHIFT 20
, B1 x$ G4 Q: n: {* \2 M - #define ITCINTEN_SHIFT 21
( K. }0 o' ]2 W. M- H - #define TCCHEN_SHIFT 22
2 m. S9 t0 y3 U( _- J3 N8 w; T - #define ITCCHEN_SHIFT 23* T# D% N8 M9 v3 B& S# B- p& x
) Y& B# U9 H- K( P# p- static volatile int irqraised1 = 0;0 W; O# c) z4 F$ `+ o
- static volatile int irqraised2 = 0;, v7 q0 E- L- T2 C+ R* ^. k7 ]' q
$ }% L# Y8 A! U" y- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 N/ \" Q" b2 H( \
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, v& `5 A( @, H9 D - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; J! f; Z" y& X# h1 j; \% w$ C - & J3 Y' g' y. F: I0 ` f
- dma_addr_t dmaphyssrc1 = 0;! y9 k) k: H S, o% _
- dma_addr_t dmaphyssrc2 = 0;
# R* y' j7 C2 f1 g - dma_addr_t dmaphysdest1 = 0;
4 a% o9 v6 V2 s - dma_addr_t dmaphysdest2 = 0;5 W2 P6 R/ {0 Y
- " P9 Q" q# y" V4 W9 S9 a1 F9 m* v% p
- char *dmabufsrc1 = NULL;, A% R6 h) W" f" I- s
- char *dmabufsrc2 = NULL;
+ P- C) w2 w% m - char *dmabufdest1 = NULL;6 v5 l+ e0 \' Y8 K0 S
- char *dmabufdest2 = NULL;+ ~! d( _- K' E, h: J
- " j9 K9 Z# L' F' J- c
- static int acnt = 512;
" ~, R6 L! Y6 B - static int bcnt = 8;
1 t( o7 J) m8 y - static int ccnt = 8;2 g# S, G$ t% P/ }! l! A
- * ~3 ^. T; q- ~, y9 n, f/ x, \5 H
- module_param(acnt, int, S_IRUGO);
( R& k* t2 Z5 N, S' L0 F8 b/ A8 h - module_param(bcnt, int, S_IRUGO);
* i2 _4 k/ J$ @% B6 a5 c; h* K - module_param(ccnt, int, S_IRUGO);
复制代码 2 U3 z! f: j( s( b# _- S
& i8 \4 J( n! A8 J: r8 {3 M 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用2 M: I: v5 I4 H5 P; e
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
$ R$ u8 p8 K! U) J- D 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。* m u: o/ X+ l( ?
* Y( q$ f' D0 t5 x+ F2 W) q8 h, W8 |
) W; }9 M$ p* k4 I3 l% l6 R
|
|