|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 D0 _: b; h+ D. K/ ~2 ~, Q; I- [code]EDMA sample test application
6 x' t" u3 H- x8 I0 A' ` - /*
8 l; @# M1 E, z% Y8 h6 N6 Q - * edma_test.c" `! i6 B; t" {3 N# ]/ W
- *- h1 k" S9 p! f6 o8 R [7 \9 I+ Y
- * brief EDMA3 Test Application2 F, Y3 M/ t3 A+ @, g" a* J- c
- *% A: O" h$ X- |: y, O
- * This file contains EDMA3 Test code.7 @. \! C6 j4 B* ^
- *3 W5 s, j9 h9 d
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
/ O& V% _9 B& p& E9 {; G - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 k+ D L. H# T. K7 d* ^( P
- * TO CHANGE.
. l! n! t N6 k& ?. s - *4 j% _% l1 h5 ~/ Y4 R
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
# S( F/ B0 b) m1 I! [: B1 t - *5 ]4 `: `% q" t( i0 J4 i
- * This program is free software; you can redistribute it and/or# X; d; ?" x& i& v
- * modify it under the terms of the GNU General Public License as
; B8 ?% W7 T9 y - * published by the Free Software Foundation version 2.
; F4 K# J8 H. }6 b% f - *$ |1 e M2 t: o" R
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any9 b" k. w, u. g8 s/ _6 H9 J; f
- * kind, whether express or implied; without even the implied warranty
" e2 Y* C5 T: N5 v+ l2 r9 I - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2 B( `9 G1 ~% U3 s: u0 U - * GNU General Public License for more details.2 q7 u9 Y7 C+ Z: p- ^9 [$ X7 `
- */; |; w# H+ Y/ t5 K( i6 b# F
2 i8 f. c0 c& G) p- _( U- #include <linux/module.h>/ |/ F& P) z0 X9 ?3 |/ B" Y$ h
- #include <linux/init.h>) c' } a- r/ X E* ^% P
- #include <linux/errno.h>8 e( g8 b L+ v6 a, R8 s: A# {- ~% J
- #include <linux/types.h>
0 k* t. L+ k2 Q1 o9 t - #include <linux/interrupt.h> C7 X7 s. j2 ~, F0 M# R4 v
- #include <asm/io.h>
. R; Q4 n4 d0 ^* K( V - #include <linux/moduleparam.h>9 m; h) F7 C. o% c' m( U- W' l, v
- #include <linux/sysctl.h>( o) c4 j* J: Q7 }
- #include <linux/mm.h>
! o8 Z5 P9 P& ^0 @ - #include <linux/dma-mapping.h>
! M/ I- \( \& i1 o4 m( u. V( ~ - ) F* y9 O9 B n7 |3 Y- l
- #include <mach/memory.h>
) V! O0 Z+ }" j" k9 c. S - #include <mach/hardware.h>
3 N7 n p4 t$ J5 g5 |# [" G - #include <mach/irqs.h>5 a& P7 p& z2 Q4 I- b( h1 b* i
- #include <asm/hardware/edma.h>1 l F9 d; X( b9 H2 P a
- - i% t" d. e" ~3 k
- #undef EDMA3_DEBUG
5 D1 U2 q% ~ }9 r9 |& j - /*#define EDMA3_DEBUG*/! c- ~1 N# Z1 h" C8 _* x
$ ^) _ P' r1 n+ _. x- #ifdef EDMA3_DEBUG
) b3 @5 U0 q5 x' v0 `9 n2 t2 ? - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
' k. C% m) m8 g - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)7 z9 R+ i/ z$ J& H4 O' |9 R
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 ~+ `9 S( I; y9 z7 ^
- #else- e" \0 r& O. W* \
- #define DMA_PRINTK( x... )
: b3 l4 ]3 c' n4 r: b9 j+ E# s - #define DMA_FN_IN
+ o" V6 _/ @% `3 h( L8 ^* n& s - #define DMA_FN_OUT
6 S* T Z1 t) b) k( |5 q) p - #endif+ G* Q: r: y0 c, \8 G
& E5 o9 e4 B6 q% H- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 o5 ?; T/ {3 O - #define STATIC_SHIFT 3
. j2 M5 ^! k$ O" ] K) A! X0 A" U - #define TCINTEN_SHIFT 20. F' d' K$ X _
- #define ITCINTEN_SHIFT 21! F! H! p* X j7 F2 w/ M
- #define TCCHEN_SHIFT 22
6 A: e( y+ l- |/ z3 z - #define ITCCHEN_SHIFT 23
4 G/ B0 f, \* E3 U" W0 { - ( P9 N5 ^( s' m5 `; ^& [% u
- static volatile int irqraised1 = 0;* D, C' ], T8 }3 A( f* S0 D
- static volatile int irqraised2 = 0;
+ L3 \! [- q: n9 K
G: y, b5 U6 s- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ o2 [7 o9 J* Z9 w+ c# t' { - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
@8 t* `3 H/ ^0 f V$ s - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 Y4 g* p" e$ p- J7 n - 6 X" r- t; t' v4 a7 y+ H
- dma_addr_t dmaphyssrc1 = 0;
- S' H' M M$ p, V5 E& Z" Q - dma_addr_t dmaphyssrc2 = 0;/ u/ E! B9 {1 g1 B% X: P
- dma_addr_t dmaphysdest1 = 0;- P% f) Y7 G8 _# {- m$ [4 |% r
- dma_addr_t dmaphysdest2 = 0;
4 `/ W8 k$ _* o8 n5 E. g2 ?0 U V) D- @ - 0 V! B0 G3 p; u3 ~% v
- char *dmabufsrc1 = NULL;$ {. A* T; ?; w+ l, Z6 B T! ]
- char *dmabufsrc2 = NULL;
, h" x' _& S9 K# ?: Q( ]. e - char *dmabufdest1 = NULL;9 Y9 y' W* s" j, q; |$ F
- char *dmabufdest2 = NULL;3 j: s' a8 [. b0 U1 W
2 b$ n$ u7 W! n3 p. Z4 q- static int acnt = 512;
4 h3 }& }$ s. K; v c1 x - static int bcnt = 8;- j' P. f& r/ y- X9 D0 R* |9 ?
- static int ccnt = 8;" z* P: V" Y" C% ?% L. @3 n2 z7 X* f
& ^) T; D* P* o# f/ H- module_param(acnt, int, S_IRUGO);
0 x$ e6 O7 S7 F7 R- j. @ - module_param(bcnt, int, S_IRUGO);4 N; y; `; E& L. ~0 W4 R
- module_param(ccnt, int, S_IRUGO);
复制代码 , k8 C Z9 j7 y
! j% `; z# I7 H' H# l* q
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用; F9 n* b+ q6 d+ }1 X$ P0 ]1 A. E: L/ 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
; ^9 l x) W: E* o* _ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。7 ^( a. g, p9 `0 W8 c4 w
, t9 ^0 F Q1 r5 g
+ u# X0 k+ z+ O2 \& y |
|