|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ) m0 l2 p' Y2 b8 V5 f
- [code]EDMA sample test application
* d* Z4 i0 x6 f* J - /*" K6 e: X2 b' J1 B9 B0 K7 s1 ~
- * edma_test.c
1 X0 D0 x3 d' v7 p - *
% U1 K/ k Q2 |& C - * brief EDMA3 Test Application* C o6 S& b5 V Q, b
- *
1 W0 b# e: G/ x$ m4 z! L# T1 [# F - * This file contains EDMA3 Test code.0 L H1 z( L* H' E2 |) R( g
- *& J5 L! Z+ [1 `$ K, X# E
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE+ n3 F7 @! c* @' u; |+ ?7 H
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
4 p$ K" ?% o6 ~$ }/ Z - * TO CHANGE.* x# Q9 j) j+ |8 E" R
- */ g, ]7 J6 {# v: ~
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 M# O( _1 z- h - *) F! I ?8 p' Q; v
- * This program is free software; you can redistribute it and/or
/ ?9 r4 C# L" Q& ] - * modify it under the terms of the GNU General Public License as
" s0 G- |1 }6 d2 A3 c8 `- G& D6 j - * published by the Free Software Foundation version 2.
3 y4 `2 }: Y$ Q j( a2 q' O V - *
+ t6 W& C- [. L* m9 ?3 E - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
* W) X" X" H- v8 X+ P - * kind, whether express or implied; without even the implied warranty7 n% I, m0 x! {4 q! Y9 r
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ \* }1 w: I7 F! M - * GNU General Public License for more details.# Q/ B0 g( |3 W7 F2 c q% p% `
- */
" n/ U% B8 X3 [- ^6 G - % G T8 _9 Q, U7 `8 V
- #include <linux/module.h>3 x! @- ]- w f D
- #include <linux/init.h>
, g4 z7 Q @+ \; O( B - #include <linux/errno.h>$ {$ u! k- `& h; c: @. g/ }8 x" v
- #include <linux/types.h>
/ U9 `) P1 W @% ` - #include <linux/interrupt.h>( {! T- }) r; h7 m W4 F
- #include <asm/io.h>% l. E4 a5 C: J& P' Z L
- #include <linux/moduleparam.h>
- a, W+ {& Z; V) p( \ - #include <linux/sysctl.h>
6 c$ ^" Z0 T/ v4 F8 R& b" O - #include <linux/mm.h># [+ Q1 P+ Q, ^7 y: r
- #include <linux/dma-mapping.h>
# ?/ M6 U* z( d3 H
0 E0 {; @- p8 G- o0 b' A; [- #include <mach/memory.h>9 K. I5 I3 O$ ]# f& S6 d
- #include <mach/hardware.h>
: L- i* A! H# e) o- f - #include <mach/irqs.h>% _* j! p. D9 _3 j: B
- #include <asm/hardware/edma.h>+ Q5 T1 h- U: [9 x! x5 d* \
" t* z) N+ I& H4 r- #undef EDMA3_DEBUG
: N' `$ m: Z- ]. p+ R% D - /*#define EDMA3_DEBUG*/
' ^2 s* y3 \* Z5 T& o
/ a- d3 `( q1 a! Y- #ifdef EDMA3_DEBUG: m: O9 s, e* P# e+ S
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" L0 a& X% U/ }9 D) W' w
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)3 p. H" u" }2 m4 B
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
* |2 W& V S% F! r) D q9 y - #else
2 I4 i1 N6 I4 g% ?, `- q - #define DMA_PRINTK( x... )7 c. f: X Q! `, X4 l
- #define DMA_FN_IN2 ^ A3 l- P/ ^
- #define DMA_FN_OUT1 f! t2 H# R1 r7 ^, C
- #endif2 D* w" N+ I8 {& ?& @/ D" w9 m% F
& u7 q+ [& N' S" O7 j' R, W- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
& ^6 Z6 n/ z1 s& a6 \! j - #define STATIC_SHIFT 3! Z) H9 G4 [* x& E, B. h8 z4 E2 R
- #define TCINTEN_SHIFT 205 b5 c9 [# @& E0 ]5 w3 s
- #define ITCINTEN_SHIFT 213 @/ M! T3 p; I1 d. n
- #define TCCHEN_SHIFT 221 @ a# x4 J. n2 a9 b
- #define ITCCHEN_SHIFT 239 H3 f O: e3 b; k6 m: O8 u
9 J) R! W' q8 R( w. R: q X- static volatile int irqraised1 = 0;9 g! a) I8 R) T: ~. V: r8 j2 z1 D) Q
- static volatile int irqraised2 = 0;
- e( a. O% a3 i, m- a3 l$ [
7 p1 t5 O# k: y6 Z0 d3 V- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' u6 p7 n8 W( v( K2 I
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) D# e' d# n8 x/ a
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& S: P/ `" j; q5 [! `( f
- / M6 h; l [- n# i8 i9 n
- dma_addr_t dmaphyssrc1 = 0;
# {0 @& h, G3 ? - dma_addr_t dmaphyssrc2 = 0;+ n% i4 j5 E f. r' v4 h! M) P' n
- dma_addr_t dmaphysdest1 = 0; t% K+ `4 C9 H- `6 z% |
- dma_addr_t dmaphysdest2 = 0;
7 V* B( d" Z8 {+ ~- l3 [" |
4 Y* _# e/ q5 v" J) p- c8 B) t3 H- char *dmabufsrc1 = NULL;. t, N) A. z+ [# H
- char *dmabufsrc2 = NULL;
8 c& K- k: S, C9 C9 O5 j9 v - char *dmabufdest1 = NULL;2 i: j8 Y% @8 M- w, z- y
- char *dmabufdest2 = NULL;6 c( G: r$ {! N2 e% J
- ' y/ n. b* ~- J. x+ [ Y1 F
- static int acnt = 512;% D1 l0 R; W: O1 ^- c3 f: s
- static int bcnt = 8;2 I* b& @$ J) c- F
- static int ccnt = 8;
! Y; U+ x7 i$ W/ l" | - 4 ]4 U8 g/ _5 l+ B
- module_param(acnt, int, S_IRUGO);
9 Y1 p" S7 w3 R& ^3 C# e c - module_param(bcnt, int, S_IRUGO);0 j1 C6 Q! {. D& _, Z6 w& l& ~+ ^
- module_param(ccnt, int, S_IRUGO);
复制代码
' h: V( E5 f6 @; A' a9 x. A1 ^+ s* F) L$ ~& U8 h& F+ Q r# _+ {8 O
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用1 A; Q% Y2 N4 X" g
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. v' N* m) X2 X7 W* U
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
; s4 y0 |" G! L# r; X. b: l1 [2 c2 W0 r/ v
: I- e e5 t; n9 a! D: D
|
|