|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. }4 J3 ]: w3 ?9 a+ j- f" X- [code]EDMA sample test application
5 W$ y5 s* Z, m! c' J - /*4 C$ A# G @/ ^" ^; }; f& N0 B
- * edma_test.c
$ m8 [; }# Z" R5 g# C6 v - *
7 |9 Y. ]) S5 `: Z! u, S - * brief EDMA3 Test Application+ E: x) h, m5 T, i- W- \5 H
- *5 j3 M, P/ b6 k) S4 ^
- * This file contains EDMA3 Test code.
( ^% X- V& b" ~. m! S, n9 z8 J - *, B0 H' K7 ~& y% [; a! G
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE; r& G' q3 d: j) E8 G4 v; Z
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT# c9 p( s! G1 w* v
- * TO CHANGE.
/ t# h% T. e5 i8 V - *: T/ {' e1 M4 ~2 e
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/5 z2 h% r* a J; r8 Y7 m, z
- *6 j0 v3 b% C& `7 e
- * This program is free software; you can redistribute it and/or
' h5 w" B( `7 L2 B - * modify it under the terms of the GNU General Public License as: `1 y6 u) g$ n7 \7 Q/ z
- * published by the Free Software Foundation version 2.4 ~' c" p6 T# W* ]1 m
- *+ o+ @. S0 S6 g7 O% L" j7 Z
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
2 I3 ^4 S( @7 M8 h3 ^& y0 F - * kind, whether express or implied; without even the implied warranty. ?6 L* r! J: j9 S7 b4 L
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) q0 N2 e; y% [/ e- [$ P
- * GNU General Public License for more details.+ _- l* Z2 P) F1 Z# U2 ~- @" |
- */5 `* `! f3 A/ d4 r! L; d
i V- `& i% Z7 R" V- #include <linux/module.h>
" m+ g; h1 S& ^ - #include <linux/init.h>
1 I" Z" \" h* ]% ] U7 d& Q - #include <linux/errno.h>$ c, u& [: `, i) ?6 R
- #include <linux/types.h>/ H* n+ p/ U) I4 j& E" n
- #include <linux/interrupt.h>
6 H# y* b& w5 Y' M ], I1 a - #include <asm/io.h>
& B0 ^3 K8 l* t; c q3 l @4 ?" O - #include <linux/moduleparam.h>
3 R; ^8 B) {! h) m1 h% r$ _ - #include <linux/sysctl.h>0 \# c/ ?2 Z; r' U; z$ q9 D% i
- #include <linux/mm.h>
- u# @! n# r. a5 e2 y* F* S2 e - #include <linux/dma-mapping.h>2 |: G$ E* r/ _* B
2 h* {! v6 [3 V2 I% y) l& H- #include <mach/memory.h>9 B$ ~. R" p% j5 `5 m: p& f/ p
- #include <mach/hardware.h>3 g1 \1 V6 ^8 m0 E* C9 d
- #include <mach/irqs.h>4 A; x5 _- M1 C- \8 M; B! O, c- U6 Q9 x
- #include <asm/hardware/edma.h>
' _3 L, E' V' B- _ - * F& m' J6 G7 [+ G3 W# y4 G
- #undef EDMA3_DEBUG
% Q: w1 X$ S3 O2 \; I8 Z8 k - /*#define EDMA3_DEBUG*/3 f& [1 q1 R3 ~% A5 H# I
0 E1 D6 d% }4 c k( _ W% u3 Y- #ifdef EDMA3_DEBUG
. c A6 V5 e5 @8 d ] E - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS). ?/ N# ]' Q p- v* Q2 ~
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
5 Y: j8 h+ j N2 m' N" i6 Q7 m- C - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)' z% w' m3 y& C$ p% ]
- #else7 m: k$ p9 ? V6 [ \, f/ x7 I
- #define DMA_PRINTK( x... )
- `, F) m3 w8 R! e+ J - #define DMA_FN_IN
) z% [6 h0 P3 J; O+ n% V* h - #define DMA_FN_OUT% V( ~+ ^. _- V, `. X7 O
- #endif
0 g; n. B6 f5 N- i) S" y# D - ' z& W) e9 d/ F8 `- f0 k6 I/ H
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)0 Q' G; ?8 ?- U; w5 D; G, U
- #define STATIC_SHIFT 3
3 P7 L" Y$ K* p" A | - #define TCINTEN_SHIFT 20
2 R* {: C% D! R4 k F- O: V1 W - #define ITCINTEN_SHIFT 21$ H% d5 ^ w- F, z |) M* C: W, _
- #define TCCHEN_SHIFT 225 Z" m: M. h, ^( d$ A; i
- #define ITCCHEN_SHIFT 23
# M2 v# |8 E% Z1 _8 U/ j8 U3 R5 M
- \* X8 L: Q8 W# A2 k6 o c- Y; P- static volatile int irqraised1 = 0;
# H5 Y& c# A( k# t7 O, _ - static volatile int irqraised2 = 0;
% z* ^& d# z' m" _
/ \" e- C- f+ N) `' \( l- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' y3 M. d5 K' f2 ~- \
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" a' y! Y2 x1 B9 w$ L- } - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 W6 L$ z$ g- G# v$ H; Q k' {
- 3 Q$ N, b3 ?1 p+ e- v
- dma_addr_t dmaphyssrc1 = 0;
/ f* k. D+ X f - dma_addr_t dmaphyssrc2 = 0;8 S& d1 v" y' Q6 p
- dma_addr_t dmaphysdest1 = 0;5 }6 N- B, k/ c# ]
- dma_addr_t dmaphysdest2 = 0;& N U4 d) c* O2 |5 j7 U' `% e) K5 G
. G& k. P5 a$ {: r5 k. P X- char *dmabufsrc1 = NULL;
: V, ~' u6 u, T# X( B+ m8 } - char *dmabufsrc2 = NULL;# N0 I* Q& Y- m; ^$ X- t
- char *dmabufdest1 = NULL;1 c1 T/ k/ d; _
- char *dmabufdest2 = NULL;
4 l% m! x0 t3 a4 Y- R8 u+ b4 y
, x9 W8 ~4 k1 N1 L K* w' T/ v- static int acnt = 512;( V+ F& z( W5 t: [. d( F* I K
- static int bcnt = 8;! D/ Y) ~, h8 n. }- b
- static int ccnt = 8;
( b$ B* w5 B( U! C' o& L
* S8 V4 ]) X( e& K9 d- module_param(acnt, int, S_IRUGO);2 m& B* p* ]! B0 ^: C
- module_param(bcnt, int, S_IRUGO);
6 A- v n; L) E" p: _ - module_param(ccnt, int, S_IRUGO);
复制代码
4 k. I- o) T4 o* y( p7 f
$ Z$ U( o3 T& L& A- {9 e 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用* G. W! W% l5 R: L! B
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 O/ b& g& ], |7 H' |0 S5 E 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。; j5 W$ O2 c1 @4 Z, t: w1 o0 s; F) u
) o- }: Q2 u1 }& y+ [8 e" G
. V4 S* i& c9 L; q# _ |
|