|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ) r' Y0 h* t. H# w; w
- [code]EDMA sample test application
4 |# q* l& }/ V; z2 F - /*0 y: J0 B) x! i$ s& A: g
- * edma_test.c
# Q$ z6 O! d% E0 N: H ` - *
3 u/ X$ m ~" L% t, [( u0 _ - * brief EDMA3 Test Application+ `$ y. p6 N, H3 w& T
- *
, ?" v" I( F# J) ]3 ]6 ~ - * This file contains EDMA3 Test code.( D# ]2 u9 d3 d( y7 U, c! u8 @- v
- *3 q) _# t9 a, s- S4 c! o
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE; W; T% Q! I( z, [9 ?. ?2 w ~
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
' g- Y$ F y w- s; W4 k% U5 T: d - * TO CHANGE.$ T+ ^* G- R$ r1 g0 o
- *
6 L) y3 b" G# A4 i" S6 |* S0 B0 L" A; @ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
& S j/ A0 y2 m: s - *
% q) p5 l8 t( M/ S( n4 Z - * This program is free software; you can redistribute it and/or0 E4 D8 m7 y! ~& |
- * modify it under the terms of the GNU General Public License as0 u) \+ T5 c! f% X" c
- * published by the Free Software Foundation version 2.9 G5 Q$ l, r8 }5 z
- *
8 b) n1 R: H- _. ~- ^& e - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
5 U/ V! e6 ]9 d! Z6 s: `+ \ - * kind, whether express or implied; without even the implied warranty
, ~: {$ [. ~6 d( X: E - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the: |0 C' P% {+ @& b% T6 w
- * GNU General Public License for more details.
' g, X2 e- Q+ j: _ - */
2 i% O0 P5 e2 E) |# S
- x9 h, L4 r+ `8 G H: y- #include <linux/module.h>
# n5 D* |! d) B- a - #include <linux/init.h>
# x' P$ j$ r+ D& X% W d- F - #include <linux/errno.h>
$ l9 ` @# F0 [+ t R% X - #include <linux/types.h>- d A, Y+ i+ Y0 t0 W2 K7 S
- #include <linux/interrupt.h>1 h. }6 W5 k' t! ^* V( w
- #include <asm/io.h>0 R) Z( @) p+ W' C* N
- #include <linux/moduleparam.h>; H" L" |+ N5 j$ x
- #include <linux/sysctl.h>
! j) R; ~& j& e# s( r% V3 o - #include <linux/mm.h>
: y1 }( G9 L, I/ e - #include <linux/dma-mapping.h>' f. V l3 R% W: |6 _ O% M0 E
% N* D: V z+ b* O, z$ U- #include <mach/memory.h>
' s# `$ D- d+ ?7 ^6 \: A) l - #include <mach/hardware.h>
8 r) x" G& C- \+ E0 E' [3 d9 v9 i - #include <mach/irqs.h>
0 E: Q" X0 T. E2 @- z: Y7 R - #include <asm/hardware/edma.h>4 M: u+ z/ M1 r
- 5 d, o/ g. Y6 s" N7 w9 H* ~( B
- #undef EDMA3_DEBUG0 \( w% W2 q0 @: g; y* S
- /*#define EDMA3_DEBUG*/+ G/ I0 F; O, B
- % Z" s2 @8 G Z9 V; d/ T2 i2 _+ J
- #ifdef EDMA3_DEBUG
* \8 J9 u8 [. U% T - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)' t1 _1 F2 }6 A8 y2 N$ G& ]
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
# ]& E, i; K, q# N1 n# A. ] - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 T' {( s* d; G0 G# f; I7 F% E# T
- #else
3 U. o: A x$ W" ~& { - #define DMA_PRINTK( x... )# o2 j) u5 H5 H1 W% `
- #define DMA_FN_IN/ p- `8 {3 p( N4 V3 w* i1 s/ u) {
- #define DMA_FN_OUT
! ^9 a) q" f: @7 i0 ]3 C5 e - #endif
9 y0 D6 x2 q4 [2 ^; a. B- r% V - * z# O% B. G3 C: u
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. l7 a; v& J I, p - #define STATIC_SHIFT 32 N! A: t# t: T2 f5 h
- #define TCINTEN_SHIFT 20: f3 J) _ r7 f% A) V! T V
- #define ITCINTEN_SHIFT 21$ Z& W/ R$ }/ j8 D2 y7 b
- #define TCCHEN_SHIFT 22, K% q' B7 j# X
- #define ITCCHEN_SHIFT 23: N* j. o. Q( M/ |/ H ]
- " T; s+ w6 i9 C* H
- static volatile int irqraised1 = 0;
' S I1 p$ f6 K; J: M - static volatile int irqraised2 = 0;* \' Y" O: G, Y; z
' z, P2 U# a2 T! j+ C8 w" j+ c2 P0 U- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 b( n" |# F4 Z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 ~; c. c0 w8 B0 N5 ?6 c# ^
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; Y7 w6 W1 _. f% [/ P, P- w' w - 3 C1 I. L" _. E1 S( ~
- dma_addr_t dmaphyssrc1 = 0;, K5 D5 p, w7 _2 {$ W6 x
- dma_addr_t dmaphyssrc2 = 0;
3 ^- q: G0 m! f7 l2 R - dma_addr_t dmaphysdest1 = 0;$ s' o3 G% _: h d/ \
- dma_addr_t dmaphysdest2 = 0;
, `. u4 S7 }$ S4 `6 W
2 N- |% J1 K! L4 h. ?3 _- char *dmabufsrc1 = NULL;! H- l6 ~' ^3 t4 ^
- char *dmabufsrc2 = NULL;
4 n+ I/ {+ b# c9 k - char *dmabufdest1 = NULL;; K" k% q4 z4 U* @ L
- char *dmabufdest2 = NULL;
# `# G/ l$ D6 {) G6 Q3 t+ V2 f - : p* T+ V, N3 ?1 i# B) R! }
- static int acnt = 512;% T0 [0 H- [/ |
- static int bcnt = 8;
2 F" D& t# v$ z( Y! Q - static int ccnt = 8;
! W, D; H5 v$ X. b, b) o* U
- h$ I' [0 A( k3 m; H- module_param(acnt, int, S_IRUGO);" e ] v4 s) ], l( X" W5 O
- module_param(bcnt, int, S_IRUGO);2 Z4 I; K' O/ ]. j+ J
- module_param(ccnt, int, S_IRUGO);
复制代码 % {# V0 Q& ~8 d1 ~2 o6 _9 b1 s J" V
/ i4 \ p3 v- |6 F; V
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用# I% e' v* W: x7 T) B
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 Y: j# v6 G1 b 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。- y; Q* F) E( ^1 [- ^" d
- U; _- _7 Q+ }1 h
! T) x# e5 z x% | |
|