|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . q, K$ e! k; ^/ _' j. p. I5 `
- [code]EDMA sample test application
7 W$ Z v; B1 B) P5 |* K - /*9 E* d4 ~, P' ~) f
- * edma_test.c5 V; D& h: u c `) \
- *; M3 k m& \+ ?7 x5 v
- * brief EDMA3 Test Application
6 K9 q1 e7 K& r7 W0 L - *) L& G* V! t2 ^7 }1 H
- * This file contains EDMA3 Test code.
9 H$ {! \* l F5 Y - *$ f- O9 J8 C) k
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
. B) u& \) ~ |# }# n. E# ? - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT8 d: p" {5 r- t
- * TO CHANGE.
" N* `1 s' k3 N - *
3 W, s0 m p7 U - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
$ g: C) Z2 R+ q9 w0 }0 d- b - *
( e6 K2 f- ~- F2 T - * This program is free software; you can redistribute it and/or9 s/ f/ C1 z1 e% _! _1 N# t7 k8 Y
- * modify it under the terms of the GNU General Public License as& L+ j( V: z0 W0 b8 V
- * published by the Free Software Foundation version 2.; [* g! J& f1 G# x7 i# f* @
- *4 k' a- W8 q0 J( T$ T+ Q
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
( H0 U5 y* ], h2 R! R - * kind, whether express or implied; without even the implied warranty( o) ?" B9 C f5 Z! ? M
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ I6 Q* S, y7 h2 r; D - * GNU General Public License for more details.
2 }/ c$ O2 g6 @- Y: n& Y" P6 `1 _& p - */
5 T2 ^. P8 u! l7 ]* @" B9 W
. |8 G8 R! K- T% ^- #include <linux/module.h>
: S4 R9 ~' \+ Q l$ V - #include <linux/init.h>
; ~# H: M- k- A. x- r1 _2 a - #include <linux/errno.h>' V: a+ }. z$ V; K
- #include <linux/types.h>
- u" |- a; E! `5 r5 b( G - #include <linux/interrupt.h>
3 W3 H6 Y8 w: j" q - #include <asm/io.h>" Q* a8 ?3 x; `9 T% N
- #include <linux/moduleparam.h>
. f9 V( N$ p: `6 I" J5 o6 z% J: a - #include <linux/sysctl.h>. `, I+ n1 S) S0 y) h
- #include <linux/mm.h>6 c" \' R5 M$ z) R
- #include <linux/dma-mapping.h>7 d" T; U, ~2 X4 v
" x; K# d! J5 M9 j3 s- ^! A- #include <mach/memory.h>& A- B! r: d. b5 l' x
- #include <mach/hardware.h># x7 l* r* b4 W' w
- #include <mach/irqs.h>
2 t0 N: m8 f+ R - #include <asm/hardware/edma.h>- G0 r+ L D9 L9 x
0 f H# `' n4 h" f7 {. D4 N G3 [- #undef EDMA3_DEBUG% p0 `4 F* f& @% @( r; x( p* u% D
- /*#define EDMA3_DEBUG*/1 c' t/ k5 v7 a' S) y
- % V+ `$ }3 G( S5 L \* X/ T% a
- #ifdef EDMA3_DEBUG2 o1 Y; K4 f: l, j: V1 t8 r
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
8 [, H: o5 }) _- T6 j - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)# d/ `% j2 t- x% t7 K# r- ]! |- S
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
' J4 s* Z( o U I/ V - #else& a4 H; q6 h) i6 u3 R/ _' T% L# y8 Q
- #define DMA_PRINTK( x... )) B( y( a# e7 D$ F, D
- #define DMA_FN_IN" ~% ~# y/ x! J4 P: F% k
- #define DMA_FN_OUT
% x' ~( u1 a: o; v - #endif( T6 W% J$ y" ?( S9 g" u
6 G' j8 J- ]. \8 L; Y0 _# t- #define MAX_DMA_TRANSFER_IN_BYTES (32768)2 S+ Q% z, Q7 r: @( M a! ^
- #define STATIC_SHIFT 3
3 ?/ L2 D. K. _# N1 {8 K9 | - #define TCINTEN_SHIFT 20# I f. j% O, l% D* x$ z w; u
- #define ITCINTEN_SHIFT 21
2 O8 S& ~% H( V! B1 Q- {$ _/ M0 x - #define TCCHEN_SHIFT 22) T! T- X2 Y' X$ T1 A- O
- #define ITCCHEN_SHIFT 23$ |& x/ J2 Z @/ g! p
# [+ }: d% f: p6 y1 @# B+ s3 E1 J- static volatile int irqraised1 = 0;
% b- {9 u5 }7 \# M8 v! Y - static volatile int irqraised2 = 0;' L7 u0 ^% w6 g. `3 I8 L/ H1 N
- % o( C" s1 q% D6 ~8 }
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
f9 A* ^/ h# E- ^6 F5 P- R& Z - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; p8 G; o. \1 R2 X8 _ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ j0 D2 z9 }+ H; `/ |& T - ; Q. _! [5 [- d2 v
- dma_addr_t dmaphyssrc1 = 0;
* v' @; @5 S3 `1 } - dma_addr_t dmaphyssrc2 = 0;+ H# J0 O4 l6 B4 t- Y8 J
- dma_addr_t dmaphysdest1 = 0;0 m6 C u7 C* g6 J% x
- dma_addr_t dmaphysdest2 = 0;
# h6 A8 U# a" v' o! ]3 p
8 z3 h/ y6 N- [- B- m" g7 [1 q- char *dmabufsrc1 = NULL;: q( e9 _) ~* d' H# }2 c
- char *dmabufsrc2 = NULL;
* G; \* z. g- G/ i% t- ]; ] - char *dmabufdest1 = NULL;3 ] [. Q" E1 K5 g5 M+ w
- char *dmabufdest2 = NULL;% ~0 N& u* _; K* X$ ~
/ A( U2 a& A k: o, ~- static int acnt = 512;0 h1 @3 ~2 W! z7 ~( E
- static int bcnt = 8;/ }6 L! {6 [- q6 Q n2 h2 |+ m
- static int ccnt = 8;
( |$ g$ a: u h; ^3 y - 0 C- H; z% u, h
- module_param(acnt, int, S_IRUGO);* h3 @+ Q4 u0 s, t8 M3 j
- module_param(bcnt, int, S_IRUGO);
* F( f) P* E/ `$ b/ v7 w - module_param(ccnt, int, S_IRUGO);
复制代码 8 G* m0 |) W, \/ `, [
! A( ~$ u1 u$ B& O5 C/ O' f 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
; u9 ^$ K" i( \( D0 Q3 c( Narm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
; C2 d$ D& c) Z5 Q* T: b 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。3 f) z# g9 o* ^2 s# ]0 y8 U: B0 J
8 _7 S' r7 s: s$ A# ?) c' d& j3 E9 j( I5 V9 X0 @. J( ]' h3 s
|
|