|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 {. q. L( P- Q" S8 {- [code]EDMA sample test application
. q& ?, G8 U, f) t6 F - /*9 a' k: ^7 M8 a2 i, X4 g1 {
- * edma_test.c
3 A$ `; p' u- k3 U4 z - ** x% m1 Z. e5 j; R: T% f
- * brief EDMA3 Test Application0 d6 h% [0 j0 B3 Y1 Q; a
- *
2 z7 W9 j* U" E* J - * This file contains EDMA3 Test code.: F) v4 u0 ~0 H
- *, K6 f" E0 j( i6 J2 E# j4 q( z
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
7 Z$ T4 }" S" C0 ~ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT, J1 R6 t% h; B! k
- * TO CHANGE.( m: |$ w1 S# p% b7 e( M4 Z
- *
" s& P6 U' V, E( }% D" | - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
! n/ M$ a. r/ V" c% D - *
7 J' t! G- K) D4 {0 g; X - * This program is free software; you can redistribute it and/or2 O% P- F: X2 k: A
- * modify it under the terms of the GNU General Public License as) C% Y S5 I. [" M' j! L5 `
- * published by the Free Software Foundation version 2.1 U3 K/ h. b, h- [. j. T$ `/ ~- R
- *
% ^, b$ q; T4 ]: K/ ~3 w4 q) F - * This program is distributed "as is" WITHOUT ANY WARRANTY of any. w/ u+ [. k$ a
- * kind, whether express or implied; without even the implied warranty$ {# R$ ^& Q8 R
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 P( @ V5 k" l+ l
- * GNU General Public License for more details.
* r# P9 J: t4 u3 g9 T - */
( I& V. r E/ }& R! J ? - + {: P6 [8 b" ?+ H& x8 K
- #include <linux/module.h>/ H& ?& v+ c1 l1 \8 g
- #include <linux/init.h>
3 u0 d1 K) j* m4 W2 Z# K$ v - #include <linux/errno.h>
, p/ _. X9 P$ i( Y0 k' K - #include <linux/types.h>0 f4 [3 S6 q& v7 y9 g
- #include <linux/interrupt.h>
. d$ S% Y: i; w) L2 S - #include <asm/io.h>! j j4 X" q+ l5 M
- #include <linux/moduleparam.h>
% y! C% Q5 }1 Z8 U+ J - #include <linux/sysctl.h># b! b1 C; P8 h9 f% q
- #include <linux/mm.h>7 h* n E" H& d* U/ \! c# f n
- #include <linux/dma-mapping.h>
! Z4 S2 ^# |0 @+ Q4 o/ |+ S$ O - ' z7 m$ ~( ]( l3 S; B& \
- #include <mach/memory.h>, q/ K5 a* ]: G( i8 v7 h3 f
- #include <mach/hardware.h>" [+ G( G2 N2 m4 n2 A
- #include <mach/irqs.h>
$ D; o/ j \; a5 j0 D/ _/ s - #include <asm/hardware/edma.h>
9 ?% t9 }. M; x* E; t - " \/ b' b7 z% a4 o) K6 f5 }
- #undef EDMA3_DEBUG
! j& j0 w) r3 x2 g8 \ - /*#define EDMA3_DEBUG*/8 u" T: q3 r' W! D- D9 B
$ s1 Y8 x4 \2 Z* z( k; V- #ifdef EDMA3_DEBUG
# W$ ?4 h! O! f9 w' l! I" D" ~ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
" w) i' S- l& p) T - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 \9 @, }; W; |) n9 p- ] - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)6 {2 o: t+ U2 U3 y3 z6 ?- g* s4 I
- #else
) n) z: Z% s1 b& Y - #define DMA_PRINTK( x... )
1 e, e0 B( y% ^# `3 c# S% B - #define DMA_FN_IN- ]- U4 @) S4 T
- #define DMA_FN_OUT
' A$ T( x4 e7 V7 {3 ^ O7 ^3 L - #endif
) z5 `& V. _$ O1 i J _ - # h. v5 A0 N: @1 R' B) Z
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 m- I+ d7 `* W: s6 T4 z - #define STATIC_SHIFT 3
; N& {& {7 p$ ?9 ? - #define TCINTEN_SHIFT 20
) `9 Z( z, K/ R2 B4 s! ]: E: m* R2 U - #define ITCINTEN_SHIFT 21' Q& H5 `* O! o0 W* e7 Q6 n! w4 l5 t
- #define TCCHEN_SHIFT 22
# b! Q5 y4 J8 P( ^2 S& Y0 e2 h - #define ITCCHEN_SHIFT 23
/ E6 ?- G: _6 \& s( M) }
0 C9 K7 d% ?$ t1 J- static volatile int irqraised1 = 0;
9 |7 R8 M3 N! T8 _' F6 _ - static volatile int irqraised2 = 0;5 {5 u& Q" j! { c8 r( n9 E4 v
- + E0 t9 e( g" v7 H8 C/ g; H
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 D! h4 B3 @4 j0 J; j0 K1 S; P
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 b# t+ d( f l8 w2 T4 k
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- {( D( T+ n( g* o9 y
9 C! ^/ u) i! P9 S- dma_addr_t dmaphyssrc1 = 0;
* T/ X& ~* {9 B& c6 x - dma_addr_t dmaphyssrc2 = 0;6 L& P- z+ {; \# U
- dma_addr_t dmaphysdest1 = 0;8 e, m$ Q. g7 R L+ V
- dma_addr_t dmaphysdest2 = 0;3 u0 s; y' w' P$ Q3 m# U
- % l# W0 W- C$ u# Y
- char *dmabufsrc1 = NULL;
( f# c5 S/ y+ n6 O - char *dmabufsrc2 = NULL;
1 N/ ~* f5 }. e7 V& @$ G! v - char *dmabufdest1 = NULL;
0 [9 p0 M9 W' e - char *dmabufdest2 = NULL;. ^ @& Q, \( G5 v- m% ^
- / d3 \ A1 f# e) U8 |- v" ?& t5 Z
- static int acnt = 512;
1 E/ j: t$ _9 B% A - static int bcnt = 8;
' M' A5 c) r, f( [' E" _" Q - static int ccnt = 8;2 h9 U# D# T% ~# ]" ~8 m2 Q
1 t3 M* h/ a3 U- module_param(acnt, int, S_IRUGO);( B6 H9 `: f" z' O
- module_param(bcnt, int, S_IRUGO);( Z3 Q1 t; R& N) C% D, _( I4 q3 l$ N
- module_param(ccnt, int, S_IRUGO);
复制代码 - r! M$ `7 z( f( a( Z- L* Z* p, B
+ O3 p* r/ P0 e2 a# J }: g
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用1 `# j$ n5 F+ `# t- F
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
) [# H+ U+ ]! W5 d/ { 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。; y, d6 o2 r; B: R, ~6 j
1 b7 n9 B, V. b, a/ z' U
) I3 H3 ~2 e7 @ |
|