|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 ^# p" s0 D+ X* r) f0 E- [code]EDMA sample test application6 l: C3 @2 ?+ q" r) d
- /*: ~, t; r1 z. j
- * edma_test.c! X$ ^) g) _# q6 ]
- *
/ j" Q( f9 U9 {! E - * brief EDMA3 Test Application
+ ?/ \/ v. s# r* h0 t* G - *
, O5 W" |9 e4 }! W1 |3 M. {) P. ? - * This file contains EDMA3 Test code.1 a) ~; o) P3 n# @/ {- J3 x
- *
- d9 ]* n7 @; q - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 e4 K, c( `$ Z$ ?' W7 W - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
1 w4 F( e6 H- Q - * TO CHANGE.
" p8 V! b% H T" A8 F9 N2 V - *) l* Z, V' S3 n, Y7 |+ C* A
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
: Y9 R! A5 U4 p0 s& r9 G - */ ?7 A7 v7 {6 m% g0 E
- * This program is free software; you can redistribute it and/or
- e. N# W4 D# h - * modify it under the terms of the GNU General Public License as
6 v$ n s2 j% B - * published by the Free Software Foundation version 2.
1 h- ^* b d* P0 z6 _9 Q - *
# O6 K% U4 g2 @' D b- G3 G8 K1 G - * This program is distributed "as is" WITHOUT ANY WARRANTY of any; |4 Z' ~. g4 R, d* P
- * kind, whether express or implied; without even the implied warranty
H' |4 L0 q! [4 o6 u1 d2 _- r - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" ~% f4 a! Z1 {! ~. K( W - * GNU General Public License for more details.# S7 O6 O/ @$ R4 P9 n
- */
& i) _ ^8 p- n& R/ V - ' g. F5 I* ]% H) a( \
- #include <linux/module.h>
. C% W. D' e# ^ - #include <linux/init.h>0 }$ }, {0 w2 C1 B2 r$ A6 p
- #include <linux/errno.h>
# X4 a2 w( f5 f - #include <linux/types.h>$ M3 O+ |5 h. P# g* h! [) p# z4 d
- #include <linux/interrupt.h>
! `2 E0 j: ~" @ - #include <asm/io.h>
2 E/ i6 @4 E/ @& s4 z8 j$ H: F% D - #include <linux/moduleparam.h>
- g6 |( \$ `' Y/ V( A5 L5 e - #include <linux/sysctl.h>
2 B& o9 T9 M! m0 B) f6 D% I - #include <linux/mm.h>
! W: s! R/ ^6 O5 m8 O s, B. Y - #include <linux/dma-mapping.h>
( [! x- z) \ U4 B; y, g+ z
; @- U: y) M# i; U- #include <mach/memory.h> M6 M/ N& A/ m$ m- ]3 D$ E' B3 H1 B" y
- #include <mach/hardware.h>/ k. P [: s' }" U
- #include <mach/irqs.h>
9 j9 |0 W5 n5 f - #include <asm/hardware/edma.h>9 O1 O L- G8 d. Q1 s4 a1 s
0 {1 y% \8 W6 \3 V- #undef EDMA3_DEBUG: @: `9 R6 t; ]0 q6 ^6 l, t; d) o- b. W
- /*#define EDMA3_DEBUG*/& @- E* }: t6 J+ W. E% [2 p
8 w! _; P3 s+ r! Z% b! z- #ifdef EDMA3_DEBUG( E; q; e: p4 _- \2 V
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 z7 d& |9 x6 N9 T. o - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
3 Q9 h" J0 \) a5 S - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
3 E) ~- y3 p- i& m1 {3 r. ]' Y) u( u - #else
3 Y% M) [# G1 @6 @ - #define DMA_PRINTK( x... )
* ]: Z8 _4 C6 B4 q) y" [! L+ ? - #define DMA_FN_IN
/ I" M9 e: a/ @( H - #define DMA_FN_OUT
" Y2 u, g& K7 j- z1 j - #endif
) B! j0 {, { P# f: R( s - % ~' M8 y& y. E7 t
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)6 T7 E7 r' h: f7 }+ Q( ]- j, c
- #define STATIC_SHIFT 3$ z- V$ I/ P7 s9 ~- {
- #define TCINTEN_SHIFT 20; E2 G# \& Z; r6 }: ~, u- u
- #define ITCINTEN_SHIFT 21
% J9 ^# [! [# f( }5 r - #define TCCHEN_SHIFT 22- ?* V1 V- |& V: n! Q! E2 |
- #define ITCCHEN_SHIFT 23* j5 U: P4 b/ ?7 X0 h, R/ A6 t6 P
- ! r9 t; k% e( e; M
- static volatile int irqraised1 = 0;/ q, r9 A! k. H- w
- static volatile int irqraised2 = 0;8 |" q, E+ b# g- y
- ' V6 ~/ ]; B4 j. r0 {$ r1 A: S
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( }: e3 l0 `# n( f
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 A7 j8 d: h. u2 r# B% O( x0 X - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* R! D4 G# c; w4 ]
- % c0 E2 o1 B# _, {% n; \
- dma_addr_t dmaphyssrc1 = 0;
2 O, O: A; K" J1 `& k. x; Y7 ?' \ - dma_addr_t dmaphyssrc2 = 0;
/ R. ]0 E, }$ q% a( A - dma_addr_t dmaphysdest1 = 0;) ] U9 ~$ w0 n/ i6 ~, p3 ?
- dma_addr_t dmaphysdest2 = 0;
7 t) f \( o3 \$ k2 N
4 y3 ]7 k' ], l5 ?$ _* n4 d: G- char *dmabufsrc1 = NULL;
. G5 G: I, [8 z! ~: F- \& u - char *dmabufsrc2 = NULL;3 I0 X7 x2 g8 [5 Z' U2 Q
- char *dmabufdest1 = NULL;
9 s Z; [1 A; r, N$ ? - char *dmabufdest2 = NULL;
' h! m' t$ T$ d
0 b$ g& m0 s- j- static int acnt = 512;
4 N" p9 K0 ]* L - static int bcnt = 8;
! f3 g. i0 y& J5 A c - static int ccnt = 8;
5 [- v8 l; e" @" V8 N6 |0 x - ) ~6 j1 t( M& S0 n5 M6 k. h
- module_param(acnt, int, S_IRUGO);
4 m6 N4 j3 J( q# L) {$ @% b - module_param(bcnt, int, S_IRUGO);
3 c7 W3 k9 X" N& w# M - module_param(ccnt, int, S_IRUGO);
复制代码 % i/ S1 H' c i3 A2 ^+ {6 x# N3 u. B
% @5 O' R' N& T( Y0 j 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
0 E8 v7 j+ C3 b' C3 yarm-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 l1 W2 n/ U3 j 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
5 s+ X; Z# b, {4 ^5 |8 s5 v& j. v" A; b, G. D
+ s$ L& ^* ^- W8 R
|
|