|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 4 B* V" U9 }$ D. F
- [code]EDMA sample test application
2 Z' P' S% `* A: z' r - /*
& f/ Y2 ]* ~: }* W! s6 ] - * edma_test.c" {+ D& F" }& Y3 W" q
- *
7 c, A0 n' E2 L4 T) L1 D7 i - * brief EDMA3 Test Application, \1 X) D/ x( F8 l
- *- {2 K% S3 l- v; K% R
- * This file contains EDMA3 Test code.+ f7 T. C! y& S
- *) O6 y5 ]* f8 F9 y( w( B; G( _( R
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE' B% H" c# t$ K1 N
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
8 K( w' a7 v/ A- V; Z# L - * TO CHANGE.) o/ H5 f2 C# H) ?( k3 a
- *# X8 X" f$ e! n [
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 ]6 H4 y: r' r5 C0 c; ]$ h$ T" _
- *) X7 a# N/ |- W" ~' M
- * This program is free software; you can redistribute it and/or9 ^9 d4 x+ M4 J5 j, m+ k
- * modify it under the terms of the GNU General Public License as
0 M0 m# D3 l/ K' t- t - * published by the Free Software Foundation version 2.$ {/ j3 X& b* |: m: r! Q5 E$ q
- *& t8 T2 v9 A0 p+ T% ^4 l& C
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
. T6 d( B4 ?* l0 d! Z1 v - * kind, whether express or implied; without even the implied warranty
5 M; B0 p8 R2 C2 C - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ o3 `# ?- V. `! F! c+ Z - * GNU General Public License for more details.
1 ^0 r$ k! Z9 f2 F - */
# X( l) n* s. J# K
* _! p5 @+ g0 K8 u2 E8 L5 m9 U- #include <linux/module.h>1 A: W- o* |. ^
- #include <linux/init.h>! z% h# y7 }# O
- #include <linux/errno.h>, q$ c- Z- J) D* e8 \
- #include <linux/types.h>
+ s4 h# x* G7 F+ J5 E. E) `+ k - #include <linux/interrupt.h>
( u6 r( c8 ], U - #include <asm/io.h>
% v5 Q# N7 C6 H' B' _5 w) a# _. C - #include <linux/moduleparam.h>3 V% r# b! t4 `" a
- #include <linux/sysctl.h>
# X4 C c y+ p% R& X9 u" c, W2 ^: ] - #include <linux/mm.h>
* W* v0 [+ Y% A0 W1 D; d - #include <linux/dma-mapping.h>" T/ k: M# y1 |% w+ K. @
+ J* ~6 d. m3 A7 S- #include <mach/memory.h>
, g# n( Z8 v! ~3 {8 `% i- M - #include <mach/hardware.h>8 o# i% D& I) a% q6 A+ x
- #include <mach/irqs.h># z! F2 k" t8 H
- #include <asm/hardware/edma.h># k! g, U' J/ D9 J$ c
! `) D7 n4 G& W& h- #undef EDMA3_DEBUG
5 n. \; P9 M* v2 l1 ~ L1 A - /*#define EDMA3_DEBUG*/
% n. t5 p5 Q* D' U. q+ ^4 U
0 |, w" Y, ~8 S- #ifdef EDMA3_DEBUG6 u% g9 H7 c |% }& d, H
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)7 W# G8 }! u4 V7 m# J; |
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 i' W7 r% d+ Y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
1 k+ c1 Y5 y( Y' l - #else1 ~5 j' ^& o& N' L3 L* u- i
- #define DMA_PRINTK( x... )
* i( K; l1 N. J& o2 h - #define DMA_FN_IN7 S" Q1 f1 Y5 d: o& w
- #define DMA_FN_OUT, h! y' G( @: X6 A! k9 \; y
- #endif8 Y3 O w( K3 v9 ]5 @5 D
: v+ C# B5 i0 S, a1 H' P( Y- #define MAX_DMA_TRANSFER_IN_BYTES (32768)( J" P& B! d( w! W3 E! n7 j
- #define STATIC_SHIFT 3
, r+ ^$ J1 k: n# @5 S9 J. { - #define TCINTEN_SHIFT 20
% Z& G4 [$ I2 b5 k* y6 ^ X9 F - #define ITCINTEN_SHIFT 21. ]# h: Y( Q" J! [
- #define TCCHEN_SHIFT 22
1 G. \$ B9 M) A - #define ITCCHEN_SHIFT 23
5 `* {$ y8 p8 X! \3 V - 2 o7 D3 b- c$ e2 F
- static volatile int irqraised1 = 0;- T* A2 g' U9 a
- static volatile int irqraised2 = 0;
+ Z0 V5 P0 R7 l# {, V3 f
5 e0 j* o I+ |/ P6 ~) i- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' J: c! s6 b7 n - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! [6 I# X- B, y# G- T. S
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; \& B4 w: \ S% U$ C4 u
' x, }. s- r0 A0 _, a x- dma_addr_t dmaphyssrc1 = 0;
2 }+ r. _& t" A2 q - dma_addr_t dmaphyssrc2 = 0;0 L ?* m4 P/ P! L/ d( ^' T; S
- dma_addr_t dmaphysdest1 = 0;6 A! F* h! {( p% q& l+ j) K/ P
- dma_addr_t dmaphysdest2 = 0;
) P% g: e7 `4 X5 b
) v3 o$ D- a I- f: h. ]# q- char *dmabufsrc1 = NULL;
4 {0 ~' V& t# d1 M* q" Z } - char *dmabufsrc2 = NULL;
/ I( w8 E! x5 U6 V( P2 H2 m - char *dmabufdest1 = NULL;
9 r4 |, }% x7 q/ q - char *dmabufdest2 = NULL;. b7 l+ a) \- ~/ {: P
- : e# V# ]/ A# W1 A. p
- static int acnt = 512;
% r) ^4 a ]9 c7 h7 e - static int bcnt = 8;
1 A% ]) m, _2 @" Q$ e - static int ccnt = 8;1 Q; G" O) e) }% D3 ?
6 J5 k5 s8 C( L- module_param(acnt, int, S_IRUGO);8 X4 p3 w: y. B p3 O- Y- B
- module_param(bcnt, int, S_IRUGO);
# e+ J2 T* l. W* w - module_param(ccnt, int, S_IRUGO);
复制代码
& u- c' W) n; }0 C
1 K6 B; @+ ?( u7 D 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 J# A) q6 U6 f8 earm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。6 H/ l: n& K4 b6 S" ?& @
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。" E0 z+ j: m" `) {4 d& J
0 Z( m* h' g9 d, \) X
. u. Q' D5 Q0 K' v0 B! R |
|