|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 6 l; s0 I7 O8 G0 f% R3 M. E
- [code]EDMA sample test application
) p- a$ z+ U% \0 { - /*
6 B" B; J; y/ T! n2 {2 M9 K& C - * edma_test.c
/ j6 \# D8 ] Z3 S) O5 Y - *
7 k1 t- i$ C# {; ^" A1 a - * brief EDMA3 Test Application! b: e% k( O/ {# t1 j- ?8 t+ g
- *# I c( p& W x0 F! Y
- * This file contains EDMA3 Test code.
$ t6 x. y% u- a3 }9 ?4 [ - *
, p0 B: U' v, w3 I9 @; q3 Z. }0 y - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE. a6 d7 B3 K- r# C+ M
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT9 I4 t* @8 x5 M! r2 j
- * TO CHANGE.
/ H( ]: W; l6 K/ o! l5 l# j - ** y# Y/ w2 G" m. K
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; P, W9 e0 g, O: C
- *
' i. u0 G1 ]/ I6 Y7 K5 P7 G) Z+ g - * This program is free software; you can redistribute it and/or
1 z n- V. E6 E" h4 c3 j - * modify it under the terms of the GNU General Public License as
6 ?. o: g( w0 F" P& W" a - * published by the Free Software Foundation version 2.
: |2 U: G3 Q5 @! s& p% |2 X - *
2 H1 O+ ^- R# C5 O; T$ x - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
4 F: v& _1 z( T6 [ - * kind, whether express or implied; without even the implied warranty
' c4 E$ h# ~* e" W: y" \ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
. n% p) i- Q; ?+ S! { - * GNU General Public License for more details.
4 l& Z2 I5 L4 h4 l/ X0 N; h - */
) V8 Q8 Q6 C! v" \2 z - ) [# ]( C. P, c5 `
- #include <linux/module.h>
8 {2 e0 w* ]8 B6 z - #include <linux/init.h>/ J1 C& `) l2 {9 ]
- #include <linux/errno.h>4 [3 P8 @1 M( x+ u0 R1 z- e" |
- #include <linux/types.h>
4 V2 W$ N$ _6 n N& K - #include <linux/interrupt.h>
% N: R7 h! f; m% x- w - #include <asm/io.h>) Q3 a9 s5 l2 o1 b2 n6 N
- #include <linux/moduleparam.h>
# p0 p1 B+ ?4 d# J/ H" ~5 w - #include <linux/sysctl.h>
$ q/ |2 c, x: T7 b" ]( S& { - #include <linux/mm.h>
7 u1 g! |# E+ u+ W# l - #include <linux/dma-mapping.h>
o* t: B- s5 t" d
& H) L' I9 k' s8 U. x7 S- #include <mach/memory.h>
8 y, C4 j. o8 f+ z - #include <mach/hardware.h>! B1 w+ t! j5 F1 ~" V! B; t) f& S
- #include <mach/irqs.h>
+ ?# t* M, C5 N - #include <asm/hardware/edma.h>0 y2 S8 A6 @! q5 U+ Z
- 5 v) n2 a+ h: w( x* F3 u0 q4 ?% s) E
- #undef EDMA3_DEBUG+ ]9 G+ B% {% C s6 |! P
- /*#define EDMA3_DEBUG*/ f3 U. @, b. |; _
+ z* v5 e$ a9 Y: ?5 r7 j* j$ {7 Z- #ifdef EDMA3_DEBUG# w/ j, q m- Y5 [7 a+ B, j/ g$ A
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)4 U' o7 o$ ^& i: s0 ?5 z
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)! ^. }8 e$ d- `( g6 L b
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)+ n- y3 ]. P- E7 T ~
- #else; |; [7 n$ ?+ }0 H. o( b! n3 }2 p
- #define DMA_PRINTK( x... )
1 P- b$ Z9 G' F, W O - #define DMA_FN_IN$ X8 C- J* d ?4 N' s" E
- #define DMA_FN_OUT
9 n5 g& \- P( i' U& Z) I - #endif7 u+ e* b, |- a) o" V$ R q$ A
- $ V) |7 I) v4 s; J- ?
- #define MAX_DMA_TRANSFER_IN_BYTES (32768); B# ?. ~. J; k3 W& m" C
- #define STATIC_SHIFT 3
, W7 w. r2 A' R: L3 ^8 q4 I - #define TCINTEN_SHIFT 20
/ z3 x8 b4 y6 H) L# W - #define ITCINTEN_SHIFT 21# |+ r. v0 ]0 w6 I
- #define TCCHEN_SHIFT 22* j6 V( k5 {* A- w/ U
- #define ITCCHEN_SHIFT 23. v; S0 s9 g& \: _, B0 J" a
0 d! `# R4 E4 r- h- J# v- static volatile int irqraised1 = 0;* o4 m* }; }: |% S6 o
- static volatile int irqraised2 = 0;& Y& h# i+ G- A/ O% n; i
- & f& ^, S. ^6 {$ I
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! b6 Y" h, \8 E0 v2 }9 n3 S - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 q* K$ v6 z( I" P1 t - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 U8 S# d8 R/ K) W' ]; u1 ]
3 t4 i2 R" A1 U, z- dma_addr_t dmaphyssrc1 = 0;
' x# _/ b- C# h8 t% N7 T- [ - dma_addr_t dmaphyssrc2 = 0;
! s. g( h! S& ]# h - dma_addr_t dmaphysdest1 = 0;
6 ?4 X1 `% l1 L6 A; v - dma_addr_t dmaphysdest2 = 0;8 h+ x! j, q" }& @# g
- + X' U9 d1 @8 ]& u0 M5 v! n
- char *dmabufsrc1 = NULL;4 Q* R' f; U5 `6 i, e
- char *dmabufsrc2 = NULL;/ I1 ^0 j b$ B7 q4 N4 _! I
- char *dmabufdest1 = NULL;
, D! Q7 |8 \: j' v) {# ] - char *dmabufdest2 = NULL;
% O5 L: R1 p. Q' _ | - 5 k" [! [2 l* Q( s
- static int acnt = 512;
- o1 l& p' P0 f" y! @7 s* H - static int bcnt = 8;4 f! L& _/ O5 z' g
- static int ccnt = 8;- z8 Z: b: [/ H6 V/ n
- & G$ V8 ]" \: M, b, W( @5 A4 r g
- module_param(acnt, int, S_IRUGO);5 n8 ~! M6 P. s4 V* M) T/ @
- module_param(bcnt, int, S_IRUGO);
0 z( C+ A1 Z8 |/ e% q1 S% y0 y t - module_param(ccnt, int, S_IRUGO);
复制代码 ! ]) \' n9 Q$ s" | n: h7 Z+ K
) g, B3 ^$ V3 D- {( p' ? 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
% G* J0 M8 C- X/ r4 e1 H" Qarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。4 E8 O5 x$ C) Q" F9 h- |
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。) B7 a1 y: t$ L; T
+ ^( F* A5 Y# \" m6 i
; a. F& P' d$ q* ~3 U
|
|