|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 7 H: W7 \9 i3 Z" y5 _& F
- [code]EDMA sample test application% t- B, R4 N) f
- /*9 @4 [" f8 a/ Y% `
- * edma_test.c
; _ _' F, u$ U; G- g; { - *9 c5 ]% E. R4 g/ t" n) K1 h9 v& B1 Q
- * brief EDMA3 Test Application
# O( \0 ^% C3 g; o/ m% G - *% d- H2 u$ _6 d# |7 n
- * This file contains EDMA3 Test code.% @' O* y4 c8 _8 e3 V3 m) @" H- W
- *5 e4 a1 |! y% ~1 ?$ z/ J% A
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE1 u8 @3 l% @4 d$ _. P6 f
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT4 b: T" |) U% h9 ]- A: j
- * TO CHANGE.
- [1 d# e% l: E1 j1 d8 h - *# N+ A: n: z7 Z: s
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/: |# h/ l" P0 z7 {8 N
- */ d# s4 \3 Q$ _( [6 Q0 a5 P
- * This program is free software; you can redistribute it and/or
7 E B# q( {2 a+ i: R0 \ - * modify it under the terms of the GNU General Public License as$ _) M2 h7 c2 K2 Q- w. L# M) r
- * published by the Free Software Foundation version 2.( ?2 K q/ B, @# K) i2 j
- *
) u7 L* e3 u8 l+ F7 _% ?% x& I - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
* k8 L7 {8 k, b, r; | - * kind, whether express or implied; without even the implied warranty( J* a% u) _# U3 s. ^& H
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 L! J J, h. S& y, N- x
- * GNU General Public License for more details.
1 l+ `: [. B* x& ~2 } - */$ B: s8 I0 @' ?1 w: Q; Y
- 6 E# ^* t1 r0 ?: h
- #include <linux/module.h>/ w4 h4 I3 R1 T* K; @. m
- #include <linux/init.h>
8 ]' i6 A' E# a0 l D. A+ c - #include <linux/errno.h>
! y5 i3 J& j7 L+ ~& A - #include <linux/types.h>2 q1 o$ M& t- D
- #include <linux/interrupt.h>0 ?! `8 ?' v- c0 W2 G
- #include <asm/io.h>- z, _) z5 t U& ^, A
- #include <linux/moduleparam.h>" Q! t9 O- Q2 p: q( A
- #include <linux/sysctl.h>" ?5 F0 c/ I+ L& K+ l9 o
- #include <linux/mm.h>( a7 v4 L% _4 ~8 s
- #include <linux/dma-mapping.h>
/ B; ^9 \9 L0 D- ` - ! n1 \/ z1 Y& _2 s9 K9 Y, J
- #include <mach/memory.h>! [' ~8 s3 {9 c+ v5 b
- #include <mach/hardware.h>! j2 Z F4 d3 l7 M
- #include <mach/irqs.h>1 ^( p5 l6 @: c7 e* V; ]- f- L4 t
- #include <asm/hardware/edma.h>* M& ]8 N3 l, h; l/ S
$ |) Z6 ~# ?& y b- #undef EDMA3_DEBUG% c% K8 x- h5 _/ {
- /*#define EDMA3_DEBUG*/
q0 y! f( ]& [8 e. C/ \" U1 G1 G
6 t0 g; F9 l2 |; b9 s$ l. \- #ifdef EDMA3_DEBUG" d! ]4 Z; H+ |5 t# \7 F& O( i
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS): M: {* n" {' N* S9 Z
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)4 W( U; h8 n4 P+ O$ O7 x
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) L. v% N" d' k+ O: X. _ g - #else2 Y: v! Z5 V% N# |6 @6 C* C4 k
- #define DMA_PRINTK( x... )/ t* a3 N7 l* Q n: n
- #define DMA_FN_IN# R0 [, D* G6 ~1 z
- #define DMA_FN_OUT$ h9 X1 X- ], V s+ p6 J9 o
- #endif1 V* H0 g B! |; ~/ U0 Y
- \; O5 J( X t$ b, ]- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
' h; \0 {, e0 Q8 t. d. x! s - #define STATIC_SHIFT 3+ U: x5 z' V: R4 p& x/ \" U
- #define TCINTEN_SHIFT 200 v1 M) P5 ?1 i/ l8 g# ]* p( Q
- #define ITCINTEN_SHIFT 21& `4 x7 G$ u5 `8 B
- #define TCCHEN_SHIFT 22+ t" I) ?( ]5 g. A6 u
- #define ITCCHEN_SHIFT 23: @; l; x6 j W2 W: m/ |
- 7 W% W! y, t* n" ?' ~
- static volatile int irqraised1 = 0;
- H! q4 g: f: d! f - static volatile int irqraised2 = 0;3 f; H% a- T" R2 m
/ N" \4 }1 u# \% G) {- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# B G; X. c9 r: z4 R6 q' G1 A9 ~ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 w- h( O. l) b) h8 g7 g$ v8 Y$ p - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 x' A4 t: u! V/ b, o
- % R: E& R" D$ J
- dma_addr_t dmaphyssrc1 = 0;7 O3 _& [4 G: {
- dma_addr_t dmaphyssrc2 = 0;4 ?$ b' Y, K% r
- dma_addr_t dmaphysdest1 = 0;
! M3 c/ I/ m) G, C1 V! M, D, D - dma_addr_t dmaphysdest2 = 0;, t9 E! g/ C5 n( w
- 2 H0 Z; }8 P: i( u
- char *dmabufsrc1 = NULL;3 P, K* R2 G: a
- char *dmabufsrc2 = NULL;
1 S, r% G* b1 p$ s5 r8 x - char *dmabufdest1 = NULL;2 w1 [2 F( R* y( ]& k! d- G f
- char *dmabufdest2 = NULL;; d# q& \% B" q$ X/ X, P
- 3 }1 J) C2 W7 b) s6 z
- static int acnt = 512;" }1 q0 A) g5 A5 Z" D/ T P2 t8 h
- static int bcnt = 8;5 y) }# N7 F5 R5 P
- static int ccnt = 8;
. R b3 e H& M
: n: n& E" c# E7 ^- module_param(acnt, int, S_IRUGO);
/ o7 x+ t% L+ g. y4 y - module_param(bcnt, int, S_IRUGO);5 v4 A8 \7 `$ |' Z) H3 L
- module_param(ccnt, int, S_IRUGO);
复制代码
4 x3 C$ |3 p7 I, Q
% e m# B5 {+ q1 J 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用4 |9 t- C: c* C* k% h, v
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。5 k1 ?! z) a% \$ A2 E
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
8 z5 o) U5 H2 b" a
6 |8 `9 @. T/ F3 |
9 M$ x( X3 F$ X' x2 G. j: w. M8 t6 {) z |
|