|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 - H' a$ g- u, x) m
- [code]EDMA sample test application
6 n; S& o% y) l ? - /*
" S6 m4 [) L* M/ s - * edma_test.c
& g4 b# @; f/ Z; w6 X - *
) {2 B4 G2 i6 q6 _ - * brief EDMA3 Test Application
9 H/ @% [$ B5 X - *
' t! L9 J- A0 s - * This file contains EDMA3 Test code.
7 ~4 }! \& a6 v! ^ - *: h& {" ^' ~' e' h' T4 p+ `" s" { w
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
9 Z- F0 |* _+ T* n3 ? - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% J0 l5 |$ Y- C2 W9 k
- * TO CHANGE.
8 A5 U) z% y, x - *; ~; k+ K& x) M; a; e2 S u5 q
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* Z4 l! ? ?$ q+ R6 |. U - *, V; R+ D" r) ~( S& p
- * This program is free software; you can redistribute it and/or9 o5 f. L( x: |& Y+ U3 h+ u
- * modify it under the terms of the GNU General Public License as
" X8 c" u8 f0 O/ Q2 r3 f h7 I) q - * published by the Free Software Foundation version 2.# k; l& Y% }/ @! c
- *0 y1 m" P$ H% a
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
* _* `1 T2 r3 O5 C, h - * kind, whether express or implied; without even the implied warranty
F2 B7 F5 w. o0 b - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ @4 {! b1 v% l% p - * GNU General Public License for more details." |! V$ V$ R5 k" X0 j# K
- */( m& U# G! ^1 f* ?2 C* W
+ v: Y4 o. d3 v( E# x7 K- #include <linux/module.h>2 H6 s5 p; x5 x6 q
- #include <linux/init.h>
/ }+ R1 P s1 U6 l4 G - #include <linux/errno.h>7 `5 E- i. s7 `
- #include <linux/types.h>
7 M% ]! ~5 B; w" V - #include <linux/interrupt.h>
/ M: E. [( ^, F& ]8 F* C( }! R - #include <asm/io.h>5 p7 p0 h9 m, {" M4 w/ |
- #include <linux/moduleparam.h>
2 a0 n2 C4 O% c - #include <linux/sysctl.h>( n/ m6 k; [2 c$ {4 O4 _( ^; V
- #include <linux/mm.h>. N3 m; O& M) F8 T0 |' V
- #include <linux/dma-mapping.h>0 h$ U# h3 G+ e+ k
! @5 f9 x% d; H; D( k4 T' ]0 d& y- #include <mach/memory.h>* X5 I& o; j3 C4 ?
- #include <mach/hardware.h>
: w U6 w( h6 Z, c' m0 d - #include <mach/irqs.h>" S5 f9 `" _6 j) t; n3 t# @5 X- B
- #include <asm/hardware/edma.h>
, t* X+ h; r9 U5 w9 n! H+ C; z6 `
6 g/ z) k! e; r- #undef EDMA3_DEBUG
# y9 Z$ y/ R3 j0 p" {1 W1 C7 @ - /*#define EDMA3_DEBUG*/
8 X: b& B/ n4 H0 Q8 s6 b0 |
/ E$ Q; v: H! G, M1 d l- #ifdef EDMA3_DEBUG/ u1 r. S4 T+ e, S" _9 m9 n
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
4 s+ w- }8 a( G* l - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
* I! r0 _) C! i - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ ], [, M- }7 y: U - #else
, E" {& i# _0 ?3 O( N- ~, M& T; J - #define DMA_PRINTK( x... )
6 B% Z; b: S" j" U i( A4 m - #define DMA_FN_IN" k0 {+ e' O H; r9 @1 T
- #define DMA_FN_OUT
2 `2 T2 k' }7 Y* J - #endif
6 k4 M& X! m4 F7 d+ K3 N% v - 0 Q- n+ m3 T/ u5 J$ N$ y
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 y/ x2 j+ V8 C( S( \1 R. l5 @" I - #define STATIC_SHIFT 37 O# f% F$ } m; ]0 x( g
- #define TCINTEN_SHIFT 20
. m4 p: L) G' w* q4 v. m - #define ITCINTEN_SHIFT 21) Q: X5 L2 I: ~# {8 I+ N
- #define TCCHEN_SHIFT 22/ `) K: I8 d/ j. |% G
- #define ITCCHEN_SHIFT 23! z7 K6 k- ?8 j& K
- * z% P' O7 P( k @2 t3 k
- static volatile int irqraised1 = 0;
0 P' Z; |& a6 A( e - static volatile int irqraised2 = 0;
% M" l. \# ]5 P' U - . j) k/ l8 \" i! d( c9 k
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: J% E' G4 q! }- A8 L; n s( u - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# z$ M, x. i7 f - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; @7 P4 B* z# j T8 b7 c% G! @ - " A. s4 C, W% i* o
- dma_addr_t dmaphyssrc1 = 0;
: }; Z9 J+ Q; V2 o' Z4 Y* f - dma_addr_t dmaphyssrc2 = 0;
+ l" T: L9 u, V- K! N! j4 _+ [ - dma_addr_t dmaphysdest1 = 0;
1 n8 F0 S7 [; n" `) n% F1 x' ` - dma_addr_t dmaphysdest2 = 0;
# | d# E4 E! T. ]& Z; W
8 v& u# }- G0 o# o; Y/ g- char *dmabufsrc1 = NULL;
6 m' x3 @( k6 n0 Z. y, U$ S& B0 e( K3 T - char *dmabufsrc2 = NULL;* K- T. x# \8 O/ _6 ?, n- U9 p0 v
- char *dmabufdest1 = NULL;, i: C L" a q* f7 p
- char *dmabufdest2 = NULL;3 Q; Z6 D! J- \: T [
8 Q/ X8 k9 r2 Q# r* y# q0 X) Y- static int acnt = 512;
5 {4 S9 m& f- V% P4 t' \" ]$ \3 B9 V; X - static int bcnt = 8;! @7 f" j2 S* l' {6 l& T
- static int ccnt = 8;
, d8 n7 O2 n/ R/ q0 f a
x4 n. N+ X' ^- G- module_param(acnt, int, S_IRUGO);3 G, E5 ~, m6 J7 x/ R% P* `
- module_param(bcnt, int, S_IRUGO);* ~6 c x4 L* A3 p! b
- module_param(ccnt, int, S_IRUGO);
复制代码 - r. I* \( e' C; u. r0 S: W
1 n- ^: K. {" R
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
2 t0 O! c {5 [5 a7 }! e6 Tarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
7 E* Z8 n2 V& o3 K 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
* ]) w+ Y0 T0 s6 u9 c& Y2 L" E
! {" Q% l$ J% D$ _4 \7 r! V
" B6 h3 i& c# s, }$ { |
|