|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 9 S) X' Z, \2 F% S- Q3 R. J
- [code]EDMA sample test application, v$ f$ e' W3 q& V1 Q' Y# a
- /*7 S+ Y- B# C/ c/ v( w- b
- * edma_test.c
4 j# `' o& g" h: a' |) n; G - *# a9 L8 X; v5 a- w+ _) x0 ]) `
- * brief EDMA3 Test Application
! P+ M9 O& x6 ~2 z' B - *
' g P# @! x9 \) f - * This file contains EDMA3 Test code.
- [- N9 c7 q2 k i - * E0 o" J* S+ K* q0 x1 h
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE+ }) ]: g4 f( b7 W4 {5 U6 d
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" u3 @7 D: J/ \) ]$ m% Q4 }7 |! z' [ - * TO CHANGE.
' I) x4 m3 g7 W/ w3 L, f6 }9 R; P - *
1 N) u. K7 Y+ R" b% n' U" P- o - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 V* g6 [ V* s( N* a - *$ h; k3 i/ o m8 B3 s
- * This program is free software; you can redistribute it and/or' i7 g* q R: u6 i1 {7 Z7 U, O
- * modify it under the terms of the GNU General Public License as- A& d1 ?5 D$ s$ |2 O9 R7 V! w
- * published by the Free Software Foundation version 2.: Q: ]( q1 {5 n9 K3 e2 b
- *
3 T+ F6 n: q, e" U# i; n1 q" l: U - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
0 N" _2 j" w/ n9 E/ L - * kind, whether express or implied; without even the implied warranty
6 e) K! t" W# _ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- L& n5 k1 [1 I* f- S
- * GNU General Public License for more details.
" k$ A4 h! y0 ^8 q# T - */+ R j2 n8 d* ?, c
. Q' v( @2 _3 i' r% j& f8 O! G- #include <linux/module.h> B; K. l, X' C3 c) ^& T/ J
- #include <linux/init.h>. ~- p8 m$ \0 g8 ?7 q% O
- #include <linux/errno.h>. x! w4 s! ~+ a# R4 ~2 A! q: p# M
- #include <linux/types.h>
S: Z( y! D3 h3 w5 R - #include <linux/interrupt.h>
" G+ [( E3 C/ @. h - #include <asm/io.h>
0 X7 e E2 R$ t$ K) ]! f - #include <linux/moduleparam.h>
! t6 J$ K+ r& d - #include <linux/sysctl.h>- b0 _- _( K4 [. _6 y; v) G
- #include <linux/mm.h>' B* X$ u# k( `% ~! U/ j; Y
- #include <linux/dma-mapping.h>) S% C7 `1 z9 S+ H3 Q
- d1 w& Q: _7 l; S0 D# z& N/ f9 L
- #include <mach/memory.h>
. Y- ^4 x% h, E; ?' \5 G - #include <mach/hardware.h>
/ w: @7 i1 g _+ H! k( d A - #include <mach/irqs.h>
5 I& b! K( @8 ~, S- ` - #include <asm/hardware/edma.h>
1 S( {0 Y0 W/ Z - ; A6 d' p" \0 T3 r4 U
- #undef EDMA3_DEBUG
. v. W4 X4 \9 n2 i/ G - /*#define EDMA3_DEBUG*/
5 }( e5 ]% _: N7 x - ( ^ h6 k' {* X( k$ I3 a9 z, u
- #ifdef EDMA3_DEBUG) c' Z; g3 s) h/ q: \
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- I2 t" k, T0 i: `8 e1 U, ?
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 s3 M- ?5 s9 F2 O) D+ k3 I Z1 M - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)4 r' d2 v9 _4 V: B, o9 D
- #else
@) _4 h, l9 z - #define DMA_PRINTK( x... )+ F9 h1 i5 D- Z9 a* D
- #define DMA_FN_IN; R' X [! h s+ }& e
- #define DMA_FN_OUT. g8 A' X- E5 w) P- X1 k
- #endif
/ U& f) \+ e' a - ( D' I9 ^& o; |- ~/ R$ P) k
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
0 H' U" X# {, n F" I' M - #define STATIC_SHIFT 3- p y3 T5 X/ ^! W# A8 E3 W
- #define TCINTEN_SHIFT 20
G* H$ `( G5 Q p! a - #define ITCINTEN_SHIFT 21
7 V; O s/ q7 S5 Y - #define TCCHEN_SHIFT 22
' [$ Q* j# D0 O% @& W! Y - #define ITCCHEN_SHIFT 23
( X. n& U+ p* } - * Z5 L- j, i5 H1 P
- static volatile int irqraised1 = 0;
% q& R [1 [0 A) Y5 N' l - static volatile int irqraised2 = 0;% B; X/ j) T/ Y5 d) a# [# }( Y
- 3 r% u' G5 Y5 s* l3 }0 z; u. j
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 ]& q; K" I: S9 E5 T0 P
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, j ], H# b- [' Y0 x: N) D u - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) ?! l( o" K1 F
- 7 b9 [5 H% v! U f1 G
- dma_addr_t dmaphyssrc1 = 0;! H9 T- i! `3 D( g0 k( R2 H
- dma_addr_t dmaphyssrc2 = 0;
' F. j u* m# I; s$ L& T - dma_addr_t dmaphysdest1 = 0;# o4 j+ Y; \% p5 A, G" N1 [) J* w
- dma_addr_t dmaphysdest2 = 0;( G- W: t! M! Z
! C. b) s5 Q' B) g' `4 a, P+ M5 U2 K- char *dmabufsrc1 = NULL;: L# i& R; V2 j' X
- char *dmabufsrc2 = NULL;7 F" a) a9 ?( Y0 c, \. m
- char *dmabufdest1 = NULL;
3 {) C w! k: t5 @ - char *dmabufdest2 = NULL;
: G1 W( F0 ^) V* ]& Q$ T
; r( ~) A' Q" j" A6 i- static int acnt = 512;& w; G# `1 W7 s# @4 q4 m8 B
- static int bcnt = 8;4 V6 S# x8 k1 P- ^0 j( S
- static int ccnt = 8;. z7 c- ^0 i9 L+ M6 V- x! T
& g, L" U% `' b- B A7 f; v- module_param(acnt, int, S_IRUGO);
# f. D4 n/ L3 w; p d& p( J - module_param(bcnt, int, S_IRUGO);
; g. ?1 [: M2 @8 h. m - module_param(ccnt, int, S_IRUGO);
复制代码
* s$ X( i' {% T s, `
f7 D5 c; P3 Y1 G 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用) s9 y* H7 |& H
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
; r9 Y+ D; b7 |. ~ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。2 D0 |3 ^- c& m+ J& P
% B: f/ x* `; I+ f% n
: \ J( ~, o( b, G4 `, O$ V |
|