|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 1 N/ ]( [4 P/ U
- [code]EDMA sample test application
( V- c+ k$ y8 ^ - /*
4 R' g- b- J2 y( X, Z! } - * edma_test.c( O! Z& H$ @/ L/ ]+ l
- *0 X3 f2 D* G* U; I
- * brief EDMA3 Test Application `9 P* K# h: o5 f+ v
- * n" ?; i3 k0 j& p1 _1 O. @7 r4 O
- * This file contains EDMA3 Test code.2 R" ~ t( J* q6 {8 Z
- *
9 A# F$ e# _- T+ Q; | - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE7 C6 v$ W- O7 G" c
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
$ M W# U$ Y0 ~/ E, T; W - * TO CHANGE., s6 Q0 S' Y4 I: B
- *. k$ t! A. j; r6 w% t4 s2 b
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# X3 p; b9 A- j6 B. K
- *
' Q. g* v" n3 F, O - * This program is free software; you can redistribute it and/or
8 T8 J! Z8 \- {% p - * modify it under the terms of the GNU General Public License as
9 y* D/ f5 s# P+ A* ` - * published by the Free Software Foundation version 2.
% O; q5 N6 P4 z0 {+ V m5 r' M - *
# L6 T4 u% p f; d. a5 S - * This program is distributed "as is" WITHOUT ANY WARRANTY of any! E$ }& R& t L( n7 o9 s. ]
- * kind, whether express or implied; without even the implied warranty0 D, |9 l5 [9 W, s# J/ i- c
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the3 S* ~4 y- S/ v
- * GNU General Public License for more details.
, W8 w! Q' g4 A8 Z - */ y0 }, j1 k4 j' q' ?# U
' Y2 V: i: O; ^5 ^- J; C4 i- #include <linux/module.h>
( a, @: e$ [1 r$ L3 k/ @4 C8 ^1 n - #include <linux/init.h>
% l9 L: W, X9 h; r1 d6 V* U! l7 K - #include <linux/errno.h>
- L: g) ~! |5 ]6 D- H5 U - #include <linux/types.h>! V3 d2 p8 b/ s7 n" G" P; _
- #include <linux/interrupt.h>9 }' P# T5 J6 A7 ]; Q, u
- #include <asm/io.h>3 _ f# Y: k- R
- #include <linux/moduleparam.h>" Y1 I' v) N" X% @7 W, `6 |# q
- #include <linux/sysctl.h>
9 y! ]) T7 y7 ~9 A. A; I - #include <linux/mm.h>: @1 c- @; L* X, Q9 h5 y' d
- #include <linux/dma-mapping.h>
; V! p7 x) A/ D1 m$ N - * i. `% v: }: S: f( l/ g
- #include <mach/memory.h>4 T6 F! r0 a% K: [6 H
- #include <mach/hardware.h>' p$ P! q8 j: ~" l" E8 d
- #include <mach/irqs.h>
3 N2 j. B/ x, Z; q& n' J - #include <asm/hardware/edma.h>
( O) V4 n7 E) _, ] - 2 |$ r; L4 o! ^% w, N2 T4 C
- #undef EDMA3_DEBUG- X) S' B; {, d V: I3 q% f9 U- O
- /*#define EDMA3_DEBUG*/2 x2 v" [) D# m! O+ s& ]. i
# w! n5 G/ a. W. k+ T9 s0 K* F- #ifdef EDMA3_DEBUG
2 L. R3 |# M: K: | - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)* V$ @7 E/ N' ] X9 q b2 a
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)9 A9 x/ o$ Z. o: w( @% @+ H
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
3 E5 D4 }$ r3 H; `% N: ~ - #else5 A2 [- M0 m5 n' Z+ g& m5 j
- #define DMA_PRINTK( x... )
4 ]) {; W6 p9 a - #define DMA_FN_IN& A: H8 Z" O! B# B8 n
- #define DMA_FN_OUT
4 t& h! D4 K9 D. |; e. ^' @# q - #endif4 K" X4 F4 H. k, X4 l
- - U2 U3 x1 B: E& [' K+ v+ Z
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
& P& ?7 t# Y" f" h/ }0 k - #define STATIC_SHIFT 3$ A: J1 Z1 H/ x& e; ~7 u
- #define TCINTEN_SHIFT 200 o% [4 N" j8 T) k' J, s
- #define ITCINTEN_SHIFT 21
, ?" `/ z( V% ^% D2 m% j8 H+ U - #define TCCHEN_SHIFT 222 L3 ^3 \: a9 g( }! l
- #define ITCCHEN_SHIFT 237 h9 K0 G6 O1 j0 s) T
- 1 U+ Q# A( i) Z3 f7 |
- static volatile int irqraised1 = 0;8 c& h. |2 b/ `
- static volatile int irqraised2 = 0;) j' H; p2 w" m- T: {
- ! b; {% G( O. u* O" e
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 B1 D/ [1 X* {3 W5 }+ ]7 [
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 R: M+ J4 B: A I; c! B7 \" C
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. v |$ w, A* a7 D) S8 N; [
- 5 D) l' G, X `
- dma_addr_t dmaphyssrc1 = 0;
. z5 s" S& W7 | - dma_addr_t dmaphyssrc2 = 0;
. Y! m; U3 t S - dma_addr_t dmaphysdest1 = 0;" l6 X% u+ x+ t- I$ W4 M2 \! K
- dma_addr_t dmaphysdest2 = 0;9 D* V# K7 V9 R2 L1 p$ l3 i
- 5 [* X+ d! ]/ \
- char *dmabufsrc1 = NULL;6 X0 s. D- K9 r
- char *dmabufsrc2 = NULL;
! z }8 M/ o2 W, F2 O3 S! L6 z$ y - char *dmabufdest1 = NULL;/ S6 |0 a" ]# c4 G" n
- char *dmabufdest2 = NULL;6 r u+ o6 [1 D0 y; D
1 H: T* z. v* }: L- static int acnt = 512;
6 k- F$ k2 u" A, t6 u7 {0 c0 O - static int bcnt = 8;
, F) o' `( i* l" q - static int ccnt = 8;
7 b- D$ e. `: ^ - ! Y' S- C, A D2 S+ ]* ^+ C( @" o% l9 J/ o9 Y
- module_param(acnt, int, S_IRUGO);
2 _8 U8 }# o' O: {8 C2 x5 N - module_param(bcnt, int, S_IRUGO);4 }* {' D7 u/ Q4 ^3 W0 @4 Y
- module_param(ccnt, int, S_IRUGO);
复制代码
5 R( L$ c6 |. h7 H: g I! T- g" d* _4 t1 j/ D. B
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
6 N2 v1 [, W8 w5 n# u6 c0 y7 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# \/ u* _( R/ U; K, |8 |
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
, z) D7 D1 Q- t1 @! b1 o \0 C+ ?9 J& W4 V: ] ^/ e0 N! ?
$ M1 p( { o) w) _0 H1 p, g* z- z8 j |
|