|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ; l, y4 [+ P, y, Z% @
- [code]EDMA sample test application' d) U0 l3 G" e7 |5 H' b9 K4 y6 O
- /*
; ~# W' L8 n0 q; d& X - * edma_test.c
( B4 ?/ X% }2 H n: G3 v - *
( W9 T1 [; }# L$ p* B, m - * brief EDMA3 Test Application
2 j7 H+ q3 I& n - *8 s i% |! G1 Y4 y$ ~3 O
- * This file contains EDMA3 Test code.0 |2 R6 W$ ^; M$ {2 b
- *
3 l8 u0 s3 A5 b. R4 s - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
9 w( i4 B& s: |( ?2 M* s z - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT0 p2 {6 O c% s9 G, s/ R* ^* C
- * TO CHANGE.
" S$ f8 {- u. D' r - *# E. C0 l4 x* ?2 M {% A2 K! s- l
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
( J0 U) F1 ]# w% x |: ?: _ - *( j2 e8 c% q+ M$ p
- * This program is free software; you can redistribute it and/or
7 H, t6 v7 g7 m) B0 E - * modify it under the terms of the GNU General Public License as
: X. B) Q1 \8 K! A+ l* h - * published by the Free Software Foundation version 2.: Y$ k8 u% ]* Y) H$ {! O
- *3 }1 l' X. f5 t8 V
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any: Q% e" k0 t: b V
- * kind, whether express or implied; without even the implied warranty
1 h. ]' g9 D; t# G) V; n" Z: d; E3 d4 e - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the5 y( }7 G; j6 I& F6 F% H
- * GNU General Public License for more details.9 G# o( |7 Z: x" x& i$ S
- */
5 l4 v) c8 w% S# N# j
8 w8 D& B5 Y: E8 v/ K- #include <linux/module.h>
1 t, W1 T. B3 [9 f) ` - #include <linux/init.h>/ c: G. K! `, @ s8 u c2 ]
- #include <linux/errno.h>' Z- i, y( ?6 r2 }
- #include <linux/types.h>, v+ J6 A9 b; N0 g8 B
- #include <linux/interrupt.h>' d2 m9 E' v. @0 ?% F$ N
- #include <asm/io.h>. ^ i1 W- B* W1 `5 R, l9 l- `) A
- #include <linux/moduleparam.h>. [; G' T& w$ C. \" ~
- #include <linux/sysctl.h>% [& q* [4 H) I0 I3 L( a! a. \
- #include <linux/mm.h>
9 B J, Q$ k9 { - #include <linux/dma-mapping.h>
. V- k6 ]4 D2 `) y, B/ _5 J x - 1 X+ _8 L: a/ q; A; j
- #include <mach/memory.h> s) ~* H2 r% A' S! P6 \; _
- #include <mach/hardware.h>
2 u5 q, E8 G) r) f* T; `; M4 y - #include <mach/irqs.h>
5 v. l2 u/ ~* W% d - #include <asm/hardware/edma.h>( k- u8 o( r9 i
/ T( Z3 q! z* @4 ?- #undef EDMA3_DEBUG
6 [; Y9 U9 v! q! x- ^. n+ H8 I- ? - /*#define EDMA3_DEBUG*/' D2 {' H; {- b
7 J$ Q* j- D/ v C$ ?- #ifdef EDMA3_DEBUG( ?8 |, O' p6 V% [2 Q, ]
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
8 r; X6 v, p& j$ C0 W' r( c - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)# O: P$ q$ E0 o: l/ w4 a
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
9 i0 g, ]1 O/ Q" J: t X5 D - #else$ o# C" O' c2 E. \& B4 \
- #define DMA_PRINTK( x... )
3 z/ a& z7 [; h3 [ D3 u - #define DMA_FN_IN. M' e- M3 \. H7 N
- #define DMA_FN_OUT
5 H2 u f7 f6 n& Z: } - #endif u6 L6 z- J. O9 ~- O1 y3 \
1 A2 U; d1 }6 p+ f8 R4 m( @/ K- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. G) Y, J6 u4 }# B$ d+ S - #define STATIC_SHIFT 3
/ W3 q5 H5 V9 T - #define TCINTEN_SHIFT 207 H; ]& V0 ]1 g8 j
- #define ITCINTEN_SHIFT 21
, G" x$ T O% U8 U2 P - #define TCCHEN_SHIFT 22
$ R3 V. ]" ^4 V2 k9 r! T/ R8 u - #define ITCCHEN_SHIFT 23. Q0 Y8 W- J& V
! T/ e5 {! T3 ?) \ x- static volatile int irqraised1 = 0;7 a$ m. h' Z* \. L. r, J
- static volatile int irqraised2 = 0;. T3 F- \# c7 q7 B
. { y5 h" [/ | F' G# O- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# b: a9 U o! O' r
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 q' u8 c4 X) \: i% x4 T
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" {- U T, x# Q) d1 B9 C" S
+ r, s. m) o7 O2 ^. o- u- dma_addr_t dmaphyssrc1 = 0;- ~: E6 b" c$ |
- dma_addr_t dmaphyssrc2 = 0;" Y% Z; W* T, e% K
- dma_addr_t dmaphysdest1 = 0;
0 A% h+ o; {: F - dma_addr_t dmaphysdest2 = 0;
0 z1 L9 k) b0 u3 T _/ }7 t0 ]& {
2 j0 e/ c E$ s7 I) G- char *dmabufsrc1 = NULL;" @- o2 ^/ L: [) v
- char *dmabufsrc2 = NULL;
" S4 p$ v+ [' V - char *dmabufdest1 = NULL;" V0 j; e+ H: z1 e: |
- char *dmabufdest2 = NULL;" t* m/ [4 A2 Y4 g: l# J
6 w$ [4 }, K7 K- j9 q- static int acnt = 512;- y$ V3 _2 S; Z/ |* s7 {$ O& b
- static int bcnt = 8;4 [) }0 r c; ~/ N0 c' O6 X u
- static int ccnt = 8;
" u U! Y7 Q+ W; { - % K0 ?" |& K, Q0 d! E
- module_param(acnt, int, S_IRUGO);
) A5 |) @ u, H% r - module_param(bcnt, int, S_IRUGO);
" E! ]0 {3 ]( O1 @, i; k - module_param(ccnt, int, S_IRUGO);
复制代码 $ f8 `) r1 P* Y& ?9 y1 L* Q9 L
4 G& u* ^# I B' B 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用0 n' O! G7 y6 ]) q% S4 C
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; i m2 @, G; A2 c5 h# P
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
0 t; @) [: i2 |- J9 M
* h9 R3 r4 h7 C1 t% v+ H, P' m" i8 u4 v
|
|