|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 b3 Y3 l- w) S- [code]EDMA sample test application
& Z" d' ]8 N" b/ F2 ?# _7 }" c - /*
0 Z2 i. |& \. E - * edma_test.c
' O1 l( P8 p i - *
6 f/ k( {; ~ c& |6 j" ] - * brief EDMA3 Test Application
9 m& h8 B2 C: O' x( M" [ - */ W% r: B3 K) I& I
- * This file contains EDMA3 Test code.
3 e) K. W9 c) ]5 ] - *) q( |% ?: [, d: q2 r
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE7 h6 @2 c) H" c
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT& F6 ?# a' e% B
- * TO CHANGE.0 J( h4 t6 _, J4 g
- *4 l: }- Y, B5 a* s6 k6 H, r7 E
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ }' o) i, S! r
- *3 I2 e+ n3 i0 b
- * This program is free software; you can redistribute it and/or
' I! O' Z* K* C8 @2 p& w- B - * modify it under the terms of the GNU General Public License as: M* r1 p, A% P' m# A
- * published by the Free Software Foundation version 2.
7 p$ p! w2 ]( q! \5 p5 O - *. B1 f+ q# }8 ]2 P- b5 L, ]* i9 X
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 a) _8 d+ K& Y* b
- * kind, whether express or implied; without even the implied warranty
5 Z! X2 b/ W0 G% m X' K/ Q$ z - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* I6 d# b9 h8 N0 m1 s
- * GNU General Public License for more details.& U1 \; x1 r2 c# N
- */# d3 q# W: y( y0 L" R0 r
, S3 Q- n8 C$ [2 ~. W% \- s- #include <linux/module.h>
4 D! @, p2 X* x) N3 M - #include <linux/init.h>& t& _, W) J: h* a( I2 ?5 j" a' ^% K
- #include <linux/errno.h>
4 U' S- `0 H/ }" V4 A: a - #include <linux/types.h>
& K4 O/ d% w e+ u - #include <linux/interrupt.h>3 I" f Z! p3 Y( Q# c% g
- #include <asm/io.h>
8 M& [) v, u. o2 Y& f6 q. F - #include <linux/moduleparam.h>2 {0 k4 G# f0 t9 G1 I. z
- #include <linux/sysctl.h>" V: n c) I; l3 B
- #include <linux/mm.h>
% f$ `# Y' S' h! i1 @. ~ - #include <linux/dma-mapping.h>
' R6 u9 {% S2 N
7 L* s7 H5 l" k, P6 m- #include <mach/memory.h>6 L' X j/ J& g$ w0 y
- #include <mach/hardware.h>
( C6 T( ^" a+ O" A8 @' Q - #include <mach/irqs.h>/ O3 X/ l# ~% @: ]
- #include <asm/hardware/edma.h>7 b$ F) l" s7 O, A! P0 l0 W1 I$ O
% Z+ ~& Z9 x" V7 e- #undef EDMA3_DEBUG \: g7 c0 g, ~0 C) {5 V
- /*#define EDMA3_DEBUG*/
4 G- H' y% R z* V' w t. F" |
: c0 S5 W7 x" s0 A- #ifdef EDMA3_DEBUG
, F0 y% W- X$ O! \ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
m& W" P7 i' z& i! _9 b) U5 N - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)1 p( W6 f) R( \) C3 ^* _+ m: E2 E
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__), L; I3 n0 H2 \ i4 F" h
- #else
2 {! V) h$ p# m# Y# |* k2 R) @ - #define DMA_PRINTK( x... )
`1 T u" a6 P4 o - #define DMA_FN_IN; u6 c& W% }- [, z0 O
- #define DMA_FN_OUT
, I5 }) l5 b3 f - #endif( b7 X4 i6 ]; r* @/ S- k- H$ i
0 ?. f, I) r% y- l$ ~- #define MAX_DMA_TRANSFER_IN_BYTES (32768)) u/ ]% i& k. @8 h7 I% g5 C2 g
- #define STATIC_SHIFT 3
& J. |) r0 U' Q2 y# f4 C - #define TCINTEN_SHIFT 20
4 ?7 P' ?/ r8 J! @; l - #define ITCINTEN_SHIFT 21( v- P+ u- v( |4 a
- #define TCCHEN_SHIFT 22
! B1 q2 j: f* r' l+ Z6 P P - #define ITCCHEN_SHIFT 23
. o5 l3 ^8 o" J- P" U9 ?+ K5 v - , `0 V! l6 w5 M: t$ ]; d8 b
- static volatile int irqraised1 = 0;7 n/ ~3 B# n0 Y, g( r
- static volatile int irqraised2 = 0;
; }# P2 B3 {' S' o' \! N0 H - % Q( L- d8 S$ p1 I( ]7 s* J+ v
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 h$ v5 b) ~# S6 ?* ~ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! c- @5 q8 C3 O9 u: R
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 T' D- H: k: u! S% }* U4 G$ P+ b
* _. O5 g. E# T+ Y; p, m- dma_addr_t dmaphyssrc1 = 0;% M7 T9 |# X) [) {' q
- dma_addr_t dmaphyssrc2 = 0;8 ]9 Q8 Y! s- V
- dma_addr_t dmaphysdest1 = 0;
$ U1 J; |- A3 |. f5 D! S; m - dma_addr_t dmaphysdest2 = 0;: @; ~4 ~- q: E3 p( t% E1 Q
- & p. v& X |) J) S$ O. c0 L
- char *dmabufsrc1 = NULL;0 F1 O+ q; Z' \, D, C
- char *dmabufsrc2 = NULL;: O- t1 E; E3 F# i% q
- char *dmabufdest1 = NULL;6 N! `) c" O. e! ^8 U5 B M% j. p
- char *dmabufdest2 = NULL;
# L+ P- N0 G: v& Q* q {) @
+ ]+ W+ U2 q4 F: y+ H, @% y- static int acnt = 512;. p: i- D E5 d1 u& d9 D0 s
- static int bcnt = 8;
$ j8 A( X7 L, U# ?9 q - static int ccnt = 8;3 O+ L: t F' ^
- ! f, a; k1 X% ]
- module_param(acnt, int, S_IRUGO);3 w# k0 E) ^" N. H* K
- module_param(bcnt, int, S_IRUGO);
5 ^# V' V0 ~: z - module_param(ccnt, int, S_IRUGO);
复制代码
. C1 Y- S! E% F8 H1 M* B
, C2 {2 W5 O% _/ @ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用 |8 H6 H$ q0 O1 r5 w" t
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。1 [5 K; } ~$ {& W' N6 N4 G& ^
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 u! _+ ?& }6 q! L" \( V- j7 J3 c
4 M! n0 `, Y* e
& W% o/ [0 O5 V1 A) Z' ^8 m: W |
|