|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 5 K6 _- P6 A$ G9 T! d" |' p6 E' ?
- [code]EDMA sample test application
9 m X( w% X: W) F - /*
4 R) f4 j/ o, C/ w9 o5 A& T - * edma_test.c
; ], \$ ]! I0 `* L+ I( z - ** B! G6 \- J' k2 ]% V! o' c
- * brief EDMA3 Test Application
7 ^0 l- x3 R% c# W$ i& Y& ~) _ - *
6 N; Q" a; z. r; j! B2 \ - * This file contains EDMA3 Test code.
$ D1 C1 L! C. R- A - *5 X5 f/ H) z! l* k0 }* f3 g3 b
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* y; c3 e' r1 S0 ` - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% V% P. i; A8 ~8 X9 W: h - * TO CHANGE.( i. v/ s% }* B) y* ]0 a/ {
- ** N, p. n" C% Z; |+ Y
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
& g, K( N* N' P7 w3 _2 Z6 R# J - *
/ F; G/ U5 Z# F( `# y7 H) o - * This program is free software; you can redistribute it and/or* I: Y- V2 P' R& r- V6 b
- * modify it under the terms of the GNU General Public License as; J9 F# O+ E1 ^5 b
- * published by the Free Software Foundation version 2.% ~7 x4 R1 O* I
- *1 f* U% l8 b/ `5 Y2 d7 O
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
( n! F5 E, w, \/ G4 m - * kind, whether express or implied; without even the implied warranty( \3 U7 m' ?3 i5 ^1 m; G
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 f4 E. p/ \& A g - * GNU General Public License for more details.
' ?/ S1 O7 J8 T9 ~' r1 g! _: q+ P - */
! w. K f# T8 b - : P) a" `" C ]: C* J
- #include <linux/module.h>& ?/ i8 Y/ ^3 [# m0 U/ C# @% C f! N
- #include <linux/init.h>
8 U- p: C L+ [- M# u - #include <linux/errno.h>& r2 n3 f. J2 i' L. U) r; }8 e6 l9 D! u% C
- #include <linux/types.h>7 O# `2 }" Q3 f- c3 M5 w- K9 `
- #include <linux/interrupt.h>
t1 t! O5 ^7 Q$ F - #include <asm/io.h>+ j" u) E- Q2 \+ l+ z
- #include <linux/moduleparam.h>& Q' }& ~ c h ^
- #include <linux/sysctl.h>
* l9 b+ P! C& I# L5 V5 W6 Q2 D - #include <linux/mm.h>
5 U( u2 j* J+ k8 E - #include <linux/dma-mapping.h>
) b& R2 u- R, q: K* B& i - 6 e# w" T& u* k0 z
- #include <mach/memory.h>% m) x$ M4 T* V
- #include <mach/hardware.h>
' a( Q# r, z% [9 z3 I2 j - #include <mach/irqs.h>3 w# S3 e# k) g2 f4 h! \" O. |0 c+ Z
- #include <asm/hardware/edma.h> C7 X) P) Y5 d7 t6 ]3 y( A
9 n0 P% u: g# }! S0 b) h- #undef EDMA3_DEBUG
$ h3 ~ l) [+ {, ? - /*#define EDMA3_DEBUG*/4 a8 z+ c) S( o& g; O+ w1 {
- 7 u1 k% ]$ y) y0 ^; [6 y
- #ifdef EDMA3_DEBUG
4 K2 a+ t* o8 a% Z - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ M' m7 s8 a. n+ r9 r0 j& i - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)4 t7 |; c, n3 `: i8 A0 C
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)+ W0 z/ e. h& z# i
- #else
: ^1 B: v+ N# L2 W* Z - #define DMA_PRINTK( x... )
& D7 w# c/ E( b/ p - #define DMA_FN_IN: ?: b" V" v% D0 T0 o3 p
- #define DMA_FN_OUT, r: { z' v7 M) n, ]; n$ G
- #endif
+ `7 Q! [% \; O" E+ R* @" s( e - ; e, c( F9 y- \, P7 J1 Z+ ^
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)4 W2 W/ o' k& x3 y6 K. B
- #define STATIC_SHIFT 3
( W; M9 ?$ \3 h% I1 Z - #define TCINTEN_SHIFT 20/ @) U, h1 M4 m3 k; X- R
- #define ITCINTEN_SHIFT 21# I5 m8 r' w2 h: y; g7 J
- #define TCCHEN_SHIFT 22
1 d: S" f4 l1 ^9 _# _7 ` - #define ITCCHEN_SHIFT 23
/ H0 c! I# g. V* }. ^/ A
. P2 _9 Y5 h, P( i8 p* n- static volatile int irqraised1 = 0;2 J& B% F( h7 y1 C
- static volatile int irqraised2 = 0;8 Y7 \ ~8 Z5 W4 J, u7 c2 W+ F+ W! e: {
/ Q# A$ r# c6 \: ?- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) K, A0 W/ m9 R# @! E - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- ]4 Y" l6 i- X% }
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! V8 V' d$ t- d: K% y
- 9 s& j& n( l# d' ]
- dma_addr_t dmaphyssrc1 = 0;1 P0 E2 t" P9 n3 n
- dma_addr_t dmaphyssrc2 = 0;' y) ~* q/ s9 C* X
- dma_addr_t dmaphysdest1 = 0;3 o7 ]% @# Q. k/ ~$ s6 _3 \4 J0 E1 g
- dma_addr_t dmaphysdest2 = 0;
" K' J1 d( t3 H3 k0 W5 H% N - - X( U& Q K3 D) Q4 |
- char *dmabufsrc1 = NULL;8 [" \4 T8 Y# `' o& d3 T
- char *dmabufsrc2 = NULL;" w) P, S3 r7 L6 X" x3 c
- char *dmabufdest1 = NULL;
8 [( m1 ]- S' D, e+ ?& [: u - char *dmabufdest2 = NULL;
w) c) _3 B- X3 V7 b T5 e# u) ?' ~ - & j" B0 ^8 S8 u6 a7 n! ^' x/ d
- static int acnt = 512;
, z, G3 E2 w" j# m7 p5 I3 p - static int bcnt = 8;) I9 v- |6 N* k# ] M% Z5 T
- static int ccnt = 8;: q$ g& [& N* u' T5 z L
6 I% Z) _ B# S- D- j) k( g% K- module_param(acnt, int, S_IRUGO);
4 j2 `4 m M* b. P' K: o/ h& t# q# U6 J - module_param(bcnt, int, S_IRUGO);8 O5 {/ L. y. h0 ^
- module_param(ccnt, int, S_IRUGO);
复制代码 " b/ T! f" U1 i' U
; S% ]3 s0 ?, T* j# M 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用4 i7 B. n! R0 l9 B6 Q8 }9 k& s
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。7 `" k+ L. a P. R0 |' R! ]
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' W) s1 _9 h; m% ` P' `
s, p& v/ s6 }/ M, @4 V. p2 ~ v" J$ I) P& s
|
|