|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 d9 c# r: t* |5 m
- [code]EDMA sample test application
J9 k2 m' b: X5 P% A - /*
. C' m* o0 { h4 `, y - * edma_test.c' E& S1 @: ]; x5 W# A5 L6 A& v
- *' Q1 w. R! [$ l Z& g; ^" s
- * brief EDMA3 Test Application6 t8 `, z' P; B' C9 v. x
- *$ W% w* u, w7 u9 D6 a! U
- * This file contains EDMA3 Test code.
+ E8 J0 |, B/ G" g5 `! o - *
* W0 _/ |" X0 t; r - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
2 G1 n: m* R: ]# n/ A - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT$ s P( S: E8 A5 R
- * TO CHANGE.
" ]3 X* N5 b9 K" n - *
. u$ g6 W5 r9 ?9 \5 v8 x6 } - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/0 O$ V, B6 R2 w8 D
- *
1 R* J& N9 W/ _/ B - * This program is free software; you can redistribute it and/or
. c7 X2 d0 `9 d3 ?3 N - * modify it under the terms of the GNU General Public License as
$ R8 I7 J5 F5 L0 }, y U4 w W4 r - * published by the Free Software Foundation version 2.! {6 H1 C+ ]7 a
- *- R2 S, e9 ^, a; I; z; X/ b9 D
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
: e3 k$ Z% b( @, h - * kind, whether express or implied; without even the implied warranty
" X- a3 `; N- k: [% f - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the/ P; [2 l: [! K7 W0 X8 q0 J
- * GNU General Public License for more details.3 U/ { F- p1 U/ R* U# w
- *// e) w/ A0 q2 l3 _# g% W2 }& N: s
- : D. Q8 v O3 b9 ?! b- S
- #include <linux/module.h>
$ Y8 O+ n" b/ V! f9 B0 V - #include <linux/init.h>
& p+ j0 Y$ I. }' q& h - #include <linux/errno.h>2 t R0 B, D. p* J3 \1 b+ O: Q
- #include <linux/types.h>
, R9 V3 w1 S9 ~2 i* M3 K - #include <linux/interrupt.h>" D3 C! k) R9 ~+ w
- #include <asm/io.h>
7 y/ x4 t& [0 z- Y( Q - #include <linux/moduleparam.h>
7 B: z. o+ R& ]& _/ Q - #include <linux/sysctl.h>
: U( x2 ~5 t' r( C$ l0 z3 k - #include <linux/mm.h>
P; D7 o2 J' ?4 |3 @ - #include <linux/dma-mapping.h>
6 P$ t1 P. o8 i) \& n# [
& z1 Q7 T; s7 [- #include <mach/memory.h>% H3 P9 H9 G8 x. ~2 [; B
- #include <mach/hardware.h>
2 v6 u4 I8 H1 x& _+ q - #include <mach/irqs.h>
/ ^1 ]$ U7 T2 T" h, E- P - #include <asm/hardware/edma.h>
2 d! i) X3 [. C
; G- |0 A: t# i3 l1 _- #undef EDMA3_DEBUG
+ R H+ i/ @( [! M0 q - /*#define EDMA3_DEBUG*/- n5 K: @/ a7 O4 g! G7 K" L5 m+ p
8 v5 Z5 l; \6 W. o S. k% k& h- #ifdef EDMA3_DEBUG+ {! ]; F/ Z" `( B4 T P
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
: \2 p3 S' }. t! T% R8 `+ L - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 k0 O. C1 f* E0 @: L7 c* Z - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)2 t( Z3 @* M" M; W: d8 E
- #else
; C9 F: p; W5 f7 Q. F. K - #define DMA_PRINTK( x... )
: G; i3 G" C- G, @5 ]" o - #define DMA_FN_IN
, [% w/ \4 ^/ o3 F! P8 M - #define DMA_FN_OUT9 s) ?( x! ^" g# g
- #endif
; }/ ~ r/ L1 O4 i n$ t2 n - 5 J! V% {8 |7 k4 [: |) ?) U7 B
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)8 ~. J& i; ]4 Q) A
- #define STATIC_SHIFT 3
% M) \# ^; ?0 d. t( a* O - #define TCINTEN_SHIFT 20
7 l7 ?# p9 [9 e( p" }( o - #define ITCINTEN_SHIFT 21
% _. E6 W( R% B% x( u8 ~ - #define TCCHEN_SHIFT 22
1 T3 E# J# c$ H) I" ~ - #define ITCCHEN_SHIFT 23
, m: z0 m2 V* o- _8 { - 9 l5 g, J) x' o) _% c2 m1 g$ z
- static volatile int irqraised1 = 0;! Q( _- H* X2 s" P5 q
- static volatile int irqraised2 = 0;
* x% v# P5 l S: @
7 ]5 U1 @5 `# A. G ~* ~- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' T) b# U# m- t. f' I3 l
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 k5 c, o2 [& U
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! N7 M$ M e* U
1 Q# `( U) P: m' K8 J$ l- dma_addr_t dmaphyssrc1 = 0;. C/ A( }7 y) l( w3 a: m
- dma_addr_t dmaphyssrc2 = 0;
' z$ T4 m R" c4 l- Z, j* [4 `/ @/ V, y - dma_addr_t dmaphysdest1 = 0;
( \1 I; T" R1 ]; t* C - dma_addr_t dmaphysdest2 = 0;
0 M* Y# Y# }% t" W% _7 u - 1 n% S: c6 C! i! ?
- char *dmabufsrc1 = NULL;
! q2 Q3 n @- K* d - char *dmabufsrc2 = NULL;4 u. q% @5 q( }+ d, n+ m
- char *dmabufdest1 = NULL;
1 \# t' H8 o$ U3 L8 S. I, z - char *dmabufdest2 = NULL;
- b+ h8 m$ A6 H; d( X# B3 X( A
( k P; r9 U+ h- static int acnt = 512;5 K' y% r/ s8 T K
- static int bcnt = 8;$ ^( v" J% o# x
- static int ccnt = 8;5 D! q8 I( L5 A L4 R, }; H
- J3 D; F) {+ M- module_param(acnt, int, S_IRUGO);
! a' R/ C5 b: u* }7 g5 g' Y - module_param(bcnt, int, S_IRUGO);' B+ g. D* c5 m" m
- module_param(ccnt, int, S_IRUGO);
复制代码
( Y) h' t4 S l+ k" Y6 a% e$ {3 f4 z, \8 r v
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ t% [' n7 o4 ~( darm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; K1 ?; |3 |; g
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' Q4 T4 N$ T! P4 M* o! x- I4 a; r9 j* K" G- D2 w% [% X$ k. P% Q
% V5 t5 e$ T0 H. M |
|