|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( m) ~) z+ C$ O s& _3 I2 G" L0 s- [code]EDMA sample test application
' f( O) k% I3 a' B2 Y. e - /*. a' H% @0 v0 }: r
- * edma_test.c
* M# y- `- D K0 k' X* n - *
- E& K# a! g u' R' A$ p$ m - * brief EDMA3 Test Application& I; H+ z8 m6 p% J5 y5 J0 [- V6 ?
- *
& d0 }9 p J; T1 |0 a - * This file contains EDMA3 Test code.1 }6 |% Q' {8 z, e% f- ~+ _
- *
3 R+ k- m9 C4 }; {9 \ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" r; @3 Y3 y$ C( J" S2 U4 H" n
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT8 F: h6 i) f; ] y% Z1 F
- * TO CHANGE.
0 l* S7 Z' B9 v& f - *- g1 Y! b" t$ u5 w7 M# ~, ]
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/3 y# A: _4 K0 Q8 q) ~) G Z
- *( v3 D+ ~* T& c% R
- * This program is free software; you can redistribute it and/or7 {1 ^7 [9 e! _6 s- i
- * modify it under the terms of the GNU General Public License as
( N1 v C" a! ~ - * published by the Free Software Foundation version 2.5 m$ N7 W( E4 X# v& h* [) {1 w
- *
3 f# A" [% Z I) ]8 m8 j - * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 m! [' Q& ~4 s* L
- * kind, whether express or implied; without even the implied warranty
& g9 Q) `5 E5 A - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- r; J! c( q9 I0 ]' H9 ^! z - * GNU General Public License for more details.1 |$ u1 P- {. x4 S+ `' {6 q$ o: b
- */
4 j6 v# K {: a% _
! s8 H9 @2 _6 m8 g o- #include <linux/module.h>; v% d! s) q- r9 E
- #include <linux/init.h>/ N. [5 J4 ~( u1 C O
- #include <linux/errno.h>
* B- {) Q. N3 p - #include <linux/types.h>& ?7 T+ ]2 f1 I+ T6 U; z
- #include <linux/interrupt.h>3 ?! G' j) Z- [: r
- #include <asm/io.h>5 i9 ^( m* A* W3 R, W* B
- #include <linux/moduleparam.h>6 z5 D4 @7 G4 o9 O1 V- y- s/ _: u
- #include <linux/sysctl.h>
# E/ j3 H* o3 [9 A6 R - #include <linux/mm.h>
. E$ J7 p. M& G( x# L i3 l6 _ - #include <linux/dma-mapping.h>
( ~& ^8 H1 ? ]9 ~7 A - : g! I V }, ?6 k. j! y) \; y
- #include <mach/memory.h>! q R# z" ~8 s- K/ V
- #include <mach/hardware.h> L* E. u; M- Y* W
- #include <mach/irqs.h>
2 S% U+ l# f6 I5 `3 D5 F - #include <asm/hardware/edma.h>9 x0 n2 d7 E- L" ~9 _. [- g
- & i- D0 q# _' ]8 W$ Q
- #undef EDMA3_DEBUG/ E* F% m6 X3 X+ x, n( n0 @/ j5 f
- /*#define EDMA3_DEBUG*/
+ l, J0 O' t" F3 N% k
2 Z- J# I; U0 D: J% [" d- #ifdef EDMA3_DEBUG+ o4 }3 Q' n# y# R; ]
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)6 [7 T" Z9 a9 Z
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)) o9 e* U7 b8 F) _" ~2 k
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
( {5 B/ D! b0 b2 o, X* v - #else
( T( Y% U2 ~4 f3 X+ A - #define DMA_PRINTK( x... )" `. m6 n: v' w7 u1 w, j
- #define DMA_FN_IN8 q( p9 F4 C' |+ _/ q+ m$ e: {
- #define DMA_FN_OUT, b7 h8 c: L/ N
- #endif
& s" y r& b. ` - / m/ b8 C6 a. G9 Q; Z
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
1 L/ b8 Y# u$ l6 O4 n. n; L$ i - #define STATIC_SHIFT 3* }0 n* R9 h$ ~* k6 x
- #define TCINTEN_SHIFT 20
% f# _6 A! u/ ~! F - #define ITCINTEN_SHIFT 21% N8 b- E+ Z b
- #define TCCHEN_SHIFT 22
8 N8 l, J) o. f: T8 L v; D - #define ITCCHEN_SHIFT 23# o5 k8 K2 x; y
6 |* \: N0 g. o2 t: z( Y- static volatile int irqraised1 = 0;1 }) A. V6 ]' C8 J; S$ v9 h
- static volatile int irqraised2 = 0;: Z3 p! a ]5 ?2 H. h/ m& E
4 t1 H! z+ \+ R. \) n ~- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* i. K, q' E' z T, M" T! T
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, l' a( h# T, d* f3 T$ a - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% |; M* ?1 `5 p9 j' \- \, J
; @! y$ K+ L# p- dma_addr_t dmaphyssrc1 = 0;1 J# o1 n" R/ _% o" Q
- dma_addr_t dmaphyssrc2 = 0;
# ~) k* t( x, f+ H% E - dma_addr_t dmaphysdest1 = 0;: T+ o3 x" F3 k
- dma_addr_t dmaphysdest2 = 0;
( S' L2 O, x9 ]( l G) w - " j- A: Z+ u2 v! I& g3 z3 Q+ g
- char *dmabufsrc1 = NULL;
" r6 j& R1 I8 n7 P( P% o5 J" L( H% J - char *dmabufsrc2 = NULL;
- j8 e- e( x* r+ N L - char *dmabufdest1 = NULL;5 [, s+ o) V+ d! Q% f7 B
- char *dmabufdest2 = NULL;
6 V* ]. k1 U, s, i- ] - & z2 G& D) a$ f0 ^/ i3 B" {4 ^
- static int acnt = 512;
8 e. t& F2 I0 O9 C. h - static int bcnt = 8;8 B5 @! K m* a8 O
- static int ccnt = 8;9 e5 @+ g# j8 E! ?2 L
- 8 q: `5 x0 j* B# N0 Y1 C
- module_param(acnt, int, S_IRUGO);9 R' k; f' P! G# n) I
- module_param(bcnt, int, S_IRUGO);
& L" E) x# L( X3 O( A - module_param(ccnt, int, S_IRUGO);
复制代码 1 a/ N2 I9 ?$ J# |$ x
* t" \) m3 G0 _/ q 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 ]- Y3 P/ _/ y; V: \- Rarm-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& p) @3 L0 q5 p/ p C 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: o4 \5 g0 q i5 Z8 I# }6 x9 k
2 u" ^" H9 i* J/ u l
# h% P8 q+ v+ \+ L |
|