|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : t8 r3 o' ?0 d; N9 L* g9 i& j
- [code]EDMA sample test application
8 _3 R. A2 n& r" |- r/ G - /*, d1 s- L* D% [ T4 y
- * edma_test.c- |- R! C+ ?' A) A h
- *
) q1 f# @4 ?5 `- a. a - * brief EDMA3 Test Application( H. F" Z! ^) \
- *, `1 N2 q# Z9 C+ Z( V4 m1 a: |0 D- Y
- * This file contains EDMA3 Test code.3 {! \# L6 E& H, b) K) F
- *& N6 ^) p" n5 a4 t- }7 v7 @2 }+ P
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE. r+ d; x p ~+ E4 V2 }
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
; t- n* V2 H6 I$ l! B4 V7 @+ H7 \7 \ - * TO CHANGE.! D# e$ s! \' b/ B w
- *
q4 Q. x- |8 `+ F - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
: r. c( E) I2 Q7 d6 J( l - *
/ d! N- m% b! y# T, d - * This program is free software; you can redistribute it and/or
( b8 F+ F# M, J' u. L6 X - * modify it under the terms of the GNU General Public License as5 Z+ w+ s8 ~$ c( G
- * published by the Free Software Foundation version 2.
4 w! y' i0 z- [0 A- F; M- |3 k - *
2 y$ w. \3 N1 r# V- L% F- [ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 T3 j0 T$ m' Y- m. }* ~+ U+ Y
- * kind, whether express or implied; without even the implied warranty
: N9 r$ j! ?' l6 i! T( k - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 k6 [8 ]3 C2 o/ M9 a! r2 F. u - * GNU General Public License for more details.# |0 C( a) q' q- V! C* p3 F7 ^$ P
- */' ^" T6 A/ ]' R& n9 }5 r+ G
6 |. o' o0 e: V3 i" ^$ E- #include <linux/module.h>; L) @" h% j) ~6 }$ ~- A
- #include <linux/init.h>
* x% Y3 R) b5 R. ^: ] - #include <linux/errno.h>
* E: h* \2 S* S9 | - #include <linux/types.h>; f" l" L) @6 N. s
- #include <linux/interrupt.h>! c% p' Y( h! u: K2 M
- #include <asm/io.h>( T# |5 A& X2 ?. j( l5 F
- #include <linux/moduleparam.h>
! Z. P( c% g2 c% c# V/ S. ` - #include <linux/sysctl.h>
, f3 A7 a9 u( O - #include <linux/mm.h>) U8 @6 h* U1 w" ]0 O
- #include <linux/dma-mapping.h>. X" S, r% |) A) q, G6 Q
- % W# `# @* ~+ ~0 M4 X( Z) b
- #include <mach/memory.h>
4 w6 i0 k! k$ T0 {6 z2 y - #include <mach/hardware.h> @& u. Z( _. u6 _
- #include <mach/irqs.h>
1 p9 V% C/ K [ - #include <asm/hardware/edma.h>" b4 w) z5 D3 ^/ b
- : L- M# o2 W$ {9 O0 {7 Q. |
- #undef EDMA3_DEBUG
; l" q# c1 H/ ]$ i7 E - /*#define EDMA3_DEBUG*/+ T% V, G* w. ? I* Z! p* X
; \( ?' \/ [8 d+ Y2 l- #ifdef EDMA3_DEBUG
% Q, q/ O6 Q% h' b/ ^) g& h - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)1 `, _" M0 h" q. h+ c/ J9 I" P
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 w i# a% b% r' `' E* E( R# G - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
8 D! G# @) N6 z - #else
6 N0 e5 d- ]2 }& S) T% l - #define DMA_PRINTK( x... )
! V9 H7 T d6 X( m. ^$ }# _ - #define DMA_FN_IN
. ?2 Z' F* G/ N" m. D7 Y9 T- Y - #define DMA_FN_OUT
3 Y3 q/ h1 o: w4 m! q# O2 ] - #endif
, l+ J. `; [: O! C - ! y. |+ N) h r: m2 `. _
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
5 c; |- ?8 s6 M9 ~( z( v/ n# t - #define STATIC_SHIFT 3: a- u) k" o4 Y
- #define TCINTEN_SHIFT 20
0 t* F1 G: Q( p5 F4 M" p# w - #define ITCINTEN_SHIFT 21
, n+ ~, ]; G3 T- M, w7 L - #define TCCHEN_SHIFT 22
' S% ^; F x: ~ `; F: [2 I - #define ITCCHEN_SHIFT 235 ?/ W2 g2 Y1 S/ X
; Z4 S3 }2 V0 [& G5 l" k3 x( b- static volatile int irqraised1 = 0;
4 G1 O2 b, M' ^ - static volatile int irqraised2 = 0;4 J5 l6 K, }9 i I/ S
! [$ s, C0 t0 Z' k v3 L, d- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 S7 q4 m" O; v/ C: W9 r" K9 c
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 n( s# Q6 q# F+ o7 d( ~1 s7 e2 O - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" j* ^1 C) |% e% E" M7 l+ V& G
' k+ u/ I% J; T3 ~. {* N' |6 }9 k- dma_addr_t dmaphyssrc1 = 0;* u& }" C* T) X. H
- dma_addr_t dmaphyssrc2 = 0;6 @; p& q& p5 B( V
- dma_addr_t dmaphysdest1 = 0;
% Y' W; h" l+ s) E" [+ ] - dma_addr_t dmaphysdest2 = 0;
8 b; |/ Y1 F3 z7 ]! y9 @" \4 ~- _ - 0 w8 H7 V6 ?3 u: U, i* d% d! a1 B
- char *dmabufsrc1 = NULL;+ |. m1 o* p% v
- char *dmabufsrc2 = NULL;0 ]$ A: Y# n8 {6 T9 n5 R
- char *dmabufdest1 = NULL;+ F* n% s/ m) G6 \! Y4 ^ [
- char *dmabufdest2 = NULL;3 d# h! K% e# j& r1 z0 }3 Q' k& y9 C
- / }: \5 f+ f4 b5 G1 M
- static int acnt = 512;) q* O7 v+ Q4 x4 m) D
- static int bcnt = 8;6 s8 K2 P: R6 j; l9 ~6 r
- static int ccnt = 8;# Y2 F5 R+ W- S9 E
- ! C. T/ ~& C+ q5 O
- module_param(acnt, int, S_IRUGO);
+ h1 v- W# L; \3 N) g! T% o: q: a - module_param(bcnt, int, S_IRUGO);
8 k/ X3 }8 Y+ } - module_param(ccnt, int, S_IRUGO);
复制代码 7 h6 w7 M u9 `2 R2 H- @/ Q4 f4 `* |
1 W& ^% S f' \0 V# [) ]* }* _' U
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
- h* ~) N' m) x [$ N+ x; ~% o4 a# uarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
) t1 o, Z5 w3 m" a; J4 q& `# Z 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' }4 D1 e: x2 ?" k c9 n
1 W9 ~# f! C! r, K8 x; r. d
" R3 m1 U$ @) P6 r |
|