|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . D8 p7 U; _/ A: L6 I# l
- [code]EDMA sample test application
: p# K' }+ n4 g3 F4 x - /*
- G+ o2 U% | E! f! A - * edma_test.c
- { C/ c& q! V* o3 z# T - *& s. f1 l1 {+ U. `% C1 b
- * brief EDMA3 Test Application
" B, c/ A/ L6 D' F - *
- O$ u# h- {7 F! p - * This file contains EDMA3 Test code.- \' ?7 Z% x& ]3 j
- *% j. R) @$ \, O9 t8 K3 `1 f* t
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
9 ]7 C3 x: i8 Q+ h3 I9 T# V( j - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
' @. H/ G7 e7 |' H4 a N+ b* Q( i - * TO CHANGE.
/ |1 O! M5 [8 w, P' S6 V* ~/ a9 w - *
+ D+ ? W' O9 \! p8 r% d - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' l3 r, ]* t3 d7 s1 K% a - * J( F* }5 U" O2 A) f
- * This program is free software; you can redistribute it and/or7 b9 U, h; Z M* [6 a! z+ G4 _
- * modify it under the terms of the GNU General Public License as, J7 V9 k _7 }6 ]7 Y* I
- * published by the Free Software Foundation version 2.( U5 x. j; T' G. X5 P0 ]1 E! s
- *
- ?* L0 p* M! d+ e/ p' H - * This program is distributed "as is" WITHOUT ANY WARRANTY of any4 k4 i! I9 C8 [; X6 H" o4 h. e# \. d
- * kind, whether express or implied; without even the implied warranty
* h4 U |" z- q3 \/ x; a - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* ?! y" ]; f7 h- z6 K; w - * GNU General Public License for more details.
( R! I( I W( }: p# b - */* \: D1 | j! C/ ^! o! \" F
# w+ _9 ~4 P% C g% k1 d* @& o* h- #include <linux/module.h> Q4 t. \! E1 q3 R9 v/ g) L$ I2 h
- #include <linux/init.h>
( N j! h' d2 d" Y' I. ?% Y - #include <linux/errno.h>
F+ S5 Y- X) J5 c7 W" U - #include <linux/types.h>+ |2 ~2 v" Q6 F9 y
- #include <linux/interrupt.h>& B" }" m+ M, H1 R0 Y
- #include <asm/io.h>
" O5 i5 T7 u6 e$ p - #include <linux/moduleparam.h>( m2 S( c4 Q1 n' e, s/ L7 d2 `
- #include <linux/sysctl.h>
2 o( u, C4 H% a( \, h9 f - #include <linux/mm.h>* |5 X. ]! l3 W. E( h
- #include <linux/dma-mapping.h>% z, }5 [& S" U
2 v8 B1 g8 B( W# P6 U+ p' b; y- #include <mach/memory.h>. u ~& @6 }/ M$ Z1 x
- #include <mach/hardware.h>
9 y* q6 f: C/ }- N' q1 |5 ]. B1 ` - #include <mach/irqs.h>' u7 S5 g9 x1 d% r2 E8 _
- #include <asm/hardware/edma.h>, g% x& Y1 I0 Q. y4 h
- & b; V9 J/ J7 f6 H; M. d) r0 \5 R; N
- #undef EDMA3_DEBUG: z" _4 w' m5 w
- /*#define EDMA3_DEBUG*/7 d' K, N8 Z( _2 F8 R. g7 w
- # U+ A# K9 y5 r0 U" t, r
- #ifdef EDMA3_DEBUG
( r1 n0 z4 M2 c* v/ }9 l# ^7 x - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
9 d8 Q2 u) z( p - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
, I W8 J3 }( }0 W - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
/ A' C2 j& E. K# o* K/ Q6 L1 } - #else
. d4 s' B, t* H$ L& J - #define DMA_PRINTK( x... )
; ~. C9 P% D3 z% R' V' M# w: \% ~ - #define DMA_FN_IN. {" U6 [, H' R1 S
- #define DMA_FN_OUT
! o! N6 _8 `7 J7 J2 e' o - #endif1 U$ G" Z6 r* S% r& P @
0 E. y) ^! S, O- m" D1 T- #define MAX_DMA_TRANSFER_IN_BYTES (32768), j* g4 f3 g3 o
- #define STATIC_SHIFT 3
$ U0 U% T: T5 m% O - #define TCINTEN_SHIFT 20
" j9 u! J7 B# G/ h& W: i: Y# `: P - #define ITCINTEN_SHIFT 21. z* ^+ @2 }) L$ E" A8 M
- #define TCCHEN_SHIFT 222 X9 Z0 J- K2 S$ u* y6 P
- #define ITCCHEN_SHIFT 23
) N: |. K' h& j) x+ V
7 M' B0 M5 }# N/ k/ u- static volatile int irqraised1 = 0;
# c" M- v7 b$ E T) ?6 L - static volatile int irqraised2 = 0;+ G" C" U& N* @4 G* l+ Q/ d& L: `
- 4 M1 ~! o. g# J' V8 r9 r! n0 ~
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ _9 Y8 D) U2 i5 W" f; X& _ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' a x1 {( s" a9 x
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' F5 x* V& K o( w6 b3 D4 @1 t
! _4 x$ I& f0 e6 a- dma_addr_t dmaphyssrc1 = 0;' F& z& \9 V: v/ }* z! H
- dma_addr_t dmaphyssrc2 = 0;
! p* X, H* w2 h7 S! O ` - dma_addr_t dmaphysdest1 = 0;
8 a% t; g7 n H - dma_addr_t dmaphysdest2 = 0;% Q! C# W3 h. ~" @- {* y* f
, p* n7 _5 x+ M6 N% ^+ r/ B4 k- char *dmabufsrc1 = NULL;
2 `, u- z G3 l( |+ ^1 `+ W1 X - char *dmabufsrc2 = NULL;1 b2 x9 u- p2 U; z# K- v2 G( `- H V
- char *dmabufdest1 = NULL;
' i4 n! g5 a+ v' @9 D# u - char *dmabufdest2 = NULL;
' e( e& Z/ i9 S. k: A8 o
, f% J( _/ {6 C6 c; n- static int acnt = 512;
9 d3 @" T- n& E: k0 _ - static int bcnt = 8;
5 s+ l4 c1 ~- h& t - static int ccnt = 8;) G0 T$ p# H% d. b
& | [. S) U8 n# d) I- module_param(acnt, int, S_IRUGO);
! O+ h4 R' e" S5 ^" o* F( m - module_param(bcnt, int, S_IRUGO);) j3 b) E% T1 C# s1 U
- module_param(ccnt, int, S_IRUGO);
复制代码 : Y& C' D6 v4 H6 L! R4 a' i% p
0 v! j, S6 `/ L& z) V- Z9 L 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用' G3 n+ R" U0 {! Z* Z+ s
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
/ R3 [' Z+ N$ c( H" f 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
$ _$ y8 K! O7 R* ]4 m' X8 m t/ Z( K% r8 J
2 U& N' ^$ T, C1 x
|
|