|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) m/ T( M. q/ B9 J- [code]EDMA sample test application% v) j7 k$ m" q, m, p' t8 Z
- /*
9 a6 |, \* C' Q/ m - * edma_test.c. M) W! V2 d5 n6 {; ^
- *: l" a) I2 i) z/ F) ]
- * brief EDMA3 Test Application9 v5 W5 B }3 k( G
- *
0 g; C) X8 `- V e& L/ t - * This file contains EDMA3 Test code.
7 i# c" H ]& z. F - *
* n* A. {+ y% k: f - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( t- `4 K+ _3 y/ O. g3 {
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
8 q1 c8 U+ L5 b; \ - * TO CHANGE., }! x3 ` m+ q
- *# B' {! [7 }* ~# r' @, i4 R! F0 [
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 h: m, g: ^. z/ d$ o
- *3 Q) e9 V" l; q1 |) i
- * This program is free software; you can redistribute it and/or. O8 ?# Z( _! w; t% i" u5 f. e
- * modify it under the terms of the GNU General Public License as
: ^7 @ x3 r: \) f. M% k6 O( j1 u6 U - * published by the Free Software Foundation version 2.: L4 Y2 _! Z ~7 s9 D% W+ a* r
- *
. @, C) _( H9 i0 h - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
" K) ?* a1 r9 i8 B - * kind, whether express or implied; without even the implied warranty
+ a3 F! e2 E% ~ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) {' R" H6 z+ ]) p+ z9 R' w - * GNU General Public License for more details.
6 u. ]' V! i9 L4 N" ~, w8 F* K. w - */
. b5 p K' f0 U3 e S$ u- P' v - ' \8 o# Q; [) r
- #include <linux/module.h>5 c* s( H1 {& b+ F% Q) M
- #include <linux/init.h># |. q% }$ q# H/ s
- #include <linux/errno.h>& O- k* f+ Z: |1 _- ?- m
- #include <linux/types.h>3 i: R* K6 r1 k% j
- #include <linux/interrupt.h>. \: G7 q7 l" C/ s2 G' l" w) @' I
- #include <asm/io.h>! x9 J2 | d& Y* c2 p! X' o
- #include <linux/moduleparam.h>
+ {$ L5 Y/ i& E5 q$ Y: T& j - #include <linux/sysctl.h>
& V" F# x, n# y0 z, E- u - #include <linux/mm.h>
$ [4 t4 p F5 Q, I% D% V; | - #include <linux/dma-mapping.h>
9 E3 a( \1 F2 N3 g8 i/ U5 k - ( ~7 l. o1 K& c2 s; N$ x0 z. \
- #include <mach/memory.h>3 ?: o! G8 U7 m( V: K
- #include <mach/hardware.h>7 ^" c- \' G v0 s+ u% ~) p
- #include <mach/irqs.h>. |+ ]- |1 g5 c# M. e
- #include <asm/hardware/edma.h>
0 I% u7 J6 c% {8 `! D8 t, i, v - 4 c2 k0 ^& A! e5 B+ g; I
- #undef EDMA3_DEBUG- Q, C# n0 F2 I
- /*#define EDMA3_DEBUG*/5 O# d# X4 O' T
( F4 i% `9 M# ?# d- #ifdef EDMA3_DEBUG r% P$ `3 e2 |& n9 r# x! z
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
# \5 i% g! ~/ L5 [ x/ A e a - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)* W+ F3 q9 O; f
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
* y/ O. }' J$ a, c4 R& D - #else
! r8 A# [; W4 i: R - #define DMA_PRINTK( x... )5 |1 W( b: O8 l# R4 g7 L
- #define DMA_FN_IN |9 P# T3 h4 I% V6 v8 @. G
- #define DMA_FN_OUT
: L0 v, |3 _" \* [6 N; d k6 C - #endif
" l6 o) ]9 N+ Z) j
) K. I3 U& D. q6 T+ ~0 u+ v- #define MAX_DMA_TRANSFER_IN_BYTES (32768)7 n f' ~( C+ w7 D* H2 L5 Y6 P# r
- #define STATIC_SHIFT 3. H9 T! N6 p" |# q: @1 s+ r
- #define TCINTEN_SHIFT 202 B1 T% W/ f+ x0 z( l; a) t# J
- #define ITCINTEN_SHIFT 21
% {: s+ r0 O' @( x' Y - #define TCCHEN_SHIFT 226 K* K$ c/ L7 f6 I6 L. @
- #define ITCCHEN_SHIFT 23, m# R: o$ Z" r$ B2 d. U
! w1 y8 A+ [# \+ _5 C. F- static volatile int irqraised1 = 0;1 @3 L0 `- G3 ?8 V5 T) ~& u/ Y' b
- static volatile int irqraised2 = 0;* E3 D/ `9 c3 {; d' K3 d
- " n' Q& D4 h; p% |& x9 r0 Z
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 Z9 l; ]. T$ _3 R - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& @% e+ D1 ^! U0 }. W; L
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* |. y1 b* i; v# R( ^
- $ x( I; Y) ^( E. l
- dma_addr_t dmaphyssrc1 = 0;) d* \6 i) M: u
- dma_addr_t dmaphyssrc2 = 0;( m! l2 i! [4 a' f! q; t" L7 N
- dma_addr_t dmaphysdest1 = 0;
& Z5 M8 ?. ]8 ?" C. X: Q% l2 t - dma_addr_t dmaphysdest2 = 0;
1 F& L% P0 U7 P
$ }& B2 e0 T; W* L- char *dmabufsrc1 = NULL;
1 T# ? t8 i8 R( R' c! D7 k8 w! | - char *dmabufsrc2 = NULL;
- O$ s+ \/ E6 J8 J: H o4 e% | - char *dmabufdest1 = NULL;' }- u: S6 T) U2 N
- char *dmabufdest2 = NULL;
- d1 `& | {: h* {+ e, i
6 B% ` e' {+ f' m- static int acnt = 512;
% ?6 @7 A/ G p! ^. S3 p, z/ L. _ - static int bcnt = 8;+ W* S# c5 z, r
- static int ccnt = 8;$ S' _: e) }8 i/ N! f
- o/ f8 D1 E L" ?- module_param(acnt, int, S_IRUGO);
1 D* O" T/ c3 g* {1 K9 W, M) l+ N - module_param(bcnt, int, S_IRUGO);5 H' |3 o7 g9 R8 }' e8 S
- module_param(ccnt, int, S_IRUGO);
复制代码
' I: m" G3 i) {; y7 P
0 J( y# l: p; ^, Q 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 O# x4 F* G0 ]1 A9 L) [) S. 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
/ p% T' t: I; E2 [7 O8 I 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。$ m& ?& L( Q! V% ^0 p6 p
. C4 k7 m- U2 L" b
) n1 G3 K- m( j+ z1 Y |
|