|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ; C, H7 f; e3 J( N: ~
- [code]EDMA sample test application# ^9 G C+ I0 W: I& Y3 ?0 x
- /*
* ^' E$ G% l4 k/ `' @* S! ^ - * edma_test.c
5 R+ B6 z! L( Y, i/ I - *( g1 j) Y7 J9 x0 W( \' \
- * brief EDMA3 Test Application: x/ ]! W9 w, {8 C
- *
" W1 k- J- z& s3 J- u0 D9 @ - * This file contains EDMA3 Test code.' V: R2 }4 h) G: V
- *0 } K9 z. N9 H6 e+ ]' q
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE# ] ~! G7 T- I
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT+ y: B8 J# @" h8 K8 U: B7 x
- * TO CHANGE.
9 W# l6 t+ I# R% B, I; U: P - *
4 i! P3 H. e! n) V9 }% n - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 B' O6 `$ q1 ^+ b$ D. S0 X; ^ - *
4 E6 X1 d+ y+ X3 r9 K: }8 O5 S+ Z& ] - * This program is free software; you can redistribute it and/or
( b4 o/ R) P0 u( T+ g" C - * modify it under the terms of the GNU General Public License as
9 c$ R. U" }3 ~6 ?0 C/ D E# c4 q - * published by the Free Software Foundation version 2.- \9 w& i- D- }* k& \
- *7 Y4 z X ?) i, R
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; C' k+ {8 D& k- J- _# q; k$ o - * kind, whether express or implied; without even the implied warranty7 }, T9 J L& E6 e# H, w+ E
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- @' h3 h6 T) Q, |/ R4 J - * GNU General Public License for more details.
' b9 i& m0 ?. ]7 z/ G - */
7 p1 E. W1 J' D$ L9 \3 K
' g" Z1 Z+ [3 e7 K1 ]2 u1 b' M9 V. H- #include <linux/module.h>' }4 e5 n0 Y3 t6 s w3 [
- #include <linux/init.h>* m, X- z6 I, h: o c
- #include <linux/errno.h>
( F5 Z2 l z5 M$ O7 [; W0 A# s# d - #include <linux/types.h>, n- E3 B7 R6 d5 u! \6 X
- #include <linux/interrupt.h>
. }* ^ f6 t- q4 m2 k - #include <asm/io.h>$ P* ], v" a+ y- v
- #include <linux/moduleparam.h>
0 M4 f$ A9 \; L4 `% J+ y, Z/ N1 w - #include <linux/sysctl.h>' T) J7 l& m$ ^8 J
- #include <linux/mm.h>
! _3 |1 N8 B$ O: ~ - #include <linux/dma-mapping.h>
& I- C' {, H5 L, F& K. W
% A7 Q3 A. X! C# F- #include <mach/memory.h>
8 @, x% i1 u/ P3 ^) x1 b, E - #include <mach/hardware.h>
+ ]+ O$ g& i- l0 y/ d0 K5 e2 t - #include <mach/irqs.h>1 V1 M* t- @. J* w- i4 |
- #include <asm/hardware/edma.h>
$ k& I& c- T' S9 [
; ]5 e0 L: a! }( ^8 `& w$ O6 w- #undef EDMA3_DEBUG& w' N5 H2 E. W) c
- /*#define EDMA3_DEBUG*/
! W$ M- ?! z: v1 R( ]/ `, r - ' }' ~# D0 Y& b- ^9 e# k" a5 A ^
- #ifdef EDMA3_DEBUG2 J ^/ H" [5 A5 |1 l- M1 C9 y
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
+ V, a4 e5 @- H. V6 R2 E - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)) p: W; X( [/ ~. l2 r* q
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
% [& t- X, w3 c6 I; Y3 n. Q9 L' G+ J2 e - #else
1 n! J% J1 x2 d" g& H4 l( y - #define DMA_PRINTK( x... )7 I2 x* O: G# W8 k0 g
- #define DMA_FN_IN: u! u9 w, G* t3 z& f& O
- #define DMA_FN_OUT
' w# b6 \6 f2 {" `# s6 N& ` - #endif
7 w8 Z+ ]/ `7 Z/ ^0 a - : Y+ ?+ P0 ]4 D( g
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
) S9 F! A X+ l4 T$ r6 j1 l1 }6 g - #define STATIC_SHIFT 3
5 c. t, F; d/ X1 `5 H" c4 K, y - #define TCINTEN_SHIFT 203 y6 R+ _8 h9 l5 V8 ~' e
- #define ITCINTEN_SHIFT 21+ K# @$ L j" N& {
- #define TCCHEN_SHIFT 22
! |/ U0 v5 ~1 z! P( z* E0 U - #define ITCCHEN_SHIFT 23
8 X* ^5 x4 d% [8 m- ~$ V& ] - # z% B% b( G* D& \# h
- static volatile int irqraised1 = 0;
/ X: i4 o' w# ` - static volatile int irqraised2 = 0;
. ?) I! p/ K1 Z& T - . [3 ?+ {* E6 h& V. O
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; ?/ ]7 `) w% C7 u# {4 M# }, S& M - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 C3 i; [3 s& t) V9 w5 V9 w
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( j. J! v) Z9 t$ r
! m) n0 q3 G0 e- {- dma_addr_t dmaphyssrc1 = 0;
6 {- }. x1 V7 z) w8 @ - dma_addr_t dmaphyssrc2 = 0;: y5 C& q2 w+ }) J
- dma_addr_t dmaphysdest1 = 0;$ B% P8 a ]" O6 I/ |* f! ^, S6 i
- dma_addr_t dmaphysdest2 = 0;4 j, U. M* u2 Z% e' e# @) [3 h! n* w
- * \( N+ x9 Y) E7 S3 l4 b' a2 h* S
- char *dmabufsrc1 = NULL;* K- Y) C$ {+ s
- char *dmabufsrc2 = NULL;! G2 o+ ^- i, _
- char *dmabufdest1 = NULL;
/ g, } m; Z7 h/ U# t: { - char *dmabufdest2 = NULL;# Z7 k9 }4 g2 e
, k2 p& R* ^9 a9 m- H1 {- f3 ^1 [- static int acnt = 512;
5 d( u% A8 M, k4 E. A - static int bcnt = 8;9 v t b& w7 r, v8 z
- static int ccnt = 8;
, D' c" k$ W$ N `/ p - H2 }! a& C/ C
- module_param(acnt, int, S_IRUGO);& s2 ?- b" a- f8 G5 j* E0 H4 d
- module_param(bcnt, int, S_IRUGO);
3 e# N) x; t" O# W: P - module_param(ccnt, int, S_IRUGO);
复制代码
: K2 z( N' r8 C5 a- Y# o5 ]" H1 J' c( k0 N' T k4 B5 x
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用: k4 q; l3 n* e. r6 W
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
B# p- T+ B) R: M 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' Q3 C0 N* A7 z8 b* ]& s [( U( a; {% f, b$ V$ N0 J, q5 V
8 `1 {1 y5 J4 A |
|