|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
: |0 f8 }0 P; P- f5 N/ J- [code]EDMA sample test application. J9 f0 r h* ^$ j) L$ u& ?
- /*7 o. a9 Q1 u* v9 e1 ~* ]
- * edma_test.c
5 G( J1 x. }. a. v/ H. g - *
; K! `1 N$ {4 [4 H - * brief EDMA3 Test Application, e0 Z1 I: z1 t& M2 | ?
- *) q& { S4 l) j" f% @
- * This file contains EDMA3 Test code.. X' d4 S8 |4 k, k: K8 q! v! f" c
- *" y0 ^8 \! K, T! m8 i* R5 U* O
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE& Q1 U6 F) v3 ]3 W1 p2 ^5 `
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT! [( J( h! H6 i) c1 I# O1 i
- * TO CHANGE.
; k0 h. }; n1 q# v - *
% F/ n( ^% x8 @" k/ n - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; J2 }! u2 H" s- ^ - *5 a/ S! N' L( [8 o5 c. Z$ ^
- * This program is free software; you can redistribute it and/or
- {. f# g7 ]& e. i% E5 r - * modify it under the terms of the GNU General Public License as6 S. @% G8 e, H5 F# w6 B' B/ m5 O/ y, B2 a
- * published by the Free Software Foundation version 2.
. A+ M! i3 S, N5 K& R - *+ z7 R% y5 B: Y& o8 c# g" h8 {
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
3 f t6 n8 N0 i - * kind, whether express or implied; without even the implied warranty
& J0 b6 g8 V% e - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the& S V( W; [6 l5 H- L0 b7 s) e5 |7 f
- * GNU General Public License for more details.6 o9 K& _# T" {! n, \
- */
8 S; k) l! a; c
# E- I1 t q- ^1 y' [% b- #include <linux/module.h>
2 J# @' O1 N7 S - #include <linux/init.h> b# s) }, Y+ }) C6 l# ?
- #include <linux/errno.h>
9 M; U0 D4 N2 Y; T* M/ M c. i - #include <linux/types.h>
( s) z6 w. U# p! g- d4 B% C0 W - #include <linux/interrupt.h>
. ]7 r7 |3 d& N8 m, I; a, T - #include <asm/io.h>, g3 s7 m6 n* Z0 y: A% ~- d: ^
- #include <linux/moduleparam.h>1 Y9 r+ i0 H9 Z5 i; Y. Y" W, ~
- #include <linux/sysctl.h>+ f, }% I1 r* _& p
- #include <linux/mm.h>
% i' t/ }# V }8 v - #include <linux/dma-mapping.h>
+ X5 A7 c7 R6 S) f& Q- Z& n - : i. y# l+ ?+ N* c1 }3 M
- #include <mach/memory.h>
1 G! T5 a+ z1 q9 A3 C - #include <mach/hardware.h>1 l! S, k, c3 `% f# O; ?
- #include <mach/irqs.h>- i. {# [+ s5 I4 e
- #include <asm/hardware/edma.h>
9 M8 k8 c- _: l* `# A) V - " Z/ j4 l' ^" x$ P( x4 r7 N& S
- #undef EDMA3_DEBUG
7 t) b1 y% F$ p& h) ^ L3 [* T1 M - /*#define EDMA3_DEBUG*/
" f' ]* I/ v- i; R
: s2 @9 U1 c; i! R2 Z) w- #ifdef EDMA3_DEBUG
& ^' J: s5 d, ?: U# a; j - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; T9 C" O9 A1 A6 J/ c - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
6 ]# u0 ], g: M9 _- E b3 L: y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)' K+ R) P. h% F' o
- #else! r ~8 v' D4 S& U
- #define DMA_PRINTK( x... )3 k0 x* a7 @/ C4 y) X
- #define DMA_FN_IN
3 g) z1 x! Y" Y& R% E. u - #define DMA_FN_OUT3 `, o2 P& g9 l! {% y
- #endif
' c/ [4 Y( E# P) d8 Y$ n - 9 o4 e& M* J% k! L& A* l$ F& Q& R& \
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
! A7 O! `. ~2 Q) k - #define STATIC_SHIFT 30 E: e6 U2 O0 {7 ^
- #define TCINTEN_SHIFT 20
7 ?6 \% X) D9 O2 N1 {& U3 d# A - #define ITCINTEN_SHIFT 21" F/ F5 c) f d! s$ j" ?
- #define TCCHEN_SHIFT 22
4 u' Z$ k5 G6 d j/ ?( e - #define ITCCHEN_SHIFT 238 m( g$ k* \8 O1 N- K1 J& c
; X& D+ `% S0 P$ V/ S- static volatile int irqraised1 = 0;- V& u8 ^* r7 y
- static volatile int irqraised2 = 0;
" w. Y$ ]. S& P. g - - P1 o$ n# O, C' `) q/ b7 P4 x( v
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 o6 z# |% t# o8 G! q - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 }; U' \; H2 ^1 ~' h
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 N8 {( w: g& ^0 R! V- I9 [$ _
) s, J) p+ R( }, J1 e- dma_addr_t dmaphyssrc1 = 0;. @9 [- b2 t5 { a1 n
- dma_addr_t dmaphyssrc2 = 0;2 Y4 | T4 q/ D6 D5 k& ?
- dma_addr_t dmaphysdest1 = 0;8 G* x1 Q6 k4 S/ e8 x. K
- dma_addr_t dmaphysdest2 = 0;! v3 _" {8 N; o1 q. _$ m$ j4 f$ l9 v
- 5 }0 Z% V) ~4 A- r$ `
- char *dmabufsrc1 = NULL;
4 |! A1 [( P. A+ q& m" P - char *dmabufsrc2 = NULL;5 ^ W- |6 T! z% ~ ~7 j- [
- char *dmabufdest1 = NULL;( i; O4 D5 ^# m! H
- char *dmabufdest2 = NULL;
2 v4 i' h/ G! K, _ x* c - % D% \' N0 m/ @$ z& z8 g# B( |( b
- static int acnt = 512;; ?# m- s( d l3 @6 e
- static int bcnt = 8;) ?4 ^- Y3 q" u+ ~1 `
- static int ccnt = 8;
3 J$ q9 t, W- I4 M5 h5 l P - & u' f- e4 b7 o5 n0 F
- module_param(acnt, int, S_IRUGO);
" ], T0 \1 O- |, Z; b - module_param(bcnt, int, S_IRUGO);# P/ x+ Q, Y9 L/ @6 e
- module_param(ccnt, int, S_IRUGO);
复制代码
; H& n; ?( h' ^: D1 S. l& @' u8 m/ {# k0 Z' G. C3 ?
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用2 k) B C7 e) ]- \* j' z( a# U
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。& x [' ?( [6 }5 y3 s0 R! W$ A+ O
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
* Z' t6 U+ C% E3 r
4 Z2 x# B" a' Y% T" A* Q: k( _
' z9 p) s& r& ~1 L7 g( j4 M5 v |
|