|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
# }) E4 b: {, ?6 w8 P# _0 E- [code]EDMA sample test application7 B- R- a$ X4 \
- /*
Q. h0 ~# N2 F& ? D - * edma_test.c
; B5 `6 ^6 R( {* K* ?$ q - *, X. r- }3 n- p, \( r* y
- * brief EDMA3 Test Application6 ?# ` p7 ]- l! `
- *; w. q+ v A$ N2 j( Q, `& B
- * This file contains EDMA3 Test code.1 k0 Z6 e* y2 N7 A' K6 Q; o
- ** d: F5 U k2 Y' ~3 o1 p' R0 M
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
c/ z+ x* r6 l+ m9 }5 U' w0 u - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
+ q: [" g; M* }% D7 j# \" P1 O - * TO CHANGE.
. M0 U2 A$ I/ R" a5 O- {4 G. B" G! D - *
0 m: w1 T% N3 W - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ U. _+ H \. z0 v% { - *) E K5 q p" f2 C6 J3 F/ J* O$ t
- * This program is free software; you can redistribute it and/or
1 K9 D/ j( ~' W; y, Y) w+ A5 [- P6 Q - * modify it under the terms of the GNU General Public License as
1 M& _# J4 S, A& h4 W! x - * published by the Free Software Foundation version 2.
% T. h% m/ ~5 y: N- ] - *
4 u1 p2 p& M1 p- M* ?0 u }8 W - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
0 e$ t! h& ^ ` - * kind, whether express or implied; without even the implied warranty
6 i: ?( u2 P2 y- c. Y - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the' c+ o' w$ n& Q$ X! `- ]2 L
- * GNU General Public License for more details." o1 X3 C+ @/ L+ x
- */8 I- b, D( l9 M; W8 S. T
- / T5 R1 T6 N! h9 y4 O# J5 e
- #include <linux/module.h>
( w. `& |& M2 e& @ - #include <linux/init.h>
/ h4 E7 m) j2 d# S$ C! t) u8 I% k$ w - #include <linux/errno.h>
: k& R+ w+ g# O: n4 K- p: l( z - #include <linux/types.h>
* \/ R% ?: C5 T3 _4 L, i. x5 g - #include <linux/interrupt.h>% U5 ^2 O. w3 ~) U$ V. ^
- #include <asm/io.h>
2 g9 e$ d4 `7 u5 P - #include <linux/moduleparam.h>
4 {" K9 d- g3 Y) D* @& w) U$ z - #include <linux/sysctl.h>. {2 W1 {# \. I( }, L) n& L- ~4 e
- #include <linux/mm.h>. O5 @1 W: d# [, p2 M7 h+ }9 n- B K" b
- #include <linux/dma-mapping.h>' A' N0 v" {' s( C( P; c
3 A$ }, ?6 h% v+ y& I. W2 h- #include <mach/memory.h>
' a% l, K: z4 I6 b6 N5 I - #include <mach/hardware.h>
& I, K/ X/ J: L8 b- E* k - #include <mach/irqs.h>
; E5 _* v, \3 X9 N8 W' H% v - #include <asm/hardware/edma.h>
, p X0 H% S5 O
( C \, l, E+ e( L. Y* \! q- #undef EDMA3_DEBUG, \0 Q7 A# F" v+ p! b a2 }# a7 H
- /*#define EDMA3_DEBUG*/* _1 r: u. T) m( z: R/ f3 {
8 I0 H1 K" o0 @! |5 @- #ifdef EDMA3_DEBUG P$ ~& s1 w7 I& }) k, Z5 v3 N
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
7 M |% v1 b# w( V; J - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
& ~4 O! h2 E. u& k' | - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__) Q" g0 ~! [3 }5 W& P# z) F$ a8 l
- #else
3 b8 s) k0 _& s: b- x" F9 F - #define DMA_PRINTK( x... )
V* e. k& ]9 @ - #define DMA_FN_IN& c' O; V$ j7 k$ `6 t& o7 ]& \
- #define DMA_FN_OUT
) a; r4 {8 B: J6 }( v/ c - #endif$ I! u6 [/ {; ^, \2 H& M9 q, c
- 7 k( J6 G) v6 G+ D; s
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 x" w3 E1 Q- [( b' L) s7 o - #define STATIC_SHIFT 3
' f0 ^! m& H" _8 c2 b - #define TCINTEN_SHIFT 20
" A7 }. T/ l! I - #define ITCINTEN_SHIFT 218 d5 H: g) Y; j |
- #define TCCHEN_SHIFT 22! w8 I; `# @0 d' {+ |$ G( {
- #define ITCCHEN_SHIFT 23: y+ N9 l- t; ^* n q
& h- L& ^- p( ?) A1 ~8 _- static volatile int irqraised1 = 0;
, F2 c; e; C3 s7 ^+ c - static volatile int irqraised2 = 0;0 Y: `- b/ @' B
, E! X2 c: v% H0 j- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 _, h1 r# z" m6 A
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* w3 H& I j8 T - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' h! h V( U% _2 ?7 m
# w5 B2 f0 b7 z& i- dma_addr_t dmaphyssrc1 = 0;
: I9 I" a. d; O - dma_addr_t dmaphyssrc2 = 0;
( K. ~+ Z! D! S8 R5 m - dma_addr_t dmaphysdest1 = 0;
) l6 Q# p J& n% S. ^, s - dma_addr_t dmaphysdest2 = 0;
0 c a% m) _8 b) q- x1 z, ^/ ~ - 5 B, O) t) v, E# c# n
- char *dmabufsrc1 = NULL;, D+ L! o9 [6 X
- char *dmabufsrc2 = NULL;
! K! }& n: y, y5 q0 X z3 Y. o - char *dmabufdest1 = NULL;0 l9 {: _# G) T: O& Y, g; W1 n
- char *dmabufdest2 = NULL;" w- \1 c. m. g( u/ Z. B
- + S$ p1 E( H: ?$ p) P' T) ]
- static int acnt = 512;
& w B1 _' b) L# ? - static int bcnt = 8;: c; }. o) L, ]) Z- P6 S- _1 @
- static int ccnt = 8;
% e! p k" [4 a% B7 x& e
( [4 a0 A& [) ?2 X1 t- module_param(acnt, int, S_IRUGO);7 V; E" ?# |$ U2 X
- module_param(bcnt, int, S_IRUGO);8 ~3 Z, V8 }5 f! A: c9 L+ I
- module_param(ccnt, int, S_IRUGO);
复制代码 7 {4 V9 B9 R4 D) T1 q! h9 h
& @* H ~( \' i# ?
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
0 Z# y" ?1 L% }5 }1 U: i; earm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。& R$ O, Q; J2 C1 L
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。# i; Y- r5 B$ _2 z ?
" ~+ Z% k3 O v' o) q5 C
3 x# _4 C M# @1 F8 T |
|