|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 $ n y5 E" c* W
- [code]EDMA sample test application
0 W* [" K3 H' N& N' ? - /*
( D* f7 P$ F; h/ G; I4 d7 r - * edma_test.c
1 O& S2 D- e+ I2 d1 u - *
2 w7 U. E" @ I- q- f( z - * brief EDMA3 Test Application- |3 _% h0 u) p5 m, }* h
- * g+ D; u6 x! w7 x- ^4 E
- * This file contains EDMA3 Test code.
0 v! j/ f4 o$ `2 F" k+ h' G - *) v$ ^# V( z2 ]/ n3 @ }3 \/ J
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE0 B4 E, [: V3 E$ z+ v0 j1 C1 s
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
& ~4 N7 ~1 Q7 H! L8 z - * TO CHANGE.! c" Y+ n3 o- x2 S. D& m
- *4 }# e, B5 c: {( w- e9 {0 S
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 W: }$ j; s& j - *
% W/ W3 Y2 {% T- ?3 a" |0 ?/ g* X- H - * This program is free software; you can redistribute it and/or, a0 a) X2 R2 w3 D
- * modify it under the terms of the GNU General Public License as+ M7 e& h& k$ j. B9 |. o
- * published by the Free Software Foundation version 2.
( }% I- ?1 W( R9 M' q - *0 w* a/ ?) N( l% a% X% e
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
7 ^- ~3 C% `) Y8 E7 w8 v - * kind, whether express or implied; without even the implied warranty3 n1 B% m$ C4 H3 E6 t) |
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% M6 D/ O* D( b% K7 Z: C; A" B - * GNU General Public License for more details.
2 f4 t/ k2 N' I1 f - */2 ?" P l' N. {) @ s _% M# Q
- 7 n6 c# w, _+ i: C
- #include <linux/module.h>
; v1 [5 z/ V8 O0 N - #include <linux/init.h>
% x' Q. q0 L2 ] v: j3 q - #include <linux/errno.h>
" {. V- [% ]) R+ S5 ]0 v; @% X - #include <linux/types.h>9 L# v, |% }) V6 L9 R
- #include <linux/interrupt.h>
" \# e# R' z# [9 B9 t8 d( c+ w4 s - #include <asm/io.h>
) q. n# R- Q6 l- g - #include <linux/moduleparam.h>: R( n% F; E$ l* c8 r) X6 w& \2 }
- #include <linux/sysctl.h>
0 Q; J8 K* g3 K+ y5 D7 ]$ B$ v - #include <linux/mm.h>5 Q5 D/ Q8 H% D6 S: V
- #include <linux/dma-mapping.h>
$ ^2 X+ f, M" V8 g& m0 E( T - + Z" k$ p: O: P. i, L
- #include <mach/memory.h>' Y$ U$ m) a7 o6 g
- #include <mach/hardware.h>
) b) o( O, m0 ^4 u& B; F* m0 | - #include <mach/irqs.h>
) T: H% f1 b$ R' K% T - #include <asm/hardware/edma.h>, s+ ^$ C3 }1 g" ~+ o$ X
$ y, K/ D" ~! ]5 `- #undef EDMA3_DEBUG' n5 o7 y( {' w/ f% Q( A
- /*#define EDMA3_DEBUG*/
2 n3 t2 _0 s1 a2 N
2 {* d5 ]8 _1 M% }% I3 x' j- #ifdef EDMA3_DEBUG% ~, u% N. v& F* S' o6 V, `
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
' J+ Z0 U0 x1 A* k H9 n6 J/ \ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__); h) s% a {) |. J% k! n
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)' y7 u6 H3 R# [$ H8 l# ~
- #else+ y1 q* g- A0 j1 @. n5 D m$ R
- #define DMA_PRINTK( x... )
5 N4 j* ^" j; V U6 U9 s& l - #define DMA_FN_IN" c2 [9 M/ O \' Z0 |) a6 y( d
- #define DMA_FN_OUT i; l6 U1 L5 }% M
- #endif5 Q1 E6 x! i- i' }8 c: d
- / }$ @- j* D- b, T* `' V
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" a! V A" P0 l- o. V
- #define STATIC_SHIFT 3
: ?; }5 j( q) t2 H" e3 f - #define TCINTEN_SHIFT 20
0 o) z: N1 {. K1 H+ s9 q, r/ U - #define ITCINTEN_SHIFT 217 Q8 K8 T2 A( x) Y
- #define TCCHEN_SHIFT 22
3 d& B' u1 A* V0 K9 v; R - #define ITCCHEN_SHIFT 23
" e9 o- `- t+ Z: z/ m3 c
+ t) E4 o# E# S4 N# W2 L1 b" E+ [- static volatile int irqraised1 = 0;* v# @# }! ?! O! R. D
- static volatile int irqraised2 = 0;
+ f9 f+ U* Q- {2 |0 [; s! h# I9 S - 7 t; G1 H0 c5 H2 K+ W+ ?, C
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 |7 S3 o0 O* K' d5 o: Q4 K, P6 `7 u
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. ?5 h- o( b: t y
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) D7 d6 d! p) _* B8 p1 K
- * @& w/ L6 u; l% @, g' ]
- dma_addr_t dmaphyssrc1 = 0;- j0 |7 q/ z: p, v8 S
- dma_addr_t dmaphyssrc2 = 0;
! ]5 [ z5 a4 [2 v8 Z9 O - dma_addr_t dmaphysdest1 = 0;
6 n0 g" p1 Q% U - dma_addr_t dmaphysdest2 = 0;
" h' a' F( |2 J, z" Z% m/ i8 ?
* D5 `; g: Q$ O4 y( G. n9 \3 ?* c- char *dmabufsrc1 = NULL;
$ D2 Z+ C' }! T1 {7 \( R+ S - char *dmabufsrc2 = NULL;
# d5 ~( w: r9 i( q - char *dmabufdest1 = NULL;
w4 p5 u( {/ `" ~( B - char *dmabufdest2 = NULL;. S! G& Z6 v& Y9 K
- ( N6 V+ I8 A& ?; x3 o
- static int acnt = 512;+ V8 N& ?* N) a3 J! }/ y; j( o
- static int bcnt = 8;9 M+ h, z' B! h& q' q6 t, w1 J+ M: H
- static int ccnt = 8;
+ ?9 m/ w9 I7 p5 u5 O* i' d1 E2 s- C- b
4 t$ `( m( c" R- module_param(acnt, int, S_IRUGO);1 H% D. m& N4 P2 m* [
- module_param(bcnt, int, S_IRUGO);- C3 S9 p: O0 z4 }/ g
- module_param(ccnt, int, S_IRUGO);
复制代码 & e/ O# b/ X# V8 K/ t' p
$ v. T5 B- j' I* u 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用2 l+ M `3 D, g& v# @
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
% `" L \$ g5 }5 I/ |, ]( S% J 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 s3 V; E+ H8 r
% f) P& s' X4 f2 Q0 H) v
" G8 ~. u6 L5 V |
|