|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 m7 r4 W8 e# ]$ A+ [! v% b- [code]EDMA sample test application
# V2 q5 ?+ @0 B `, q: \3 y+ R6 y - /*
. ]$ o, L$ p( T - * edma_test.c& a* g8 O7 } {9 q6 u6 _7 D
- *
a2 y0 a/ l0 K - * brief EDMA3 Test Application9 j# g- S6 ?( O, B
- *% w1 A- i' E9 D( |* ~7 J
- * This file contains EDMA3 Test code.
# V$ c0 S8 L) z: G+ s - *# I2 V; W; V: K: Z' k
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE0 I7 J3 ^7 L5 U. z& p
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 P c8 r% ]% [$ m- [ - * TO CHANGE.
L/ [3 E" F `9 s+ M - *
/ O, b. c% ]" w8 Z# [9 N: m. a - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
2 C/ m+ Y; _& A0 ~& r# C - *
# X* Y, {8 U0 }1 I l2 o3 A7 t2 n1 p - * This program is free software; you can redistribute it and/or
8 i n! u. E& D) }% r) [' y" p - * modify it under the terms of the GNU General Public License as. N& W! E% c) r: \8 G3 C: Y
- * published by the Free Software Foundation version 2.
L1 F: B; U' T - *1 [* l& f1 A$ A. k2 h
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
4 ?2 }5 m" j+ f) u" M/ K1 W2 x - * kind, whether express or implied; without even the implied warranty \" U! i/ m+ j* \- x3 l8 H
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4 n# w) Z4 V' |3 R* e3 I+ T - * GNU General Public License for more details.
4 |+ M- A" l) b! e$ |% P' S* k9 o - */ s" ^8 W( \: P& G
- " ^& ^! S- S1 K6 R7 N
- #include <linux/module.h>
4 u, C9 |8 {$ l3 S - #include <linux/init.h>4 {8 p: ?: u b# p6 M$ F
- #include <linux/errno.h>
& n$ h! y& v* N - #include <linux/types.h>) p7 c. P {( Z/ c/ o0 u+ I' p$ u8 I
- #include <linux/interrupt.h>
! }1 q4 ?6 v: \7 v% a5 D- P% b - #include <asm/io.h>
7 B# S5 s6 W$ R! {" f/ { p# H5 V - #include <linux/moduleparam.h>7 t- M" [, a1 D
- #include <linux/sysctl.h>
% f" L! R* l6 y- c/ H: T. {% } - #include <linux/mm.h># |2 d. [5 ]/ f1 a/ M
- #include <linux/dma-mapping.h>8 ^( W$ o# {5 @5 y
- " a5 b- u" p* D; Y3 W# o
- #include <mach/memory.h>' u" |- P! d; M1 ?/ S
- #include <mach/hardware.h>' a% `# }% v) ~" z9 f0 Y, `
- #include <mach/irqs.h>7 F8 l; n5 y5 f v! \
- #include <asm/hardware/edma.h>$ g Q" l5 y- Y, F6 z/ h. |
- : n2 S: t7 q5 e( Q! y# N8 P8 `% o( Q3 o
- #undef EDMA3_DEBUG9 ` q$ v: s1 a8 z* q
- /*#define EDMA3_DEBUG*/8 \4 J, ]0 ^4 X+ K4 M3 v
- 7 O5 m' s3 G$ W* k- L
- #ifdef EDMA3_DEBUG
: i7 ]* q$ {; S' p, H& B2 L - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
0 G6 L: \. Q# S' ?+ i' j% u - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__); I: m; Y {/ c' `* L
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
& r4 [1 X2 i* g& [' L2 S; M# T# N, I# g - #else
/ ?; l5 f6 ?7 O1 F0 |$ e2 Y - #define DMA_PRINTK( x... )
" P a) A( S9 s& z) }9 w - #define DMA_FN_IN3 k, Q8 I! z/ B+ G3 ]4 ?
- #define DMA_FN_OUT
. _) \. a; E s! T \2 j4 P! E - #endif
' p2 E' K' c: `5 r3 z
- F0 V/ x, Z, e5 u* }( t- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
0 k0 w- @$ l1 R3 J( X" { - #define STATIC_SHIFT 3
8 o3 C; B, v2 {3 F; ~. w2 n - #define TCINTEN_SHIFT 20- a O2 Z" i! A. U+ L6 j9 H
- #define ITCINTEN_SHIFT 21
' o* X+ D1 O w" b* I! }$ {2 [ - #define TCCHEN_SHIFT 22
( R9 k; T8 A) {: A7 Q - #define ITCCHEN_SHIFT 239 m1 Y! C4 q1 b9 t# [
- ; ^' s. H' c; h
- static volatile int irqraised1 = 0;, J0 h) k- Z: a" [' o9 {
- static volatile int irqraised2 = 0;
$ ^5 ?9 l2 x/ o" i# L - , s9 K) [/ o( l( Q/ M$ [% v9 T
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 g9 {+ k. ~; m9 k
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, Q0 s9 v8 z! [0 k _1 x% e1 ~5 y - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- X. `" h2 m3 M; e0 E
7 W% m6 a( z, t& |/ v7 z- dma_addr_t dmaphyssrc1 = 0;& v) @) A# C' ~3 w
- dma_addr_t dmaphyssrc2 = 0;6 h8 f- A" ~) M4 }) \8 y
- dma_addr_t dmaphysdest1 = 0;% L- @+ u& [! ~
- dma_addr_t dmaphysdest2 = 0;2 r7 n9 x P1 d; b3 {* `
- % L) F: ^% q2 C4 q) f
- char *dmabufsrc1 = NULL;
9 D) S! v$ i/ @2 L$ Y' y% N - char *dmabufsrc2 = NULL;4 u$ o. D2 l. _
- char *dmabufdest1 = NULL;% a0 L5 ^: O. s- y4 k% m7 ]
- char *dmabufdest2 = NULL;9 ?5 [3 S1 m6 W3 Q! i! A8 D& W/ F5 Y1 ~
! m! y7 X8 l" S1 n/ Z j0 l6 T- static int acnt = 512;2 f. W& |$ E. W5 C1 x; U
- static int bcnt = 8;% J5 }' Q; m! l4 Q* u y
- static int ccnt = 8;* |# i4 Y1 g! z! U$ g* A5 K6 H I
3 n8 u! W9 q$ x8 U/ P( D* y, p- module_param(acnt, int, S_IRUGO);* E; j5 ^% i9 k0 {. ?$ W
- module_param(bcnt, int, S_IRUGO);5 q+ k4 M" j. R' `
- module_param(ccnt, int, S_IRUGO);
复制代码
1 i5 g# w0 J' G* c, _
/ U7 G2 V7 a$ U0 k% f+ F U 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用' e, M! b" z+ \- i4 C2 @# l$ 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。 N0 v& e% t: S' g& u9 L5 J
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。7 H" s' b+ X2 g5 M# Y$ ~( h# A
7 }9 I( y# X1 `. x
4 J% Q& ^' G/ U R. M |
|