|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 $ k& t2 a8 a1 t8 f: k, y
- [code]EDMA sample test application
* g" G+ |5 g7 y) C( o+ o4 d - /*
; {( s5 {$ Y4 I% m- `6 L3 S s - * edma_test.c- Y) W/ n. v8 ?4 @" e9 z2 f- o
- *
: N" k) }0 J W - * brief EDMA3 Test Application
7 E5 |! ?# f+ \5 v5 G* r$ h - *' z# `3 C' J( D. y& s
- * This file contains EDMA3 Test code.+ P S. R. I" H# J' M4 j
- *5 v- G+ l1 G( }2 D+ O/ V: W
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE* L3 i0 O# t* v3 w, y) t' J5 k
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT0 E6 H8 a! ^! i+ j
- * TO CHANGE.
- z+ Y. E* ]- w9 { - *) W. X4 L5 M8 d) [/ U B0 f2 _3 l R
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/: e; u& D4 M: g! y Y' a$ W: s
- */ h) P5 y0 I5 Q
- * This program is free software; you can redistribute it and/or+ B: G" L- n, M2 `1 Q7 C
- * modify it under the terms of the GNU General Public License as9 u. R0 o5 m9 M, t7 q5 J
- * published by the Free Software Foundation version 2.
) R, i' w/ b$ |% a" H0 z - *: m* n3 |( k2 g
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
0 v" O1 t- P, { - * kind, whether express or implied; without even the implied warranty V% |/ C2 K$ j, H
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& Y! U) ^7 Q6 \+ e; Q7 l( @ - * GNU General Public License for more details.* M1 m0 L* J3 S8 P' |; `5 E
- */6 v& R; {8 _2 Q5 P5 b- v
( M6 F$ E2 ?% m. T6 v) X" [4 `- #include <linux/module.h>
. E5 F+ Y T% h$ J' ]" Z4 x - #include <linux/init.h>
# t% M/ T4 g. f9 t - #include <linux/errno.h>" M: g$ c2 V# ~1 c# ~
- #include <linux/types.h>
5 ^4 C. J! J, c# o - #include <linux/interrupt.h>7 k" o' ]& r; C2 M" p
- #include <asm/io.h>
4 y- M& v8 K- a; Y9 w7 y - #include <linux/moduleparam.h>
$ Q1 ]" }$ @! F7 V- E - #include <linux/sysctl.h>
8 T1 W0 i& U/ |' K- M - #include <linux/mm.h>7 ^$ c8 r/ C% N4 o, N# \; D# x
- #include <linux/dma-mapping.h>5 {- ]7 i, W9 b; U s5 T
) |" |$ H- H/ E7 X; {- #include <mach/memory.h>
% y5 `/ |. }9 Y/ M" ` - #include <mach/hardware.h>
5 Q# K. x! ?3 a - #include <mach/irqs.h>9 w; T' I' M' U! x/ R5 |& h
- #include <asm/hardware/edma.h>! g* e$ N3 F) {- ]
- $ b& p# m" D5 k. N
- #undef EDMA3_DEBUG. X5 n$ {# |# y: g$ u2 E3 F
- /*#define EDMA3_DEBUG*/
) a5 E7 i3 t& }/ v - # Z. x5 G+ q. h
- #ifdef EDMA3_DEBUG# {, R8 M( w* `' \
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
, Y" k+ a. y# r: U' Z" L - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). c5 j. K5 _: y2 N" l
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# h9 {, n }- { - #else( u9 Y: {; m$ q; X
- #define DMA_PRINTK( x... )
& u q. e1 r2 }7 U- n+ @4 O - #define DMA_FN_IN" y, \8 t2 ^: f1 ^7 u( p. r
- #define DMA_FN_OUT
. |. ?# U% K/ O( l) Z - #endif8 T& |5 i' x& h9 h p
8 k# b6 z" C5 t& Y- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ _ p( N* y' a- g
- #define STATIC_SHIFT 3
- g: `) ?8 Y9 l" P" m - #define TCINTEN_SHIFT 20
- ]3 P4 m* Y0 U. \2 Y - #define ITCINTEN_SHIFT 21; x! W7 c$ u- L; t5 M
- #define TCCHEN_SHIFT 22
! A4 {" I1 `0 H! t3 R$ r - #define ITCCHEN_SHIFT 23
% ] Q3 j# t; Q0 ~ - 3 B- X( ]) p. X2 `0 R l" b
- static volatile int irqraised1 = 0; l" i- Q# c _( `2 P; u7 S
- static volatile int irqraised2 = 0;
" Z9 W* m5 \; Q$ {9 P8 P
5 _) b c9 \0 g- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! u: |7 t' d# N
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* u% s+ d) _( c/ T9 |6 `) }
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. ^. w1 i- ?* {4 y
- ! R1 C0 M' `' ?- y# z/ P
- dma_addr_t dmaphyssrc1 = 0;1 v2 h; w: \7 H! c% h8 _
- dma_addr_t dmaphyssrc2 = 0;% x( Y6 Q3 C0 \
- dma_addr_t dmaphysdest1 = 0;
% F: ^7 F9 w ~- Z. t - dma_addr_t dmaphysdest2 = 0;1 K3 f/ h+ A4 r: r0 i
- , H a3 `$ X8 Y% \3 C
- char *dmabufsrc1 = NULL;
! b$ N' l1 c) |4 N+ l - char *dmabufsrc2 = NULL;
. p# m9 v2 v( x% s( E; t' R( C - char *dmabufdest1 = NULL;
3 z, ^, [+ o, U6 i - char *dmabufdest2 = NULL;
; T4 ^! ~. ]: X- A2 b1 h
: X- A9 w6 ^* c. H$ D- static int acnt = 512;/ K& Q: G4 q# P0 \1 I
- static int bcnt = 8;. T& j( k" C/ H. k+ u
- static int ccnt = 8;
+ ?) s3 i9 A6 B0 h% ` - 5 a9 d8 b: ~% e8 q
- module_param(acnt, int, S_IRUGO);
9 j( @) s+ X( F - module_param(bcnt, int, S_IRUGO);
l9 Q$ Q6 a4 y+ P6 w - module_param(ccnt, int, S_IRUGO);
复制代码
1 E6 b+ f5 p) Z o3 @1 f0 V, L, v% `: C$ u5 t
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用" v, v0 x3 |# `( 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# f; A8 Z6 K$ t0 ^7 K f4 \
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。" u$ h+ G. G) e4 b/ }4 X( D
" V; Z' f0 X# o' J; A3 f
" f/ X) L6 v6 L3 |$ p |
|