|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 4 p$ v$ G- f* L0 T9 {8 j" U
- [code]EDMA sample test application
2 O% m4 j. v3 ~* b& r - /*
& r/ n/ n! C P - * edma_test.c! J+ n* D0 ~6 b( y0 W7 F
- *
! j9 c D6 O! k, B; t - * brief EDMA3 Test Application4 U9 u' H S/ B) \6 X
- *
2 y# u# e0 j( h3 y5 X3 E - * This file contains EDMA3 Test code.$ M: t) g; R2 K
- *
1 l6 I7 B& f% _/ L - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% V( F( u" b- F - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% G+ A2 \; x, j1 R ]6 C6 h* ? - * TO CHANGE.
7 c" w- {) e" G7 A/ U0 D - *1 o/ B3 P8 N( u/ \$ u" c1 o+ ?
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/4 K7 j" f4 _0 f9 h2 u9 x2 M
- *
) T$ t1 y) s' \0 m/ b7 I$ Q7 M" e - * This program is free software; you can redistribute it and/or- _2 J. m& p& S5 O0 L
- * modify it under the terms of the GNU General Public License as" W: R; T6 B+ q) v% c
- * published by the Free Software Foundation version 2.
2 f7 k7 d/ R, }7 @& x# U/ H - *3 j% w3 P) K) c3 T8 [
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; x; f! E# s( U4 n5 X# t1 Z - * kind, whether express or implied; without even the implied warranty0 v" d+ F3 r7 w' U2 X
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) t2 F( }% h& p+ m - * GNU General Public License for more details.. u6 P* n. N; ]6 s; I# ^' D
- */ ?+ [8 C3 O# y1 _5 A/ Y$ B
- $ S7 I$ z1 i! m8 C
- #include <linux/module.h>2 l u* z3 s4 u$ _
- #include <linux/init.h>) w( m/ w: y0 K3 {
- #include <linux/errno.h>
8 ] d. P! a, g+ h7 e5 X - #include <linux/types.h>
0 y! V1 B1 Z: e( f8 ^ - #include <linux/interrupt.h>
5 l7 b& E$ F) [' e# Y2 { - #include <asm/io.h>, F5 w3 Q& \9 \- Z6 [0 t
- #include <linux/moduleparam.h>8 z% T7 B7 _& M$ E, M
- #include <linux/sysctl.h>9 c6 ~( D% _" z- y% [
- #include <linux/mm.h>( {- b2 E: ?* R! V
- #include <linux/dma-mapping.h>
2 `- I, }8 X& L) b4 S - % w2 {# W9 g/ P$ \2 B0 e* y- ~4 ~
- #include <mach/memory.h>
: R+ n* J/ J; ?1 q3 L" c; x, ] - #include <mach/hardware.h>
$ h4 ?% T$ v; R4 T; Q5 N! X1 G - #include <mach/irqs.h>/ `: B8 f6 O! J- Q+ f$ U
- #include <asm/hardware/edma.h>
$ q5 Y6 V! O, y: J& q7 S" w
V( }. l# O% N1 m1 i- #undef EDMA3_DEBUG
1 d. N. f; e; x8 Y# s - /*#define EDMA3_DEBUG*/
3 W3 a' s. o, c - 6 J+ G8 K1 t7 [1 Q- k$ V
- #ifdef EDMA3_DEBUG7 \% C* V4 e6 R3 m% L. I
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ X. a0 R |9 X- e* p: r - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 l6 f+ d: V1 W8 h# T( H - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)/ p( U$ G5 e1 ?0 v( U5 w
- #else
, t9 S2 g8 e4 _/ y: C - #define DMA_PRINTK( x... )& N/ o# S% |2 @1 Q
- #define DMA_FN_IN- \4 x4 i1 t( o/ @0 J o
- #define DMA_FN_OUT: z5 a- B; i6 U t5 ]
- #endif
+ m; r4 D/ [& R& C' T. a
7 S4 e6 h" f* N- n* s. [7 a6 u- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
' T/ @- _- U; K; N! ]+ Q - #define STATIC_SHIFT 3; N* D: y7 R2 B# c/ R, Q
- #define TCINTEN_SHIFT 20
- D3 C! R1 \ F7 F5 f: X9 `% n - #define ITCINTEN_SHIFT 21
: y- W5 q( V, U, W- T& D- k - #define TCCHEN_SHIFT 22- w# I& Y3 m3 P& m
- #define ITCCHEN_SHIFT 235 R) | V T E L k
0 C, S% m4 d1 E I- static volatile int irqraised1 = 0;
! r8 t: x3 G1 m* D: X e - static volatile int irqraised2 = 0;* k! x! ~/ p+ G
- 3 v! q5 b* p* p0 c% y6 E; I
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 I( e) U; o7 C& W - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' Y4 S( \8 C' r1 X3 q l. J+ h - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 ^8 |. C0 P4 c( S
- 0 c! P' H/ F4 L8 j
- dma_addr_t dmaphyssrc1 = 0;
+ Y+ q, y6 V. K' q: M7 n* ~1 T - dma_addr_t dmaphyssrc2 = 0;# P6 g( a2 J& f+ U* E! o
- dma_addr_t dmaphysdest1 = 0;& j6 F b+ v O7 s' D, O
- dma_addr_t dmaphysdest2 = 0;
1 o, _8 h1 x( W% u) ^6 Z5 ]* T - 5 ^3 G1 T. W* g, r! h8 J% P ?
- char *dmabufsrc1 = NULL;
+ @/ [; ~) _5 x5 `: D4 S P - char *dmabufsrc2 = NULL;
3 g8 e* @1 j" R3 v - char *dmabufdest1 = NULL;; }% u; W- C3 L- z
- char *dmabufdest2 = NULL;
0 g/ A; |8 p) Z. Z" P - # R. r9 f o4 {+ S F
- static int acnt = 512;! @# i0 g N" R3 r2 o. @
- static int bcnt = 8;
+ J0 d& j! R* U. v9 q" C - static int ccnt = 8;; H; b7 c7 S, U$ q t# m) w: {
- 1 T' J1 J7 A9 y( B2 d
- module_param(acnt, int, S_IRUGO);& p$ c8 W* Z, ?6 G% Y3 V0 m
- module_param(bcnt, int, S_IRUGO);
) f1 E2 I7 s% F% [ - module_param(ccnt, int, S_IRUGO);
复制代码 , Z# R* F) }1 ~3 y/ @& I
5 Y- q( j. a* D8 ?; G 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用8 @7 K/ ?+ W+ ?; N& |
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。1 {7 C& m6 N7 |* z) y5 a2 N! ~
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
$ F! M0 I2 i t& i% S' s! {& c5 A8 z4 b0 Z) n) |2 Y3 S' d
2 |# R8 v3 B& p$ V2 w8 K$ d1 X
|
|