|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; |$ R V( o- l- [code]EDMA sample test application
8 ?! n. B; e3 P# m9 L3 S4 @, |& w - /*7 w0 @) g) l4 C
- * edma_test.c9 s* }* N% R5 t2 k6 U; f
- *
/ _3 K7 N9 |4 f% s& @ - * brief EDMA3 Test Application' [6 |" ^1 Q: w8 z3 K
- *
- }. n+ W- Q9 s8 @! O" Y" o - * This file contains EDMA3 Test code.* B$ {5 e1 d' u" r
- *
1 m7 d. l0 u# S8 j& }- g7 y! N' o - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
/ @! x6 o1 c! ?, ~9 e - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
$ p, O+ m5 ^- h0 G' g - * TO CHANGE.
& D6 K0 ]" \$ A' D: i - *- N8 e1 J+ ~0 [ d. Q
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# s5 Y! w3 S$ W6 ~+ C
- *
/ W; z L- l& B5 j' H! e4 w$ R6 o - * This program is free software; you can redistribute it and/or
9 B2 S- c- t9 G7 G- l& z' p0 X - * modify it under the terms of the GNU General Public License as6 H# Q) Q6 `, y" d( W
- * published by the Free Software Foundation version 2.
1 R2 I1 U/ ~& H+ b - *
# I: n4 o, C! } - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, H6 h `$ Z8 B& {% z# c - * kind, whether express or implied; without even the implied warranty
" l3 n; w& D9 {. [$ s( T - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& M3 T2 y5 U5 s4 M/ M$ C. q - * GNU General Public License for more details.
; M9 P/ J" N% |* W* Z( k4 ]+ u! m - */
6 \( e& j! O; |! u9 R3 m) d8 V - 4 ]! n' e! ]3 a
- #include <linux/module.h>5 `) t9 m, G% K$ P) H9 X. @
- #include <linux/init.h>
- V& r. Z g1 _& ? - #include <linux/errno.h>; t1 l" W6 K' U3 W4 Z
- #include <linux/types.h>, @* V( T; w' f
- #include <linux/interrupt.h>
- {% c" L8 H" u0 B+ P$ Y+ z - #include <asm/io.h>. t* C3 A7 J5 N
- #include <linux/moduleparam.h>
I$ f M6 J/ r; I s& j r - #include <linux/sysctl.h>7 u& J& z0 Z, r
- #include <linux/mm.h>
4 K, K! ?1 n1 f6 @/ @$ e - #include <linux/dma-mapping.h>2 a4 C" o* |. B1 n
- $ R% T. ^( W. z! }% H
- #include <mach/memory.h>
) U7 {) a$ U4 R. c* [; X+ i3 f - #include <mach/hardware.h>5 c. l( U+ [: D' z7 W- b: ^
- #include <mach/irqs.h>
( j5 u2 Z. K3 s' Q5 w: D1 q - #include <asm/hardware/edma.h>0 \/ h4 Q0 B/ W8 [6 U
- 5 N8 @6 b* ]7 [+ h% t# P+ R
- #undef EDMA3_DEBUG& w' i2 G( ?' A' Y+ c; W, [, a
- /*#define EDMA3_DEBUG*/
' L0 \: Q% y& n - & S2 E* m: u, S" f @# U4 o, z
- #ifdef EDMA3_DEBUG
* b& u, R0 i% [, B; ~3 d5 ^5 _/ r5 p9 g - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ I2 w- N& w; k& l. l - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
( v# @/ y X5 B% g* | - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( z' p, D2 s8 J
- #else
/ F) K3 |+ m+ ` - #define DMA_PRINTK( x... )
3 ?; \$ t) @" V& ]5 s* `4 Q - #define DMA_FN_IN
, ]7 P0 U! k9 k" M1 x - #define DMA_FN_OUT% ~. P7 S' ]# x x
- #endif
9 Z# q4 G, M a3 E3 U: p" e1 M - & V$ _+ r1 ]( t
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; C$ ~3 ]( ]- T, Y - #define STATIC_SHIFT 3
. A& S' j' T4 r8 } }& ? - #define TCINTEN_SHIFT 205 P, c) N. `$ M- E9 G( K: J$ _
- #define ITCINTEN_SHIFT 21" h8 z3 ?7 q3 H& ?" e* K0 F
- #define TCCHEN_SHIFT 22
7 z! t# f) d& I U9 l - #define ITCCHEN_SHIFT 23* k8 h. l; l) {' T+ c
, t) F2 S/ C! f& y# E, @" U- static volatile int irqraised1 = 0;
3 V9 V3 d4 G4 ]' m - static volatile int irqraised2 = 0;
: O: E8 u- ^$ g5 s' m* O. p( ?+ A - ; \- D: E) \) r I
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( g3 y: u8 ~: X! q) s1 x
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- j. \/ u% W T7 h, r
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, l+ w, Q. Q5 `/ K2 l( P
" p9 x# s& X5 D: z+ \3 c( w. y- dma_addr_t dmaphyssrc1 = 0;5 `, c9 ^9 |0 I5 P M4 m- f$ J) k
- dma_addr_t dmaphyssrc2 = 0;
" a9 r) f# r0 ^5 ?: a - dma_addr_t dmaphysdest1 = 0;: e, m' r Q* G+ T; ]
- dma_addr_t dmaphysdest2 = 0;5 A7 R ?$ D* F+ d$ R
- , ?3 H2 j6 b; {, ~& I
- char *dmabufsrc1 = NULL;8 T, y& _5 L- h- e, Y
- char *dmabufsrc2 = NULL;& M0 c& j3 U8 q) C; J1 J
- char *dmabufdest1 = NULL;
/ o, u7 ^4 J" a# v4 c - char *dmabufdest2 = NULL;& v! R& R$ ^. ^- m+ S
- . y. p# O( f ^7 I$ ^1 O7 O
- static int acnt = 512;
4 Z3 {6 o8 ^5 ?% T6 S# e - static int bcnt = 8;/ Q; x' c- \( b& m& ^
- static int ccnt = 8;* D5 w5 x4 p% J1 D+ h/ X7 b
" g0 B) U5 @& r- module_param(acnt, int, S_IRUGO);
- F( W6 z$ f, K$ s+ C - module_param(bcnt, int, S_IRUGO);
5 q+ r- F- a: R I0 W3 M - module_param(ccnt, int, S_IRUGO);
复制代码 # u, w* \# g: v5 G0 P" {
" D$ H9 I- A" f! E7 I 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用9 D+ M1 U4 D! ?. l' [: q
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。' G3 M0 \/ i+ X
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。& y4 Z6 E- @- c; X# X7 t. x7 `
- J4 }& v( d" D% Y) a& [* ~5 R- g9 U* H
6 B) o+ z8 ` K. C |
|