|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 [5 w' k9 P3 A- K( c+ H- [code]EDMA sample test application6 B4 |; l- f3 N5 ~
- /*) K; S, B& Q* C
- * edma_test.c0 X: D. V# p2 O h0 v" m$ A
- *
- V3 w/ m) s% F+ R5 ]6 q0 |4 i# e* n - * brief EDMA3 Test Application
. o' c% w/ r% B: Z: _# Z/ T% x - *
% x2 y/ x& ~' Q) X$ {; R: z0 F: } - * This file contains EDMA3 Test code.2 e5 X; }) L0 e) p" Y. \
- *
4 a( D( e' X4 b - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
! @2 P9 L2 ^5 y7 n8 W" f1 i& g( L5 h - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT4 I9 i1 X2 u, Z& c' o
- * TO CHANGE.
8 @. V, R) x7 V4 z - *
+ O4 i, j% z& |6 w. | - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- d& I9 H* {4 q$ z J/ e+ B& B
- *" y- @; Q- s9 ~; g9 y( J6 p: @6 {4 V# o
- * This program is free software; you can redistribute it and/or
# o0 A9 k$ W' h2 | - * modify it under the terms of the GNU General Public License as
9 Q. c, f3 E5 G- C5 ]& ` - * published by the Free Software Foundation version 2., d0 [. ~5 @+ W. `, F, q2 F6 l: d; Z( j
- *
. S" y& c0 h; R2 A# ~ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any) Y. J! N2 r" y
- * kind, whether express or implied; without even the implied warranty' p. ~- a5 l8 D, n
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 S' G6 x w# ~+ V1 m* w- E - * GNU General Public License for more details." K2 A# z( S7 _( J
- */, q, @0 x2 _; x
- ~6 ~; V. @0 B4 @: G! c* K- #include <linux/module.h>
# U4 d2 ~' Q& l! e2 q( M; a - #include <linux/init.h>
( U2 t0 H3 p3 k; y5 x8 F. o - #include <linux/errno.h>" j8 Q* u) h" I0 ^3 K: x1 ]7 ]$ t
- #include <linux/types.h>0 W# _6 g# k/ i8 n9 A7 Q
- #include <linux/interrupt.h>
) v/ H& p( l' B( Y3 w9 T2 X% [3 R: p - #include <asm/io.h>
" G4 v* s" L6 z5 N' ^' l* e+ V - #include <linux/moduleparam.h>2 E# v! u6 J! o- s& Z/ s
- #include <linux/sysctl.h>
# r! H) N( f6 G; n- I - #include <linux/mm.h>
+ z3 J/ K B; |5 M. v/ E - #include <linux/dma-mapping.h>
* W0 E+ `# M/ V# Q1 R! `4 _; Z; x3 E - ) T# \7 h0 U9 |5 b5 w0 @
- #include <mach/memory.h>
# [$ a) A( b$ |7 ^5 L2 o/ G - #include <mach/hardware.h>
0 P" @: x7 w# s' r: @- G6 @ - #include <mach/irqs.h>1 H3 Y" p1 b5 z
- #include <asm/hardware/edma.h>( Z) \5 ]9 w' S; P9 W- c
- Q" M/ c5 l2 J# [
- #undef EDMA3_DEBUG1 Z4 S$ M. k- d# B
- /*#define EDMA3_DEBUG*/% `/ _. t+ o4 Z0 |7 Y2 N3 H9 [8 F* B
- : z) w3 f8 u0 Z/ Q0 t U6 f
- #ifdef EDMA3_DEBUG
( j! d: K1 U E- Y5 y- @ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)& \, m L, L; z c- a
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)2 ]3 T: t; E6 Z7 Z
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)" p6 u( m3 r1 W4 x, m$ t. H; W
- #else
& z- J: k3 a# U- B& {: B - #define DMA_PRINTK( x... )0 t4 _3 Q& U! D+ [1 q: q
- #define DMA_FN_IN
' i2 R& B1 y) c/ h& i N7 ?. o - #define DMA_FN_OUT/ X( B/ O5 K+ \$ X. D( I
- #endif
! C0 x" l+ N0 H& o& g
1 _9 e) X& f4 j- #define MAX_DMA_TRANSFER_IN_BYTES (32768)3 K1 _3 c; w8 x* K8 l9 x
- #define STATIC_SHIFT 3. W* n% \( H5 y j! [
- #define TCINTEN_SHIFT 201 R# f! y) N$ U7 a
- #define ITCINTEN_SHIFT 21
7 `4 ^8 c( s, S6 b, @+ @+ G - #define TCCHEN_SHIFT 22
, }. [ `2 M( R - #define ITCCHEN_SHIFT 23
+ ?% T4 S' `8 a o3 } - & I3 {. |# f- g! R
- static volatile int irqraised1 = 0;
2 }" H& P& t' Q - static volatile int irqraised2 = 0;
6 c4 j" z2 f' k. A$ r$ ? - `1 D! s9 \1 |: q& X2 R9 f7 G
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( \3 C( Y9 y4 F* i7 g* ]
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! s! [& F7 w. F - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ X7 u* L7 t) m0 G4 d9 f* q& P
t6 t% {) \: `; e- dma_addr_t dmaphyssrc1 = 0;
: C2 V# P% K# Q; F- C3 Q5 f - dma_addr_t dmaphyssrc2 = 0;
7 A _& w5 ]1 u! f, [1 [' q4 ]2 b - dma_addr_t dmaphysdest1 = 0;
0 V' [: j/ V+ i }' n# H - dma_addr_t dmaphysdest2 = 0;1 ]3 Z' D8 b- b% }
- 3 z% p3 Q5 _4 v& w! c% `; c
- char *dmabufsrc1 = NULL;* }+ w2 R" B8 j1 r
- char *dmabufsrc2 = NULL;
0 Q4 R! h; }4 F1 q! Z4 \# ~ - char *dmabufdest1 = NULL;6 E* _+ e C( B7 g& y+ Y: t( a
- char *dmabufdest2 = NULL;$ @$ Q" O9 v. P
|6 S& f1 n- R$ g' d' x8 j3 p4 \- static int acnt = 512;4 Y; K/ {# [8 `0 y/ r! _' h
- static int bcnt = 8;9 @1 v# h% I+ j
- static int ccnt = 8;8 u5 C# [5 Q- V0 U. w' S G
( W: U4 A3 h! H" v4 k- module_param(acnt, int, S_IRUGO);( a( I# x& U7 n2 X+ v% L$ Q
- module_param(bcnt, int, S_IRUGO);; r8 q$ {5 k3 i( L, B: U
- module_param(ccnt, int, S_IRUGO);
复制代码 + x2 ~ X6 Y9 l! I1 r
9 k- u3 V# R! k9 l
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用! K! t, m" g5 i& q8 _' S3 y' g
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
9 n$ |6 B5 S: I 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。! G6 S x3 e3 |$ K
8 }# r1 W* \0 x1 j6 y0 _; @) ~- C
" v0 `1 h( J1 [, Z! W: \! n |
|