|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
: b& E& x) b1 L& p. T1 R- [code]EDMA sample test application
0 H6 F" T' P' \% B - /*
0 e2 f4 e. h, O - * edma_test.c. G* @0 P: a! d4 ?
- *
. \7 j0 `7 T4 o. T - * brief EDMA3 Test Application6 R: q Y( L R; b# M
- *
1 z: G+ E, u& `, H/ R+ d - * This file contains EDMA3 Test code.
8 q6 T0 r" K7 [* r - *
: J% H" d$ R* X9 h- r2 b - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE5 C6 D8 G i* u9 M+ k+ Z. b
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" }4 w4 _. {" n# I* u5 P- F - * TO CHANGE.
( i+ D7 X7 [" h( w, C7 z" x - *
9 G$ D) O7 l; z& F5 a2 `: ? - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/' y: F: m& @0 X
- *
% s b5 Y2 J5 b1 I2 H - * This program is free software; you can redistribute it and/or
' a: v, I. ^' w. C) W( O' c/ C P3 w - * modify it under the terms of the GNU General Public License as) j5 v% L4 v& A8 b+ N- S7 h/ S
- * published by the Free Software Foundation version 2.
$ G6 Q# O9 U( b; r& b - *
% z) Y' x6 F/ I! c% [ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; |1 X3 o# l; D! e+ q - * kind, whether express or implied; without even the implied warranty# r8 Q# l( S" b+ b
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
F) Z6 p+ z- @! S; U- ? - * GNU General Public License for more details.4 @" y6 V* z+ D
- */6 \9 }6 ]$ I* y g
0 u8 T8 L0 P$ F2 N- R- #include <linux/module.h>
) `8 l* e1 }; u - #include <linux/init.h>$ T1 ]1 E: B7 K: ?
- #include <linux/errno.h>8 }. {) c; s4 W4 M) V, F: `
- #include <linux/types.h>9 [: h. w( k' [0 P. n
- #include <linux/interrupt.h>& `! o. u0 t0 p3 \. Z O
- #include <asm/io.h>5 y- v. F2 t: g1 {; W
- #include <linux/moduleparam.h>
5 F* f* N/ l/ g/ L# X8 Q - #include <linux/sysctl.h>
& T; @6 N/ X5 a, d - #include <linux/mm.h>
6 Q! F! A- E& E5 T/ m, p( X1 h* z - #include <linux/dma-mapping.h>
& H4 U: N' E% x& t! b9 L6 L: g - + d a$ R$ \( Q3 m6 U/ N- r7 o
- #include <mach/memory.h>; @5 L: p {" f9 R4 g2 o" N u9 s, x
- #include <mach/hardware.h>
; P( r. U0 ?$ w# X9 L$ K3 g - #include <mach/irqs.h>
7 G* z: m: Q& R L' V+ j& E8 I - #include <asm/hardware/edma.h>+ [# M% X( C, e3 L
! N2 m% N4 D3 @* i- #undef EDMA3_DEBUG
5 v% ?! ?, R# r+ v7 U5 a - /*#define EDMA3_DEBUG*/
' }& v5 J' C; x6 x" l - 1 a8 x6 H7 ]( H
- #ifdef EDMA3_DEBUG$ `* r6 X# |( q
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
+ S$ c) T# B! r$ D - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
, S c3 n8 K c - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)6 d# ]6 x/ Z: B
- #else4 l! ^' }" R7 Q9 Y6 u1 h% e
- #define DMA_PRINTK( x... ). h; w) W0 q: h) b D% F
- #define DMA_FN_IN
L, _) y' C' J - #define DMA_FN_OUT
% l$ [ I5 @, `+ b1 n/ H" O - #endif
" R+ u" m, o" C' Z4 F
* f* o+ ?/ x$ w9 s- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
& M2 w7 W- j8 R; i( I! s - #define STATIC_SHIFT 3; A- L8 a1 U, B/ i, D9 H
- #define TCINTEN_SHIFT 20; V) j6 Y2 U; y* G
- #define ITCINTEN_SHIFT 21+ o& h4 O1 B. o# m6 V% ?" ^$ L
- #define TCCHEN_SHIFT 22
8 D2 ~' w3 f- t/ U* z' r: | - #define ITCCHEN_SHIFT 23
/ d+ B; d+ Q; g7 O+ V - . O! ^5 q: r9 @7 q- z3 H, E
- static volatile int irqraised1 = 0;4 I7 H' c' n* u+ B! J
- static volatile int irqraised2 = 0;
# q5 e7 d0 F& b: N4 ?3 b
6 G# M/ \( k# W4 v9 J7 E2 Z. v T- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 t6 g, ]% ]2 N T
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. X5 P! }4 v! M' K- ]" }$ _. l - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( q, Q) I, ^7 X2 f7 C4 b
8 J0 z+ o; t0 a* D! x( ~0 q( Z- dma_addr_t dmaphyssrc1 = 0;
9 D; @: n$ i8 P4 g - dma_addr_t dmaphyssrc2 = 0;
" v& v8 F, W- V2 @, F" t. s - dma_addr_t dmaphysdest1 = 0;
; |; W j4 ]; w { - dma_addr_t dmaphysdest2 = 0;
. \1 O7 I6 r* F1 ?
8 v1 Z9 @+ \; A+ s& \" [% C- char *dmabufsrc1 = NULL;" }9 H3 v" i4 s! x9 |/ P0 I
- char *dmabufsrc2 = NULL;& A) u* g, L8 O- ~
- char *dmabufdest1 = NULL;
$ r+ x$ _& K- A7 u, }# A6 C/ f! ? - char *dmabufdest2 = NULL;% p' G6 b! C4 k- {; b8 {5 {& l
- - ]5 R3 L6 ]: ^0 O; `6 y) H9 u
- static int acnt = 512;0 y% W4 B" o+ {2 ]5 J
- static int bcnt = 8;
1 o. J1 _* M' K7 o - static int ccnt = 8;% R/ d6 J: _% t& A, x& R
- ; o6 g, l0 R& } A: {3 {; C! r
- module_param(acnt, int, S_IRUGO);% G8 y Z9 \" I1 a7 Z, S9 C: t4 |" S
- module_param(bcnt, int, S_IRUGO);: a, L. `2 ~+ j; l0 a& R+ d6 ]* |
- module_param(ccnt, int, S_IRUGO);
复制代码 4 r( F) [% v: p$ b+ j
: H3 T, W& Y2 {7 ^; R6 B) o6 M
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
' i! F$ c- O3 E' U# 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
" G4 |4 i" X) K: Y3 | 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
+ q# q" c+ t D' d: b' ?; @' d5 G3 p4 \' c
) Y5 `2 R0 j' k/ N. a& C
|
|