|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! r& d4 ~, Y% K- `$ y* L0 n- [code]EDMA sample test application
4 q' d' _( F2 w0 A% ~( ` - /*
# b& c& d2 _. O - * edma_test.c
4 t c& h9 T9 ]7 W6 z - *, Y) P& O" g8 L/ j, x' l/ S
- * brief EDMA3 Test Application( {, J0 \+ }" Q* H7 W) f+ \1 `" G
- *
4 l/ n) \) o3 T. Z0 O0 }3 Y - * This file contains EDMA3 Test code." y, r/ ^* [- i# p5 t. N" I, M) B
- *
% u/ z( U; v$ K6 l. Z9 U% o4 s - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE8 R' w( R5 G3 ?' f
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 P# _2 W/ p' h. c/ z7 b
- * TO CHANGE.
" d( |) I3 D0 P( f0 Q4 k2 } - *2 w4 \7 w. i9 S
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
% R& _8 y5 P+ I$ M& B+ v - *7 w" T1 \" Q. [% F" _. g
- * This program is free software; you can redistribute it and/or
5 e% w) V# }7 {" d% W - * modify it under the terms of the GNU General Public License as4 P) x1 s; W4 V. C
- * published by the Free Software Foundation version 2.
4 u3 k: U. b9 y! t: e - *4 v2 S" g' E# g2 ^* J# L) r
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any- `1 `& } j4 K( b
- * kind, whether express or implied; without even the implied warranty1 o/ o% E3 c$ N+ ~
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- H/ f1 H. C# r3 C: u+ g - * GNU General Public License for more details.
& t X/ t- s- q - */
8 }2 w7 T, @+ e, N - ; H2 }7 I4 q8 z) ?; J
- #include <linux/module.h>7 T& k2 x' o! A- a5 w/ e% g1 O- ]
- #include <linux/init.h>
3 o( a% a/ `; W* N5 A - #include <linux/errno.h>
4 {9 l9 h9 c1 A3 K! e - #include <linux/types.h>
$ k' c# U8 o" A7 e - #include <linux/interrupt.h>
: Z9 g9 z f& F; x - #include <asm/io.h>/ o, W- N8 @" K+ l/ T- {
- #include <linux/moduleparam.h>
+ o4 |8 \. s$ t. ?6 I5 _ - #include <linux/sysctl.h>1 i {' m, w: I3 O' w
- #include <linux/mm.h>5 c5 c, r- N* V( x+ n2 u8 b
- #include <linux/dma-mapping.h>+ V* e) x/ D" y% _
- 2 `+ F7 ]. \- g+ V u4 \
- #include <mach/memory.h>
3 o8 T2 W2 C$ n+ u6 u - #include <mach/hardware.h>
3 w$ v: V, G) } - #include <mach/irqs.h>2 z! y' D% w! c1 y: K- M' L+ L
- #include <asm/hardware/edma.h>
+ c" [+ v$ n, z; |* a( e* Z" Y* T - $ Y) w: a$ {/ r* \+ n. r( r
- #undef EDMA3_DEBUG3 E: i5 r8 M" D7 [8 \
- /*#define EDMA3_DEBUG*/0 u. r8 F. b% m1 Y& `3 J1 i
- 7 E: i4 j# l9 z' V" v2 W
- #ifdef EDMA3_DEBUG1 A, D( z: D0 N2 C
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- g7 ]- _* R! v3 J: T6 [
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)6 p, E- @2 Q" R e
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 t8 k x( A. P/ m, c - #else, e0 ?/ E8 r! R# s+ U: J
- #define DMA_PRINTK( x... )
7 {4 v i3 Y- l9 ] - #define DMA_FN_IN
/ t2 [8 d! ?# @5 B0 b5 p - #define DMA_FN_OUT
7 K; p# G* t% @2 l - #endif
: d0 z. a; ~5 O+ U2 r4 s - $ }- G3 R* |3 t- ?1 G0 H4 h) a2 J
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 Z6 v/ w: U8 y - #define STATIC_SHIFT 39 L3 L* J: Y% v
- #define TCINTEN_SHIFT 202 t4 Y) n" g) o1 d6 U% F
- #define ITCINTEN_SHIFT 21' [1 y: j. Q2 H4 w
- #define TCCHEN_SHIFT 22
% N }: ~: u W6 O - #define ITCCHEN_SHIFT 235 A' q5 a. W6 O2 d0 y V5 C
- " b. j- R) d% j3 N* m! D6 B- t
- static volatile int irqraised1 = 0;% B. d7 i. A0 l4 E( Z" u
- static volatile int irqraised2 = 0;, O7 _9 k4 P! k4 j2 J
+ L( }4 X( y2 g3 h% Q* N- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! \' B. L8 K, u2 d - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 Y5 K+ ]4 _+ T! d
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" s9 `3 O5 h- Q( [+ x. @. }( K
- 4 ~3 F2 D% Q: w2 D# O# D# ]
- dma_addr_t dmaphyssrc1 = 0;
, ~2 n+ N- l: {* f - dma_addr_t dmaphyssrc2 = 0; R$ R" X# S5 u
- dma_addr_t dmaphysdest1 = 0;* i3 \1 u- h l, l. s" T
- dma_addr_t dmaphysdest2 = 0;. W$ g/ ~, X- l% y2 |
% @& l8 b) G& F# O5 z- char *dmabufsrc1 = NULL;
2 r$ A; H" _ h2 M2 \ - char *dmabufsrc2 = NULL;8 I5 `2 v9 h3 v
- char *dmabufdest1 = NULL;
; }# D' s& T9 c) H' D* z9 \2 V - char *dmabufdest2 = NULL;
7 q! P: g G. J$ O$ p2 @$ T! v - : D5 `* n( O' c$ r2 E! n
- static int acnt = 512;
* c8 k" ?. a- |1 \$ q( R - static int bcnt = 8;
' F$ T$ e% N4 t" Q' K0 u8 F - static int ccnt = 8; D- r+ Z l: o
- # o ^, z) O$ V6 c2 A
- module_param(acnt, int, S_IRUGO);9 d) d6 G7 n0 X7 A' r- O
- module_param(bcnt, int, S_IRUGO);8 }- G6 H. n C2 S& ?5 ], }
- module_param(ccnt, int, S_IRUGO);
复制代码
h8 y. J$ D' f% W* ? N# W! `+ V. M6 \% `4 \6 g) n
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用+ X, b4 X$ a8 J, |' H- m
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
( D6 E \% `8 j. H 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。! M6 R* {6 ]& z
8 d# i5 @' m `4 ]1 Q# [
' S2 I, q0 ^7 V) I$ R0 i |
|