|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 a+ B$ g9 @" T# E1 T- [code]EDMA sample test application/ g& k1 w) Q0 ~2 y
- /*
7 }& @% H o' l" `2 i" W - * edma_test.c
. `8 S. g' h" w, c9 C - *
, N6 w! A" E* X; X9 I0 n* X3 l' F* W - * brief EDMA3 Test Application! Z4 V9 _0 v N; t* `" h
- *
) A9 o k- a9 n' Y8 e" R - * This file contains EDMA3 Test code.
) ]0 M* p& ^+ X4 e f' j& g! S+ \ - *% x6 R5 P5 A* f, l; R$ h
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" i: c9 F4 l4 O
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" c& d2 P# v1 B# \ - * TO CHANGE.# E( {4 ~7 D/ w4 E6 d x
- *
& K- M& r; y G: t - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
& G' m5 I, V: o' j - *8 a: o; V( y+ M3 w) m7 i
- * This program is free software; you can redistribute it and/or- i' @( b! e u4 J" o$ E: d) p$ y. \
- * modify it under the terms of the GNU General Public License as7 Q" `, L" u" N" H) `
- * published by the Free Software Foundation version 2., n3 R$ R' ~0 z
- *$ F0 h8 q6 s7 z2 z
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
2 H* T& `2 R6 @' U0 U$ M2 o - * kind, whether express or implied; without even the implied warranty
; r0 }' k) Y% r5 d, Y1 K - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the V8 e' P1 k8 w/ ~" Q0 E
- * GNU General Public License for more details.
& x3 r" u K& L - */
% q) u( q. N P) _9 o8 y/ { - 5 t" W$ N$ k( }: h0 q g- F
- #include <linux/module.h>/ B( c$ T# ~, `) {* Z
- #include <linux/init.h>
' Q& u8 j$ a/ n: O - #include <linux/errno.h>
" L$ X$ X5 }' Z; V6 v5 S( _ - #include <linux/types.h>% G- A0 E* p. t9 z% J
- #include <linux/interrupt.h>
* N% G7 B& Y: k) y - #include <asm/io.h>$ |0 Z' o( T) g5 u; _! b
- #include <linux/moduleparam.h>/ M0 m7 W. R$ i @; ~
- #include <linux/sysctl.h>
. O+ K/ x1 g. G( {) {! R - #include <linux/mm.h>" E, ^2 u7 b1 I
- #include <linux/dma-mapping.h>7 E: i1 n& C1 Q6 c: t9 U5 g
% r9 D6 G6 {; @" M- #include <mach/memory.h>: h$ @* M! ~4 ^- i! e4 ?
- #include <mach/hardware.h>
5 q9 B) e/ [7 E) e) E, f - #include <mach/irqs.h>: B, |1 p2 `8 ^
- #include <asm/hardware/edma.h>7 F" h Q! M+ ^+ N
( U" Z0 Y) g/ R- C- #undef EDMA3_DEBUG! ] g3 O7 }: F+ C- v% c9 H
- /*#define EDMA3_DEBUG*/
- l. T4 S9 x G3 T7 o
) [8 P3 ^8 \! [' ^: E- #ifdef EDMA3_DEBUG
7 O s5 Q! _7 W! w* S: ]1 y - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)# }0 [1 N. e* Y8 \& _; H8 N) Y
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)7 s6 @0 z8 Y) G4 @( e
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
' ]8 }2 n! E7 X0 e# h( l9 l4 R6 I - #else
# y. a n t) e8 d* N# P - #define DMA_PRINTK( x... ): ~ i% B, `- W! U; v, k
- #define DMA_FN_IN
\ W2 ]$ [; \2 z6 m6 Q - #define DMA_FN_OUT
2 C' x2 ^& g8 p: ]5 V* T - #endif" a* F5 [7 _+ z! u+ Y
- ( c! H _# F0 G) b0 _
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
5 s; q, G6 I1 o) E5 M - #define STATIC_SHIFT 3- c* U ~+ @: n' h1 y. g
- #define TCINTEN_SHIFT 20
( h7 u' N3 M z) Y) g2 K2 V - #define ITCINTEN_SHIFT 21
+ z2 D2 u: P+ F - #define TCCHEN_SHIFT 225 u0 w, A7 C' ^; O) u
- #define ITCCHEN_SHIFT 23
- f" _1 j4 J% n! } - 7 Z9 v2 `4 k/ h: [$ L% @0 ]1 v
- static volatile int irqraised1 = 0;
) L4 c7 ]: d$ D- y$ Y6 C - static volatile int irqraised2 = 0;
8 e6 e' O( Q7 M" I% E! Z* U, Q - 3 S1 A1 y7 ^4 i+ n1 @
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 _; z! e+ l' T+ z" C* R6 ~& E - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ }' a9 L; {* }4 [
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! G$ n9 i: |* w% H
' @9 ~8 S4 r, |+ f9 p( e" K' J) v- dma_addr_t dmaphyssrc1 = 0;
g2 a$ O/ X2 V" F6 [8 D8 |" | - dma_addr_t dmaphyssrc2 = 0;
( f( J# t! k1 n8 B9 t( E - dma_addr_t dmaphysdest1 = 0;
4 T$ a) W# p/ z+ W! A; @ - dma_addr_t dmaphysdest2 = 0;
1 ], Q8 L0 F7 }( S& |! E/ M- ] - ( a/ a! ]% ]2 ?3 s- L
- char *dmabufsrc1 = NULL;; T+ w3 d2 g6 T, ?9 L) X
- char *dmabufsrc2 = NULL;
" {6 C# Y5 D+ i0 q$ K - char *dmabufdest1 = NULL;
. Y6 f6 U. k" A. `% O) G* d. l - char *dmabufdest2 = NULL;# B8 J6 x4 ?3 ?8 |
- 3 ^0 z! [& E" M- r2 M
- static int acnt = 512; y2 m- A0 e N5 ^* Y, X
- static int bcnt = 8;
5 n+ q% J! |' L" ] - static int ccnt = 8; K2 N: I- A: L: l C4 I9 Z
- 3 _+ ^* J' W' N" P2 C/ E
- module_param(acnt, int, S_IRUGO);
1 V0 |+ e# [! ?# Y8 [. q4 y4 E q - module_param(bcnt, int, S_IRUGO);
( r$ B9 R) u, r4 v$ f2 M9 m+ A - module_param(ccnt, int, S_IRUGO);
复制代码 % y& U0 z$ B8 C" g6 ~
& v" Q' ?5 H1 I4 D' n+ F P 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用+ P6 A7 T% }6 ~ |6 m9 P
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。+ o9 L( C1 I; J" k5 V" A- o
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# Y- [" I. D5 H4 N B& u& g8 _( M9 I H
4 U. ?/ b% _' {! }5 G |
|