|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : a+ Z+ |) o1 S) F: Q
- [code]EDMA sample test application
; u3 A* `, {! j - /*8 [ T6 W, \# Q% h: f4 u7 k9 N) U H
- * edma_test.c
7 n& k3 Z6 o% s8 Z6 q! m - *
. j" m H, T& O& q. d6 M& @+ N6 g* e! [ - * brief EDMA3 Test Application5 Z( X" E h. }. I7 _. U) L5 {
- *
& L" F6 n7 w* \% I - * This file contains EDMA3 Test code.) v! v+ U# q5 M# L
- *3 e1 P8 h% ?, F. J, P v
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
) v) D; Y0 n# g M& K: F - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT) E( o" _4 r Z$ I3 b( P5 ^# P
- * TO CHANGE.
; {- \7 T i. o( x4 w, m - *# H+ s" g( h6 h% q% g, L
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com// I& e6 X: h8 O! i: G
- *
$ Q/ ^) [6 a) ?8 P7 U$ g% L - * This program is free software; you can redistribute it and/or6 [+ M3 v! Q1 S3 G5 e6 Y, r
- * modify it under the terms of the GNU General Public License as
5 x$ E6 c- ]7 {" X - * published by the Free Software Foundation version 2." e: M: G7 y% t8 \% K, W# y
- *
! F1 q- m8 f8 d+ N/ z7 N5 q - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, [* O* x$ e7 _9 f3 I% N1 m0 ? - * kind, whether express or implied; without even the implied warranty
" r0 z5 q8 M( X& v) d - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 N5 s5 }$ o' ?3 x% } - * GNU General Public License for more details. H8 ^9 C( t* f3 c7 y! l/ e, S' v
- */
5 q% s+ C% v' R2 M: n; b - ) c' n8 L8 Q- F6 N% e% h
- #include <linux/module.h>
' J6 l# x9 y/ |- B9 k - #include <linux/init.h>5 @5 Y* l4 L* f. ?, e
- #include <linux/errno.h>
" C9 U9 E! D7 H9 K! q( C - #include <linux/types.h>
/ F+ c* E5 x9 E& K5 n0 F" J( @ - #include <linux/interrupt.h>
2 U( S [0 ^! A2 o, K4 F( o; m - #include <asm/io.h>. v1 C+ _. M5 M1 M* i% t7 k' m- A
- #include <linux/moduleparam.h>3 C1 r: i# F5 n5 S P' x2 M
- #include <linux/sysctl.h>
2 _7 c* c0 C7 z' c5 Z2 d - #include <linux/mm.h>
9 [, M' u2 {9 I4 \( Y1 _ - #include <linux/dma-mapping.h>; a- Q. y9 J" K, B/ j( ] Y; z
x3 V) r" |- E" d# }- #include <mach/memory.h>0 T/ S8 D9 u4 x6 f" e- ]. K
- #include <mach/hardware.h>
) S) U0 }1 g& q4 `! c0 B - #include <mach/irqs.h> r! r3 R1 O/ m$ N* o! R+ j
- #include <asm/hardware/edma.h>( u7 ~. N8 Q% h$ x2 ?) E
- ; L4 o& n8 q1 N9 i3 r
- #undef EDMA3_DEBUG- x& T5 R/ I& ]: K$ `. t% U
- /*#define EDMA3_DEBUG*/ ~- F) Y4 }) ^8 k6 @; ?) X% T
- 3 _: {/ w4 j) m0 `: @, e4 x
- #ifdef EDMA3_DEBUG* v! w7 J6 v& U# A+ T
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)' v1 F( \( L4 Z6 B
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. g4 g9 f" c# q+ R - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* Z- y4 ^3 d3 y1 {) m$ u
- #else5 ], P/ V7 X1 P! M( w" ]9 w
- #define DMA_PRINTK( x... )
( F4 {5 S' }# u7 r* F, L6 b! o - #define DMA_FN_IN
Q) }+ L R3 Y P$ J - #define DMA_FN_OUT+ I7 q& A3 @" F9 q0 y9 Y
- #endif
C& R: Z7 }; A# }: e - ) D& f+ a" X2 [( }7 D3 ~9 P9 H3 b
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)1 R/ n* M( {( L
- #define STATIC_SHIFT 3/ Y* [2 o( Y& w7 P) Q, [' G, _
- #define TCINTEN_SHIFT 20
5 G$ h" j/ r ?& ] - #define ITCINTEN_SHIFT 21' B' @1 G. [" C/ x! ^: m
- #define TCCHEN_SHIFT 22* t$ l# R/ C' N; H/ D# L1 ^7 v8 A
- #define ITCCHEN_SHIFT 23
9 W4 u! p. \: c$ J8 A/ ?
6 y0 c0 N3 ^! u! y- static volatile int irqraised1 = 0;# t' E( R6 C [/ L2 r: M2 F" R, B3 f
- static volatile int irqraised2 = 0;
- P! M/ h. N2 S0 }5 p6 a
* g% y: O" z Y L0 }- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& s7 k+ O3 A% |& t9 ~
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 e% _, v& j1 k# k _$ b3 J4 Y - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% J" x9 ]) D- ]/ n4 ~: b
" `+ y, ]- D& i& A1 o% d. f- dma_addr_t dmaphyssrc1 = 0;+ Z9 o9 r4 [# _5 f! {) ^$ C
- dma_addr_t dmaphyssrc2 = 0;
' M+ o8 Q+ Y7 n: v& v! Y - dma_addr_t dmaphysdest1 = 0;0 k% n! Z9 Y) L
- dma_addr_t dmaphysdest2 = 0;8 T0 S3 a1 K6 Z# F
- 0 p. L$ h! m7 ^) F7 |8 B3 d
- char *dmabufsrc1 = NULL;
' w% d0 I9 z8 e0 Y! \ - char *dmabufsrc2 = NULL;3 R2 ~% u# A& F$ v& f! S
- char *dmabufdest1 = NULL;5 x( Z1 N) t: w; ?" E, ]6 W
- char *dmabufdest2 = NULL;" U# c' G# I' A0 x, |% i X5 E7 U
, h8 L H' l4 j5 r6 M' x- static int acnt = 512;9 _* Z9 S: @8 E
- static int bcnt = 8;% K2 |1 E8 Q2 v+ o% q' v, D7 F0 Z
- static int ccnt = 8;$ v& m2 g4 _! v
* d/ Z* W! d% k& e# S& o8 B- module_param(acnt, int, S_IRUGO);
) c7 y, W3 u t# S - module_param(bcnt, int, S_IRUGO);
8 U! j. K1 |* O+ B2 L - module_param(ccnt, int, S_IRUGO);
复制代码
' U5 n6 L" c) W" Y) N& {. s6 o Y" O1 F( w
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
7 `- S4 t) d/ n$ Barm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。- ]9 i) x7 ~! e5 U' g; C7 \
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。# Q1 V1 r9 R; I$ t
; ~0 n4 ^6 l1 k; ~
( b- c* e' W; D$ j9 |$ F |
|