|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : J& F0 ^$ j' c
- [code]EDMA sample test application
% x) y# m2 c$ x( B' J - /*; E, l/ [& U; C% y
- * edma_test.c- d; A1 a9 d; R& N; {1 N2 C
- *, q/ X6 |/ @+ B
- * brief EDMA3 Test Application
; A$ v, M7 v! v1 a9 {% r6 F - *$ J+ R5 t; @4 ?2 B- Z* e& `
- * This file contains EDMA3 Test code.4 j4 f, _2 w# `5 |1 \
- *
- Z6 x6 ^; I2 e' J3 M8 R - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE# W8 T% O( D- X. {/ W, J
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
# X h. D2 x9 F% d. p) O - * TO CHANGE.
5 Q; J. T8 D0 D3 y' `- x - *
: ]2 u L# l. J4 | - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
: J7 Z/ W" `6 m* u' U; V: L - *4 x% A$ t9 @$ l- C) V) l8 J0 `0 M
- * This program is free software; you can redistribute it and/or
- \, ?$ T4 D/ _% j( X+ V) s - * modify it under the terms of the GNU General Public License as
% m* s; ?/ s. Z9 ? - * published by the Free Software Foundation version 2., s& v) ]: J$ w
- *
! a& e" R5 e8 t/ K8 S) o& o# H3 u - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
" T; X: _* H! P4 _ - * kind, whether express or implied; without even the implied warranty, V# y# C* P! M A
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) [( I8 V9 G& k6 S3 \ - * GNU General Public License for more details.; r6 Y3 {# S# L0 n3 y( ^
- */
( Y9 `0 N0 L& T' i - 0 q% ?8 C2 f- t6 C2 z7 I* X U
- #include <linux/module.h>/ y/ H' M" \: c5 | T
- #include <linux/init.h> U. d/ {- G' A5 u o; ]: J3 s( }
- #include <linux/errno.h>
; I% _( E- G R+ g - #include <linux/types.h>
$ _( U, d: X4 d! ~' g6 j9 ]# @ - #include <linux/interrupt.h>
$ a Q( \6 C6 u9 I& O! I& @ - #include <asm/io.h>( q! D' F8 F |- i
- #include <linux/moduleparam.h>
7 B z+ t" |5 B( W9 B+ ~3 N - #include <linux/sysctl.h>3 h2 B- O6 Z( c& |3 p
- #include <linux/mm.h>
u: o1 Z# V. L# G6 d - #include <linux/dma-mapping.h>% O3 o. B3 |2 L. t4 ?
- - U: r9 _+ c" P/ B
- #include <mach/memory.h>
8 Q4 j! A, v7 E; u - #include <mach/hardware.h>
6 A* g. q3 o. v [0 N Y$ Z+ b - #include <mach/irqs.h>
0 t4 [0 ^$ @' p" E2 H - #include <asm/hardware/edma.h>
/ S, i6 X* m7 i. G( i
# m; W& N# R) z& E9 V& e3 U( S: I- #undef EDMA3_DEBUG
9 @' u- L5 w* |& Z. K6 X) U - /*#define EDMA3_DEBUG*/
6 m& e u- A. Z( |. [6 Q
- a6 V& M& t% D/ `- #ifdef EDMA3_DEBUG
* O! p! j" a& i - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
' ~8 B# p, F% ~& x/ \0 V* u" T) _ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)1 m0 W, z& U1 J2 @6 K7 ^! A
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__), r$ D; p% g4 K! t! _* g
- #else
9 v/ |- L, \2 d* i4 k) {' q - #define DMA_PRINTK( x... )
% }; Z$ W8 V, T4 ?% i5 Q: \- O! C - #define DMA_FN_IN
- C2 h$ i/ J& t" i - #define DMA_FN_OUT
5 i% P' [9 |' W. i, V) q" E% G# Z - #endif
1 B3 W2 }7 }8 A/ B6 e6 C& W: D - ) g$ `, c3 C2 o0 r# z- L, Y: w7 K
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)8 g/ k5 ~# O4 ?" Y" u& Y
- #define STATIC_SHIFT 3
6 Q; A- H- g8 ~/ W1 N - #define TCINTEN_SHIFT 20
' ~, E# ~1 s0 W0 x - #define ITCINTEN_SHIFT 21
/ q: r% K; v7 ]# i* k$ [# M - #define TCCHEN_SHIFT 22
# t& L+ h# E2 `! ?9 [5 w& t - #define ITCCHEN_SHIFT 23
3 i' C' x. Q6 z1 c3 v- h( q - + Z! o0 C& \8 J a# I( M9 n
- static volatile int irqraised1 = 0;
o8 S$ ?: ~% } - static volatile int irqraised2 = 0;
* u! a& z: v/ c$ o' J - * @. ~, f: E& F0 y+ G) H
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 V i% s; D: V* [% M2 l
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); T& A N. Y: l* @; _! v
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" G; v$ _$ t; Y3 T5 ?7 |
: v% _2 N& n X, y3 V2 ^- dma_addr_t dmaphyssrc1 = 0;; ~- O1 X# y* a9 x5 e- p
- dma_addr_t dmaphyssrc2 = 0;- `! u) O8 ]0 e# A
- dma_addr_t dmaphysdest1 = 0;+ e L6 ~0 X S, J) x" F. v
- dma_addr_t dmaphysdest2 = 0;
' b; q! K, x% n ?& z$ c3 f9 a5 K - % M' g7 C- e1 }4 N: [
- char *dmabufsrc1 = NULL;
: R7 L$ F) p; y/ @+ n. c' u - char *dmabufsrc2 = NULL;
1 C5 b4 w0 n$ r$ K4 E - char *dmabufdest1 = NULL;% C& T3 w8 _" b8 M# p$ T! q, ~
- char *dmabufdest2 = NULL;; i* O: Q$ F5 y4 a* W- C U
- ! h- V% ?" c' E) B; a& l0 B: Z% M
- static int acnt = 512;0 r6 g& f* R) ~2 z% D
- static int bcnt = 8;
# [+ \$ q* T& m+ u - static int ccnt = 8;9 ?" V* y9 ?, h8 @8 n" D
- L* j& T* | ]* y6 T+ @3 [
- module_param(acnt, int, S_IRUGO);4 I& K/ h& p2 v- \- u0 O9 D% d4 q
- module_param(bcnt, int, S_IRUGO);
/ R' L: M% @* _0 g* b3 q+ e ^ - module_param(ccnt, int, S_IRUGO);
复制代码
# Q$ r. l# c9 a! a9 w% L
% }! Z. A9 C" D/ D; U 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: V) g5 t3 Y, G2 E q: Sarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。7 g+ ^4 t8 ~- s( C: K5 a
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
- ~. f& D& Y' S+ A4 U) k% O6 [; } [* O) ~1 p( _+ k
6 s) s, f2 e: i1 n6 N1 e1 V8 ` |
|