|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ' V8 s8 ?7 L2 b- Y8 W, V$ e
- [code]EDMA sample test application; |' s5 y; |7 { N5 G
- /*
" V, ]2 W2 C3 t6 j$ X/ y5 q - * edma_test.c
7 J' M" [$ a% I1 `; Y - *
6 x- [* O% P/ s" f$ z! w \ - * brief EDMA3 Test Application
' Y0 N2 _ {8 X. g - *$ e+ t) I# T) n) g8 r: z0 e1 f) @ `
- * This file contains EDMA3 Test code.
! f" G; P" _0 G* R! c2 Q% v) q - *
+ q: q; L z% b( b# [8 H - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
' C* s* x: L5 o6 u2 @) h* H9 q; J - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( N3 a) \/ B5 p - * TO CHANGE.) B0 I0 d" _* L, V! s5 U: z
- *7 d7 E: N8 p! \( i
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
# }. @, z1 t0 W) |9 u+ C! { - *
- T' S3 P" z- o3 a: N5 d) ~ - * This program is free software; you can redistribute it and/or3 x5 i9 m! o, X' f+ [
- * modify it under the terms of the GNU General Public License as1 `4 I# |" P M# ?9 }
- * published by the Free Software Foundation version 2.
0 M" N* d- Z2 z# j - *- l* q+ I7 d( B! ~
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
3 k) ]) k' X) U - * kind, whether express or implied; without even the implied warranty4 @; Q* D1 h4 P* v g( A
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) j7 l7 n: ~4 g# n
- * GNU General Public License for more details.; P0 _0 {4 R0 N4 b9 y
- */! V5 ^5 h5 B6 i2 l" v+ T% b
; |0 I/ n8 _' H% n- #include <linux/module.h>* t2 @+ p! | ^! s" T
- #include <linux/init.h>* i7 B9 i2 Z* p7 M0 {8 @
- #include <linux/errno.h>! |. r' E g1 \7 L# h
- #include <linux/types.h>) l9 d) H& m* q0 W& A4 V, g7 r
- #include <linux/interrupt.h>
5 |) ^ `, y# o( v1 L; V# I1 X - #include <asm/io.h>
1 e$ O) R' X3 @0 @) ^' O3 ~' u( x8 N - #include <linux/moduleparam.h>! b; e5 H1 A1 |: O' @+ X7 i& J/ {
- #include <linux/sysctl.h> C0 O d1 Z. Y' B* h
- #include <linux/mm.h>2 {6 m& i# ?# H/ o$ y( r
- #include <linux/dma-mapping.h>4 y' `5 i4 L, [& A" z+ y: x+ h
' x7 t }6 ^4 S3 Y& B; X- #include <mach/memory.h>% l: @0 I1 J* B- D+ T% x( m
- #include <mach/hardware.h>
0 \/ e6 ? }- S% S* D2 s. ]; s) ] - #include <mach/irqs.h>
$ I' M5 C$ e, U1 K7 W8 L( x9 R4 C - #include <asm/hardware/edma.h>
+ Q$ {$ ?6 ]) N# x. D - . l4 i8 R6 i' A* M( ?
- #undef EDMA3_DEBUG
0 u# V. N; T3 n: h5 h4 u - /*#define EDMA3_DEBUG*/+ C: k: f6 |. p, P, u
% l" ?& M4 y, \% y* G- #ifdef EDMA3_DEBUG
/ M& V% q3 G( c0 G8 A% l - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
V& j8 @. Y0 I* M - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)/ u9 f8 V: ~0 x; O
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): G# Q* B6 C% U4 }3 k
- #else
# f# ]) O! j/ `; C' J8 E - #define DMA_PRINTK( x... )
) X% J4 `2 q0 O" L& q - #define DMA_FN_IN8 K5 I; Y' `$ k& D' @
- #define DMA_FN_OUT6 q& j( y, Y- y- D. e9 J$ V
- #endif# _) _$ h" v9 J7 ^8 Z( R
2 I. f! | ^% n' L$ {$ y- #define MAX_DMA_TRANSFER_IN_BYTES (32768); R7 e, s; n2 h4 P+ }4 N
- #define STATIC_SHIFT 3$ ~" h& I( O% M* Y
- #define TCINTEN_SHIFT 20
& {8 a5 _! {" J/ V# K* ~ - #define ITCINTEN_SHIFT 21
. `5 Q6 w# [9 ?( e" ?* W - #define TCCHEN_SHIFT 223 a' E0 e r8 ?2 [8 w5 l/ [
- #define ITCCHEN_SHIFT 236 S# V Y( ^& _, m9 {7 l
- / m$ R0 V1 q' H8 J
- static volatile int irqraised1 = 0;( L/ F. H' |4 W6 G- _
- static volatile int irqraised2 = 0;: A2 j7 ^3 `& z1 ~/ J
- 7 Z! R: K! Q- h1 _7 b
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* [5 ?& C8 l, J1 a2 E! E# t
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ N( e! t8 ]; e2 ~: i, r* T2 d6 ?- U# m
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 G/ O B8 Z w# ]( R
- - a' n1 y& n/ k
- dma_addr_t dmaphyssrc1 = 0;
6 T6 }; p8 T) m# _. o# R: w3 ~& u - dma_addr_t dmaphyssrc2 = 0;
5 h* {' x( v; ?# Z* }$ U- ~( {" L - dma_addr_t dmaphysdest1 = 0;: z% t' H0 i/ {2 n
- dma_addr_t dmaphysdest2 = 0;' \( ]0 K0 L: \8 U Y y4 J
: x* z4 ^5 o! [' j- char *dmabufsrc1 = NULL;
7 M- n. q' T5 _, i* ]0 K - char *dmabufsrc2 = NULL;1 S3 I3 L# h0 o4 L7 V
- char *dmabufdest1 = NULL;
- j: B1 U5 S5 T4 Z I - char *dmabufdest2 = NULL;
+ o; T/ {" d" n
- m5 t# q, H0 B) o* v5 _- static int acnt = 512;
( f5 n8 r! c4 r7 f- a3 ^ - static int bcnt = 8;
/ }" o% u- Y, ~ - static int ccnt = 8;
! A: ~7 e8 I1 F4 ?$ M; _ - : k) M% b3 r# ^
- module_param(acnt, int, S_IRUGO);* x* j) z* C7 j' J: X2 }% M( Z( k
- module_param(bcnt, int, S_IRUGO);
9 r7 m1 o7 W4 D* a- P; ^2 b* H - module_param(ccnt, int, S_IRUGO);
复制代码 . M& Q; {. E4 @" ?$ A
8 B+ n0 y- c8 X
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用3 Z' h3 f% q1 O2 S$ D
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
$ \8 |/ G; {) t: N; L6 z2 A1 _ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 c' s! Q: b `9 `/ ~, m N
- ^( i+ A9 b, [: s* v3 ~
3 T& _' v+ M5 u2 t |
|