|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, n" k8 }+ O# _, R- [code]EDMA sample test application
I9 T% x/ e/ h3 I9 f - /*" ^) k; D4 j" u( j5 m6 R7 e
- * edma_test.c% @; F7 N- s; z0 \ s* F
- *! b2 q( f/ q6 J7 }2 n/ b
- * brief EDMA3 Test Application2 Q$ c1 M- |7 n8 t
- *
1 F6 \' M2 u$ v5 S; F - * This file contains EDMA3 Test code.
8 C, l0 A4 ~6 ]. X: n& \: `# ^+ Y - *
) R% D9 K. W! ~" y; j$ d' J - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
/ _ o5 y5 U6 S( {4 [ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
& V4 o" k! Z- `- l( F( W - * TO CHANGE.1 m& _. S, I, L
- *. f) T# ^1 h# u% P; I
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
( j% [/ Y! Z2 d5 h- r8 N# y - *7 l* h) c3 f. c. I+ K6 h
- * This program is free software; you can redistribute it and/or; |. r" s& T" C% L2 s1 F: Z$ g) P
- * modify it under the terms of the GNU General Public License as
( h; B- K" A7 u6 F' B2 ?+ S - * published by the Free Software Foundation version 2.
1 g6 Z! W3 V: D2 R% L) l - *" s% N# N A# W' N4 i! G) D7 C
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
* J% J6 S4 Z( R+ K+ _0 t7 ? p - * kind, whether express or implied; without even the implied warranty
( w. i' D8 f' v- }9 \* V - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ r; Q- W# r! b" i' K
- * GNU General Public License for more details.' _7 U6 ?4 f$ e* N' b. e
- */
1 L/ h$ e9 O: u8 j, \# X - d" Q/ ~6 H: i. {" U7 \
- #include <linux/module.h>
/ v4 d6 Y5 z! z0 {% C1 n3 k - #include <linux/init.h>
6 |: ~. j2 [" k( c9 d - #include <linux/errno.h>! ~/ X0 U# Y; z/ s! R; A* @
- #include <linux/types.h>3 h- \/ A, ?" T9 t& |8 f0 L
- #include <linux/interrupt.h>* I$ j* @) ?3 h" }
- #include <asm/io.h>
I( B/ b3 {) p" K2 u. o - #include <linux/moduleparam.h>$ H# I. L% ~- }, n* E. @
- #include <linux/sysctl.h>+ T7 c/ d5 J8 u$ u+ O6 S4 q& |6 E
- #include <linux/mm.h>. Y# j2 T/ p' g' y- F* ]8 } r
- #include <linux/dma-mapping.h>
$ V) U+ I* }, w1 d6 c* P& K( P
[- n7 ~1 _: O* T* M- #include <mach/memory.h># u8 H, D+ B) d& d- Y: e
- #include <mach/hardware.h>' W/ L1 z! {6 u3 X4 {: Y! V* }
- #include <mach/irqs.h>
* x5 s( Z& m4 _+ Z/ Y7 G" E5 ] - #include <asm/hardware/edma.h>
" s6 U& A! y; M" M
' J x6 S. w1 T; H; e- N0 E- #undef EDMA3_DEBUG! P6 ?! Q+ Q! H' F
- /*#define EDMA3_DEBUG*/
, p! D. q. N4 L - G3 J2 ~1 d3 P; ]7 }
- #ifdef EDMA3_DEBUG
6 l' q* W, u4 H# {4 v - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS): T# a+ @1 _3 K" O4 k8 ^
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)( p: v: r2 d5 U0 m
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
& V) R- t( L' N( x - #else
4 I# A0 ~0 `: ] - #define DMA_PRINTK( x... )3 M! f' W& y! x' n
- #define DMA_FN_IN
- P9 f! K# y1 m/ p - #define DMA_FN_OUT
- l* [0 Q w. m: F - #endif/ x( H8 G! n3 ?4 `7 ?6 j
|5 i( X. F; A- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
4 x9 M" J; |+ A0 g# O( ~+ T& D/ {8 ^# w - #define STATIC_SHIFT 3
- f+ z5 F9 f5 r" q; p5 z - #define TCINTEN_SHIFT 20( {% G7 z4 t" Z q. { E# B! `
- #define ITCINTEN_SHIFT 21
/ V' E1 J$ v4 h4 L# b3 D6 c - #define TCCHEN_SHIFT 22
+ e. p4 r7 `4 H" w - #define ITCCHEN_SHIFT 236 \/ V, L& ^; p0 | ^
- . L8 }7 @8 r+ g
- static volatile int irqraised1 = 0;, L Q- U _# q# R7 B/ ]
- static volatile int irqraised2 = 0;" V- U$ W0 O/ p% m
" f% K" F, ~# y" ]- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 J% r7 Z: M% {( D/ e% W2 p8 P- C/ M0 J - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 G0 R" T; C& C6 m( C - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% H! T6 H4 m0 \# n" O5 _9 }& |% R
- & u5 v; _' E* I; {6 a8 _% B
- dma_addr_t dmaphyssrc1 = 0;
" J6 v$ t& C& o - dma_addr_t dmaphyssrc2 = 0;+ H- s2 E: a$ o
- dma_addr_t dmaphysdest1 = 0;
7 ^: }" w; s+ y8 H - dma_addr_t dmaphysdest2 = 0;, Y. b8 _( M2 i- ^6 Z, z6 ~
+ U! p( W% H5 }* q- char *dmabufsrc1 = NULL;2 ]* X; h" S+ k, m5 c
- char *dmabufsrc2 = NULL;
% [% ?+ A5 x8 ^4 A( ` - char *dmabufdest1 = NULL;- p L0 p. V. _% O9 l
- char *dmabufdest2 = NULL;7 L2 T- P3 L/ r* ^3 B4 M" H
; @: Q+ k2 \/ @0 I! S- static int acnt = 512;
" r3 i. r3 y5 s/ L: ^. H! _ - static int bcnt = 8;6 ^/ F! M) N. \3 t
- static int ccnt = 8;- C: Q! r2 Q* M5 n# ]5 r
B( G7 o! i$ t7 |) B- module_param(acnt, int, S_IRUGO);' H: p8 B% ~( a- ?/ ~% L, F
- module_param(bcnt, int, S_IRUGO);1 W) F# M% I: X) h# l( F9 H' u. t
- module_param(ccnt, int, S_IRUGO);
复制代码 6 ~0 ]9 F$ S& i3 O& {: K: g# o. R
- H4 k$ ~- {, z- a( f7 R 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用! T! Z x! z* {+ t+ B( ^
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。$ o) }3 L/ z0 f+ K/ Z% ^$ f: h! D& ]% y1 ~
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。, Y7 \* [( M' _1 D
% `, X- u3 u* Y4 E
& b% \3 T9 A# t7 v' n2 u& H/ _ |
|