|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 k5 |% f& D6 ]: ]% B4 [- [code]EDMA sample test application
, n1 S! O/ g) q1 s2 V) }* R - /*
% Z" o2 C) v- y# [0 E. b$ X# e% O - * edma_test.c4 n1 D% h3 v$ v5 ^6 [4 ?3 Q
- *$ c2 ]( a5 p2 a- b
- * brief EDMA3 Test Application0 o9 @0 z, U0 F! R
- *: ^! U* o# K q( W3 Q) ?1 x
- * This file contains EDMA3 Test code.! J1 X. j0 U2 v
- *
6 y1 l& |2 w0 D8 d3 p4 o6 M - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
) v4 X9 m7 G0 B( P7 r( x D3 G3 R8 T+ u - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 e+ d# |6 z) A! {3 @" I
- * TO CHANGE.. R7 w5 ]$ n1 o( _
- *
8 M, K% N" [' j4 O$ e7 z5 i - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
. F* B- s) e, T1 O W, G - *# e9 g+ a8 L! g5 q, g
- * This program is free software; you can redistribute it and/or
2 y0 A2 J6 }) ] - * modify it under the terms of the GNU General Public License as
& r/ ?# T4 a+ \- @3 Q+ i - * published by the Free Software Foundation version 2.
2 _- H+ A- P6 J% |% [# V - *1 A" [5 D! r! H# H3 C
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ W( N! w1 e x4 L( w" V - * kind, whether express or implied; without even the implied warranty0 {& W' A8 G7 `
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# Z' S: p7 e& ^6 R- i4 x3 g6 Z
- * GNU General Public License for more details.6 w8 `9 c9 v# ^& v! P9 b2 g
- */7 L. b: z, h; M& h
* e( T, n% | J% P( f# [- #include <linux/module.h>' {+ z; S9 A/ X4 x' S( d8 j6 L# v
- #include <linux/init.h>$ C2 l2 K e: S. y ^9 Z
- #include <linux/errno.h>- Y9 z) E8 g: `$ V: u G
- #include <linux/types.h>
8 a) {1 Q- c- W - #include <linux/interrupt.h>' A/ n% s4 k8 H, ]9 p
- #include <asm/io.h>" X: H% m% q! k8 W5 u1 F
- #include <linux/moduleparam.h>) y' D8 z7 U; a- I4 H
- #include <linux/sysctl.h>
5 r: c- x7 Q. d6 p8 O - #include <linux/mm.h>4 `8 \0 {5 C1 ^; h
- #include <linux/dma-mapping.h>
0 d0 a: O! j& R& U+ m - 2 G: y* x% U0 ?/ I" M/ {! M
- #include <mach/memory.h>
8 k0 Z# n. O, a - #include <mach/hardware.h>
! S$ u: e( ^* X, T; m: w6 S - #include <mach/irqs.h>+ `5 P* z- ~" }0 o7 A" K
- #include <asm/hardware/edma.h>6 P; \" c! T7 ?
- 3 v8 i; \$ n- D8 r' b8 B7 [
- #undef EDMA3_DEBUG
# R% L4 J2 R7 I4 F3 q- Y$ t - /*#define EDMA3_DEBUG*/
) P& `# c( o+ a0 q7 d/ p( f( h - # C J+ [0 C% \0 b: @* ]+ @+ `
- #ifdef EDMA3_DEBUG
7 v5 K& H$ f. }' t& W - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)( b3 f1 {0 F) `6 y' j4 T; i
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
$ `9 y9 ]0 O4 t, O - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# T3 g4 @" A' u9 F' V$ n - #else2 b& r! f0 U |
- #define DMA_PRINTK( x... ): Q" }1 W; u( _2 }4 t
- #define DMA_FN_IN0 E) m& S+ b z! b* ~/ \- d
- #define DMA_FN_OUT
{+ v3 ]9 P% d& M9 J7 F - #endif& V3 n6 {# Z+ o: Q: \# n7 G' b t( N
1 q, g$ k4 r1 t$ N/ D4 c- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ s0 o% K7 n. G" e
- #define STATIC_SHIFT 3
& L9 Q- O$ I- H* y9 B7 R$ u4 [# p - #define TCINTEN_SHIFT 20' z7 R V# [! E4 E
- #define ITCINTEN_SHIFT 215 O# ?+ F( d* D7 m2 T
- #define TCCHEN_SHIFT 224 S" q, D6 c6 _" I7 h3 v
- #define ITCCHEN_SHIFT 23- Z" ?8 [' x% T% ]: i* k9 h: z
- # `% q. {1 j [ u$ s0 y
- static volatile int irqraised1 = 0;
2 t: {% ]. P8 S1 W2 U1 d - static volatile int irqraised2 = 0;1 D0 ]8 p( p& m7 |9 c
+ f! M9 S& F. F1 q4 O4 E- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 ^; ^* A, G( k- Y9 y4 E
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 r! D" k& D$ d. h- l - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 ^: x: r: F1 Y3 ^
- ' k" ]% S( e% _. c+ S3 F6 H, G. i
- dma_addr_t dmaphyssrc1 = 0;" T. J _ a" i8 N0 }
- dma_addr_t dmaphyssrc2 = 0;
) L4 U- B; ?; |& j$ B! F1 H - dma_addr_t dmaphysdest1 = 0;1 ?0 E% N* N$ p
- dma_addr_t dmaphysdest2 = 0;
: n J) m2 k' M' S7 w7 n - 8 I3 K( M3 [% i
- char *dmabufsrc1 = NULL;+ I7 K8 Y$ W2 R
- char *dmabufsrc2 = NULL;
R* x! v. K1 Y7 C- @/ ] - char *dmabufdest1 = NULL;' {) S! t( Z4 {
- char *dmabufdest2 = NULL;/ z8 h- m7 X! v% l
: }6 x+ S/ [4 M. X* \- static int acnt = 512;
; Q$ E0 ~) g. C, F O - static int bcnt = 8;
* |7 O! p& L3 \3 M* T! t - static int ccnt = 8;) ]+ R1 w2 h* I! H% \- B
0 S7 L% W8 S7 X- module_param(acnt, int, S_IRUGO);
5 N2 S5 b# Z: O; \4 e1 G3 W2 C6 u( a - module_param(bcnt, int, S_IRUGO);
8 K( l( b) s, N9 X7 l, g9 { - module_param(ccnt, int, S_IRUGO);
复制代码 9 D/ q4 b& h! h2 i' ^4 r" M
0 m% e0 @8 X$ a$ W" o$ g$ q2 `7 B& J: V 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
; x5 m- b" K7 k) Jarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。- z9 u- s; _5 p) f- U9 b6 \. ^' ]
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
" c* N' {/ f8 [* T; S1 h
w& v0 u6 K+ I8 u% M
% ~( I' ~7 [8 v, J8 ^ |
|