|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 4 }7 [. q" w3 O6 U" b
- [code]EDMA sample test application/ W- j! n: B2 S6 z
- /*8 d, [2 ], u9 \' z' c* w
- * edma_test.c
- Y# Z, H# v+ f6 _- P, G - *
! E: A4 j" b$ r b6 F - * brief EDMA3 Test Application
( I: y8 e; i0 ? - *
) f3 p( K/ n7 u/ ]1 W - * This file contains EDMA3 Test code.* S+ X4 |& u& l# L& D9 W" |/ U- _
- *) N$ t+ z! U$ N# Z; }1 C, n6 S
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE+ J s& ^3 m/ @4 F% ~
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
; Q$ j# @& l) ?0 k5 v - * TO CHANGE.
2 H( j8 u- l8 Q4 C5 k - *' M u3 P+ {, d) P
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
9 @ f( R7 B; n) R8 f! g9 w - *; U9 M" l! ]' p# p) c
- * This program is free software; you can redistribute it and/or
1 a9 V$ R3 a8 y7 l+ A - * modify it under the terms of the GNU General Public License as$ M7 e9 C* ? _
- * published by the Free Software Foundation version 2.
# X. Y- h* u" p/ q% h" z - *8 k6 y P0 ^" ?! H
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any( [. u) @/ s, Y: q( E1 k
- * kind, whether express or implied; without even the implied warranty9 D, T6 f! m7 S: R) e3 i8 d- ^ @
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ h+ }6 E/ @, N9 M - * GNU General Public License for more details.
& p }- ?; A0 @: u - */$ I, [ {& M. \
7 r2 s& j) t- D$ V$ a8 j! O3 L- #include <linux/module.h>
% Q! ? k A5 v6 b4 U0 p g - #include <linux/init.h>
/ v: k( t* ]/ o - #include <linux/errno.h>
: g. ~: E( U' B0 A: z: H, c" U4 U - #include <linux/types.h>
5 p" n& W( w2 q% |% y" w5 s7 o - #include <linux/interrupt.h>
/ r# n& l3 O Z& T- r - #include <asm/io.h> e1 k3 d" Z# S" D% [( Q- c+ k
- #include <linux/moduleparam.h>
2 R. y9 W \2 i e3 [! L - #include <linux/sysctl.h># g1 {+ r1 x4 e2 ?( V
- #include <linux/mm.h>0 e2 I0 j: @" t. `( c q* D
- #include <linux/dma-mapping.h>
6 \8 [' X: v8 X* q4 X
8 }7 a% g6 s) I7 w1 L/ f4 z- #include <mach/memory.h>6 Q3 ? l9 |7 d2 p/ C0 k
- #include <mach/hardware.h>
4 D# @4 i3 u- m4 c - #include <mach/irqs.h>
5 \' A, u$ @* J/ e2 L - #include <asm/hardware/edma.h>. \) y' I; i! @0 M: g; A: |
- 8 j8 W8 Y% U- E
- #undef EDMA3_DEBUG8 i) o! u* d0 T" [
- /*#define EDMA3_DEBUG*/5 q0 Z' {# z) o- P4 J
% E4 ?% Q. I; G/ \* a- #ifdef EDMA3_DEBUG& X9 S2 M5 f; d( z; \
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
4 g7 U+ S7 V9 R) g( e - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
% l# Q- z) W; R( ?; a$ t! k - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# r. L3 t) m) r7 Y - #else% b% @5 k' P" D* P. n
- #define DMA_PRINTK( x... ): H R; [* k1 g) h. C! u
- #define DMA_FN_IN
7 m$ ~* ]2 t9 J3 V( X2 F - #define DMA_FN_OUT
& n! M" }$ A% |" D# c0 p$ N - #endif
6 [/ p) H# m# }9 X; T5 P' F
- |8 C/ l5 K' A8 f6 f* ?. y' Q3 H- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: s$ R9 n: t0 h% b: C9 { - #define STATIC_SHIFT 3 ?( R; N- ?3 [% N- Q4 b
- #define TCINTEN_SHIFT 206 x0 d4 Y" P( `/ j
- #define ITCINTEN_SHIFT 21
" r6 R% ]& e8 s2 L+ t V - #define TCCHEN_SHIFT 227 ]2 N. c& z5 m( I' i! D
- #define ITCCHEN_SHIFT 23
- r3 |3 K# P/ O- \9 [
2 Q! q& A" [# X# d- i- q3 k- static volatile int irqraised1 = 0;
3 a/ C+ U. ^. V- q - static volatile int irqraised2 = 0;
: d) R L6 S" V9 A; n0 y. O" O
! E" ~& ` {2 a# u( O/ h. _+ N- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 e+ D& G8 @* x# x$ [8 D! ?3 P1 e
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 ?, x7 h, N/ N4 s+ X - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ F% ]1 Q+ O4 p - ' C3 Z- p- d7 G! A8 k
- dma_addr_t dmaphyssrc1 = 0;2 M8 q1 a3 _% g4 W1 F. `
- dma_addr_t dmaphyssrc2 = 0;
8 v9 F" y. |* \" ? - dma_addr_t dmaphysdest1 = 0;
5 g# R0 I/ K9 g9 s$ w1 i' Y6 H% ? - dma_addr_t dmaphysdest2 = 0;- h+ E+ t5 a4 O2 l
- " _7 g' M9 c5 n7 B" A
- char *dmabufsrc1 = NULL;
9 R6 x( o( H) O: l8 s3 t1 U - char *dmabufsrc2 = NULL;
$ J. q9 u; v. {- L" ~ - char *dmabufdest1 = NULL;- L' D5 r4 C% I9 ?, X/ O. V
- char *dmabufdest2 = NULL;. O3 h; y x/ v, |
- " E8 N" H: v+ _! b: s, ?# B
- static int acnt = 512;
+ J o' M1 ~" [/ G/ C - static int bcnt = 8;
& Q7 C4 b3 }6 V- L3 w/ f5 U - static int ccnt = 8;$ p5 b" v! K% k9 P# {
- 3 l) k7 g' o; }- z% B0 Q
- module_param(acnt, int, S_IRUGO);
% T" B2 |* `* n2 s/ P% H - module_param(bcnt, int, S_IRUGO);
6 _( `6 y7 h/ D - module_param(ccnt, int, S_IRUGO);
复制代码
( Z0 W( {$ I7 E2 O. \2 i1 ]0 U
0 k1 e# \- U: U5 A: r7 l5 v& ^ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用% K: s$ O" y3 j8 ?
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
. _6 K6 A* x7 j- `- { 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。* [% b( E" r2 @$ y! ?
" ~% V, |( E0 |) b! q4 o+ ~
6 _3 @, E' O. b; [; V" h9 ?# T: U |
|