|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 7 ?; k2 z. c, d. z
- [code]EDMA sample test application
& f* q! z; c& K - /*
: w! X# B1 k" O/ M - * edma_test.c5 x: u6 }5 j+ x- C- Q) \
- *
" u9 ^* X D( n - * brief EDMA3 Test Application) R/ l; c" Q2 X( X0 @% R) X
- *
4 m& t# H8 V' y+ n - * This file contains EDMA3 Test code.
8 E5 L6 K4 q& Y0 j9 ~2 x2 T - *4 D3 F, ]7 P# l) X9 w$ W; B
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
) { M- S3 i# E) |( L - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT, }/ |6 j1 K) Z
- * TO CHANGE.
; @7 e6 H7 B7 z - *4 X, R8 Q% P: l) E* F; q) b2 x
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/$ K6 @7 L3 t% u
- ** l/ i- f' W, r- b
- * This program is free software; you can redistribute it and/or
1 _7 C/ k- @, R - * modify it under the terms of the GNU General Public License as, N" c8 N+ `1 F5 e1 ]
- * published by the Free Software Foundation version 2.9 J& b9 i G, _9 y7 a# C2 \/ J
- *
3 A) P3 _8 C; G$ m - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
2 u6 D% ]- G) @7 Y8 N3 `5 V - * kind, whether express or implied; without even the implied warranty
5 Z7 g3 [: b$ ^! B! u, |, \ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6 q4 ?$ P( l) W' ^: r6 ?; I- o - * GNU General Public License for more details.0 y( M7 J& |0 T
- */
! M' ], d w/ A
+ u: U3 Q B5 U1 w$ H- #include <linux/module.h>8 N7 j( @; `/ f3 o) o( ]
- #include <linux/init.h>4 z% z! K& ^& f, Y3 T
- #include <linux/errno.h>
! l7 Z `$ p& G% k" Z$ l - #include <linux/types.h>8 F7 @5 ]- E* a2 B5 A h
- #include <linux/interrupt.h>; Q I; A. Z4 W5 M3 C
- #include <asm/io.h>
' |+ u3 M7 F; z2 U, G- {( a - #include <linux/moduleparam.h>
8 y; ^- W9 b, l- U! {6 w - #include <linux/sysctl.h>5 S! s% o6 z# e& } h
- #include <linux/mm.h>
5 J6 C' M3 m% V5 Y - #include <linux/dma-mapping.h>, F& X4 z/ N4 }4 T/ j- Q; J/ i
4 z1 H3 p% e, B% W' e- #include <mach/memory.h>1 p) i* N+ v+ ?, h7 v1 i; `/ l
- #include <mach/hardware.h>
5 R: |" N6 |& P+ |+ g1 B/ w - #include <mach/irqs.h>
6 H6 X8 I8 I5 e+ q5 f4 t - #include <asm/hardware/edma.h>. b* U- M* Z7 | S) w+ s
- 4 I$ S' y, z9 L1 w6 j6 k) J, X
- #undef EDMA3_DEBUG
5 P# \1 R8 ^1 o. k0 w - /*#define EDMA3_DEBUG*/ f( {' a; S: x- V/ Y& K9 B- k! q
: W' u& t5 T3 `7 z- #ifdef EDMA3_DEBUG: x& y0 L! s3 [: F8 @
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS) }2 E/ k$ v, e' T: x+ C8 o4 W
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
! z/ d# v& D$ s" _2 [: i2 O: @+ v - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
" Z! F$ R% [5 z - #else
1 R: T# s" d3 c$ K$ O - #define DMA_PRINTK( x... )
( z C8 `4 @! U; x8 L1 e - #define DMA_FN_IN
' j7 h& E8 N0 d: j - #define DMA_FN_OUT
$ y8 H5 E. P8 d4 [! | - #endif
9 r' v+ l; O% A - ( ~+ i( O( m3 Q6 m
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
6 J! q! W/ c" L0 D - #define STATIC_SHIFT 3
, A2 `( o& T' ]$ } - #define TCINTEN_SHIFT 20
$ r( x) B7 b5 \9 J! @9 X - #define ITCINTEN_SHIFT 21
+ X' ]+ g9 j0 d, b" o* v" Y. m) u - #define TCCHEN_SHIFT 22
* X3 ? N W0 i - #define ITCCHEN_SHIFT 23
0 \+ ]7 C2 C# D1 G, A - D/ D% G+ E' c( J( D" \2 X2 }% {
- static volatile int irqraised1 = 0;
% p4 M/ I9 A8 `( V9 R - static volatile int irqraised2 = 0;0 }! ?' ~3 p; w% B
- ! E& C& p4 v( d$ C
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 }, `1 O" H- L X( a& t% ]
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! ?4 A. ^2 S5 i - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 K1 p3 ?8 Y: h4 j! _; }+ g - 1 o" E1 k( A, U# r' [6 Z( m
- dma_addr_t dmaphyssrc1 = 0;+ U( Q. [# g2 e( W! N9 {8 G
- dma_addr_t dmaphyssrc2 = 0;
: e: [5 h% n9 h# |6 b - dma_addr_t dmaphysdest1 = 0;
% @: |! Z: X- i - dma_addr_t dmaphysdest2 = 0;% Q2 L/ O. v, }; t+ }$ x0 V
- , |; x b3 f8 d2 o. Z0 S
- char *dmabufsrc1 = NULL;' L4 S6 U6 Y/ `9 H* |
- char *dmabufsrc2 = NULL;5 c7 t2 ~6 v0 i. O! N
- char *dmabufdest1 = NULL;% t: s3 L: t+ K# C, N5 f7 E; e
- char *dmabufdest2 = NULL;4 c5 z& S- I& X& {
5 A9 ~* k& I7 \) e$ Q- static int acnt = 512;. b2 e9 R2 J; U! |" Y: _6 Y' t
- static int bcnt = 8;1 x% |/ i2 ?) @5 ]3 H
- static int ccnt = 8;
! R% Z4 X7 f8 ^
+ m& }) r1 |' q ?) S" p# Q1 v- module_param(acnt, int, S_IRUGO);5 ]* D1 [6 g0 }" W7 N. ~
- module_param(bcnt, int, S_IRUGO);; r! [- W, K) H9 c# Q$ W4 J! b5 n
- module_param(ccnt, int, S_IRUGO);
复制代码
) ^0 {2 _ f/ ]) @
! [7 Q) R5 [- P# ]3 `2 Z 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用* c- T1 ]; v; Q6 R$ J
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
9 k9 P& s# {( k" t 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
5 Y/ s, z! E2 ~6 R4 A$ l. s4 p$ @* O) C+ @* D6 I" N
! s G9 Q8 q4 j+ [
|
|