|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 I8 X% X1 f2 V, B! C' E% w- [code]EDMA sample test application
8 @- a# F3 G' \$ W; s9 i% K - /*
6 ^! f# v9 O4 K, u* k6 a - * edma_test.c
- P* e( n% p: m0 V% R' a2 Y - *
, e6 p) n" R# M, |. z - * brief EDMA3 Test Application1 W9 p" T# m3 O v7 P
- *
5 T6 e; z7 M3 b( o8 Q) I( R - * This file contains EDMA3 Test code.6 c, q: `" X @% \9 Z1 h! Y
- *
3 G5 z6 D/ t+ o g - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE. R1 x' q0 b4 o$ y! R7 ?& V
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; n" p$ }9 ?; k* t9 K3 N- g9 E' P3 F* R! I
- * TO CHANGE.
) I& F# e9 u6 L, A5 {9 x - *
9 d0 b9 e/ @/ D* Z5 d6 F5 x - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 ^, S; y6 T1 }. F0 }4 x
- */ G2 L3 t+ P* W
- * This program is free software; you can redistribute it and/or/ A; k+ u6 r: W9 g
- * modify it under the terms of the GNU General Public License as
$ E; @6 z1 h2 d5 I" @1 l - * published by the Free Software Foundation version 2.# Q3 Q& A1 q7 z! A$ Q
- *
; m, c; U4 U6 p# o) U - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
8 I' e- X* J* f4 d - * kind, whether express or implied; without even the implied warranty0 V+ }; E- |7 A2 x ?
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) M- X2 n+ X$ F3 ?
- * GNU General Public License for more details.# W$ C0 r+ u/ H* _2 v' E1 v1 I
- */$ j4 y/ l( g% M& ~- S! z- ? A
# c1 d( }& q$ R8 R1 @- #include <linux/module.h>3 R% B) q' N( c
- #include <linux/init.h>/ \2 \; w, w0 i+ p8 b
- #include <linux/errno.h>% N- d: H) O5 `# u' P, [
- #include <linux/types.h>7 L( o- a+ P# Y4 c1 @5 ?" F
- #include <linux/interrupt.h>
8 i7 c* X$ Z& O2 J Z - #include <asm/io.h> k" z+ U) f' m) j. k6 Z
- #include <linux/moduleparam.h>3 X9 v3 {6 S" o% D+ Z( a! Z% H
- #include <linux/sysctl.h>
8 Q( N3 a; [4 \* a5 _& O - #include <linux/mm.h>
* }8 e* C2 i3 W0 g: J8 { - #include <linux/dma-mapping.h>
0 P- a' m2 B6 i2 m0 l - # X( D$ w3 D' h' ^% ]7 {$ B
- #include <mach/memory.h>
, K# L/ p* @: a9 W, h: u - #include <mach/hardware.h>
# B6 ]% _( r9 s- f( R8 l4 [: P( P - #include <mach/irqs.h>
Z" p- e+ H3 Z$ _ - #include <asm/hardware/edma.h>
3 `6 a. I. [# l) E0 _, c8 ^3 v - z+ s* e4 H# \0 n1 n2 s b
- #undef EDMA3_DEBUG
6 [' ^. I( _/ q v2 x* G+ j7 a - /*#define EDMA3_DEBUG*/
- H& | u/ Z0 j: G1 b - 1 V2 \7 q% L% L- g; M
- #ifdef EDMA3_DEBUG
/ [" G% ?" F; h, h W- E* W4 S - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)$ W# F% } Y) K" m
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__) |7 R4 C) q3 G
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
" x+ t0 K/ x: p1 I* J7 { - #else1 }8 Z$ S9 j# s% d7 @! k8 n! L, Q
- #define DMA_PRINTK( x... )
% d: \2 r' G8 L: `4 H! R8 J - #define DMA_FN_IN$ w8 h" a! x( u1 _4 _
- #define DMA_FN_OUT: f4 g5 l3 F6 \* i
- #endif) X: s. a7 x4 q- y% M9 o, a
5 ^ \& i z$ O- I8 X# ]8 i N9 K- #define MAX_DMA_TRANSFER_IN_BYTES (32768): l$ U: h2 `- n. G! H+ L3 k
- #define STATIC_SHIFT 3
! b$ S$ W, L G0 N# i - #define TCINTEN_SHIFT 20+ r0 ^7 b0 o+ B3 a" O
- #define ITCINTEN_SHIFT 21
7 A. O- A; J+ A, f8 m! m9 u5 A - #define TCCHEN_SHIFT 22
4 o) Z7 X7 v9 Z - #define ITCCHEN_SHIFT 23
1 H u. E) e- q5 m. A- {! t) v
' @$ ^! Y9 e' U9 }- static volatile int irqraised1 = 0;
+ ?7 T( z3 ?. z7 ~ - static volatile int irqraised2 = 0;, }3 ?6 j) T" C ^! C7 D1 m2 F
' X' L; }- s* U& h8 p- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); @) U* z0 }6 R/ F4 `+ [" i( \& d) J
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& p9 e7 V% f9 ?* K- T2 h1 }; y - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 K! @ S- l# n, D# d+ E2 L. D% J" D
, I* V7 n: x7 R" P9 Q- dma_addr_t dmaphyssrc1 = 0;
& h, O+ @! M. T5 t- K! @ - dma_addr_t dmaphyssrc2 = 0;
6 U. ?7 ^6 ?1 ]% c. ~ - dma_addr_t dmaphysdest1 = 0;; b& A8 i. Z' \3 y# u
- dma_addr_t dmaphysdest2 = 0;$ Y% V9 V/ F2 u( M3 f% J( g
- ; U* N# @# O+ Z0 I, F Q
- char *dmabufsrc1 = NULL;
8 C% q9 \$ P! n, B, ^5 ~8 Q* [6 s" L* J - char *dmabufsrc2 = NULL;& M3 u. W; N; s3 F
- char *dmabufdest1 = NULL;
* O6 s# k* ?" Z- i - char *dmabufdest2 = NULL;% S( I% [2 a5 H5 J) |% z$ [8 w
- 9 Y2 v8 | H+ e# \ T1 F
- static int acnt = 512;
& A7 V& C) D. f4 N) @6 l! v - static int bcnt = 8;
' g; ] f7 ^$ E) U' ] - static int ccnt = 8;, u; p+ h& E# ~# \: E% h
- + w: H/ E- z% P# ^0 D. ?: L
- module_param(acnt, int, S_IRUGO);8 c5 \: W/ B& H
- module_param(bcnt, int, S_IRUGO);
' \6 x( E1 [; z - module_param(ccnt, int, S_IRUGO);
复制代码 1 I* S7 m0 N8 c% {9 ?2 Z
# ]% ]( o5 t I7 V8 c
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ Y4 n8 E, k4 ?0 [ G, varm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
4 v4 V) l/ L; @0 t( {) s 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。% |/ U" k9 }1 j6 M3 C
% Z# n. T3 Q1 u4 `: h
5 |6 r" T( J9 h: @% g |
|