|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 J- c3 ~# b" E) q7 j: \- [code]EDMA sample test application S4 W2 i. D( m. \: u( j
- /*
9 l! ^: P) C6 t - * edma_test.c; e6 s U% V" N I
- ** p* {3 S. B) |
- * brief EDMA3 Test Application m5 K5 |! E$ A
- *
. A8 w& H* C& l4 ?& {: R - * This file contains EDMA3 Test code.8 ?( O0 e4 d. ?. f" p$ ?
- *
4 f f" |& ?% i, i5 j. C3 D! L$ H - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE3 q% a: `0 B! X" R5 Q
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
/ c f, Z/ V# @ - * TO CHANGE.
! |1 q$ {5 X3 h# ~ - * K8 P1 Q0 O! r& k, @5 @
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/1 J5 v1 c$ B& z! g: J
- *
& ~) u- ]6 n+ y! I; Y& {7 i6 I - * This program is free software; you can redistribute it and/or! v0 A$ l+ h5 C
- * modify it under the terms of the GNU General Public License as( K% s! L k/ J" B& T. l
- * published by the Free Software Foundation version 2.
4 d9 E& k% E" }4 G - *! P* w# H( ?/ T& o8 m# f
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any& k0 d7 g) V6 P: I
- * kind, whether express or implied; without even the implied warranty* b. S; o) U. H! `7 j
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1 x- J' B) h1 ^! _# P
- * GNU General Public License for more details.4 X( k' P5 [ P S V# L0 Z4 P
- */
7 J! a% S4 ?0 H - ! u U! p- f# r$ R, t
- #include <linux/module.h>1 e. I: M5 J# c1 N
- #include <linux/init.h>8 g2 i. J9 }2 l( X
- #include <linux/errno.h>
0 u1 B' x4 N4 B7 V2 c+ \7 G* g - #include <linux/types.h>* Y7 ]9 V& m2 A5 b& K$ v" w
- #include <linux/interrupt.h>
7 `. Q3 ?: T9 _: f8 [ - #include <asm/io.h>4 ~# W$ M* A" u
- #include <linux/moduleparam.h>+ k; y# i j- {% y/ ~
- #include <linux/sysctl.h>
' g6 z0 K, B# x) r - #include <linux/mm.h>5 K) N/ h8 _$ `4 O
- #include <linux/dma-mapping.h>
; I( P0 g( `. q - ! d# e" \- X: C- Y% m# w- `* S
- #include <mach/memory.h>
0 X* {5 z4 ~$ o1 R! M - #include <mach/hardware.h>% V7 R3 V$ R, k0 E
- #include <mach/irqs.h>$ L5 p6 ^4 e# p5 p0 u
- #include <asm/hardware/edma.h>5 d$ S; \$ L$ {/ z! X& o
- $ V6 }9 B- M/ R9 s" G8 U) e
- #undef EDMA3_DEBUG
9 V/ K/ a/ i' x! i - /*#define EDMA3_DEBUG*/
: @9 f) t( e4 J
; p# H( u; C% p: l7 k- #ifdef EDMA3_DEBUG
4 Z! r7 U- p- P; P - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)3 D4 V& N5 D( P- G/ J" ~
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)0 `' Z; |& {- M. U+ {$ X
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( F; {' ^+ v, W* x
- #else
3 I$ i6 R0 P0 i1 C - #define DMA_PRINTK( x... )0 h \7 |2 e. ^+ V! \; X _
- #define DMA_FN_IN3 p. U$ b9 }+ v G( D$ `5 Q
- #define DMA_FN_OUT
4 f- O3 D, k/ ^7 Y* Y1 K9 i D - #endif
. I' a+ G6 s; b! `2 j
- W1 P8 l) B( j9 k# s2 E7 J- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
8 L5 x2 a, E3 O/ q% @5 D, q - #define STATIC_SHIFT 3
+ n8 @7 u9 v( R, _" D - #define TCINTEN_SHIFT 20+ ]# D' j! h1 j6 s
- #define ITCINTEN_SHIFT 21
u4 b9 c; z- d* T, R, W% r - #define TCCHEN_SHIFT 22
2 `7 G9 k- X' ]/ P - #define ITCCHEN_SHIFT 23
* E/ o! T. t: }4 U! `7 H
# H, f8 u: p1 M+ |' R5 h- static volatile int irqraised1 = 0;1 t4 O3 v, v- Q, P) H
- static volatile int irqraised2 = 0;
& s% t7 e) Z" M f - % g# [$ R. I4 U7 K' r
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, F4 m5 `" w0 b0 r - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 s0 @9 }0 o* c
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ I- i- I6 v; I: h - ; @. j! e- [: y. ^
- dma_addr_t dmaphyssrc1 = 0;
. v, D$ o: u3 C, O0 Q - dma_addr_t dmaphyssrc2 = 0;
; J: q# s r% w: s+ s- P - dma_addr_t dmaphysdest1 = 0;. q; ]0 U- L3 A" H3 D% f# s- s$ d! V
- dma_addr_t dmaphysdest2 = 0;% W. ?* G2 R% Z; A- q: J
- / n" l8 c* V- y7 l6 o
- char *dmabufsrc1 = NULL;
; r4 }1 \0 i9 U) I( L6 Y) E d - char *dmabufsrc2 = NULL;
3 p- L6 v) g: b8 J5 o - char *dmabufdest1 = NULL;& R- p2 q9 @( P' I g# k
- char *dmabufdest2 = NULL;
S4 g* E4 P* d- b - 7 O7 E' ~& {8 m; T3 J! @
- static int acnt = 512;
3 m6 a" X' ?/ N6 U% F6 m4 V; E - static int bcnt = 8;
|- @7 L7 F, Q' r - static int ccnt = 8;
3 A3 C6 h9 m* w; Q - / d, f- O) l& b1 f7 k c
- module_param(acnt, int, S_IRUGO);1 W* q0 B* n. y% S9 @7 J* X) `
- module_param(bcnt, int, S_IRUGO);
# A1 a- J. _3 O8 X2 M - module_param(ccnt, int, S_IRUGO);
复制代码 ! b ]; R( W8 L- n% j
: }2 B5 `0 k G5 E) h4 @& Q 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
% N* A+ k( e( ]2 J* Marm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
9 z$ X- Z- e+ U0 |! J2 g 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
7 r% E6 \, a3 D/ A" I* c
/ `- k, [: P- O) m& C
% c" J1 H/ G; T |
|