|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) K% K& c& U5 n( ^7 n- [code]EDMA sample test application
; w/ @; }7 {7 c2 ` - /*9 }: j" h6 b" H
- * edma_test.c
5 F7 x/ e% Z) u3 _2 o - *
# @& |: H9 H+ E8 K) `* E& D - * brief EDMA3 Test Application" s) ?, M T% s
- *" ^! d# L& D- w; j. b$ s9 W
- * This file contains EDMA3 Test code.
+ E1 G0 U$ D$ P. |- y - *
/ _+ Z% t3 T' s6 p- Q0 M" H - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
~' o: C4 C, m+ L) e- U" }" E - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT. s" F8 O8 S6 U' l" t) y" Z
- * TO CHANGE.
. z2 h2 b4 B9 d$ [ - *
( J1 v$ |6 m) ^# R( u# R6 G+ n5 a - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- ~- M& x1 Z' K0 |0 V q" o9 P' b
- *+ h p& l# h( J# ?
- * This program is free software; you can redistribute it and/or6 {/ \) ^# ^, E/ M1 N* a
- * modify it under the terms of the GNU General Public License as
$ ^5 [1 J( W( p- X2 L - * published by the Free Software Foundation version 2.
0 f! B2 m" t; q( M+ a - *5 r' ~7 c6 d1 o& v1 b
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
4 J( J& a# l# Q, [ A6 F. f - * kind, whether express or implied; without even the implied warranty9 \: t- p. A3 G3 R2 N
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the, I o K" ^: y
- * GNU General Public License for more details.
# s; n9 V: P7 t/ l+ R - */
7 U$ ? g4 U6 x8 S+ c- \ - 3 s2 N' k) m3 o1 W2 f
- #include <linux/module.h>4 N, r! C% `1 D k9 @
- #include <linux/init.h>
& |) N9 Z' W$ _1 v" E$ o7 y+ p3 N - #include <linux/errno.h>6 {; i" ]2 i6 Q8 M) o
- #include <linux/types.h>
% w. z1 O; ?4 @# _ - #include <linux/interrupt.h>' w5 h' d, L M! W# U, b! G$ h
- #include <asm/io.h>% k T& E* _3 _' {; W. |3 o
- #include <linux/moduleparam.h>
( Z9 j( d' _/ z7 M6 P% n1 s - #include <linux/sysctl.h>) w. [3 q d+ q# S
- #include <linux/mm.h>2 J0 E& k J# A5 f7 N* {0 u
- #include <linux/dma-mapping.h>3 Q- g. k2 w* w! |4 o/ w
2 Q; p' W2 l4 e) W- #include <mach/memory.h>
+ E1 m3 {9 N6 X$ c6 {5 B1 |2 s - #include <mach/hardware.h>
8 w9 l! E- v& l/ ? - #include <mach/irqs.h>7 v1 X N, d, D) e" b! y
- #include <asm/hardware/edma.h> M2 b4 |2 F n9 t
- 9 e5 B5 M1 i0 u) s6 E$ l' H) Y
- #undef EDMA3_DEBUG0 M+ ~3 {: u8 l e; X+ h
- /*#define EDMA3_DEBUG*/5 M' ]/ Y# O0 }- S% A+ e& r( J' X
3 h1 n( L: |" T2 ^1 \- #ifdef EDMA3_DEBUG
$ Q4 h& O6 ^3 a( A. C( C2 ] - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ n4 `1 ^' B' A - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
! @5 ~: x- n! S+ @ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)2 ]* `0 q: G8 x- A( A2 E: n# D% ~
- #else# P) z% Q) I$ o" M1 i" ^. C
- #define DMA_PRINTK( x... )
* I. C$ t! H8 b. d G6 k5 P/ t - #define DMA_FN_IN% E7 D1 J% K( y* z/ a6 e7 r
- #define DMA_FN_OUT$ c/ ? s& s* h4 I& T9 ^' S' l
- #endif4 O; M: f4 q% e9 F% h% ^5 s1 X
- 8 b9 K' ]* e4 W) n* A0 J! f
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 f k2 \; D9 u- ^' l" P) _4 t8 l - #define STATIC_SHIFT 3
" B% X5 v( ^: N2 F6 w - #define TCINTEN_SHIFT 20" [& J/ v# k0 {# R: |% O
- #define ITCINTEN_SHIFT 21
& {! c2 ?! W4 l5 R+ [ - #define TCCHEN_SHIFT 22
) f) k- g5 y( H - #define ITCCHEN_SHIFT 234 N8 A# x% ~& O
/ y7 r% o& O( R# `- static volatile int irqraised1 = 0;
# t7 h4 a; j0 P2 o - static volatile int irqraised2 = 0;
4 o/ j2 v, q; X
+ s, _6 m4 C" Q$ a; Y3 j- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! @! m3 y! R" k4 u- m - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ g; L# v$ k, i, S7 e1 z. H
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& a$ W+ J- u+ D. S1 B" u* D! }* a
8 Z1 f" `8 v# _; D: m. D- dma_addr_t dmaphyssrc1 = 0;
4 T. N/ q; a' p" `8 d - dma_addr_t dmaphyssrc2 = 0;+ _9 E( P) b7 C: @( B! c l
- dma_addr_t dmaphysdest1 = 0;: l4 n" O) {! [1 _2 |- E! f3 M0 Q
- dma_addr_t dmaphysdest2 = 0;" K, D+ g8 ]2 `( b7 Y
' I+ G0 ?; D+ V- char *dmabufsrc1 = NULL;: |9 R" E& s3 {
- char *dmabufsrc2 = NULL;
, m1 t0 P0 G, O( H0 s - char *dmabufdest1 = NULL;% o+ F G; Y2 f7 W4 l( f; z" _4 H* ?
- char *dmabufdest2 = NULL;
n9 j* x, N- J5 q - & R% A! L1 ~1 }: o% T c
- static int acnt = 512;2 f {: P# p9 K! `7 |
- static int bcnt = 8;
6 ~7 S& I- C+ g1 n7 C - static int ccnt = 8;* B, P0 E( g1 e6 A
8 \! I* c9 N5 Q; g4 `- module_param(acnt, int, S_IRUGO);
( n' p! j2 M, N# K$ j6 B - module_param(bcnt, int, S_IRUGO);3 ^- `- V6 F. @$ Q1 ~
- module_param(ccnt, int, S_IRUGO);
复制代码 3 ~6 |4 v; Z$ j. L9 ^" H
& C3 U- x8 B1 P6 Y5 C4 y
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) V, a6 y1 B7 j/ }; K0 w) Narm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
1 l: [ y8 C7 H 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。) y+ W$ a" c& `, X
$ R5 \0 x1 c$ [! X9 }0 H1 _
$ A4 E) m+ m5 V8 x |
|