|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 7 i' D9 b3 q7 O& {$ b6 j% Y2 ^1 U
- [code]EDMA sample test application
5 P& t* t) |# Z, {5 H/ p - /*
$ B+ D' E( U, C7 F! \+ e$ Q - * edma_test.c
6 R# B* A' w6 F - *: a& f9 E. K }0 V& b3 M; j, Q+ m8 C% U6 {
- * brief EDMA3 Test Application
; U) m& J) `; P2 H' T - *( h# H7 X2 J9 f# a: O
- * This file contains EDMA3 Test code.
) |( ]& M3 j( L% ^ - *2 G; t+ T, L$ k, y# k a9 D4 _
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE5 ], Q7 O& X8 P0 n
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT2 |( y" v2 P8 C/ b
- * TO CHANGE.; k; X& L, i9 D d' q
- *
+ [0 V& p$ l% X. U# b9 s' U, h - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
" p+ ~& n- O' N, I - *) f; k; Q1 D5 [! p) j5 @5 j$ R
- * This program is free software; you can redistribute it and/or. n9 o7 p7 U) C# t0 x0 S0 U
- * modify it under the terms of the GNU General Public License as
" X/ R0 x U/ \/ R" u - * published by the Free Software Foundation version 2.
! i0 }! J/ D9 M - *1 [$ k) _/ k" n7 C0 B x
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any6 g& J7 }( C* Q% A' x
- * kind, whether express or implied; without even the implied warranty
2 O; C. _2 |5 l% u - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 R5 t! m" ]7 K3 ]
- * GNU General Public License for more details.
5 e. A/ F: T. e) V5 C' q D2 ^ l - */# q' g7 M) J* q: [3 b
- ( t# b4 X6 O7 ?! j+ l. U' U
- #include <linux/module.h>* ^5 i- s. T! f% u' L; @( ^+ r
- #include <linux/init.h>2 p! n$ I, ], M6 y
- #include <linux/errno.h>* N6 V+ [2 s- \( }9 x0 y, ~# p- U
- #include <linux/types.h>9 ^ t6 w; k% r m3 e3 {
- #include <linux/interrupt.h>
( `0 N1 @) E7 o - #include <asm/io.h>8 g7 z7 ^4 c& ]) }$ ?9 g
- #include <linux/moduleparam.h>/ M, G- q6 _# V6 @& a* f
- #include <linux/sysctl.h>
4 t. O0 ~; q. M+ l F/ _ - #include <linux/mm.h>- N2 h- @: N" o8 R) y" s$ C
- #include <linux/dma-mapping.h>
+ E% A/ ^- s2 ^: K4 ?/ m - / E: u/ B4 k6 K4 R. K* M, C
- #include <mach/memory.h>( _4 ]/ S3 _ F r/ J
- #include <mach/hardware.h>2 G7 F( {- t% i" Q
- #include <mach/irqs.h>
8 R/ W2 @. f; Y7 D7 w2 m - #include <asm/hardware/edma.h>
9 k7 I r) X; Y( M1 g+ ~2 W
H& j/ }% p% k6 p( `- #undef EDMA3_DEBUG' H5 |6 q+ H! i( E7 H, k4 A
- /*#define EDMA3_DEBUG*/
( y; ^: [9 \& h$ u, }* ?% C0 O
4 z$ p- D8 q, n1 `; O3 |- #ifdef EDMA3_DEBUG
f$ n- [6 n3 c7 e - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
' X- L( I. b; I: ?8 Z* n - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). U; i5 S/ Y) n, y4 h4 S
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__); |$ V5 }2 B; Q- p0 Q
- #else
+ w) h! a; |& V3 W - #define DMA_PRINTK( x... )
4 g( o7 y. {, o - #define DMA_FN_IN
* ~! U3 _# i" D - #define DMA_FN_OUT
4 a5 D2 V/ v. a. |- b - #endif
& K, k" V( ?2 o) P# G - 8 e$ l" d: F2 L& d" i- z& J
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
1 ?" ?, h/ v2 e8 c6 s& S r - #define STATIC_SHIFT 3; h# e4 v0 h, v5 B; s3 K: x
- #define TCINTEN_SHIFT 20
% A& i+ s% p" g8 ^ - #define ITCINTEN_SHIFT 21
) r" k6 ]* f4 W# r W6 [ - #define TCCHEN_SHIFT 22
3 d2 @" N1 Y" g, J3 \+ {+ I' O9 D - #define ITCCHEN_SHIFT 23 j# J3 W4 Z- d+ M
P1 D- w( U% @7 ]& E) }- static volatile int irqraised1 = 0;
# z2 f5 {0 U9 s' w# I$ W/ ] - static volatile int irqraised2 = 0;
* u" {8 O; M2 v* I/ i
6 D {' ]: o8 F- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: P; B! L ~% {0 y( d0 k* u - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ p* @8 i5 a5 z9 _& }7 Z - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- |! E7 n1 N$ {& { - ' D: f* T% @" k; Y
- dma_addr_t dmaphyssrc1 = 0;
$ I% y; g' l/ U9 q - dma_addr_t dmaphyssrc2 = 0; A- \9 E6 z, v& J4 f( @
- dma_addr_t dmaphysdest1 = 0;
0 a0 n7 _1 x! d8 ?6 e3 l - dma_addr_t dmaphysdest2 = 0;
! _8 C, x, L" z' W
! U5 i, r+ c% C- char *dmabufsrc1 = NULL;
& ]1 Y2 M7 w z' {2 d% X - char *dmabufsrc2 = NULL;; ?$ _8 N& z; o+ z7 Y
- char *dmabufdest1 = NULL;
6 I9 w/ o. H; M* [+ K2 Z, m0 {$ L - char *dmabufdest2 = NULL;
' v8 {2 J4 s4 Q. | - |( F4 U, u8 H7 H4 m9 X5 ]
- static int acnt = 512;
& H8 S: z5 t$ P& ]4 D - static int bcnt = 8; o$ Y x, B& a
- static int ccnt = 8;
" `+ G8 c. ?8 W$ |3 T% \4 i" O - ; [" a9 P% `( F* K% I
- module_param(acnt, int, S_IRUGO);
% C* [" a: a3 O8 ?) b+ W - module_param(bcnt, int, S_IRUGO);
1 K: T5 p" P" v2 ~ n- x3 l - module_param(ccnt, int, S_IRUGO);
复制代码
0 y L" |2 k+ H
1 x+ `( C: B8 n7 y4 _0 y* q 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& c7 U0 @5 U& E1 o) v/ z7 Aarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
, j/ R5 o+ @6 f$ h. _7 }) O 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% T" ^7 c$ N$ P( {0 n& Q
$ S ]% l- M' t4 y R
& E/ T3 r) q- `- N* b |
|