|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ; ~8 T0 ]2 x$ [9 X7 A$ O6 E6 J
- [code]EDMA sample test application9 j1 K9 x8 M( |0 l# _
- /*
5 o; o: u" P+ v7 S, |+ e/ w - * edma_test.c* T/ r) m+ T/ O( u/ E
- *
$ e; G$ h! C% ]8 K) a - * brief EDMA3 Test Application
2 m# p4 J$ |. i! @* M3 Y2 v4 c - *6 A4 U# }* t. ]
- * This file contains EDMA3 Test code.
; M6 {. E" n/ T5 r - *+ z! b+ v; c5 ^$ }: [* a. U
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
/ o8 [' A) {, e( ~ l" Z: N - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
4 f' E, c3 t( O1 d+ N- p$ q, D - * TO CHANGE. K0 k; T8 E! J
- *0 ~4 u8 {2 s1 e! _ U
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; D; k* p5 U. Q& ~$ B - *
+ I) S" n0 g" x% w1 N M - * This program is free software; you can redistribute it and/or
+ O0 E! I1 d( o: B! B I, Q6 b8 W - * modify it under the terms of the GNU General Public License as) a, G6 Q9 T6 m+ s c N0 F: \
- * published by the Free Software Foundation version 2.; i+ N5 m% j- v! Y8 T" Y/ e
- *: H& B4 q7 ^4 _) N* n, p2 s: ^
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any l* V. ~4 @% L7 ~3 u. t6 }: G
- * kind, whether express or implied; without even the implied warranty
8 Z7 \( g5 U& U: [& X9 Y - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* U8 A/ _) ^: y$ `/ g3 l - * GNU General Public License for more details.
% W2 ]0 E/ d- l' ?3 H8 X - *// N9 y/ e8 c0 |9 F5 ?
" ]4 O2 h t; K- #include <linux/module.h>: ~ E% a8 x$ M3 q& {
- #include <linux/init.h>
! [$ ?0 X" G1 c9 d+ J - #include <linux/errno.h>7 S# R5 V6 X! u; m3 @0 z7 \
- #include <linux/types.h>
% o. G' l* b; K. ^' }4 n1 D* w - #include <linux/interrupt.h>
4 e2 [& S8 E5 @) I% a3 i% A5 v - #include <asm/io.h>
x2 N/ i! j0 I+ ], } - #include <linux/moduleparam.h>
6 o% V+ R3 i/ L) \9 w) K - #include <linux/sysctl.h>
5 E* M- ~) L" J* W1 g - #include <linux/mm.h>
, M' m2 C; w+ U2 J" ?2 H2 ~" a - #include <linux/dma-mapping.h>
6 `8 f+ |) E$ u! e8 A) a- s
* N2 Z1 @6 @) M* D* B8 c- #include <mach/memory.h>
% }8 N3 x3 U% x) e2 n2 g - #include <mach/hardware.h>
6 |7 h' I" V. m - #include <mach/irqs.h>
( R' M# H0 w6 b k+ J3 k+ N' f8 w - #include <asm/hardware/edma.h>
2 n9 M& ]: C1 q( ` - 4 Y+ |( i3 f- r* b- K$ z6 W
- #undef EDMA3_DEBUG9 u. n, s3 Z1 o$ S5 Q
- /*#define EDMA3_DEBUG*/
0 g) a% V5 s2 z! X4 m1 L
{4 v! H! @4 ~% q- #ifdef EDMA3_DEBUG
4 f" }2 H# E' r, A - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS) }0 K7 ?( U* y% {2 q+ {% m) ~, r
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 ~/ p- B# Y& o' y7 E - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# |4 R/ m* D' L; x6 u - #else
" n5 |1 _. y2 M1 j: | - #define DMA_PRINTK( x... )
/ U; ~. h/ I. N" ] - #define DMA_FN_IN
: l2 @) _4 S9 l4 ]" m) R! g - #define DMA_FN_OUT
- |$ C0 I/ t1 L; t - #endif
1 B, W' ~% f9 |) F
" x- C0 B+ G; F- w. q2 v- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
8 M" U+ V% e) j9 N* c - #define STATIC_SHIFT 3
7 B1 @& H5 x! L( t" P9 B - #define TCINTEN_SHIFT 202 r S0 ~$ M6 R0 L: m/ H
- #define ITCINTEN_SHIFT 21
7 `) k. X. c" Z+ ?1 B { - #define TCCHEN_SHIFT 227 \. ~" Q( x' W
- #define ITCCHEN_SHIFT 23$ ~% Z8 o, i: }. e
& h( P/ f. \5 x1 F" g" W- static volatile int irqraised1 = 0;/ A7 G7 p" V& a& e" E
- static volatile int irqraised2 = 0;; D8 x- l n; {
- 8 \( X2 u: k5 [
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! g2 w9 G5 e. Z& E - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); _8 b0 G+ Y3 E0 Q
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" c2 V5 d2 O) x. \2 K$ B
9 E" k9 A0 [. t6 g- dma_addr_t dmaphyssrc1 = 0;
6 }6 Q( y. r& @% ~2 a - dma_addr_t dmaphyssrc2 = 0;
3 e7 E/ `, u# j8 s9 x- p- y, Q - dma_addr_t dmaphysdest1 = 0;
; X. a# U, G- {! w - dma_addr_t dmaphysdest2 = 0;& P: W! x( W" A! [/ h" t; P
- 7 C5 k) T$ K7 t9 C/ V) C
- char *dmabufsrc1 = NULL;
0 ^" A# ]- w, P& ` - char *dmabufsrc2 = NULL;
2 V5 M- k |% b - char *dmabufdest1 = NULL;
" w! |7 d) d1 l; N1 K - char *dmabufdest2 = NULL;
j% k; G2 g; P - * [: ? T( C. Y) J% O1 W
- static int acnt = 512;
4 n3 A% h$ _- t1 E6 M! o - static int bcnt = 8;# z n, y% B; Z: `2 H) |3 D
- static int ccnt = 8;. u% O( X. J1 ~5 ], p; c
( L3 [; G# R( r7 r* C& S- module_param(acnt, int, S_IRUGO);* H/ p! Z3 u- g% T& V
- module_param(bcnt, int, S_IRUGO);1 {* m3 `9 Y) y: a8 ]) A8 l
- module_param(ccnt, int, S_IRUGO);
复制代码 6 C- Q8 Z9 G# k; E
3 r8 b- b" e" N) [7 S 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
; ~0 P! J- e$ \8 J* i" b h. iarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。$ P; E% F9 O; ?1 @
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' M3 Y" M+ H+ `" g2 C' f! v/ K8 b+ P: }. v6 g
0 ^+ j# i: k. \! W |
|