|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; g$ b& C2 d1 J- r- [code]EDMA sample test application
% U4 y) G+ J4 T8 t - /*
% ^0 V2 I# u1 ^; t1 Y2 Q2 U! t - * edma_test.c4 q6 @5 y( e/ {6 m$ ]. v4 ~& a; N. k
- *- O0 S- k7 e2 l7 m+ P' {
- * brief EDMA3 Test Application, L5 H) }/ C% C) |5 `9 K
- *
w$ Q4 @) i, Y h1 x( S- s - * This file contains EDMA3 Test code.& |6 o( p5 q) j2 S
- *
; C* ?8 a" a& T, f, C0 | - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
& S/ a+ D/ K2 d* ]9 b1 C1 ` - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT. M; Q# G0 L. i/ B$ n' `9 s1 M
- * TO CHANGE.
8 ?, N0 f$ y7 O1 W! J2 h+ y - *
: K( s* x( u+ ^+ e. ]9 Q - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 y0 l( a: F) Q/ H0 r
- *) e. A, @; }( G- ], [
- * This program is free software; you can redistribute it and/or
, c- }/ b. Y- U( J6 \ - * modify it under the terms of the GNU General Public License as Y) r7 a6 j3 l! o# S5 x: g
- * published by the Free Software Foundation version 2.8 A3 ~3 d0 O t% R
- *
! }9 Z2 N5 T5 I f" M' o - * This program is distributed "as is" WITHOUT ANY WARRANTY of any2 H8 A" n7 |. m0 l7 t$ V1 ~1 P
- * kind, whether express or implied; without even the implied warranty2 C' O- h N! J, l; m3 r" U
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the. K% ]4 c& m, ?# d- R" h* ^
- * GNU General Public License for more details.
0 x9 ~+ V2 ~0 _1 y - */
; n8 G, c+ H2 r; h/ H$ `( b7 G - $ u5 B% H1 h" I. K! m, J* c
- #include <linux/module.h>
% ]8 y! i, S7 I7 M3 Q - #include <linux/init.h>
* y9 Y! @7 @0 X: w - #include <linux/errno.h>; w8 E7 @ V1 t/ v/ C. R
- #include <linux/types.h>: x9 A; ]1 e( a* n O# `7 `
- #include <linux/interrupt.h>; {% v1 t% t, `4 W
- #include <asm/io.h> E+ v8 |9 A+ x r7 g$ i/ z
- #include <linux/moduleparam.h>
3 y( h1 D& ?- Z. x, ~1 y* Z - #include <linux/sysctl.h>
7 X& [4 s$ r2 t) _5 i- \% @6 S& D - #include <linux/mm.h>0 T& _- |1 M" ]3 a c& m9 m; n1 C
- #include <linux/dma-mapping.h>
. j2 [# d" a4 j3 \/ C
7 H- I8 U5 Q2 K0 _- #include <mach/memory.h>
/ V- \( G4 ]" V. p - #include <mach/hardware.h>
7 w$ q: z# l0 v4 S2 w9 h" X. w - #include <mach/irqs.h>
; O9 v) r. H+ w: L5 C - #include <asm/hardware/edma.h>
3 s x1 A' @# H: ] - 6 L' [& [) Y8 o+ |% V
- #undef EDMA3_DEBUG0 d1 ?! d$ ]: s8 ^
- /*#define EDMA3_DEBUG*/* T9 P1 X$ k+ |6 L2 ~) p. b, s
4 u1 ^3 a9 G3 c8 J+ W/ W' s, K- #ifdef EDMA3_DEBUG
. w. v! ~9 N1 i* l' r% O - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
A X- `/ @2 u! M3 N) {1 r+ Q; q8 ~ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
9 p: Q+ y0 W) j - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)" J% t6 h) b" P
- #else% V' K4 A* o5 V! A; ~3 ^7 W' w
- #define DMA_PRINTK( x... )
0 D, @) i/ b& H" P/ C - #define DMA_FN_IN
9 B2 P) f4 k+ ~. G! g: Q - #define DMA_FN_OUT: e8 h8 P4 z. p/ H9 {8 J
- #endif+ S. X) e) D/ p6 [& m" @
- . f% m D/ x3 K1 }, V" n, `# d6 b/ w
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
6 o$ N3 b1 Y7 t. z - #define STATIC_SHIFT 3
% |/ W6 Y6 P4 t7 Z/ b- a - #define TCINTEN_SHIFT 20: ~3 E: d0 O! d& ?7 Y# a& G5 ~3 m
- #define ITCINTEN_SHIFT 21
6 g8 J. i p/ D0 O - #define TCCHEN_SHIFT 22
; x/ t. n8 x. R. k/ J# Q M4 O - #define ITCCHEN_SHIFT 23
- t( R4 n9 u* f$ i6 z o - . M% e2 U+ p& j& n
- static volatile int irqraised1 = 0;( C4 N. m4 P& l" m
- static volatile int irqraised2 = 0;" W' E7 d% l3 P' a' q' c
- ]! B! e. j+ Z1 T' u- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 U T8 R0 W9 t - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# U* Z5 k: [9 t - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ R1 q* S. V# A9 r, ~
- , D8 o6 W! J M, _9 _
- dma_addr_t dmaphyssrc1 = 0;! W! u# O- Z' M- W7 O3 X% d9 d
- dma_addr_t dmaphyssrc2 = 0;! G8 k+ |% F$ \/ W
- dma_addr_t dmaphysdest1 = 0;
" T! M+ Z" l, h. w9 x - dma_addr_t dmaphysdest2 = 0;" U% H- \: L7 a3 w6 ^! V7 ?% T& ]
( f: U \! w# C9 [/ R* @! N- char *dmabufsrc1 = NULL;. e. v0 ~2 v& k
- char *dmabufsrc2 = NULL;1 d# @- I% c l6 u. \: T. x3 }3 V
- char *dmabufdest1 = NULL;
/ h! ?# R3 i: x+ g5 G - char *dmabufdest2 = NULL;
4 E6 K; T, V- ^6 K% r' Y
" J) X! |2 p8 l- n( U5 ^( Z- static int acnt = 512;5 @& X; T4 _2 u* x
- static int bcnt = 8;4 D4 ]: s. A" [
- static int ccnt = 8;
* O$ {; u: Q4 i4 r
3 H& ?* B& T4 B/ }' k- S- module_param(acnt, int, S_IRUGO);7 f2 P! s! B/ Z' T
- module_param(bcnt, int, S_IRUGO);( S7 n1 q! t- q+ @7 t* G2 D* L0 g
- module_param(ccnt, int, S_IRUGO);
复制代码 & y3 `* g" q4 e) J
# R- U! W6 L6 p+ J4 R; w. M
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用/ S; i% Z9 D/ 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。: S6 R9 g# x( M; T% z
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。* {# m9 v& h2 j
4 O0 G# m! u' |2 ]( K# c3 j0 D
# }7 o+ ^3 y# B+ ?& y2 \7 [ y |
|