|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 * K% V& e+ L9 c$ u
- [code]EDMA sample test application
! O: z# Y7 G* J - /*; p7 F+ `- K% R
- * edma_test.c
4 E. q; K' h8 g& s - *. n% M' L5 P8 ]- }1 ~
- * brief EDMA3 Test Application
F7 [: Q+ z9 H' I' x# h% d - *7 ~5 F" ~& Q+ Z- F( T! ]
- * This file contains EDMA3 Test code.
9 n% N8 {, ~# ~$ Y$ B2 a* Y) n T7 ] - *
2 X5 l: d4 E9 R+ j* J' x# ` - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE9 N u) ]1 _% d$ V
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% O9 e' l+ a+ p- ~" c - * TO CHANGE.; M- @' W- t$ \" `' z% |* A
- *- c! \2 K3 m7 L7 L6 n v* l% d: G
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/0 P s2 |. H; u. \+ U& b+ @
- *
) h$ g% }; K& N# X$ Z - * This program is free software; you can redistribute it and/or' v" i& ~3 h0 c, |
- * modify it under the terms of the GNU General Public License as# ?9 ^" T, \. S! i, ]" {
- * published by the Free Software Foundation version 2.6 ^1 n; y: R9 I) C) t
- *" G4 @4 M7 ]- y) A/ @4 [* g* I
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- c: ?% L( r4 C3 M& C - * kind, whether express or implied; without even the implied warranty
# L3 c' q* \# b4 C N+ u - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- A# r' J# d* n7 M' ^
- * GNU General Public License for more details.
3 s" x$ ?! h1 f3 @& T Z0 a5 ? - */: n5 }/ @# J n
- : Y+ b1 m4 v6 y) c+ ?
- #include <linux/module.h>
0 F; B8 Y( r! X/ B7 X4 ]% ~ - #include <linux/init.h>" b! `4 p8 L/ B7 T; ]4 N" {
- #include <linux/errno.h>
% Z8 z: ^1 B7 Z& y p2 s7 i - #include <linux/types.h>0 N! O8 V( F7 o. x- s' s
- #include <linux/interrupt.h>
1 ?: m& }9 \' b M' f - #include <asm/io.h>
8 c3 T; y, D: W, _9 E' g - #include <linux/moduleparam.h>
6 b& {% i3 W; C+ u9 S7 H) _ p% q - #include <linux/sysctl.h>6 v. b3 Z: d# |' H
- #include <linux/mm.h>
: E- {+ D$ d1 r& B8 v - #include <linux/dma-mapping.h>
1 X% Z+ F9 V/ j8 S. n - " J$ Q/ ~" a" f- V' {# z& C5 O% n
- #include <mach/memory.h>
9 M4 P# f* T' O) s5 g - #include <mach/hardware.h>- ]9 w3 B8 _3 Y4 M5 y
- #include <mach/irqs.h>
6 B' E3 |& r9 W8 u e. B# d - #include <asm/hardware/edma.h>
2 G; B' a( p$ F2 W0 z - 0 z. i" u! q, ^ K# y- _
- #undef EDMA3_DEBUG
$ a1 C6 h% P O, f - /*#define EDMA3_DEBUG*/
# V$ N6 z0 } i7 z8 P+ P2 M" K+ [) d - ' m5 v7 r$ V ]: m2 \5 `
- #ifdef EDMA3_DEBUG8 v0 u8 I+ r6 w$ P6 ~
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
! j! v1 a r9 x% C% ^* ^/ K - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
( G5 v: u* T5 F; G1 G- R - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
- Q7 o) _4 p" r+ Z0 `% d+ q - #else
7 c5 V% {9 u T5 Y+ z4 D - #define DMA_PRINTK( x... ), J" z# a8 w' Q) U, d/ c! F1 A
- #define DMA_FN_IN
^4 S9 E6 k2 a6 N, R6 A; \ b - #define DMA_FN_OUT% @) r5 Z3 U' I
- #endif/ \1 L9 }2 _( {& Y% J; A" J0 L
6 k v& k/ ?5 T! W5 F- #define MAX_DMA_TRANSFER_IN_BYTES (32768)0 ]4 q) I- S- S9 E" o3 n
- #define STATIC_SHIFT 3! B& i7 E" ]! o; C# L$ \7 g( }
- #define TCINTEN_SHIFT 20. M% q, V4 n6 V$ o
- #define ITCINTEN_SHIFT 21
5 @3 g6 |& Z8 Y$ `1 V, I7 Q5 |' ]% u - #define TCCHEN_SHIFT 22
7 R$ e5 R" ]' A9 n$ r( l9 I1 Y - #define ITCCHEN_SHIFT 23
) W4 X) E: U3 p* m X; j* H+ g3 I
- u8 b$ P y0 G2 B: h- static volatile int irqraised1 = 0;4 a. W/ w" n l1 s5 p
- static volatile int irqraised2 = 0;
Q3 ^2 y6 a6 [) \* v - ! f3 I) c1 P- x7 i
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 V) Y; V$ H4 \3 Z9 }- B: A! I - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) o6 @3 K3 q( w0 p" U5 y8 l - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# l$ ^0 g# N, M, I2 U1 `; } |* E
3 V0 h" j! o, F+ o% C# T- dma_addr_t dmaphyssrc1 = 0;6 X1 X: g) V3 `% I& d
- dma_addr_t dmaphyssrc2 = 0;/ ?. ?; o2 P$ g+ t
- dma_addr_t dmaphysdest1 = 0;- U/ H2 ^- s; n2 t
- dma_addr_t dmaphysdest2 = 0;
/ v1 o. U3 a) A, U( a
8 {* u8 V, X) A" V: y. C1 O- char *dmabufsrc1 = NULL;
8 b0 R6 c; K& R3 d6 e5 K, s3 R - char *dmabufsrc2 = NULL;& d, V2 V! D9 j4 |" f7 g
- char *dmabufdest1 = NULL;
9 f% m, p) d& B" M - char *dmabufdest2 = NULL;' `. ?$ g' @- A+ {5 c$ q
- ; j3 i% U# K2 B- D) T
- static int acnt = 512;
7 b) E$ a0 T/ g$ t9 A* y1 k9 J+ S - static int bcnt = 8;
5 u: V- u0 H: c - static int ccnt = 8;
, f2 f7 H9 x6 A: @+ `' v
0 p8 G- }6 R/ J2 e7 C* I2 f" ~- module_param(acnt, int, S_IRUGO);) x1 f1 c/ H( ]9 c' q
- module_param(bcnt, int, S_IRUGO);
1 @) U# U4 ?( ~3 r - module_param(ccnt, int, S_IRUGO);
复制代码 . m' I5 v, Q1 g
' U! {8 ~/ \7 N2 Q3 e! ~4 A& _
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
1 y2 I! L7 x# L4 T" i harm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。' c# h# [4 `+ z4 `" h
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# @5 t+ E8 F+ J. \* p1 q3 A! h5 V- K: ^ ^# P
& X5 F3 k4 C; h# c5 G& w- d6 J. D& ] |
|