|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ) E3 v! e8 s7 @. { h
- [code]EDMA sample test application
\6 I" h d# I% e$ v6 S - /*& @/ \3 U& z$ V, N0 u
- * edma_test.c3 i) r l* W6 D; i. u# b
- *
. R; Y2 c' x& b - * brief EDMA3 Test Application
: s- i. d8 Y/ s+ _' z. T - *' Z1 ?# X7 D* V! O
- * This file contains EDMA3 Test code.0 z) p) M; s$ c
- *5 Z- j* j! M# ]0 p
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
6 @: t6 X. H8 |& | - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
Q8 R' U9 g d) M3 g* T2 b - * TO CHANGE.
/ L8 E) r( `9 L, V - *
, w5 K1 \: H. V: \& I; B - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; b8 [/ q9 s. h1 W! M - *
5 U3 q# n$ Q8 }8 @6 k9 l - * This program is free software; you can redistribute it and/or/ L& r x d* G
- * modify it under the terms of the GNU General Public License as
& w- W6 A+ ]& H3 M J9 x, T6 e j% R - * published by the Free Software Foundation version 2. Q6 a! B" M I) W; |
- *
# {1 c: n0 p8 h, l0 z0 C - * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 ?- S/ f3 v. w3 q; a$ _( n! w, p
- * kind, whether express or implied; without even the implied warranty+ o: x K/ M- b
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the( w* p" F& V- ]) J, r
- * GNU General Public License for more details.
# M+ [& w; I) E! z9 Y - */: t) R( r; g E. g4 I
- 5 c; u! y8 b g" V
- #include <linux/module.h>
5 j# h6 K+ I, B7 T - #include <linux/init.h>
% d& p! K/ P. ?5 _5 T+ s" p - #include <linux/errno.h>9 }" D) |* d7 k0 G! A. R c Z
- #include <linux/types.h>8 O5 q; o0 }: ~* t* u
- #include <linux/interrupt.h>4 S2 T1 |( T2 `* N; r6 f% J1 r0 V
- #include <asm/io.h>: e8 k% A: i* O6 M& Y" m
- #include <linux/moduleparam.h>
f/ k# v n, ?5 X; E - #include <linux/sysctl.h>
" W1 C, m" ^9 Q9 \4 p% _3 M7 ~, M - #include <linux/mm.h>0 x4 T" J. t$ r, L7 @) k* q) k
- #include <linux/dma-mapping.h>
3 d/ ]- q" @; Q+ \ - 5 U' D; Y5 J1 Q" q, x
- #include <mach/memory.h>
/ `% k5 s' O3 [0 h- u - #include <mach/hardware.h>0 `5 _- | q, O9 Y9 [
- #include <mach/irqs.h>3 E; s0 _# J, }# C4 w7 }
- #include <asm/hardware/edma.h>6 A; }' `9 q% Q* `( B- m
- J* |9 @ u" k; j, h; g
- #undef EDMA3_DEBUG, L$ Q! ?0 j# h4 [" a5 x
- /*#define EDMA3_DEBUG*/, h' Z. r! i7 J$ g/ e
' P2 p* o" P& ^8 l! v8 V7 T- #ifdef EDMA3_DEBUG
: D1 l: B5 H0 W: O% f! W% O# U - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS). |1 p3 l) C/ |& j, {
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)) [4 P5 c" ?! ^( U& p) W% g
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)" P* P/ l1 g7 |8 r2 U
- #else3 ?, R/ ?0 u/ o& Y1 z' A& c
- #define DMA_PRINTK( x... )" y5 B2 V$ ?/ p6 w o
- #define DMA_FN_IN
. X) Z0 Q# o7 @5 {/ m - #define DMA_FN_OUT
! u! D% N) T: d/ v - #endif
! c9 a* b$ {1 ]
+ e4 P2 s4 q0 I- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" h; E( f9 w1 Q, J8 O
- #define STATIC_SHIFT 37 B( b$ H ^5 T% _, r( c
- #define TCINTEN_SHIFT 20
+ L9 F, H! q/ x R# x2 V, i - #define ITCINTEN_SHIFT 21
* i2 o. \. r- X/ F" p - #define TCCHEN_SHIFT 22 H3 g2 V' C2 G0 d* w) B( [5 Y
- #define ITCCHEN_SHIFT 23
* O$ g7 f1 P9 w; Q0 K$ t P
" y; ]3 @ _ T! f. O- static volatile int irqraised1 = 0;8 u0 }* F" [9 q2 V" L
- static volatile int irqraised2 = 0;
; K. ~ B( v, S' A2 d: V
7 L5 e2 B! X8 ?% n; x- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) v3 [9 Q& _9 \/ ]2 x. `6 { - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ L8 v/ z2 V8 @
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) r% q! I* v6 A7 W
4 p% P& ?0 N ~: E7 a+ H3 x7 I" h- dma_addr_t dmaphyssrc1 = 0;
& ~. f, O4 r/ T* m; m - dma_addr_t dmaphyssrc2 = 0;
; v$ t. x1 l% l' n& a& ?6 O - dma_addr_t dmaphysdest1 = 0;8 J4 y3 q7 @' S* w3 S
- dma_addr_t dmaphysdest2 = 0;
# F! M/ d8 c- e# G; _ - 0 G: Q( ]$ J# s
- char *dmabufsrc1 = NULL;" B+ s' n: `6 s. c0 _) L
- char *dmabufsrc2 = NULL;' k5 O: m9 X! Z- a2 e
- char *dmabufdest1 = NULL;
' Q0 c7 w: _3 d* v0 |. E/ I - char *dmabufdest2 = NULL;) U9 m" b, ~# O( n8 A D7 m
5 d' H/ Z) B8 }+ l# q- static int acnt = 512;/ _( ^; d) f6 B! z% S
- static int bcnt = 8;
3 ?0 w# `5 M% a: [: y - static int ccnt = 8;6 \3 ` |, z5 _ I( x, W1 E/ k* V
- , g b3 |$ N2 y
- module_param(acnt, int, S_IRUGO);
( H7 C6 U% {& o4 E, L - module_param(bcnt, int, S_IRUGO);4 t9 ?7 D7 a c& i+ H
- module_param(ccnt, int, S_IRUGO);
复制代码
9 c x- U- e0 N+ p$ M# |; O0 ]: q J6 x
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
% j: O# f$ s" B$ 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
5 R# {4 @, J, ^0 `1 F 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。- g a- R$ H" O
, \$ g; c$ J$ ]3 y
0 d" t8 |, @5 B |
|