|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) @- \( z! A5 v- [code]EDMA sample test application
( n% n# z0 Q- P. X - /*' |! L! c, Y2 ?
- * edma_test.c
}* r9 \4 j0 `/ F- m& E - *
# @1 H5 W- i; f* ~6 \; R# |. g - * brief EDMA3 Test Application
1 B4 o2 D. F0 B$ W. | - *. e$ C8 w0 ^8 {# W. v4 |4 o
- * This file contains EDMA3 Test code.
! L; J* \( E. y1 b% z - *, |* u; f% D, A* u1 \
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- o* N `: c* t3 A% s - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
- Z( x% M- ]% ?* b; p - * TO CHANGE.. ^+ ]" z# N) n
- *+ _. O: k; s7 D* t; ]$ I
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; b# b0 Q$ W# h
- *1 z! T/ D1 a: x$ l% F" d2 w5 s
- * This program is free software; you can redistribute it and/or
. `* @! G" j, L* L9 p7 X8 t4 T {$ K - * modify it under the terms of the GNU General Public License as
6 Y. w5 x' i- G( F! D, j, H - * published by the Free Software Foundation version 2.
2 j# G7 l1 U3 a: f: | - *. u9 ?4 s& [+ h5 m" U
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any( ]; G$ I, S/ r% D+ l, m
- * kind, whether express or implied; without even the implied warranty5 ^( E/ ?/ y" ^; x4 B& b% t
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the4 D1 ?1 I0 Z. {( Z3 x
- * GNU General Public License for more details.
; x# _* l/ V+ {! D* X - *// }" S5 Q0 Z: V
- 5 i% i- k6 ^) @1 ^% }4 t
- #include <linux/module.h>1 G! f9 `& t# E0 {: {: [" V
- #include <linux/init.h>
) W. Y( R. o9 @* {( p% E - #include <linux/errno.h>9 F' Y; r# e; X4 B! B3 \! r4 B" {
- #include <linux/types.h>
4 p5 r, E' Q" r2 s' N - #include <linux/interrupt.h>
: z% l8 t7 I1 X, P8 k- ~ - #include <asm/io.h>9 D2 ~. ]: B/ N% [5 i; _8 ]
- #include <linux/moduleparam.h>
3 ?! h$ G, M( A: t1 g4 N - #include <linux/sysctl.h>0 z& k+ B, s+ n; Y: @) J
- #include <linux/mm.h>
- e8 s1 _4 k8 e; _. F. F$ G7 s - #include <linux/dma-mapping.h>
}' ?/ }% G: A
, f `: U& l* d$ c! t. I; I- #include <mach/memory.h>& K' D) i5 C: u- y+ k
- #include <mach/hardware.h>) z; ?, L+ {# ^% O
- #include <mach/irqs.h>
. F9 R( k9 F* i" e& }! q - #include <asm/hardware/edma.h>% x' h. x* b9 t. R4 ^
- C8 Q( `( v. b( _0 N
- #undef EDMA3_DEBUG
B U: |9 p7 `! d& L* ]- I1 m9 l - /*#define EDMA3_DEBUG*/
0 a& L3 i; S3 p z& v. o - ( K5 U7 j4 @7 @& Y0 h
- #ifdef EDMA3_DEBUG
+ y2 K2 d$ s* W' k& x - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
% n8 O3 c7 `7 w+ m - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" v9 G4 S$ E( l9 k" U! X9 G
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
& G" c8 N# S% c) z, y0 _2 K# i - #else# k2 ?+ R- c: \9 J
- #define DMA_PRINTK( x... )
$ w& i) j9 ]: h" p) m: Q' @ - #define DMA_FN_IN
- W1 e* I; ?6 }) w - #define DMA_FN_OUT4 x: K! K2 n2 f3 S7 Z
- #endif
1 {% A5 z2 f' Z" C) p - " P# B$ Z5 D, A8 }, H
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
) E0 V- A$ Y6 e" F ? - #define STATIC_SHIFT 3
: a4 {) `! ^: | - #define TCINTEN_SHIFT 20
- k% u1 |/ I* o. ^2 }8 O - #define ITCINTEN_SHIFT 21
/ I$ t0 u; p! c3 C& ~& E0 m - #define TCCHEN_SHIFT 22
t& b: {2 x; E) ^. {' T - #define ITCCHEN_SHIFT 23$ q% \) K+ A; e ?3 K7 f+ H
- $ y6 v" H* i5 \0 _
- static volatile int irqraised1 = 0;
: L, M2 G" _2 f - static volatile int irqraised2 = 0;
0 j8 c( B, B% i- M# z
4 ?( I) x6 u: g9 ?8 g7 v# g& U* F- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ v1 C, ^4 @6 D' w( m, U - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& E) q# b: h" T3 U% f4 q# ^, f
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ `+ h b( m- G2 ?1 c
- / Y, P) r' A; S: U- k9 q- i% S
- dma_addr_t dmaphyssrc1 = 0;
* @8 t5 m$ G, O% B( b. v! O1 `7 _ - dma_addr_t dmaphyssrc2 = 0;
, O \6 b7 R1 r9 z6 [& U - dma_addr_t dmaphysdest1 = 0;
5 n/ K+ P3 K; S7 D* } - dma_addr_t dmaphysdest2 = 0;
* `2 N4 s# y; y G, h - # a1 u- c. j4 Z: H1 R' Y) i
- char *dmabufsrc1 = NULL;( q: ]3 Y* I" S8 ?
- char *dmabufsrc2 = NULL;# r1 e8 c1 ]# F
- char *dmabufdest1 = NULL;
* G; k. ~& r7 L& c! r! j - char *dmabufdest2 = NULL;6 B% U( U7 h0 {0 D8 |
- 8 A8 U% \* k7 o
- static int acnt = 512;
" v4 {" ?, w6 `: a- w/ g2 w2 ~ - static int bcnt = 8;
! j4 b6 `! j' p+ I2 c- h1 u3 \ - static int ccnt = 8;
2 T- m8 V# g% y3 W8 P& A0 _ - # s |9 Y+ e) N3 _; R
- module_param(acnt, int, S_IRUGO);- \1 q3 w2 |4 d' {/ B# O$ ^ `
- module_param(bcnt, int, S_IRUGO);! t7 n2 a2 F: q
- module_param(ccnt, int, S_IRUGO);
复制代码 6 P: W2 z4 w% T7 V# Y
5 ^# I7 J- X$ m3 G* n; C- d
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
J- S q, R3 j6 A! Earm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
/ k' h T0 H& T" V3 d9 O 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' ]4 e! H" _$ a, G; _) g$ I. w, u) E- z! r$ P- p0 U+ y
5 G b7 J: l/ B+ s# d$ s1 F! z |
|