|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. K! ~8 `8 U, w: }) a- [code]EDMA sample test application ^8 @) R8 J3 N1 g4 G9 ^
- /*
# b/ O) t' Y- ?7 ~. `5 u - * edma_test.c) g. x2 u+ U3 E7 U
- *
# U4 d; b, J4 \! P+ D9 T/ c, Q - * brief EDMA3 Test Application
. J! \. O0 L; O6 u; ] - *
& u" S4 j8 l+ O& { - * This file contains EDMA3 Test code.
/ g& z1 t7 s) B w5 [ - *
1 D' Q! |. N8 [8 S, M - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* N5 V8 k3 j" F+ |7 m* }0 D) {0 n7 k, K - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 P1 S5 D' m3 h' y - * TO CHANGE.$ A4 E$ ^, S6 G% U1 K1 y
- *4 W& b/ Z6 w; a
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- f# r/ B; `' N- S! n1 A
- *4 J- A) E* }) h/ h3 }/ `4 X2 H# `
- * This program is free software; you can redistribute it and/or5 }' m0 q; F& s
- * modify it under the terms of the GNU General Public License as
7 k1 s% B2 H( z% W - * published by the Free Software Foundation version 2.7 m3 o, f& i( c
- *5 F: S; A0 d+ b0 v: y
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
6 @( p1 ^. `) x' j) H; i - * kind, whether express or implied; without even the implied warranty- w1 v4 \! \2 Q$ l
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the2 x6 z1 H- L' O/ T9 |) Q
- * GNU General Public License for more details.
" X$ }* o5 a" q- B. o - */
6 L+ o1 r8 s7 S) H+ K) _' m
& {) o, j6 c. h2 Z8 u5 f1 [- #include <linux/module.h>
. N4 ]3 A* J3 u+ U! k3 {7 p) V! U - #include <linux/init.h>. U6 @9 c" }4 Q, v
- #include <linux/errno.h>
- ~+ A4 x" J2 O; q4 q+ L# E4 a - #include <linux/types.h>; y: N! K1 S6 B, G3 t
- #include <linux/interrupt.h>
) s; ]: ^# m% Z" e* W g8 e - #include <asm/io.h>
* L& U# [/ E& V5 p! c - #include <linux/moduleparam.h>
0 W# t* H; s# e* c$ f, i- Z' Q - #include <linux/sysctl.h>
% \3 F. f1 v1 e; G+ E+ Y) m. h - #include <linux/mm.h># b- U- a# V+ d, w
- #include <linux/dma-mapping.h>
" j) v2 I5 @9 }- ]! @ - ' u+ N v \# L! M; Z: I* _
- #include <mach/memory.h>$ S* B$ q. F2 s, z- ]; ^
- #include <mach/hardware.h>0 F# ^8 ]" ^. t; m1 V" W) A( z1 x
- #include <mach/irqs.h>7 f* D+ z8 ~ q6 {, A6 b
- #include <asm/hardware/edma.h>9 ?7 i: p. |# r
/ S+ N" a; ]. ] R* n1 ?" x- #undef EDMA3_DEBUG
M" f1 O) L M. M9 X( N2 i, r - /*#define EDMA3_DEBUG*/3 T: |) H; h |7 o( h
- 9 y" U% v! u$ a" k
- #ifdef EDMA3_DEBUG; ]. }& S9 R+ i% I2 g; ]0 Z
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
+ w3 v4 e, q# ]) l4 C/ y8 S - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)7 P8 [/ E' W( A- j
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
2 z( G7 _! i3 X$ V - #else* d* F: b) {1 C' d' i8 E
- #define DMA_PRINTK( x... )/ H8 {3 S& P B/ ^/ v/ b5 j2 M
- #define DMA_FN_IN
% i6 s I2 `1 X, j( n - #define DMA_FN_OUT" ~0 T0 y& @1 {' y1 E# C/ t
- #endif7 }+ Y! Z# P/ S: t; l" ~2 d
* ?& [+ S! X' ]& X- #define MAX_DMA_TRANSFER_IN_BYTES (32768) w# @" @- I3 E% o# U
- #define STATIC_SHIFT 3
# R3 o2 H! P! H( ^ - #define TCINTEN_SHIFT 20
?2 I* X; L& Q9 d - #define ITCINTEN_SHIFT 21
2 H# \. b' t* m/ L9 m; s - #define TCCHEN_SHIFT 22
# A8 h4 n$ R, I - #define ITCCHEN_SHIFT 23
, M h9 P! d* l* F3 K
# j+ V( W- g: c& J- static volatile int irqraised1 = 0;% c8 A8 d+ T* u& Z
- static volatile int irqraised2 = 0;
$ L5 ^& y- @- ?/ h" J - 3 K0 x% |% z4 Q; \1 H
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 h: d" {' U, M1 V5 q6 Y: s5 T
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 r# U5 v. m5 y: \: q
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ H6 Z2 A( f/ F, u: {/ f% v - # p' [4 W! O" B# D0 }8 y$ ^
- dma_addr_t dmaphyssrc1 = 0;5 U1 d/ i" y# ]3 w3 ]& u5 o7 H5 S
- dma_addr_t dmaphyssrc2 = 0;
& R$ d' z, V1 e# s% J - dma_addr_t dmaphysdest1 = 0;5 `( A! }) ^/ `: j. z2 s( R r
- dma_addr_t dmaphysdest2 = 0;
/ W- B: X+ W. o( u j - # A% R* U- q; m" [
- char *dmabufsrc1 = NULL;
: v n' h! k# x# b - char *dmabufsrc2 = NULL;
' V, X$ A+ g! o - char *dmabufdest1 = NULL;
$ a- D) `( R" P2 I: T+ l& @7 y - char *dmabufdest2 = NULL;* o$ M6 B+ H3 W
- - v( o1 \% z! r7 d9 k
- static int acnt = 512;( ]: h0 W s+ V5 X
- static int bcnt = 8;# d7 [) x* K8 U- @
- static int ccnt = 8;
P, A, M, ^' n0 U5 { O
) i/ b: A/ h4 H- module_param(acnt, int, S_IRUGO);5 E0 P0 Y9 v4 A, c4 [
- module_param(bcnt, int, S_IRUGO);
4 s% ~0 X& S4 {( }6 c4 W, i+ y) u% h - module_param(ccnt, int, S_IRUGO);
复制代码
: E2 L0 S: N9 f! U0 x, w d
7 x3 \; j5 o* o4 v1 t" q3 f 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
; x! R, B8 T: J; N7 Earm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# `* X3 {' U, \# v) d c4 ?
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
. b+ W) `9 m, i" I7 x
6 G+ D$ b. \4 d( M6 G$ i' X, S' F8 J, p( g% o
|
|