|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 M+ \& }# v# T) G0 u- [code]EDMA sample test application
" ~) Q8 C, W2 ` - /*
* O4 |/ U( y/ H - * edma_test.c
& v# [. z% h' O% Y: A( _- i( W - *
1 c6 P2 ^# m D7 P# ^- E - * brief EDMA3 Test Application
$ R7 G' Y4 a: Q4 Q, k1 S W4 R) A6 K - *# g# \) d U! N
- * This file contains EDMA3 Test code. d* V6 f( F) v& I$ [; g6 L
- *
2 A! c3 v+ K- \: b8 A% {+ L1 a - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE, ]' D* ~3 L6 w# `
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
1 X% i- ~* p0 y) |$ K$ l - * TO CHANGE.) I; o% u+ [3 U' M
- *
7 n% s& V, T( }) P( a8 C - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/3 Y* y4 n9 R) i$ ^4 y; s/ h
- *
' }- x- g/ D9 L# ~" W4 D9 @0 a6 l - * This program is free software; you can redistribute it and/or
5 Q8 ?3 E! `% `+ w$ E - * modify it under the terms of the GNU General Public License as. ?! `( z% u& q
- * published by the Free Software Foundation version 2.4 `* q" M5 }0 c( I& g @& V; C* D
- *% j9 p* Q4 F* K
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any! W% h+ z9 }6 \& [. B
- * kind, whether express or implied; without even the implied warranty+ x9 O1 b; r3 ?0 p. N
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the$ D. X9 B! ]) L0 m! }
- * GNU General Public License for more details.
3 U% ^2 c8 y1 l% ] - *// a6 q- t% g! y E9 E
- 2 L6 P- `. l) X/ X9 @
- #include <linux/module.h>
0 ^- J' I# Y9 b. U! L* g" G - #include <linux/init.h>, ?$ d" K; \, K! I. o0 b
- #include <linux/errno.h>) ]# s* k$ f! v# o/ s2 \5 U
- #include <linux/types.h>6 s% ]& G; L( C
- #include <linux/interrupt.h>2 B" C0 N% `9 G4 J# i# `
- #include <asm/io.h>
- g3 D# M6 x) |, K4 {0 n - #include <linux/moduleparam.h>( j9 E" }; V' K% \2 d
- #include <linux/sysctl.h>
9 B" l5 x' j1 r8 N - #include <linux/mm.h>
; H( A0 i8 @- t+ C0 \* t! z; m3 l - #include <linux/dma-mapping.h>
0 u; S3 O: W5 i4 L; K! K
" f: T1 |# `7 ]7 A: w- #include <mach/memory.h>/ M+ y- _" u6 t4 h) c/ }2 c
- #include <mach/hardware.h>. Y7 H0 o& m- H: ]
- #include <mach/irqs.h>- v% a3 B% m( B4 H% M8 k8 h4 u
- #include <asm/hardware/edma.h>9 t* \0 N9 n! ]6 @1 j, Q
- 5 v& k' Z1 d5 M4 L& @# b
- #undef EDMA3_DEBUG8 X$ Z0 k. z- l7 |# v3 a3 V
- /*#define EDMA3_DEBUG*/
# s$ N$ B4 U6 l1 s& g2 w' C - % G5 ]3 h- F% d9 t
- #ifdef EDMA3_DEBUG) J N7 T* f- h, S* {$ |
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
A/ F. L- `9 G+ y" f7 b9 J: r - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
- S; Y w0 f2 F/ |5 }( Y, H: X - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
, w* Y- `7 e+ i - #else& M4 d( J! @, f8 ?
- #define DMA_PRINTK( x... )! l( p6 @' R! L
- #define DMA_FN_IN" T6 u7 Z; D8 a; R
- #define DMA_FN_OUT& B5 A6 O3 S5 o) z/ b3 d
- #endif! [; f% a- S& w
* X- W# ~2 o: v1 K1 y- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
) L( J" u, [1 X - #define STATIC_SHIFT 38 o; s& D! t1 X: o' ]6 M: Y
- #define TCINTEN_SHIFT 20* s( K( G& S% b- T; r* K' C7 J" {
- #define ITCINTEN_SHIFT 21. d* l* F" M4 D
- #define TCCHEN_SHIFT 22
8 ~; K6 s4 Y% r" j2 _$ @ - #define ITCCHEN_SHIFT 232 q6 l: B2 e4 o$ ^1 `
- ) o1 s6 Q8 \0 l" K6 w
- static volatile int irqraised1 = 0;
& ^7 o( f* D( C - static volatile int irqraised2 = 0;- ^& {+ y4 @2 T, ~+ y
* p% ^! y M9 w2 _# A8 G; a5 h- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ I0 n! m; g( n9 ?. Y
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, A h7 b" z% Y8 A$ k% X" d+ s - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 R+ z0 Y S4 P( }
* f8 K4 v) \; H( R8 d- dma_addr_t dmaphyssrc1 = 0;) p, J8 |& u3 C3 Y( p! j4 a& @
- dma_addr_t dmaphyssrc2 = 0;
' \2 `8 G, B+ a$ |+ ^3 R& p, d - dma_addr_t dmaphysdest1 = 0;
% ], z: u- m- H1 l, H - dma_addr_t dmaphysdest2 = 0;
# ^! I! J3 E$ h+ n/ G/ v$ j' B9 Z) X - $ M* i& U4 t5 |9 d6 T1 r7 P5 A+ \! \
- char *dmabufsrc1 = NULL;* }# h8 T, }6 Z0 }
- char *dmabufsrc2 = NULL;; d3 ?1 _* I. o1 a l, N; o( X
- char *dmabufdest1 = NULL;+ M. E% y& p! Z" u8 O# u
- char *dmabufdest2 = NULL;
' b$ e, I4 n% S% v
0 i/ p# C7 x& y# S6 c+ r8 S+ O- static int acnt = 512;2 I1 n/ I' L. ?3 ~' Z
- static int bcnt = 8;! U6 |# K, a8 _. \/ P
- static int ccnt = 8;0 ^4 \8 `, H. X7 {7 |7 w2 ]. \' r
- 2 T# m1 k( C5 B8 G1 O5 d
- module_param(acnt, int, S_IRUGO);% N2 \+ B: J: C' N* ^
- module_param(bcnt, int, S_IRUGO);
8 ?/ k: R) ~' X6 G4 ^' i - module_param(ccnt, int, S_IRUGO);
复制代码
# ^. C Y* j Z1 }- |- ^& d! n" y
5 |: d9 P# h! d m- i 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用+ ~! ?1 C6 S4 _8 M; ?8 z
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。! }4 X, X4 s3 U6 e
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。7 J) p4 f5 q( c- g, K0 n# P
0 u1 f$ `( {$ s0 c: L
/ R* H6 X* L( q! F" ~ |
|