|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 \( B8 A: x% b4 I( I A- [code]EDMA sample test application
4 c& k. s, m$ ]2 | - /*! B, V6 b4 Y! _5 y
- * edma_test.c; `& k$ U' D' o5 y% G- W
- *% H% j; w! O5 R
- * brief EDMA3 Test Application
( r, ~! S$ ?6 l9 C0 ^4 b - *
' s& A( U0 K* S# |6 y( Y: d: m - * This file contains EDMA3 Test code.; @0 W( ]2 f$ K9 f
- *
; [! @/ D C4 A - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE2 R8 B F i; e! v2 X2 q4 G7 L; H
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 F5 N& j0 ]/ I5 Q
- * TO CHANGE.
6 @: P* P/ d7 ]8 G# z5 |# o - *
7 C- R, Q* J% { - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/% z# E* K# m9 f6 c* F, C
- *
# j& u" O0 e; ?- h; K$ s - * This program is free software; you can redistribute it and/or
# p; V0 V: c: ~7 t - * modify it under the terms of the GNU General Public License as
7 g1 Q9 p! i; k6 r1 a5 m - * published by the Free Software Foundation version 2.
! D; C5 k, n; L! A: o, ^ - *
6 E, _; B3 ?5 R4 m - * This program is distributed "as is" WITHOUT ANY WARRANTY of any" ~+ T3 \ [* ~9 ^# I
- * kind, whether express or implied; without even the implied warranty
2 u, Z. [. H- w- r) |& v - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the, I7 Q' S5 h+ k; x# Y& Z
- * GNU General Public License for more details.
v0 p1 T6 U d- \& `; U - */
) F4 a( m u* l0 e% k: g- F! {" @
# J* k6 D# f+ t( Z7 V# Z- #include <linux/module.h>4 [, q3 Y4 i+ [/ M, x+ V
- #include <linux/init.h>$ b% S9 k7 `" A9 C5 d
- #include <linux/errno.h>
: P/ m; N* w |8 E1 C6 C - #include <linux/types.h>
3 l/ B/ B0 l( H - #include <linux/interrupt.h>
. d* O& r, ]" W+ @9 Y - #include <asm/io.h>) I7 Z& x/ r) i$ {: Y9 l6 K/ X& e! I
- #include <linux/moduleparam.h>
5 R8 J X6 C2 n" n; C r5 { - #include <linux/sysctl.h>
9 G( s( N; Z) ]% ` - #include <linux/mm.h>
" S' N2 z; R! Z! y' i - #include <linux/dma-mapping.h>3 c% W' d2 F( O
- ) D8 @% r/ L* j3 t# Y
- #include <mach/memory.h>- Z, J e6 T i, B
- #include <mach/hardware.h>1 O0 h5 T0 }& ~" j3 K% V, r
- #include <mach/irqs.h> \7 `6 T2 D! h1 y. c
- #include <asm/hardware/edma.h>6 X8 O$ }/ P: O$ I3 \ Z
1 B/ r+ A: C, e( }- #undef EDMA3_DEBUG2 P% M8 d, s9 u, p7 U
- /*#define EDMA3_DEBUG*/
( U5 |2 e* x3 a$ ^. u3 _+ i" N - . [$ ]5 a4 {- B% l- ^7 _$ r \7 J
- #ifdef EDMA3_DEBUG7 P" v# X5 l& [* z% c
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)+ f8 g' J; g8 J- k* [, p
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)& G! }+ l( c# k) y/ H6 C; W- ~
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)' c* |. x: Q5 V6 F7 k7 P
- #else$ s& [8 C M9 J) {
- #define DMA_PRINTK( x... )
8 o7 `. t' h& R# i) F$ R/ | - #define DMA_FN_IN7 h, t* w" d, b' G% J+ J5 X
- #define DMA_FN_OUT8 E! ]% ?% j) b) S7 z/ {' G2 M! T- l
- #endif" l6 D9 d7 t3 x5 D, V3 @8 X" w/ E1 j0 M
+ F7 ^7 ?9 |4 l \2 C5 @- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
( m9 O( E0 V2 J6 l. K7 T: K - #define STATIC_SHIFT 3* t0 R2 h4 Y# [, {+ n P
- #define TCINTEN_SHIFT 20
: t. e4 u9 e+ G - #define ITCINTEN_SHIFT 21" o* x/ o2 o: r3 W
- #define TCCHEN_SHIFT 22 K4 p' f4 z* g% [* ]# r4 R0 ~1 N5 L9 a$ |
- #define ITCCHEN_SHIFT 23# ^4 D. f0 g/ J0 f) O6 g
' {8 Y7 O8 J! t- static volatile int irqraised1 = 0;
' Z4 t% E7 Y% i' q& s - static volatile int irqraised2 = 0;
$ a. A6 \6 H% m) d: C t+ s- t - 2 \9 E$ L* p- ?5 Q3 T, t# C
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 e5 [ c) h7 s
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) y' k8 X" X* ~* e - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 _7 N1 ?) l3 j* y% X, ?4 \ - # G9 l" A' P4 J3 I
- dma_addr_t dmaphyssrc1 = 0;
1 E% l4 p H5 y4 J; y& s o# L! r { - dma_addr_t dmaphyssrc2 = 0; {" H. y; _. l6 m( Z
- dma_addr_t dmaphysdest1 = 0;
" v' Z$ `( R1 V5 ~ - dma_addr_t dmaphysdest2 = 0;: C; O# ~# r& h, G/ z1 w
- 2 }) P7 |8 s: Y7 }2 A
- char *dmabufsrc1 = NULL;0 w( N( d# b! A8 u' I( u8 k- J
- char *dmabufsrc2 = NULL;
3 D2 @$ g$ g7 S0 ~ - char *dmabufdest1 = NULL;
* Z8 I6 g- l/ O* N - char *dmabufdest2 = NULL;
' L9 e1 }8 ~) b1 b
" p( G1 d& ?& E- static int acnt = 512;' q/ u8 O# N( Q
- static int bcnt = 8;; y7 X3 X8 w2 h! U; p" n0 ~' _
- static int ccnt = 8;
, U$ @, v. L) H* u- D9 \/ m - ) n. \- Q1 m' r/ S- p& [, _( o
- module_param(acnt, int, S_IRUGO);
1 r# _8 ]) V8 k$ }, m - module_param(bcnt, int, S_IRUGO);3 X7 ?% q1 ? {6 w( Y9 g% r
- module_param(ccnt, int, S_IRUGO);
复制代码 . H$ s6 ^4 _; E9 N2 k
! o7 F4 [+ e) I+ P
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ G" r( z# F9 V, harm-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 F6 q7 v" B8 g% _+ b4 |* s
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。" J4 V4 Q- U0 ]; z5 Y
; v3 f5 y! G3 X# U. ^0 l: d
+ B- ^/ [; Z2 ^" Q% g$ b |
|