|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! z" N# H+ V. P9 E- [code]EDMA sample test application! Y. N- B& F+ N) o" K
- /*2 D8 }# G) P3 x5 N. a( A( J4 @
- * edma_test.c
0 W" ?7 D6 L$ l' ~% I @( J) R - *7 s) P8 y( q, Y, d# ~. j8 \$ d2 J
- * brief EDMA3 Test Application( ]2 s; `. ~. v$ ?1 W. P; o
- *
8 R* I7 m; ^/ Z* `" ] - * This file contains EDMA3 Test code.
' P) w: s8 u6 u* A( f# v4 Y" H - * D6 e; A' r& z- D. o) G0 P
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE9 U( f; ^( T. i# V% M
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT) U- s6 P; W/ h1 @' n
- * TO CHANGE.
7 H+ A/ J8 h; h; B - *
; x2 M j# q, ]" g& t1 ?0 ~. Y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/, e: z% X' M- o' w9 G( b' T* r
- *
. p) r8 Q2 L6 R, ~/ f' O - * This program is free software; you can redistribute it and/or
, s0 [- `2 P7 ] - * modify it under the terms of the GNU General Public License as8 _& f/ P9 C7 j
- * published by the Free Software Foundation version 2.
& Z, O r3 h, C - *7 q9 O) S9 r. d( `
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
3 Q$ @. s$ r3 F" m: \/ _ - * kind, whether express or implied; without even the implied warranty
& V6 S% d& g3 h - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
, k( N$ {. r- V' C - * GNU General Public License for more details.
8 y; P* _! W( I9 J4 J$ l _* N - */. {: R& }8 {# [8 k9 V/ d1 ^0 [) n
% O, S0 c& A! ]$ j D O5 S- z; J- #include <linux/module.h>
9 \1 n* O# \- {, ` - #include <linux/init.h>+ ~0 f* V& Q* \( t; S
- #include <linux/errno.h>
2 Y) O: M" c& J! i y$ C - #include <linux/types.h>; P8 x- y2 [, G, D$ ]" v
- #include <linux/interrupt.h>
# `9 `" Q/ [# y9 q' a" V - #include <asm/io.h>2 x1 L% Y. I) |# P6 t8 f- g
- #include <linux/moduleparam.h>* Q$ _1 Y$ c9 G' U. R& N
- #include <linux/sysctl.h>
& G" V, E5 B7 D5 v - #include <linux/mm.h>
$ R6 [6 N4 k3 y$ y! i - #include <linux/dma-mapping.h>
# F& T3 U" a8 a: A3 t, e4 T
% [/ L. L2 `( C6 V- #include <mach/memory.h>
& G! m3 e4 W3 k6 h$ \6 c - #include <mach/hardware.h>
5 ^: h8 }# X7 ]: q3 W - #include <mach/irqs.h>6 v& O, N4 ^: P, V6 e: {
- #include <asm/hardware/edma.h>
9 Q8 f1 n$ c9 X - % i7 @; H# {/ a/ \+ R% ]0 k
- #undef EDMA3_DEBUG
- ?/ o4 ~" A) f* _6 D3 ? - /*#define EDMA3_DEBUG*/+ F( c& t5 I. x5 j( R- b- K. d- J$ W
3 L3 I3 e1 x3 J0 P( g- #ifdef EDMA3_DEBUG* h1 p/ L0 U6 z: j/ F
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
+ R7 J! l& V, F& y" ]8 b - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)# L2 a5 I7 J0 e* r; g1 L# x
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
% R2 m ]- B) t" I0 Y - #else
+ }, s' I l3 C+ ]& o2 z' k - #define DMA_PRINTK( x... )1 \! `- c9 h& H: _+ r5 v; }) i
- #define DMA_FN_IN$ t; N- Q7 U; n# z# c/ P
- #define DMA_FN_OUT- y* Z, c% |3 l' h1 L. q% U* ?1 X, I
- #endif' q7 n& W% k5 Q7 n' T/ G5 R
- " }3 z# f! {6 ^" I X2 U
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ Z: n% L8 G" ~: l, X0 Z
- #define STATIC_SHIFT 3* ~6 x' L( t1 ]& V2 X1 i4 ^5 p
- #define TCINTEN_SHIFT 20
: w2 `; F* b' f/ b% {" M# q - #define ITCINTEN_SHIFT 21/ A8 ?7 T2 E& {1 N
- #define TCCHEN_SHIFT 22; w* v/ u8 r) F$ N$ K
- #define ITCCHEN_SHIFT 23
% [2 ~: Y! J0 J6 h
. g, p5 e! w( I0 b$ v. |- static volatile int irqraised1 = 0;
+ f0 Z& s3 B1 S3 |) {( y3 ?( W - static volatile int irqraised2 = 0;3 ?! F4 F \" I! l& L$ [
5 C* l; R! E/ Z8 V- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 h' }2 ?+ I7 r: i3 R - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ o& @- T3 @1 ~5 m0 o5 N5 h - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& e* _; ?0 e# g8 E, S! J# e5 Z- g
2 x1 X( f$ [: {7 @7 K& s t- dma_addr_t dmaphyssrc1 = 0;
" ^" I) ^# b2 y4 M' ^ - dma_addr_t dmaphyssrc2 = 0;
. F+ e( Q B D# z - dma_addr_t dmaphysdest1 = 0;9 R% Y7 r9 y; k( Y' _
- dma_addr_t dmaphysdest2 = 0;
- Q9 Z9 |# K' `8 `! l2 o
0 G1 B# u: \6 H# F. b- char *dmabufsrc1 = NULL;8 z! ^2 Z' f; j8 t( q6 { E
- char *dmabufsrc2 = NULL;2 B6 Z6 K" ], S6 |/ y f8 q5 Q! A
- char *dmabufdest1 = NULL;1 F4 E( A0 @6 m- V: F
- char *dmabufdest2 = NULL;
* k) |9 U) A" p* L6 f - * h5 G3 J3 P5 n- G" Q4 I
- static int acnt = 512;& [, P1 X S) f( ?9 G3 O
- static int bcnt = 8;
. ^7 h3 b. H! X- m - static int ccnt = 8;
# n' E1 P' X1 ]/ y
. ~3 _8 {# j! V' e3 m" p G- module_param(acnt, int, S_IRUGO);. a7 I4 @5 [4 E8 {- x2 t. {
- module_param(bcnt, int, S_IRUGO);. f$ z9 ^5 {" z: P
- module_param(ccnt, int, S_IRUGO);
复制代码 5 v! B0 \" n$ {# s5 c" ]
+ `. q4 E, [; H8 a8 y6 {3 {. @
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 S% [' v% D5 L4 J/ Oarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
8 Q& h7 d" z( ~2 g 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% D/ ~ x" M. h0 B3 j* b9 W; k0 w8 _! W p& i! C- _( `; I0 Y
6 C/ L- G7 k. d4 `8 ?
|
|