|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; c# l2 B m: s" Z" l- [code]EDMA sample test application
; r% N+ A6 P! d" L& q - /*
2 C' ?" O; F0 S3 j - * edma_test.c
; O- z2 x& I# a2 V$ Z - *, i6 i. M! w) s- R! Q
- * brief EDMA3 Test Application" u2 d9 b& O# h; Y' F4 ~4 ?: |
- *# `' n$ _8 O5 p0 \7 q! D) Q8 h- q
- * This file contains EDMA3 Test code.4 J% c; @' B7 n! g
- *9 l+ ^$ K- d4 o2 b" L
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
! e2 e$ k: ]5 F2 M8 w7 y* _1 h6 b - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT: L6 b3 ~+ s+ n6 p, ]
- * TO CHANGE.6 b. M) J% `0 \ U6 U
- *
* S; T+ I; x; @) y3 d/ x) T% s - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/4 E0 h0 R- \: U
- *4 ~$ R/ X6 X' G' S. x3 F R# N
- * This program is free software; you can redistribute it and/or
) v) [$ b- t3 q! z2 Z+ L - * modify it under the terms of the GNU General Public License as3 n; z% n+ e9 w# D6 f* B7 |# c
- * published by the Free Software Foundation version 2.5 g1 m' s4 }. V S
- *+ p% u& i) S! T# z8 u
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
* E. }( i6 u5 t0 [: P - * kind, whether express or implied; without even the implied warranty
T: l' @) x) w( e - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* U) r" Q+ J. l$ P: f
- * GNU General Public License for more details.0 `7 v1 B: y0 I# _; o
- */) i" m9 W& o' o. F k
$ [3 Y+ _% _& x- #include <linux/module.h>% g6 I: g2 y. p( F2 h- I2 P
- #include <linux/init.h>/ y: m7 G7 w+ Z% Y
- #include <linux/errno.h>
' @* }1 e! u/ w6 D0 u) K - #include <linux/types.h>
m0 D1 n3 M/ e& h+ A5 p; p* f - #include <linux/interrupt.h>4 q/ x! j0 X( m \; m; [4 y
- #include <asm/io.h>
5 p# t2 M) f0 g- T, c - #include <linux/moduleparam.h>. m1 e+ j- C; h$ L: M3 w E. Q
- #include <linux/sysctl.h>! G" e G* @6 D* |" m2 c
- #include <linux/mm.h>6 ]' `% w+ I \ _4 V1 P+ ^0 x _: F
- #include <linux/dma-mapping.h>
' [; o0 s& M* R: ^
! ~" G6 {+ d2 _2 ^9 H' k- #include <mach/memory.h>
+ E! Y7 l+ E+ i - #include <mach/hardware.h>5 E6 ^8 ]2 d: J' X `5 a5 L
- #include <mach/irqs.h># A4 S+ ~& U+ h. D% N9 E
- #include <asm/hardware/edma.h>9 x3 A A1 {2 ~9 F+ Y) q
& U! \+ [7 R) }# D4 }2 b1 @1 N1 d- #undef EDMA3_DEBUG
) O+ N! W9 a" t6 `1 Q) l - /*#define EDMA3_DEBUG*/
: x& P6 o2 J% B& ]* V! x - ) z% k$ O8 u1 C9 m- f. |9 @ }( U
- #ifdef EDMA3_DEBUG! X) t: Q4 w) [3 d1 X! D
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 v1 U9 T1 b5 N G, x - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
# D# M8 T7 g1 M) b B8 V- b1 _ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)8 ^6 f ~' a) A
- #else
# T. ^2 j6 U% F; |4 V- N2 b - #define DMA_PRINTK( x... )' B% T/ C8 t! l3 D
- #define DMA_FN_IN
- p+ o2 `3 |" O$ q$ W' E+ D" r - #define DMA_FN_OUT2 z) v G0 e+ J
- #endif$ W' M* W: S7 {; a; t$ o
" c P! W9 H1 S: X" O' e: |- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, t6 y* v; g4 B9 a' U - #define STATIC_SHIFT 3% }7 a: ~, P5 r8 S+ M. ~5 Y
- #define TCINTEN_SHIFT 20
& ]6 j6 e1 ? W# v" Y& ` - #define ITCINTEN_SHIFT 213 r/ g8 `* B0 e0 b
- #define TCCHEN_SHIFT 22
0 k ~( W* X) o7 H4 }8 A - #define ITCCHEN_SHIFT 23/ f) z, D, [& l( {& n0 c
- $ |( k# k8 O" P4 G% n8 V6 i& U
- static volatile int irqraised1 = 0;
7 I D3 F4 ]' Y3 e5 H' X - static volatile int irqraised2 = 0;
0 e' ~+ \9 J8 F# @* q - 2 n# W5 T0 L( H1 Z: M9 i7 j8 B! X- x& U
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ ?" b a' [% x8 P2 g
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: C4 o' w/ `& m- A" F
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% h4 i$ ]- i0 M1 a3 a
- & Y5 ^4 j0 S: M/ ^' E
- dma_addr_t dmaphyssrc1 = 0;
) r* J n. S0 X$ |/ k# a+ j6 A - dma_addr_t dmaphyssrc2 = 0;8 V2 _) W% w$ M
- dma_addr_t dmaphysdest1 = 0;) v a# W. V& y" m2 e) Z
- dma_addr_t dmaphysdest2 = 0;" [- M3 x( S" o3 Q% C
- - b$ h% {7 k# ~' a1 y9 O) `% D2 c+ e9 p
- char *dmabufsrc1 = NULL;
, R5 G5 c0 K. ~" \ - char *dmabufsrc2 = NULL;- ]. ?1 Z- q- | e! s/ H" `% c
- char *dmabufdest1 = NULL;! Y! J% M% J5 f% O- i) _" _# x d
- char *dmabufdest2 = NULL;
# q2 B# Q+ f9 O! Q g8 o
' Z$ \- o$ p! w- j! l6 g4 X- static int acnt = 512;. n) o6 v$ T6 A* s4 Z9 y! ~
- static int bcnt = 8;
3 c# N; P; M ^1 ?- p9 | - static int ccnt = 8;
9 ~: ?3 j, ^- Y- A
3 h; a& z: S9 K' ]3 O. x- module_param(acnt, int, S_IRUGO);- g2 D, M4 x" S5 W
- module_param(bcnt, int, S_IRUGO);
4 {( V/ X2 H( m K; s3 T - module_param(ccnt, int, S_IRUGO);
复制代码
0 t+ F3 r! J; n6 T8 U, Y" K5 w, L( ]) E$ |2 @5 H7 f
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用6 o" q/ C( x1 O$ 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。. {7 S4 f- t u0 s0 C
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。, h$ Q* p! w, ~+ B4 w5 {
- x& v4 s9 ]2 H! B6 P
9 |. Q* ?+ `4 D: \; V) O& w3 G% I |
|