|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 * e" g) w& Y! k* s4 V( j* f4 O
- [code]EDMA sample test application
; P% r* O" u, q% { [ - /*
5 I; r+ A4 ]1 {1 N, U6 P - * edma_test.c
# C/ S# l8 M. A" n1 h# @' q: g - *) E* R5 r4 V7 ]. N+ J3 ^) `& Y5 H
- * brief EDMA3 Test Application1 _; n6 P! ~4 g J/ m
- *5 A7 u# y9 y j1 I( g. Z/ G
- * This file contains EDMA3 Test code.! j- [8 h( W! I
- *
2 ^1 q1 `4 K. o! c - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% [( z0 h0 z# _$ v/ H- f- ^/ B - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
8 c0 N, |$ X4 ~5 j - * TO CHANGE.8 v0 W7 P! B/ ~
- *
: O6 _1 C1 L$ k! Q$ M - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/1 r" g0 J A( ~/ I' i# r" T
- *- v. H' n g s- `2 c
- * This program is free software; you can redistribute it and/or4 K( S& }" B }
- * modify it under the terms of the GNU General Public License as% ^. V" O: W0 B9 ^
- * published by the Free Software Foundation version 2.
# f+ ]8 W! [/ m# E7 G - *
. h+ n" \) t5 S# `8 Y R - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
: w6 Y6 x0 `* e3 d, ?4 y8 G+ @% K - * kind, whether express or implied; without even the implied warranty- s- h* p. d$ w. ~8 l
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3 k q% O# c( Z - * GNU General Public License for more details.
7 d/ w6 ~: N7 v; i - */9 y: ]! F3 R: r6 |: n: |; {
1 T% s4 i( Z7 |! h' {$ Z8 u) @1 o- #include <linux/module.h>2 E3 I3 ]! r, t0 V! h4 u
- #include <linux/init.h>
0 c4 b+ p- h, k% x6 ] - #include <linux/errno.h>
9 h; E9 T# S$ p, X - #include <linux/types.h>
6 N8 j( W6 A8 D9 g$ @1 U9 L - #include <linux/interrupt.h>
7 J3 E7 O, \0 D - #include <asm/io.h>: U# ]) B) p. x1 ^/ l4 K; b+ u( V
- #include <linux/moduleparam.h>; W5 G/ L( A+ H* V
- #include <linux/sysctl.h>
: G3 W$ Y( k9 F0 x. d5 } - #include <linux/mm.h>: z5 k) K( S' `& K
- #include <linux/dma-mapping.h>
/ l; D" V. ?. R# i1 I% z# o, [ - % l L2 I7 P+ Y! K/ m& A* R5 ~
- #include <mach/memory.h>
) t @2 g6 k& v3 s' w - #include <mach/hardware.h>
0 ]% l$ H7 r' W9 S* i7 ?0 M - #include <mach/irqs.h>- L0 M$ ^$ P7 G5 `1 S
- #include <asm/hardware/edma.h>
& M$ B0 c2 _" c - $ {4 l3 s3 B* a9 @+ A
- #undef EDMA3_DEBUG- c7 U; i4 p. r+ c S
- /*#define EDMA3_DEBUG*/
% ? x0 t5 g7 r9 K - 7 W T6 X5 u8 F' I, ^1 q0 C' N8 o' n. E: D
- #ifdef EDMA3_DEBUG
8 A0 C% P1 B! ?9 N' S - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)5 a$ J% o# {" R! ^; U
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)' _+ u+ n0 {6 _' C9 I, A. H
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)# o/ b/ x$ `$ @0 R3 r
- #else
0 P# B, R* }. C - #define DMA_PRINTK( x... )
- ]2 u) w: y, B - #define DMA_FN_IN
: S* ~4 F3 F) s9 | - #define DMA_FN_OUT" `: z. j( a; `# C: G' |2 t
- #endif
% C7 ~1 R! e* v9 k
! ` n$ S+ W5 S8 _) M- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 i: a W8 m: E" w7 @ - #define STATIC_SHIFT 3
( p* D0 A8 r! d6 [: u$ T. t' n/ I - #define TCINTEN_SHIFT 20# z! o0 n Z9 a7 \
- #define ITCINTEN_SHIFT 21
! q/ H1 m+ j0 G M+ H% r1 O# X - #define TCCHEN_SHIFT 22, k3 X9 o6 x% H8 K5 M* r; H# S! Q
- #define ITCCHEN_SHIFT 23
C9 K" [. @% p) I9 ]" f0 j - % v# i7 m$ d8 M
- static volatile int irqraised1 = 0;
0 \# E* f+ J! @3 Y, f0 \ - static volatile int irqraised2 = 0;3 Y: w! Q, t5 V
, m6 y: g6 s& r- h- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) N' b/ A. Y2 G, u - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 T, w% e/ [4 K - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 j l1 ?; y' V1 h/ g
- 1 O, A7 [; ~, r' G
- dma_addr_t dmaphyssrc1 = 0;* I* R, ^6 g3 [3 M5 J4 [( y2 ~
- dma_addr_t dmaphyssrc2 = 0;7 } y& L, B( D, J9 M
- dma_addr_t dmaphysdest1 = 0;
- N& @: U) |& d$ U: j9 I! s - dma_addr_t dmaphysdest2 = 0;, H$ x- K& {* U- @
# S3 t! `$ m. c3 |8 G o3 L! `5 W- char *dmabufsrc1 = NULL;
; V+ W# N' V( i - char *dmabufsrc2 = NULL;
9 A) \) q0 z5 {5 h6 L |" b; K - char *dmabufdest1 = NULL;
) n6 z7 \' A: h- I - char *dmabufdest2 = NULL;4 |; q. X& g. f% i. _# M
- 0 |2 g: s( F0 e$ z5 D
- static int acnt = 512; a9 _- S" W* B$ p
- static int bcnt = 8;" I: G$ s% v0 W/ G, S. i& I
- static int ccnt = 8;
: V3 c4 U. c4 l# U - 4 n( R& e/ V6 P( |" y6 ?8 _1 `
- module_param(acnt, int, S_IRUGO);
& X6 M, Y( F3 W& R O - module_param(bcnt, int, S_IRUGO);
" X% `& j' x e8 u! T8 t - module_param(ccnt, int, S_IRUGO);
复制代码
4 w+ B @! }+ i. I3 C. G( z5 f
% e# H( N6 {4 p& B" O" [ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用9 Q3 ~) n F. N/ i+ }* e% v. K. o; x; S
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。. {- j& m% a) D% n+ d+ m6 _1 `
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' I. z2 O% X# V" w* ]+ Y
4 m F" C5 [" Z+ s$ e; w/ T
2 e5 _- f# o- g% S( b1 T |
|