|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% e: M1 k- X6 b5 T- [code]EDMA sample test application* f- `8 G* ]5 T9 d8 n8 y
- /*
# f0 m3 e; P6 n - * edma_test.c6 G) ^ n5 e' Y
- *
3 o; g+ a* Z `/ R - * brief EDMA3 Test Application1 K# \- H0 {" ~- c! a+ N
- *, X& m1 [6 _' @+ M
- * This file contains EDMA3 Test code. Y2 V, k8 F* ~7 \
- *
( p: A% ?9 R B& ~5 t8 H8 a& m - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
9 X1 D% W1 x: o' {* \ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT- m, j( `( Q+ i3 L/ \& f& z
- * TO CHANGE.1 P* Z$ ^# a4 M2 m: j! n: F, p
- *- G! e6 N! ~* ]
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/. b2 g1 T! E0 Z" P9 S8 V
- *
K2 k- s% W0 B3 b - * This program is free software; you can redistribute it and/or1 ~4 V9 g3 O; J0 q9 \1 C
- * modify it under the terms of the GNU General Public License as
; {/ S0 @8 H2 t' N' u - * published by the Free Software Foundation version 2.6 ~2 l" @) a. P- `' f
- *
8 ]' a3 B/ n3 w - * This program is distributed "as is" WITHOUT ANY WARRANTY of any, N# u" U& }* m+ [( w
- * kind, whether express or implied; without even the implied warranty, I4 f; `; l# `+ a8 ~
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the( \1 }: Z1 W& i) E- b( e* ]
- * GNU General Public License for more details.
, i/ |% D! n' z) U! c$ N) G- O0 I: V1 ^ - */
) T% h; G, l6 B5 ~$ `
X( y. t9 o4 {8 q7 l. x- #include <linux/module.h>
5 J f. O1 g3 ~. C5 E+ T. U" U - #include <linux/init.h>0 l& k5 f% c0 w* _' @" V. Y, u
- #include <linux/errno.h>
, M, D4 D* m0 b+ e# T: A - #include <linux/types.h>
" Z0 D( F7 @8 H5 ?4 f - #include <linux/interrupt.h>
$ \ j# L! ~( X! A& i - #include <asm/io.h>
- M0 O5 c1 F$ p$ |+ E1 a; Z# l - #include <linux/moduleparam.h>
+ _# O& G: H# ` - #include <linux/sysctl.h>
2 D3 q5 M9 X, W2 P' ?" d7 g - #include <linux/mm.h>
0 d4 Z$ a+ S' O. s - #include <linux/dma-mapping.h>- n1 N- p, W! ]! k5 T
- 8 w+ w' i3 |* k }2 Y6 R
- #include <mach/memory.h>. b: c6 ~8 @" P) v$ A; k: _" ?
- #include <mach/hardware.h>) E% F0 i! d% }2 n, @
- #include <mach/irqs.h>7 w: F( E+ @ @* K$ ?7 ^. }
- #include <asm/hardware/edma.h>" T, W9 ^7 e; u5 m" B
- 5 Z' I/ Y' N# H, j/ W; l' X( }" M
- #undef EDMA3_DEBUG
. n% L( L- `* g, d: Q - /*#define EDMA3_DEBUG*/
6 @8 A8 }1 t$ k* |. v1 ?: ^: a - + q) ^3 k! P! h
- #ifdef EDMA3_DEBUG! |9 ]- s4 ?. K. i. f) e
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
4 A" L6 i* S }4 V8 |' l* C - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
% m9 ?$ a% E5 E( X4 d% k2 a - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)- ?4 y/ \5 W5 V+ u( Q; |
- #else
; y e0 ]; r! v& g' ] - #define DMA_PRINTK( x... )
0 Q0 x+ D! a& o) [ - #define DMA_FN_IN0 x2 c6 k0 x9 B$ n7 x E: u g
- #define DMA_FN_OUT6 i7 v& I7 i D i% Q8 x
- #endif( s# _) }4 N/ k9 u" ?2 j H
) {+ \& k' e' n" l b- #define MAX_DMA_TRANSFER_IN_BYTES (32768): C& w: G+ q n5 p% l2 G$ }& S# A
- #define STATIC_SHIFT 3
/ i7 J7 ^- A2 c - #define TCINTEN_SHIFT 20/ O2 _) A! I1 e8 u% r
- #define ITCINTEN_SHIFT 21
" b0 P* n" z2 E2 z; G, w- l! S - #define TCCHEN_SHIFT 221 o6 j, h; e3 c# [8 |' @
- #define ITCCHEN_SHIFT 23
! E; ]5 r( M4 L. l5 V) ? m3 r
2 u! c' w) s0 I- o. Z- static volatile int irqraised1 = 0;5 [$ w. D% N6 V! C
- static volatile int irqraised2 = 0;( B. _1 W2 U e& i2 n+ [; T
$ S+ A( R J j+ \ @) t! N- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. ~4 \' d, \: g P! E" x- p( R1 Q
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' r! ~; r( r1 E l [7 _
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( T4 O V8 @( C1 {: v, z
* z T" S$ C5 \7 ]; R- dma_addr_t dmaphyssrc1 = 0;6 P9 b g3 s3 I; @
- dma_addr_t dmaphyssrc2 = 0;& K- w1 @5 I- j$ p% ]* P
- dma_addr_t dmaphysdest1 = 0;/ Q+ X! J9 j# J0 n, M+ J% U& d
- dma_addr_t dmaphysdest2 = 0;
) B0 y1 u# C2 X3 Y+ W - 0 L& J" C4 ^' Z# p9 ~0 o
- char *dmabufsrc1 = NULL;# ?1 B% t; _! K/ G1 a$ h- ~. t
- char *dmabufsrc2 = NULL;
( p _# y" W4 W g - char *dmabufdest1 = NULL;8 m: L' @) p! b; W% h0 g
- char *dmabufdest2 = NULL;% h7 X, t& L* b( h3 z& Q
6 N" F" s) S# u: g! E& V- static int acnt = 512;/ @( O" u x4 \3 m, `; Z8 s
- static int bcnt = 8;4 `+ [4 P7 k3 t# y% g
- static int ccnt = 8;5 T" n9 o0 R/ W( g! v5 j9 t1 {
# e1 t) O$ B6 Y ^% G: t# }; g- module_param(acnt, int, S_IRUGO);1 _ J" l6 s8 |7 O( s2 R, H/ C
- module_param(bcnt, int, S_IRUGO);
2 j. s# r9 l- q. C5 s- _ q - module_param(ccnt, int, S_IRUGO);
复制代码 ' M: B. {: R8 f- C8 Q7 v+ E4 B& ]
; @% T6 _$ V# t5 P& q 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用* N" ~& n% v% c" I$ f% p1 i/ |
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。 ^) x6 C ?- y. M% j
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
4 N9 c8 {3 ~; \$ z6 b. R/ i8 g$ P
4 d' |5 Q" G6 x# z& L! C
7 x5 H$ o6 ^# r6 S4 b9 {7 q S |
|