|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; F+ K! K- w* \3 I- [code]EDMA sample test application
( P( l. M2 v' D3 I# x9 e - /*! d( `3 c; R0 N
- * edma_test.c
P% A6 a V. K - *
" z7 J+ q2 ~6 u+ D. R5 P( L4 c& e - * brief EDMA3 Test Application
5 \9 Y/ a3 X0 n' ?' J - *; P/ a& x- k" r% z: h
- * This file contains EDMA3 Test code.
8 ?9 v3 b% M- |& }8 \$ s - *$ R0 ^' W [% s. ^+ V7 _+ [
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE0 G$ V! k+ ?7 z; F
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
/ ] F; }- j: Z* r4 p" r; z. ^ - * TO CHANGE.0 S2 X( F' V+ F( a
- *0 g4 s5 k9 ^! V6 _: L
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
/ x( ]/ k( V( _8 @4 J( P - *
; Z& }; k0 w; D: T: u G3 ^8 R - * This program is free software; you can redistribute it and/or
1 j. D1 n2 h+ S j1 o/ k - * modify it under the terms of the GNU General Public License as% t$ N8 \; [. U2 D' D
- * published by the Free Software Foundation version 2.
6 n3 ^+ S# n& P# Z! ?/ m* E - *2 m3 r7 N! H6 M3 T$ m" P
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any2 u) ?' N4 I# v1 l
- * kind, whether express or implied; without even the implied warranty+ n, f) S1 a6 {) Y
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 e: q% I! D5 y% B6 D0 G+ R - * GNU General Public License for more details.
; c# V) q' q* \- A f5 Y - */
8 p# G, V: a. g1 c9 ^. `. [ - + M- Q/ j3 G# o( u( ~
- #include <linux/module.h>
|% o) j7 H. r - #include <linux/init.h>
7 `7 X# u; h5 t3 X# {* ?6 U - #include <linux/errno.h>- A$ v6 Z2 @# O! V4 X I% `
- #include <linux/types.h>
( Q" K! `1 z( x* i - #include <linux/interrupt.h># r3 M/ V4 q6 U
- #include <asm/io.h>2 @) b3 I, Q# @( q& v2 \
- #include <linux/moduleparam.h>! M( J2 c3 k% P4 O: p; @+ A
- #include <linux/sysctl.h>
3 X0 N- L1 J' f; N' w& U/ G - #include <linux/mm.h>
, X. C1 W4 G& T( @0 D# J - #include <linux/dma-mapping.h>: k) \/ Z0 n! R
- & ?0 \0 n% y: U! D- K, }2 t" q3 s& ^0 {
- #include <mach/memory.h>2 d. M A0 g3 H' o+ z) i4 N J
- #include <mach/hardware.h>
) G% P1 p b9 S; K# n - #include <mach/irqs.h>& Z2 r1 Q. W9 s% a
- #include <asm/hardware/edma.h>
7 h7 M, z' o* ~) j2 e1 S$ F. C$ Z& h - 8 L5 u- T @ s( _8 a# j
- #undef EDMA3_DEBUG- }; t }9 i, ~* q$ Q% w% j& O
- /*#define EDMA3_DEBUG*/8 e5 ~! D, Z$ z/ B; b' \9 x9 Q
- ( x# s' Z5 c; C1 o$ I6 t4 h; m
- #ifdef EDMA3_DEBUG" j. K' f, c$ Y/ s: e, t
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)! G9 O2 `: |" Y2 X; |/ c
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 }! k' _/ Y8 j$ y- A) k - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) b- s& s" D$ B! t8 ?' z - #else( F2 z+ c+ c3 w
- #define DMA_PRINTK( x... )7 {7 `$ T0 J* a# } s
- #define DMA_FN_IN, f2 r& n! ^) H- I( P" N
- #define DMA_FN_OUT
+ g4 S$ f' e \5 O5 v7 w' } - #endif2 f# p* j( x" ~. N- H9 Z6 R
- 3 h+ C9 K; Y& P
- #define MAX_DMA_TRANSFER_IN_BYTES (32768) V+ W8 j( ]( g' h
- #define STATIC_SHIFT 3
, \ H* q/ f) j - #define TCINTEN_SHIFT 20
5 d, ?8 k% L0 W1 L9 H - #define ITCINTEN_SHIFT 21 e) c3 B, X3 d
- #define TCCHEN_SHIFT 22
9 _# C7 h; N+ s' G - #define ITCCHEN_SHIFT 23# a' `$ `3 F9 Q p! _# T
0 N: K% ?' w# D- static volatile int irqraised1 = 0;# K# u& ]+ |+ Y l) p
- static volatile int irqraised2 = 0;) d2 o2 l% _0 I+ a
- $ k/ H- }( I I+ R B+ `
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 o: Q1 H- n- p: B# Z* _" L6 f - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. ?/ S8 }2 a2 {% }: e3 G# z# P
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 M9 N$ L. @; y) V
# \3 a) F, M& _; j- _" x* e- dma_addr_t dmaphyssrc1 = 0;/ g3 P$ A8 d8 w1 [9 r! F
- dma_addr_t dmaphyssrc2 = 0;
. H, ?7 E3 e L: ]4 L - dma_addr_t dmaphysdest1 = 0;7 B/ E2 d" @0 M1 H& u G( U
- dma_addr_t dmaphysdest2 = 0;& f2 U- k2 e8 F `/ O8 w# c: u
; w3 t0 t, o; k [- char *dmabufsrc1 = NULL;
" T8 r9 S* E. s* K; J7 d4 D - char *dmabufsrc2 = NULL;# Y2 h# L F! g$ @. }% B
- char *dmabufdest1 = NULL;! p! K; W4 T& {: O
- char *dmabufdest2 = NULL;
" ^) S$ B0 K$ m
/ ?: s4 |0 P# M' K. Q1 T- static int acnt = 512;
g7 b9 F% ] G/ ]; n1 ?5 c - static int bcnt = 8;
" |0 X* I4 Y5 G3 E/ s - static int ccnt = 8;
; w: B+ H* k9 T% _, F, U$ O" s - ; d+ D5 h( a9 k' V" ]( m( b+ A
- module_param(acnt, int, S_IRUGO);6 ?! d# k% X/ Y1 e ^; C
- module_param(bcnt, int, S_IRUGO);
# }- W! G, q* w) N2 [4 J0 }2 {& k - module_param(ccnt, int, S_IRUGO);
复制代码 - Y' P) C6 c5 C8 A
% {# t( J/ [" [' g+ K 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用- W5 n1 H8 d! q8 t$ T
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
# _ X2 H7 p& P; o; p 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
4 W3 c" C: s [, T4 D+ D; C8 }, M" F. a0 m; J& s
8 {' ^* l1 q6 I0 l! | |
|