|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
" s$ r% r, w, U5 I* ?: I: D- [code]EDMA sample test application, W @, B1 Q% O" Z( h6 [
- /*$ e$ M$ x1 s/ ^, t
- * edma_test.c
; p9 t- G& j7 ]6 K3 @8 Q% ~ - *" C) ]) T. M# n5 h" C
- * brief EDMA3 Test Application
6 W+ h# x9 c( U; U4 m. j+ N% K - *
v F: V! t$ B/ \" I - * This file contains EDMA3 Test code.
) p5 y, o1 w6 ` - *' h4 S+ n" E" _' O' g
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
( O* }- m/ U) \) g7 @ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT+ a7 ^9 A: S4 p
- * TO CHANGE.
; t) P7 ]# N. U - *
i* x; S% j2 G! Y) [ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 f" ^9 y& [: u2 M) A
- *
4 K6 O" m3 g. j - * This program is free software; you can redistribute it and/or
0 p) y( k4 h: p/ V' Q. v - * modify it under the terms of the GNU General Public License as/ Z0 u- e9 H% Z
- * published by the Free Software Foundation version 2.) M5 l" A! G% c2 o2 k! K9 S+ y
- *7 e& \, U. U9 }; G! y$ g0 X9 P- O
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any4 r8 _ c( t4 V* W% L \( i
- * kind, whether express or implied; without even the implied warranty) d& z/ A2 F. A/ b# j; s5 f
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the( ]" J4 H3 A1 b% r; L8 B0 @/ c
- * GNU General Public License for more details.
. N3 N/ E9 m, M# B2 `1 [ - */ v' |, ^. \6 Y$ w2 b
3 r' Y& {2 e% k8 S( F/ \- #include <linux/module.h>
6 o7 M L x6 V3 f+ N7 v - #include <linux/init.h>$ f% G, B: \9 F" Z. @6 N+ p0 M
- #include <linux/errno.h>
* T1 B0 v- N: R& r& I - #include <linux/types.h># W, O& U) R( r& m& l6 Q5 }
- #include <linux/interrupt.h>
# |$ X, p0 I M0 N& f - #include <asm/io.h>! E3 N1 D: D: N
- #include <linux/moduleparam.h>
$ H* r, M1 C& W - #include <linux/sysctl.h>( f1 e T/ q, x; I$ F" T
- #include <linux/mm.h>( W0 t! m, y! o
- #include <linux/dma-mapping.h>
?+ z7 V0 O# f1 n" w - 9 H7 y a; I) k4 ]! z
- #include <mach/memory.h>
) N+ ?, `5 X6 ~: o6 I4 ^* P6 j - #include <mach/hardware.h>
* w* s2 F% c2 `, n6 k - #include <mach/irqs.h>* d1 A) d0 d4 f; t E* t
- #include <asm/hardware/edma.h>0 z6 B4 p6 j9 i
# B2 }1 c; v4 U7 |5 k$ W- #undef EDMA3_DEBUG
: b0 P0 f6 V$ b - /*#define EDMA3_DEBUG*/
9 V# }0 w; q, R9 Y3 W# U0 w# E - ( k! a) \+ n* x( r% |! H
- #ifdef EDMA3_DEBUG: v& l# }( o: F8 q' x2 `
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ m. X3 ^8 K9 D1 n* n( w5 h3 l - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
3 X% O0 z, y* y; Z! A! F" U - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 n$ p- H; b8 G( y0 H- p
- #else
2 W: A1 _9 j1 r; t* P- D - #define DMA_PRINTK( x... )
! ], B% B/ ^$ |/ r7 H3 z$ V - #define DMA_FN_IN
2 ~4 `' f& {+ S l7 d0 p3 g - #define DMA_FN_OUT
2 }, G1 N. S& { - #endif5 g/ e" _# S; y. @" j3 U
) [9 p. B( N4 r2 u8 R% |: B- #define MAX_DMA_TRANSFER_IN_BYTES (32768)7 n( M5 K& B# u
- #define STATIC_SHIFT 3
) ~; M4 ~' L8 Q, ` - #define TCINTEN_SHIFT 20+ D D5 q+ e! d/ x
- #define ITCINTEN_SHIFT 218 v0 a6 ], N8 C" U9 f2 S
- #define TCCHEN_SHIFT 220 Z7 ?; {( a% @1 L7 L) c7 I
- #define ITCCHEN_SHIFT 236 b+ |3 a ]3 M# [0 l& j
- 0 W9 R/ b- G: g
- static volatile int irqraised1 = 0;1 J' n) g) a; ~, g
- static volatile int irqraised2 = 0;+ l0 v; L- Q u; i4 e
; L* @: W' ^& p4 w3 F0 b% a5 W# @- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* }7 a5 h4 m5 X5 a, ]: w
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 k0 E1 T% u2 l9 r
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 ?. W1 z) p4 O3 w; \ - % B2 V6 v& O$ Y: h
- dma_addr_t dmaphyssrc1 = 0;& ?1 V/ G3 h$ C/ M6 K
- dma_addr_t dmaphyssrc2 = 0;7 K5 y p% c/ s1 h3 h0 V7 {
- dma_addr_t dmaphysdest1 = 0;2 c5 E8 T) H- N8 F& D- a
- dma_addr_t dmaphysdest2 = 0;6 G4 ?2 z. [) o
- / d7 ]7 z5 T) U* p) c1 Z
- char *dmabufsrc1 = NULL;
" Y( I: Q3 _$ d! P - char *dmabufsrc2 = NULL;0 g# D$ g2 o, Y8 j9 B
- char *dmabufdest1 = NULL;: ?' X2 k( @; x
- char *dmabufdest2 = NULL;
- p( u E5 c& r' R# Q- d - % _! Q# Z4 J# U+ G
- static int acnt = 512;/ U: l$ K' {9 T' _. R3 ^5 v8 l
- static int bcnt = 8;( K& {5 J; D+ S5 _5 v/ O7 Y
- static int ccnt = 8;2 V `$ c2 o% R6 z6 \& B& h
6 Q' [# J) D4 D6 a: a' L- module_param(acnt, int, S_IRUGO);, R( y" z! l. w* R' ]$ q6 `
- module_param(bcnt, int, S_IRUGO);
9 } u5 J( K% y1 q - module_param(ccnt, int, S_IRUGO);
复制代码
- F; U* e. H! Q5 F" ~2 b& ~+ v7 u( w4 F
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用9 H, k$ C3 v: O* r
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
9 R1 R$ h2 ^# M7 K* C. R8 ~* y 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。" j+ b$ n& `" w( V1 }$ i: ]) B
* v( M" S/ M. J" r1 u* r5 e' a9 \2 E" x( y& e3 c
|
|