|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
- l: V, V3 \* ?" X2 v- [code]EDMA sample test application% A0 n! A: o$ p: Y. h6 `
- /*
( ^% W: j r' F* P$ f - * edma_test.c. ~' _2 d" } z& m% [% m
- *% D- p/ W+ q' F
- * brief EDMA3 Test Application
2 q2 U. Y: t3 n6 Y7 {5 N - *
+ L( Y8 _1 V8 u+ F - * This file contains EDMA3 Test code.7 b! D x# a4 l1 M
- *
% k3 w8 c/ t7 d% E1 W$ \ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
9 H9 C4 ~) S0 a! Z3 j# ~ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
X, l. n& G: V - * TO CHANGE./ R% T; Z; C% A2 g" Y- Z2 n
- *
, T; M! b7 x3 ?; c U9 F" m6 P - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 ?/ @4 G1 f- W) d& ~; b
- ** {0 r# o% t$ _. ~! a7 l
- * This program is free software; you can redistribute it and/or/ U/ y( N& J5 k% C) G8 R
- * modify it under the terms of the GNU General Public License as+ V3 h& R; v0 V4 Z: y3 v: F* _
- * published by the Free Software Foundation version 2.
. h$ }$ y" z `8 i7 i0 M - *
) t3 R* C% J+ e- c( k7 ? - * This program is distributed "as is" WITHOUT ANY WARRANTY of any% Q( V/ }8 i( J1 h8 B: K
- * kind, whether express or implied; without even the implied warranty
0 e$ ~$ @! ^# M6 z' e - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the6 t% j! v- n; [/ f
- * GNU General Public License for more details.
5 M* C/ i& u/ D) z* x7 b: Z - */0 p; ^. F) ^; t6 z7 p4 u
- F2 M/ u9 {: L/ V# }" l6 A
- #include <linux/module.h>) `% S* N4 H4 J V( r# a* I
- #include <linux/init.h># ]* L0 [* G, c
- #include <linux/errno.h>, Y) c% I1 T' T6 R; n% _
- #include <linux/types.h>) I/ Y- U. ^. \8 i6 R
- #include <linux/interrupt.h>
* r0 W( i6 d' Z6 ]3 \1 m - #include <asm/io.h>: A- M! H F% l5 d* u
- #include <linux/moduleparam.h>
7 e- h$ Q& O% N! l+ ` P, ? - #include <linux/sysctl.h>) V) A4 ]* F1 _! x2 T! F
- #include <linux/mm.h>( K3 U- A- Z' `+ \
- #include <linux/dma-mapping.h>9 M$ W- v; D d8 N D1 T$ h' B8 d
: \' Y. Y& v: ~3 l# @0 }- #include <mach/memory.h>8 _7 E0 |" j) m* h$ o, ^
- #include <mach/hardware.h>
0 `! |, T q0 n ] - #include <mach/irqs.h>5 U/ l; y* G2 A2 x& D, }8 L0 @4 `% n
- #include <asm/hardware/edma.h>
1 ~4 y2 ?9 z. E5 o C0 I" s - ( r: B& V' B9 f0 _ Q1 y
- #undef EDMA3_DEBUG: g3 O# W) j7 `9 t$ d' h+ o7 ?
- /*#define EDMA3_DEBUG*/: `% ^' h4 l' o' t, ~% ?! O
- 0 p& F4 i7 K, w5 b [3 H1 y6 ?" g) R
- #ifdef EDMA3_DEBUG
9 m8 _8 I" C- Q+ w( `& `; f - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)7 {5 u1 X, z- V) ^: r% O
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 i( O! ?# S3 v6 f, Y% n J9 H - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 ^7 T0 r3 H$ I; a4 O& h6 | - #else
) T2 O( a- s2 F" P2 ^5 C* R - #define DMA_PRINTK( x... )
2 L. P% [/ ~0 O+ A9 \) x - #define DMA_FN_IN7 u/ h \; y$ I# B/ G( j
- #define DMA_FN_OUT
5 T* v# }3 v, U/ v. \' } - #endif1 q6 Y# v8 M: R" B! b
- 0 K2 W8 e8 {% r7 G! y
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ ?% T- j' x. M3 F- D( n5 G+ S
- #define STATIC_SHIFT 3
4 m" m2 M$ \6 l7 g6 q# N - #define TCINTEN_SHIFT 201 C, z" [1 _9 N. P( W
- #define ITCINTEN_SHIFT 21- Y! W J: j2 C. Z T, n/ v
- #define TCCHEN_SHIFT 22* h# b8 K. o* w# P) A8 N
- #define ITCCHEN_SHIFT 23 s& S9 s: M, B$ A
- 6 ]1 \& @7 w& o; o
- static volatile int irqraised1 = 0;5 P7 z, Y. E& W( _$ {
- static volatile int irqraised2 = 0;0 C# l' k6 y+ l* E @; @
- 6 |1 O* h# U; F# z3 C' ~( m
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 {& E% _# o( d8 F% E6 y9 I6 r ?
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* k$ c% r, y5 O/ n- U' ^
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 P2 U& u$ ?) ]) W( n, U9 U
- ! x, e7 N4 {# G, D" _' R
- dma_addr_t dmaphyssrc1 = 0;
8 c9 W$ W. P: w; h3 i - dma_addr_t dmaphyssrc2 = 0;
) U( Y, Z n8 H1 P) R+ Q9 B1 X9 d - dma_addr_t dmaphysdest1 = 0;3 ]" f- x1 F( F2 o& a4 m
- dma_addr_t dmaphysdest2 = 0;, O2 d+ @4 R7 [: Q2 r, e
- 7 u; a' S( [) P7 f! c( s* d r' \( ~; V
- char *dmabufsrc1 = NULL;
3 N# K( k# K4 U* n - char *dmabufsrc2 = NULL;
8 M$ A5 N& S: f1 b: G - char *dmabufdest1 = NULL;
& |1 [9 x5 r& j8 w; I U - char *dmabufdest2 = NULL;% }4 I8 j# C+ w2 ~
* H8 q. t( P8 k* T% `, d6 A. |6 `0 b- static int acnt = 512;
9 e7 M: g) ^# o* c% O# a, ^' X - static int bcnt = 8;
5 a0 c# `& c1 |; d0 q0 g5 J - static int ccnt = 8;
; C3 c s! _2 ]. _/ ]
- c3 P2 \ `& p# k1 m- module_param(acnt, int, S_IRUGO);
+ k1 C0 z; j) M: _: G - module_param(bcnt, int, S_IRUGO);
5 h5 z4 B3 D3 b2 l5 I - module_param(ccnt, int, S_IRUGO);
复制代码
7 I6 w! k! d X6 w: _" |
5 U, l9 [, H3 } 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
6 A5 }" J3 Z7 q( c, ]! Sarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
% D5 l" s v; V' |- v0 H 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
) J" @/ B" M9 ]7 a+ ?. h g7 D6 \4 g U% Z, K
/ m4 t _8 h6 k9 S
|
|