|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. t3 i' z) |4 F- [code]EDMA sample test application
2 E6 U& M8 s6 `( R2 Y( c4 Z - /*9 j# s" Y2 d% \' n- o2 ~
- * edma_test.c
. M3 c& F) {+ l6 m2 T# Y - *; W! o+ ~/ z N2 c5 d) x
- * brief EDMA3 Test Application
+ `0 T; W0 Y2 W) i - *
$ E. x. E& ~( @. L o - * This file contains EDMA3 Test code.8 p4 I, U! d# j9 y# |
- *' K' v$ ?4 P. Z+ M
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE- v p' Z6 C! T' @$ H7 x$ m
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT$ A* ?- a- }- t) n$ ]2 n; g; ~+ X
- * TO CHANGE.
! E, I- `* G8 w7 X, F2 r. {' R0 a, | - *
8 A+ M- V8 G0 L - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
) @7 A2 N: e& k, A5 j# p- G - *# V& y3 q8 \6 p
- * This program is free software; you can redistribute it and/or: C; m5 q. ^" T h
- * modify it under the terms of the GNU General Public License as9 p" _4 @; [, D
- * published by the Free Software Foundation version 2.
! O8 Y9 l$ q; n0 J, |' M* B' n - *
( P8 o1 h- ?7 Y1 N% X. R R - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& y9 t0 Z$ x& q* ~1 p: D# _ Y - * kind, whether express or implied; without even the implied warranty. q! _ p L, r$ q
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" D1 @( I4 e+ y - * GNU General Public License for more details.
1 N: s1 q1 @! H2 G/ w0 T5 x - */. z% r3 C. b y; J! j1 I) ^$ X
- / U) Z6 W ~# o5 E. x, v1 h
- #include <linux/module.h>
, b# x' D: F( P$ Y$ G# s# J* {! |- o - #include <linux/init.h>' E2 `* N3 `8 @, m+ D. n
- #include <linux/errno.h>( g2 K8 z2 A; \' U- u3 ]
- #include <linux/types.h>
# G& O- j, |, v' p+ m - #include <linux/interrupt.h>' s, I+ L( t2 c6 [ P$ p% P
- #include <asm/io.h>' j2 O" h3 J, y) t; d
- #include <linux/moduleparam.h> O( O+ g: l& M8 H' w W
- #include <linux/sysctl.h>
" y/ I9 ]' K8 {5 F9 W/ \ - #include <linux/mm.h>
1 Q b0 b5 ~# q( U/ c - #include <linux/dma-mapping.h>8 Y2 L' s$ h# V/ n
- 4 l$ K9 e1 A$ v* u
- #include <mach/memory.h>7 y9 g7 F: b) H, [/ k- M( U f1 Y
- #include <mach/hardware.h>2 S4 {4 q2 P# L! o
- #include <mach/irqs.h>: ~0 T0 b- A1 h
- #include <asm/hardware/edma.h>
5 L3 O$ B8 o' {9 Q( q" G9 N0 n( o: B* B
3 ^. S; Z! O6 k+ g1 t2 k- #undef EDMA3_DEBUG
! T8 N+ [$ H( ?3 A' c - /*#define EDMA3_DEBUG*/) W8 s- M5 R, K0 T T
! t6 X" E4 F9 e$ z6 o- F- Q- #ifdef EDMA3_DEBUG
/ F. e$ G* k5 z( C3 A# w! i - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS); i4 H7 K# J- U# u' Y8 J. ]
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)1 ?9 @8 k$ }6 s, o# d5 Y
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): I3 @3 ~0 j! h6 P
- #else
/ R0 y4 l1 B9 z0 c - #define DMA_PRINTK( x... )
7 t0 z: Q% W5 d7 U3 T - #define DMA_FN_IN
5 J& t' Y) l% X3 W0 ?( ? - #define DMA_FN_OUT
7 e$ I" I- Z5 E, o0 o, L - #endif, j0 J0 ^ Z m, p, V
- ; s* B, ^# U, h& B
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; P7 d& x4 E: w$ x/ }6 W - #define STATIC_SHIFT 3
- B8 A$ R. Q1 m7 R1 f' a- p - #define TCINTEN_SHIFT 20
( r% ]1 X$ D& X4 m6 \6 X - #define ITCINTEN_SHIFT 21( N8 r3 D/ ~2 N8 e: O
- #define TCCHEN_SHIFT 22
( a, `7 e* j9 M! Y1 X3 O - #define ITCCHEN_SHIFT 238 u$ b/ s0 _0 q0 ]
+ S- q# M3 `7 q7 J! a6 r- static volatile int irqraised1 = 0;
- l) i3 B8 l+ i - static volatile int irqraised2 = 0;
& Z& q$ s A5 q( [$ J3 e - % M0 |% @: e/ c$ w0 a0 U4 U
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( B% g! b( J- Y* {$ z+ l - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 i i) V* [( d# ?+ k$ Y - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); I# }6 e) d0 d1 |5 \5 |
( ? m- ~" w0 L7 e; G5 f- dma_addr_t dmaphyssrc1 = 0;# Q4 d. c! I$ e( b
- dma_addr_t dmaphyssrc2 = 0;
2 i$ j# ~. }* s! [+ ` - dma_addr_t dmaphysdest1 = 0;/ R& \ T% Y% c7 l) R
- dma_addr_t dmaphysdest2 = 0;- ~" X/ N( x2 J
" w- W8 K) e+ p; {& j! K. i7 A0 z4 B- char *dmabufsrc1 = NULL;
# [/ o1 Y- Q4 o2 R7 x- n - char *dmabufsrc2 = NULL;3 C3 G, C- H @6 {1 Q5 x
- char *dmabufdest1 = NULL;6 h. e0 f/ _( _1 R V1 m8 F
- char *dmabufdest2 = NULL;
- F4 }! J0 [! V$ h: }9 ?" U
2 x, d4 p) @8 q5 }" D% [- G. B/ B- static int acnt = 512;8 ^ i% n ^4 n
- static int bcnt = 8;
7 Y3 C- }, B1 u" f9 G - static int ccnt = 8;6 J( o, b6 t8 n. W @
2 m7 @& t a* r) X. F: {- u+ j, ~- module_param(acnt, int, S_IRUGO);7 x6 l, P% y/ m2 f) ?
- module_param(bcnt, int, S_IRUGO);
# t7 K5 f# N/ b - module_param(ccnt, int, S_IRUGO);
复制代码 2 {" r9 k; ^0 H# o" Q
+ }2 k2 N& B& _: s* ]4 s1 T
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
3 S2 }' p# f+ W9 Marm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
4 v0 S, E3 P3 D' k# U7 b% C" x 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 T3 ~) Q* A2 U# ^5 Z5 r
2 C% i+ U2 l/ ]( m' }
# V0 @+ A3 }/ L |
|