|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 # k8 G% G, b' K6 C- G: H
- [code]EDMA sample test application
$ |6 I* c% a8 n$ @% Q% A0 ~2 | - /*- s) n" V9 D5 i# t" ?; t4 P5 {
- * edma_test.c
: o0 X. u* v, _2 u7 z" E( T1 a - *
" F* D6 w. x e; z( e8 L - * brief EDMA3 Test Application
& G7 I0 ?9 [/ J* V2 g) Y - *
$ s( Q. b! ]) e, z4 D/ x - * This file contains EDMA3 Test code.
1 G% z0 f' C& G, ^, d+ c$ C2 E - *
+ `8 x4 U- C. K( U: N - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE2 b2 v$ d7 j1 P% D. G
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT& I* J* |, t" Y
- * TO CHANGE.
3 k) s8 C. R2 E - *
1 t4 H9 o/ Y% _ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- _) X. R# _8 ?) Q0 e+ P4 f
- *2 H. c% u" ]3 ^# e
- * This program is free software; you can redistribute it and/or
) N: i+ Z, U) G0 z: E4 H - * modify it under the terms of the GNU General Public License as4 n) B+ X& Y6 w# X) z# X
- * published by the Free Software Foundation version 2.) f/ V6 z5 O b/ s: @# Q1 c9 k
- *
5 M; g2 F V7 g - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, `* d G: Z- y$ ~8 I5 D3 ] - * kind, whether express or implied; without even the implied warranty2 W0 W5 L0 q, q! N: U3 q q
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ O( ~) @$ d6 O' e, H9 z - * GNU General Public License for more details.
9 P+ j5 c+ @3 B# o4 z - */
, ]3 K& R8 b; T, [ - 1 G& h, _ o: j- x7 W# \' s3 P
- #include <linux/module.h>3 d, z, H) e: A. |$ D
- #include <linux/init.h>
! P6 ]8 s9 V2 m E2 t5 a - #include <linux/errno.h>8 b3 e" G2 p* t8 m9 d' L' J8 Q& c
- #include <linux/types.h>, @" |0 A: ^- X7 F: [. L
- #include <linux/interrupt.h>7 v |$ B1 ?5 h. L7 {( x
- #include <asm/io.h>3 @2 X; |/ G2 z1 V! s" H: i
- #include <linux/moduleparam.h>
! D: E( e* I0 h! F+ e! u - #include <linux/sysctl.h>
" S# g" j# P, m+ w. }- _2 k - #include <linux/mm.h>
, Y! q% [' H' {& E: I5 Q1 I - #include <linux/dma-mapping.h>) J" M0 [9 |: |& ^" u' R
- * k; J; \/ ^1 A- H, s7 ]* I) Y
- #include <mach/memory.h>
6 C5 @; N6 s( U N- \* c - #include <mach/hardware.h>
+ i9 c" f8 W- b7 T, H, Q) ]& | - #include <mach/irqs.h>
7 }, u3 J9 f" ~ - #include <asm/hardware/edma.h># z( I& A5 ]0 \4 U6 `! `: s
- 3 z' f: l# U2 A$ o, y# X& e' p2 A/ Y- n
- #undef EDMA3_DEBUG
: D0 K# u6 L# M5 l; L/ [$ o - /*#define EDMA3_DEBUG*/
0 B( @, T. E- c/ V1 y5 O6 h- i. I9 t - ! e/ n/ N3 g; e6 C* f
- #ifdef EDMA3_DEBUG( C8 d2 L9 Q: Y' ^0 h7 e) E
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)$ A' J& d6 x2 y8 O2 w
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)4 N8 E, ]! Q, \- j# g- d
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)' P8 L b/ o+ R8 \6 ]6 r
- #else
5 _3 N( l- d: } - #define DMA_PRINTK( x... )
! L8 D- ]6 d: x7 h& i; O - #define DMA_FN_IN
4 h1 [' A. w! N2 ] - #define DMA_FN_OUT- y+ e+ d. Y J. |! d" ^
- #endif7 @+ g9 z" x8 e8 Z! t$ K+ h, I
4 G5 X6 E# v" M) C9 g- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ ~' [" m8 z4 U; ]9 P
- #define STATIC_SHIFT 3
t \- e9 J8 |' c8 T - #define TCINTEN_SHIFT 20
?: _9 L" `; M S/ l - #define ITCINTEN_SHIFT 218 `% j8 H& g T1 J2 @
- #define TCCHEN_SHIFT 22
" F& Y0 o6 q! t. a- P" @8 x7 l - #define ITCCHEN_SHIFT 239 j: p0 k5 [$ l3 B; T( l
; v3 k- Q n" L% O4 e- static volatile int irqraised1 = 0;5 J* U) i: K* j6 J) r
- static volatile int irqraised2 = 0;' Y, p% T. j1 `; R8 F, l
! }- e" W6 r: g' L* p: T: \; n- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- Q* U, n9 L6 m0 {7 C% d4 E
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 d6 _. O7 e/ |0 f- _3 u( W - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ a/ b( [9 `; u
' k4 ?+ \# G# X$ B- V( D8 X1 ], O# I6 E- dma_addr_t dmaphyssrc1 = 0;: v0 A8 W" r/ P6 d" ~
- dma_addr_t dmaphyssrc2 = 0;
' K9 k/ v2 T5 x - dma_addr_t dmaphysdest1 = 0;# t. Y$ y2 l2 ~% Q/ q! G X
- dma_addr_t dmaphysdest2 = 0;: m7 o; H/ h7 J5 x0 q9 L; M# T% }
# y0 Y$ y5 c! W7 C' h+ R5 `- char *dmabufsrc1 = NULL;
9 ^; x3 D' ]/ `/ r# D9 n* O - char *dmabufsrc2 = NULL;
6 N* H8 h- j5 v3 j" b - char *dmabufdest1 = NULL;; K8 q3 ~4 y9 q" X
- char *dmabufdest2 = NULL;# S9 O$ u2 y: K+ `
- & _! r( O# B V+ ^+ U* E
- static int acnt = 512;
5 A! F0 \- z/ Z7 w" U4 _ - static int bcnt = 8;9 O* N: d# I3 ] J5 f
- static int ccnt = 8;6 g) Q( B* _; T0 H' k$ V
; ?$ P5 S5 e, x& u/ X3 } {- module_param(acnt, int, S_IRUGO);- {" W0 P: d# o1 S# U- m3 T
- module_param(bcnt, int, S_IRUGO);3 R) P: j+ Q0 O8 {
- module_param(ccnt, int, S_IRUGO);
复制代码
7 P L, V/ U V. g2 x( J0 s$ m9 \1 ]- Z+ O' F8 C4 U5 c' ~
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用1 u% R# G2 {7 v) |. A- 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。/ Y7 u( \4 R1 L) \9 x- T
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' y: }( }4 J: S. O. [% n6 C5 g$ _8 ^# q" S6 l, Q, ]. m* k3 {
5 ?. f; G; |& ~" f+ e) m
|
|