|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% |# F+ X6 @/ r% h- [code]EDMA sample test application
; s# r5 B2 w: \5 z- ~ - /*
$ n6 w5 O0 J5 x - * edma_test.c- ~% _# c( T4 X9 z7 Q9 N7 {% ]
- *6 K7 t, S- b i Q" z
- * brief EDMA3 Test Application
2 P) C% Q7 I1 L; e, x* y - *
9 {8 W9 G, ~' w9 L+ K E - * This file contains EDMA3 Test code.
1 E m) o7 ]5 m0 s - */ @$ C' f* a6 m8 n8 e
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE, X; Y/ |; K- i$ u" z# _7 P3 {
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT. O$ p# ~& H& |" e) S4 j3 j- |" `2 w
- * TO CHANGE.# o& N; J% i8 g' W
- *
! c9 C! H& o& G1 I1 U/ |" K - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ x' x U/ I* m% W) O
- *+ M6 J4 e( k/ i5 c
- * This program is free software; you can redistribute it and/or
, q$ K4 {7 K+ {. S - * modify it under the terms of the GNU General Public License as
* e8 h. D& i1 p! i! @2 a - * published by the Free Software Foundation version 2.0 u3 @4 b/ M' |2 o' a1 n
- *- s& i- c3 O ]$ c
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any* `/ q, b: T% l4 V
- * kind, whether express or implied; without even the implied warranty
! i; e0 \ M' h B7 I" v* g - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6 I( {7 P. @/ \" E9 G - * GNU General Public License for more details.) H6 G$ X9 c1 k
- */
% s: r! l! b }
. [, n" D' V1 \- g W. F- #include <linux/module.h>
0 ?5 G( C9 h4 T) b - #include <linux/init.h>& r2 W4 ^2 ]# A+ c
- #include <linux/errno.h>/ @+ F* P+ t- }. w: `
- #include <linux/types.h>
. F, z! o% w0 _/ ^% U: [3 w - #include <linux/interrupt.h>
" j( R* _1 ?) L+ d7 b9 t& T - #include <asm/io.h> c6 H K0 g$ X, _2 x% D
- #include <linux/moduleparam.h>
- h" O# `4 k# Y6 p$ K4 \" [ - #include <linux/sysctl.h> ?# m2 s7 C5 D
- #include <linux/mm.h>
" n0 B# q# u6 H. @/ x! S5 B - #include <linux/dma-mapping.h>" H$ Q; [& W4 T o' F
- / K8 f3 [- R0 k2 P% W6 s' N$ w' o
- #include <mach/memory.h>! \2 |0 Q' ?+ C2 A# l9 c
- #include <mach/hardware.h>
9 ^. a& e# n2 Q" W8 b - #include <mach/irqs.h>
0 D2 q* M0 Y( d - #include <asm/hardware/edma.h>
8 G# q( I, g1 `9 ]) P+ g$ c8 Y
) v4 r2 X4 s1 Y/ q- #undef EDMA3_DEBUG( A! E0 b9 c& v) {% E$ b3 J
- /*#define EDMA3_DEBUG*/* ?% e& r0 U; v5 l
3 Z0 \$ T8 B1 X$ l4 W7 ^- #ifdef EDMA3_DEBUG! X1 a+ Z/ I: M+ y
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)0 k2 q$ P. e; N! \( K
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). M! s' M8 V) C" X Q$ [7 O3 O8 `
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)6 `2 e; Q3 [; [! P8 W
- #else
( _# L. _+ X$ j - #define DMA_PRINTK( x... )( P( e4 B5 E J; m
- #define DMA_FN_IN' ` R2 P! J4 A. ]
- #define DMA_FN_OUT
3 K7 Q8 M) s: Z; B0 } - #endif. K. D% K- ]7 _
' Q$ j( X$ q8 K7 V- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
3 ~# C9 T" d5 R - #define STATIC_SHIFT 3
) i. ~' v# P0 Q. X - #define TCINTEN_SHIFT 20
/ P+ H- p* |7 B - #define ITCINTEN_SHIFT 21
' ~- K: d2 Q( ]0 { - #define TCCHEN_SHIFT 221 H( Y! c. D) K: R, i
- #define ITCCHEN_SHIFT 239 ^7 u, k) z+ @9 J( ~9 w0 C8 [) O; q3 ^
- . j, {* h0 D" Z& U( ~
- static volatile int irqraised1 = 0;) G8 n9 a/ P$ I5 t0 C9 @: ^
- static volatile int irqraised2 = 0;
) r( d6 v: L3 g% Z# n - ) V7 |( c: b( {
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* r$ s# R0 o+ q& h6 `3 g - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 z: _* I8 t B& s1 k1 m% { - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 l& L5 _2 U, \5 a$ z7 s
0 T* j5 e9 y" K+ g, _+ i/ C2 Q- dma_addr_t dmaphyssrc1 = 0;
# @ n* ~9 M- h( m - dma_addr_t dmaphyssrc2 = 0;
) f. k* L' s& ^ u7 ? - dma_addr_t dmaphysdest1 = 0; H: U6 M0 s0 W8 n, V# G) D q
- dma_addr_t dmaphysdest2 = 0;
( N/ J; v7 t6 r
* o, a. ], i& a2 ?* f- char *dmabufsrc1 = NULL;
; f; D9 }$ o0 p( U/ T - char *dmabufsrc2 = NULL;3 ]" L8 l p/ L1 Z5 j( x
- char *dmabufdest1 = NULL;) L$ D- W) P/ y6 w6 J9 ?% b
- char *dmabufdest2 = NULL;
# p( h8 j+ S& T$ \
! Y" b" {8 ]# y" H- j& ?8 Q- static int acnt = 512;
, s: n3 Q3 L3 i% k# v$ \" w" ` - static int bcnt = 8;) }8 l% w" j4 Q! S
- static int ccnt = 8;+ ]! M. M4 s6 ]; b9 a5 f
+ Q' u( k( N$ U; y) x- module_param(acnt, int, S_IRUGO);
8 t8 I2 x0 N- g5 j - module_param(bcnt, int, S_IRUGO);
( Z" w7 J2 W- f8 H/ H: E8 q( y - module_param(ccnt, int, S_IRUGO);
复制代码
/ G& y; L+ X# K# q0 c" r- E6 Q
7 o& e/ r# N% j 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 W) ^$ R. r3 W8 M5 G2 y+ sarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。2 |2 O: M8 X" X$ z2 {' p9 {
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。( a; k) ~5 N; [4 Q" W
8 l" W w* f/ J+ X
. D* W0 ~0 o$ c! u |
|