|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. L* J+ s. v* Q0 E* g& w- [code]EDMA sample test application
/ J5 {( n" u& Y6 u - /*
) T" j8 H/ a2 v4 k! C! q9 @) f6 r - * edma_test.c
, o1 k) T5 }; q8 j/ w: T - *
8 @ N" r. I6 ]* J7 m - * brief EDMA3 Test Application8 g8 H3 X6 b' z9 o5 w w5 k* x2 {. ~1 c
- *6 f( W8 F1 [5 g E2 E5 V
- * This file contains EDMA3 Test code.
+ F; Z4 d. O8 |# m; l% q8 | - */ X3 { V1 G. k# F
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% ?) _( X* v M" ?' ?; @7 C6 R - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
0 T" I/ _9 \ Z% k - * TO CHANGE." F9 I$ @. ]& b4 ~
- *; q$ s: F' i) G: G2 G7 i# n. {! s: K
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
, {* _3 i: d y N! P b - *
1 |: J8 h S, U: v7 ~7 w - * This program is free software; you can redistribute it and/or
1 b- S8 A3 N* ]. f ?3 T9 j8 R - * modify it under the terms of the GNU General Public License as
% U/ p: H1 V! H7 O - * published by the Free Software Foundation version 2.
- h; p' B1 ~' P6 G. K: ? - * E% h1 r. g: O2 Z4 L2 `6 g& W
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any0 D" q9 H5 Y% L- s
- * kind, whether express or implied; without even the implied warranty; w; u/ t0 ]- d2 k9 g% u' ?
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the/ C0 @; L" y. P& X7 S, |7 |
- * GNU General Public License for more details.
' W0 j* d& V. }3 D" E - */
; e7 I6 }; d& U+ V - ! F/ ^/ w( ]/ G2 P
- #include <linux/module.h>; E+ ~5 J2 B: Z( q- a& [6 p J2 q# [
- #include <linux/init.h>) Z9 W% m- {: ~; y& w$ A! v. ^
- #include <linux/errno.h>
" q5 i' F3 c+ g2 d - #include <linux/types.h>! J# G8 u0 K+ I" Q. d- t0 A. v8 E
- #include <linux/interrupt.h>3 g' F" t. R @ U( O1 N& _/ @8 V
- #include <asm/io.h>
) l* p# m# D% k% C; q5 S - #include <linux/moduleparam.h>- Z9 S7 S0 V2 r% o
- #include <linux/sysctl.h>, S6 D, O3 U8 Z6 Q* G% }4 H& Y2 b
- #include <linux/mm.h>5 m) ?0 x: @ d2 ^! h
- #include <linux/dma-mapping.h>
/ b3 \6 X2 J1 O, p - 0 M' r o, }% w- f' r# Y
- #include <mach/memory.h>& a8 b5 R e* J0 W& q/ S
- #include <mach/hardware.h>
3 @, M* b9 i0 n - #include <mach/irqs.h>( ^" [. E* s% d3 [, Q$ v4 n/ X: V% T
- #include <asm/hardware/edma.h>
( y) |9 m# G; C6 m- |0 b( V3 D
2 L% M6 t" w: ]. @! c! u5 g* Y- #undef EDMA3_DEBUG
2 P0 O4 E# ^. d% Q3 O - /*#define EDMA3_DEBUG*/
# U9 S; F |* O# S$ ~& s
% Z8 I" j8 u# {- #ifdef EDMA3_DEBUG, @+ u( W* @. ?+ l/ V5 O3 y
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)! P3 h6 R: C% }
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" e) S! H3 S D4 r# f
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__). ~+ J6 v- d3 a
- #else" }5 u. t/ o/ z4 n! o
- #define DMA_PRINTK( x... )) O G w7 o- ~9 F" `% r
- #define DMA_FN_IN
/ O q- B: S# h - #define DMA_FN_OUT
- t6 g& z8 ?! @ - #endif
. y. ]( k- f+ d ^6 n9 j - 3 U- u/ |6 G* T; C$ G Z& w
- #define MAX_DMA_TRANSFER_IN_BYTES (32768): H# H Z3 T8 I \! h" F. G
- #define STATIC_SHIFT 3
2 c5 e2 q2 \% p: P0 ~ - #define TCINTEN_SHIFT 20
1 d0 f. Y z7 T, C& U+ { - #define ITCINTEN_SHIFT 214 M( S6 |2 k6 j: C- C0 M
- #define TCCHEN_SHIFT 22
" q% r' O7 }2 Q$ N3 W% a - #define ITCCHEN_SHIFT 23
, Q% p3 A( Y/ x) u - 2 K5 `' U9 j4 q J2 g
- static volatile int irqraised1 = 0;
$ _+ v& T3 n1 m6 V' @ - static volatile int irqraised2 = 0;
r4 q% \) G* c! w+ e4 m - 4 h7 s/ G; ]& k. L5 {5 a7 U
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 T; c V. S l9 o5 C; y+ e
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ p/ {" \+ ~0 r$ f _% B; ^8 a - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ u; n* Q4 ]# ?3 O2 a; b- P: J1 e9 D - 2 F& C' Y3 x a F% U
- dma_addr_t dmaphyssrc1 = 0;
0 C' T2 _/ b& c! ^: f2 o! P" C6 { - dma_addr_t dmaphyssrc2 = 0;" [. m4 F, B' T0 g# Z1 g: g6 r5 q
- dma_addr_t dmaphysdest1 = 0;
4 o2 v0 n# ?4 p: L+ J: d1 G - dma_addr_t dmaphysdest2 = 0;
; _) b& P% e3 ?3 e+ K$ |. z - # ~4 V6 Q2 w* F
- char *dmabufsrc1 = NULL;# I4 F& U0 O7 }# R
- char *dmabufsrc2 = NULL;
5 m6 o$ i5 z. _ n - char *dmabufdest1 = NULL;
) e4 p0 y K, u- I, g" ~ - char *dmabufdest2 = NULL;( ?4 S2 x b( o+ w1 L0 `. Y
1 w0 Y8 E5 m* S+ ~+ k% U- static int acnt = 512;! N( I; k, W- ~# \/ S6 z
- static int bcnt = 8;1 K: y H7 j* h7 F6 |* K2 u
- static int ccnt = 8;" [4 ]9 {( e1 o% K4 ^ E4 B( D
5 _$ q* }: E3 e* P7 Y2 R8 c- A- module_param(acnt, int, S_IRUGO);
" Y- U2 C$ ^+ c0 C/ i - module_param(bcnt, int, S_IRUGO);/ k" H) X1 `: S. [0 h
- module_param(ccnt, int, S_IRUGO);
复制代码
, Q9 h1 v) r3 o! N8 h7 M
/ v" f( ?6 p5 T% h, |3 k4 }- j 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& ?; x6 G0 E$ ^0 R X4 B) W: Oarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
! G2 o/ B0 D! @) d 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 y! B; z( [1 p: j; m9 c
/ Y# T8 g* v3 B; d a0 _& A: T3 j
& \1 p2 ]5 G" Y6 r) Q
|
|