|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, y9 [3 A! }: R6 y* r9 S4 Y- [code]EDMA sample test application
6 ~, j) S( k; Y6 \ - /*
" ~; X0 T. B: M, O9 Q3 ?# [, \: k - * edma_test.c
- Y0 N8 a/ p1 O& S. Z - *
0 F8 `$ ?# a I" _% K, `7 K - * brief EDMA3 Test Application
|: K$ p) F( e& w( Y) p - *
! b. W: J8 S9 D) y) u5 W: C - * This file contains EDMA3 Test code.; e( e% [) b$ o
- */ k- u9 L5 s# W# V2 a7 K
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* B1 O2 E/ H- p$ y; k. w - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
, D9 [' s- d! z+ N0 }4 P - * TO CHANGE.' e- Y/ q+ Z$ V6 ]7 X
- *5 X0 w) A6 A n9 h& N& o5 _: d4 D
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 e& {% e# |7 R - *+ N# U9 E% H6 }, E5 ~
- * This program is free software; you can redistribute it and/or
# c f& i$ y+ I, D# W6 K) Q4 I0 h - * modify it under the terms of the GNU General Public License as) n& O" S( M6 w! p2 n/ h
- * published by the Free Software Foundation version 2.
8 c6 o! j! a- l - *
* Y9 a+ P8 F# i l$ W - * This program is distributed "as is" WITHOUT ANY WARRANTY of any( x6 j3 `4 Q" k, s( M7 a( g
- * kind, whether express or implied; without even the implied warranty
( s' R- u% \( O7 c& A; ?2 i - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 v! O- u8 C) l- {( m. @( E - * GNU General Public License for more details.
9 E7 w, ?0 R/ }6 u - */
, a3 T; j! {! H1 ?
6 p5 o4 M/ e T) A0 @5 P- k- #include <linux/module.h>
, n7 k0 P+ `( |0 m X. ` - #include <linux/init.h>2 Q7 s! ]* M; R. }. \' N
- #include <linux/errno.h>
, L. H. e ^; L$ E% B2 \2 ` - #include <linux/types.h>. w! K& D a3 q7 |
- #include <linux/interrupt.h>
/ W8 k# n* y( x6 y% m) ? - #include <asm/io.h>* k& R* j( U C0 k/ c
- #include <linux/moduleparam.h>
) |+ B/ d% E8 V0 O1 n- j - #include <linux/sysctl.h>& D. q) C3 i5 c) \1 p8 P
- #include <linux/mm.h>
3 x; f9 h7 e5 g# R4 a - #include <linux/dma-mapping.h>
) O5 e, D, Q4 [) O: K b - 5 a0 e$ z6 T* t( n
- #include <mach/memory.h>
( i6 R7 R! b) t; D9 _! r. O - #include <mach/hardware.h>
2 s' g7 N- y" g$ W - #include <mach/irqs.h>
( B% W3 g, h+ a. v5 w - #include <asm/hardware/edma.h>
! q1 H, @8 L. r8 k- d7 w) [ - 8 f1 u$ Y( k, \; H* N8 r2 O
- #undef EDMA3_DEBUG
' _3 |2 y, s1 y0 A6 N# l5 t0 D' ^ - /*#define EDMA3_DEBUG*/* u% x) u" \* `/ u( U
- * y6 F- L4 x d& X
- #ifdef EDMA3_DEBUG
0 K9 I/ p2 N! n' s3 |8 n5 L - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
" y* E5 A. S9 A4 c# k - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
) W+ y+ D% n- T7 x - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! s3 v) c0 Y$ v$ z( a* r3 o. W, y9 n
- #else3 y3 L1 z- x* Z- K8 K! b
- #define DMA_PRINTK( x... )) N5 n3 P6 N$ @7 x6 F9 e: M
- #define DMA_FN_IN$ s: s/ N. c2 M! b$ [0 b4 j( Y5 ^
- #define DMA_FN_OUT/ n E- f; W- {6 i7 @
- #endif
7 Z4 B2 U: a1 S - " E% h, I) i5 u! b+ T4 G
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)$ n3 B! [* H4 [9 C! I3 C
- #define STATIC_SHIFT 3
4 }/ B }. M4 e! q - #define TCINTEN_SHIFT 202 G( m: _2 h" t: g$ P8 T
- #define ITCINTEN_SHIFT 21
; j: {/ D+ [$ V/ C3 R( X# N5 o - #define TCCHEN_SHIFT 22* N0 t6 l9 C+ [/ b7 y/ Q1 c
- #define ITCCHEN_SHIFT 23
6 A; j/ {+ b- A2 W4 u7 s. S) U1 H - ) P! c" g+ W* M" y1 b5 i
- static volatile int irqraised1 = 0;
! ?. w' h5 ?; p8 o+ G - static volatile int irqraised2 = 0;/ l6 k$ Q5 L0 x' a. l
- 1 g! {: ]* o/ e
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; u; o) A2 b* U$ ]& \* T
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) w I6 |( C2 @$ c1 U L7 a - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' P. d, c, g6 j$ N# m$ Y
C9 h" p; y6 o/ t$ }( w- dma_addr_t dmaphyssrc1 = 0;$ v( M0 Z0 n# {, }" f5 a6 E
- dma_addr_t dmaphyssrc2 = 0;
0 P( Q% `7 y* Y' n, o8 E5 G - dma_addr_t dmaphysdest1 = 0;! e. K, L1 z5 }6 f
- dma_addr_t dmaphysdest2 = 0;
5 V3 o% G2 @8 c8 M# p
B1 `1 l1 b1 y3 Q$ E- char *dmabufsrc1 = NULL;
( H- b6 t' ]% S6 d! U& l, |$ J - char *dmabufsrc2 = NULL;) o7 R$ V8 b9 W9 h1 q
- char *dmabufdest1 = NULL;
! z' z$ V) N7 l9 G4 I. [6 o - char *dmabufdest2 = NULL;8 F$ l2 v% w' S2 P
- ) O8 y6 a6 H* {
- static int acnt = 512;) k n, b1 Z1 Q+ N' I5 z! x
- static int bcnt = 8;
- U) M) F4 m* g U9 \+ t - static int ccnt = 8;
3 F! s1 T8 a2 J5 F* A$ y5 b
' \) l/ A. n& A- J9 P, d) ?- module_param(acnt, int, S_IRUGO);9 i- q2 s' h. n- I1 ] J: `8 c
- module_param(bcnt, int, S_IRUGO);& q$ r+ _( _+ P/ }9 f& ^6 T, |: E
- module_param(ccnt, int, S_IRUGO);
复制代码 ( n8 O. v/ ?, j H
- d" H+ n2 _$ h- h5 O- a; i 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ Q1 h3 ~0 y6 s/ R5 W/ ?' ~: Xarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
" n1 n1 B7 i# v& }7 m/ I# [$ v: @$ { 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
5 s3 V' r: U2 W; w# N9 h8 B
v5 V6 z2 L- P3 n
% B3 x% [/ ?# } |
|