|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
* I$ h: u. y1 ]6 p- [code]EDMA sample test application' I* s, t% p) M' T! J/ l9 B
- /*
3 I) p* P! r' D - * edma_test.c$ t7 J; k( W* b* Z: o* F
- *
& J& d2 t. Z& i! _: O$ J - * brief EDMA3 Test Application
# j! S4 V: H* W4 k3 M - *
3 c* r+ b- N1 E; Z3 d: y. Y+ @ - * This file contains EDMA3 Test code.; Y" k. \7 Y2 r5 ]2 w* s5 E& z* H
- *
: w$ f: s# a* I$ x - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 j. b8 M7 k! c! `( _/ F1 P! [ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
9 N( U+ t# k* O* d! A( U - * TO CHANGE.' o: i5 g( h c. V8 A
- *5 a+ B9 g, R5 f% E( |
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
0 n3 p' I. B$ u8 y" V - *9 [! y! o; @; O( B+ i5 C% m
- * This program is free software; you can redistribute it and/or
) V- R" j) V) N; G1 I8 C; Y+ J - * modify it under the terms of the GNU General Public License as
! E: Z6 P, J) [4 [6 U% K/ N - * published by the Free Software Foundation version 2.
: x, [9 \6 Z6 Z6 M" e+ V5 m S - *. [0 P# l1 y' R
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, [0 Z" \9 ~3 p: n - * kind, whether express or implied; without even the implied warranty4 j7 O; u/ y# ~5 P
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ ?' F' y8 w! P6 `9 l; G - * GNU General Public License for more details.: t# C+ H+ I; T
- */! z9 d% X1 H9 H* R9 i& m8 \% l
% [9 ~" _2 G& v+ a- #include <linux/module.h>
/ u# a+ Y) E6 }; `1 `/ `7 \6 { - #include <linux/init.h>+ z) |, a& A' ?7 t# R8 d% K
- #include <linux/errno.h>
/ p* x/ K# D7 E - #include <linux/types.h>3 l' [3 S# k5 o# G' m
- #include <linux/interrupt.h>
; U5 y6 A: T% ]3 A! ^0 c - #include <asm/io.h>
& N' I3 D3 e. |% X - #include <linux/moduleparam.h>
/ x6 p, e& ]0 x- @ - #include <linux/sysctl.h>5 r$ `$ O% K/ g0 g0 V1 ^: t9 S
- #include <linux/mm.h>% M) B+ j1 D% c# R
- #include <linux/dma-mapping.h>
6 Y7 O( j' w% V- E% |, ~$ X; h6 a - 4 f: G, j) d7 [
- #include <mach/memory.h>
2 H- T% J- i2 v8 k6 J+ }6 c - #include <mach/hardware.h>: Y- X/ `2 R; H, ^$ Z' g0 M5 ]3 A
- #include <mach/irqs.h>. A" O' U( v$ n) b; E8 j
- #include <asm/hardware/edma.h>
( e/ {2 d- {' ?1 u
0 Z, x# z! l8 t# k' F6 N- Z2 g- #undef EDMA3_DEBUG
) P1 _' G% F0 L# O - /*#define EDMA3_DEBUG*/
% t2 |3 P8 ?' E/ n- K; Q6 }6 S5 \: D
5 a2 K7 \8 M3 g( B( Q- #ifdef EDMA3_DEBUG% Z3 t- {2 F' e/ T: G
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
}* n8 d& k' h9 q, ~( X - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
! B# Q f1 j" C, o8 G - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
; T, @- b3 j2 Q N - #else
+ K5 \7 Q; Z; d) L% r. V - #define DMA_PRINTK( x... )
- K, q# u5 _/ Z - #define DMA_FN_IN. x; b3 {( ~0 j2 i( J6 I
- #define DMA_FN_OUT5 s, G4 _* `# r. t3 x- k
- #endif, V% I, z0 I p! q) }5 ]) C c2 \
) ]- p: s0 C' u; R6 m- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" U4 R# l. |& s6 l1 |; ~0 f
- #define STATIC_SHIFT 3
) e8 C9 {1 `1 a4 G1 A - #define TCINTEN_SHIFT 20, e1 }' v% w* _+ j% D+ E
- #define ITCINTEN_SHIFT 211 w! ]2 n+ V& X% t3 \0 k
- #define TCCHEN_SHIFT 22
0 g+ V% Y8 ]* g0 N- g7 ^+ A - #define ITCCHEN_SHIFT 23+ L. S) H9 N9 E- N6 r' {. V' b6 _2 @
- 2 ]0 @) h( K( [) H
- static volatile int irqraised1 = 0;, N/ n$ F1 ^) |* U& w' T8 R5 P/ d7 ^
- static volatile int irqraised2 = 0;5 k% a6 |% J) U& R6 p: r$ V$ [
# Q2 F1 c/ I8 Z% O% f# ^- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, e# q% b$ B3 `7 q: z, j
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) W/ D: D& F3 X; ?
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ F# i. n# F2 l5 k8 P3 A
- \5 ^: ]# e5 W9 y6 I
- dma_addr_t dmaphyssrc1 = 0;
9 a. R7 ?) L$ s0 q# }' M. \ - dma_addr_t dmaphyssrc2 = 0;
, \* T. y! e" ^) F - dma_addr_t dmaphysdest1 = 0;0 f0 g7 ?' ~; S' t3 e+ }# c- _
- dma_addr_t dmaphysdest2 = 0;
$ H# Y! q; @ d* u6 e2 _* }3 x - . M6 _1 X+ f% O. I2 e
- char *dmabufsrc1 = NULL;
6 s9 @/ `7 f5 }6 y - char *dmabufsrc2 = NULL;
% T0 R' p" ]+ @ - char *dmabufdest1 = NULL;
7 r0 i; a$ P* A0 I - char *dmabufdest2 = NULL;
& B7 m5 z5 ?4 t6 T) ?# x
7 ]* a/ A1 `. h- v y- static int acnt = 512;
4 ?2 x! y# w* T6 s+ }* t' H8 W+ Y - static int bcnt = 8;
( Y; J& }# ` I2 }0 m! ] - static int ccnt = 8;
3 \+ f' I9 r" {/ n
2 Y4 G/ O- ^2 A9 k& I- module_param(acnt, int, S_IRUGO);" N3 D) }9 o0 x, V7 E
- module_param(bcnt, int, S_IRUGO);
5 ]& S& h+ C. A0 r3 P r - module_param(ccnt, int, S_IRUGO);
复制代码 3 D# \/ c7 S8 l- w% r7 D- W2 \9 u
2 f# l! S2 w- O/ J 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
2 u$ s! W1 _4 n: T9 `4 d0 darm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
# W. W+ k- S7 b; n6 u 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 x( _6 \4 \% c$ r1 V& y1 p) D
- T8 g; f2 L$ s# U7 ]7 X
; \5 f1 ^! {4 S
|
|