|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
& W/ t4 j) y5 i1 V+ I: r- [code]EDMA sample test application
, K/ s! u" k% h; P - /*
& t& R! D+ j9 J @+ r - * edma_test.c
* m1 k6 E$ X& V& s, p" W6 Z+ i - *; z0 W$ z" j N7 O
- * brief EDMA3 Test Application
2 |6 |4 o6 ^8 F5 p* J - *, f, ? k6 J i& p6 M2 H
- * This file contains EDMA3 Test code.5 `- `$ L# ^& t2 @& ?
- *+ x$ u9 Q1 D. y6 G
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
4 Y" B, l- W1 H! }7 R( g - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT9 S" Z/ ?$ D3 X% s: o
- * TO CHANGE.
0 H. E+ ]1 D7 A' T; Q - *2 M1 }$ P# y# e, Z0 Y
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 M7 }2 _% S% V4 R9 k - *5 m1 H, j! y# v3 u& H$ [8 S
- * This program is free software; you can redistribute it and/or
; Y5 n M- o0 C - * modify it under the terms of the GNU General Public License as
t+ |: g% }8 M6 O' x0 V1 j! F - * published by the Free Software Foundation version 2.
3 k5 O/ f1 V6 {' V8 z# O - *
# d- t; s$ v' \$ }2 x - * This program is distributed "as is" WITHOUT ANY WARRANTY of any9 v7 c6 [! H7 G: g' @
- * kind, whether express or implied; without even the implied warranty0 [; [/ u( M9 ^2 I+ w6 i! \/ o
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 s6 [) S" ?% {, i& ^ - * GNU General Public License for more details." N$ l- i. C- l" k* x3 _
- */
$ I. ] m! j( Z1 Z - ' U* {, V2 g5 M, K" Q. V U1 }
- #include <linux/module.h>
' i* f! F, q9 c5 l4 @ - #include <linux/init.h># X! K$ R- b% [6 x5 }
- #include <linux/errno.h>* h3 d0 E- m. _8 M3 z$ w" A
- #include <linux/types.h>
. c, C0 z$ i+ U6 w/ j) F - #include <linux/interrupt.h>4 w5 \, d1 V( W( G9 J
- #include <asm/io.h>
' } K/ _7 ? G - #include <linux/moduleparam.h>
$ t. j* L. w7 { - #include <linux/sysctl.h>
2 e6 j% _$ o7 N# I5 ? - #include <linux/mm.h>
+ p! A$ _2 Y3 M% |; a1 M. C" E M - #include <linux/dma-mapping.h>" n9 h1 r2 A& D! r# v0 \( {$ M
- 6 Z8 q: E3 i1 j5 o, l4 ?
- #include <mach/memory.h>
& H. C5 f- l# r5 T9 G! x - #include <mach/hardware.h>' g8 U6 h. t$ r5 Q. s" y, F
- #include <mach/irqs.h>3 a- T0 y2 {/ \. g5 Y
- #include <asm/hardware/edma.h>
5 ^1 F$ w9 O7 i) X9 ]. v8 F. B - 1 a# |2 ]0 r5 U! X0 Q
- #undef EDMA3_DEBUG. x1 N) l6 i. O' q, g! y5 X% A7 I ?
- /*#define EDMA3_DEBUG*/
) z! u# R; w" I1 Y, n1 W
8 [% z/ b1 b1 B, T- #ifdef EDMA3_DEBUG9 ]% g2 m9 O6 a+ g8 j7 h8 G
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
* ]) s! h) R6 W0 g5 _/ j - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): K. E3 R z) b) r
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)4 R/ `2 Q0 T! H3 w
- #else# b, z2 A: y' q# z" Z5 O
- #define DMA_PRINTK( x... )) `% u2 ?+ }2 e: F
- #define DMA_FN_IN
2 Z" K. ^! f$ t1 e7 o6 [' d5 } - #define DMA_FN_OUT( t# ?7 V$ E: F/ E
- #endif) A6 o/ u* q9 K9 a
7 l+ J0 x3 S/ e7 x ]- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
( o2 O# D1 L9 Z+ J/ H - #define STATIC_SHIFT 3
0 S, N# S% x- S3 G, }# ? - #define TCINTEN_SHIFT 20
# l N0 W+ V* y8 ]8 j- l - #define ITCINTEN_SHIFT 210 S- b2 t# v1 ^" \7 e; N
- #define TCCHEN_SHIFT 22
9 V1 ?' P1 A, B' j- P - #define ITCCHEN_SHIFT 23/ g* A, t L; g5 J+ f9 s5 ?
4 Y" D2 j" E- V+ A0 j- static volatile int irqraised1 = 0;
8 a* H+ [; b: `9 x6 m1 M4 l - static volatile int irqraised2 = 0; b y) K* y+ Q* [. W
( L+ D2 m, [' C1 H- Q- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ k9 f$ u+ q+ m- t+ T - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ }0 d$ F* S& I# E* @ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 z" P, {" U% C9 y5 E- N, s, `
2 H S% a" ~/ b/ E, A" T$ d- dma_addr_t dmaphyssrc1 = 0;# }1 N2 v) g3 F9 i- e$ c. O
- dma_addr_t dmaphyssrc2 = 0;' V5 Y- r3 k/ O, R# a) X0 y6 | x
- dma_addr_t dmaphysdest1 = 0;( T- A* @ t# g& `- Q& s% z
- dma_addr_t dmaphysdest2 = 0;
, c u9 i, u. o4 z2 o) \# Z" t6 P% h% [
' g: i( E; z2 e9 C" F/ B. o- char *dmabufsrc1 = NULL;5 J7 j7 ?- v7 j! k
- char *dmabufsrc2 = NULL;
/ W. K u( [ h, W0 X P - char *dmabufdest1 = NULL;
2 i1 I& a, j& n4 E - char *dmabufdest2 = NULL;6 ^9 @' e& ]6 d. w" u" m
6 r" k1 z9 n+ ? G) X- static int acnt = 512;6 L. }5 S: y. X9 l' f
- static int bcnt = 8;
( h8 ^ G8 m6 l$ C2 z. o - static int ccnt = 8;- o+ o) c# t. p$ _, e
- 6 Y+ i& E" z- ~5 e0 |* P# K
- module_param(acnt, int, S_IRUGO);
( R. s Y* B, v. x5 p0 U, B - module_param(bcnt, int, S_IRUGO);
% P1 i! j: R; o! n - module_param(ccnt, int, S_IRUGO);
复制代码
7 D! _& f8 z. A7 V
/ {# U# F) j# A) l- T6 s" j9 U ? 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& R5 D6 e. s( U) H" {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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。( ~. ^! U! H6 k% O
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
$ w( q& W" q- Y, a: I4 @$ r, X8 o' {& X) {& V
/ D4 M% s N- ^$ o# u9 I4 K* _ |
|