|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 6 G% g* y) v0 h; e$ d C" y! l
- [code]EDMA sample test application
- \+ H7 T6 j, Z) C: N2 i6 m7 H$ N - /*
O: T" a! w# } - * edma_test.c J: }1 e0 |6 k- [
- *
4 O, S8 ^# f: \& D8 W9 B - * brief EDMA3 Test Application
7 z/ _0 z I4 \+ T- E - *, @/ U: l' S6 ^+ {" I/ `: }
- * This file contains EDMA3 Test code.
' U5 @& }* H) ]* x5 j5 Y - *
" h& X' V( H; ^, p0 s O3 D3 T - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 N% N2 d5 M* I/ F7 U
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
P3 c; v! v, |; e6 v - * TO CHANGE.- L# l( W7 y/ p; a
- *
& v7 {) f% k2 _& f* h& ^8 V1 | - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/+ i$ M, w' w# i( O( S
- *, |: x2 D( D8 g' L+ Y6 N4 M6 @( \
- * This program is free software; you can redistribute it and/or8 | R7 `- g0 b* B3 Q+ L6 Q4 a
- * modify it under the terms of the GNU General Public License as6 N; t- s* f2 ?* \# k& n/ |" Q
- * published by the Free Software Foundation version 2.
9 n5 H9 v/ m- m: [% |* B - *4 C2 ?8 l, h7 @
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
1 ^. D$ |/ i3 L - * kind, whether express or implied; without even the implied warranty& X/ R4 k( [$ {1 S# b5 P& O
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1 w; V: {+ @9 d0 a1 t; L7 F3 g
- * GNU General Public License for more details.
6 b% u3 _6 Z( g- _" @$ { - */
3 q# ?+ W% }4 B* ^6 F2 }+ a5 B5 L
' c6 V9 [4 I' Q" s1 m o- #include <linux/module.h>: _) z; y8 `' P6 x5 {8 A% n2 V0 U
- #include <linux/init.h>
$ \4 H+ E# L5 N - #include <linux/errno.h>% u7 U5 |3 D1 F5 ]4 U, y2 P
- #include <linux/types.h>
. R. i0 q. v0 _! v; n; q4 i' F - #include <linux/interrupt.h>+ {2 `* s% r: f, i: m9 R
- #include <asm/io.h>1 I I0 g4 z* K. U
- #include <linux/moduleparam.h>
, v+ W. l( ?0 A) J/ E% }( U - #include <linux/sysctl.h>
& F2 U- h$ v( F& {5 Y7 _ - #include <linux/mm.h>7 Y& s8 m! K1 J! O) w. d
- #include <linux/dma-mapping.h>. U4 e+ P- q8 c: |" i; [% x
2 H9 A! O; e3 s# t! o; v }% }) X- #include <mach/memory.h>- ^+ d8 y+ B+ g( h6 u
- #include <mach/hardware.h>4 W$ S1 @5 T! f* e$ f
- #include <mach/irqs.h>
% b6 }7 ]3 l: g/ X/ z3 v$ E - #include <asm/hardware/edma.h>* ^" f h, i, `/ Y( k9 L7 k: H! `
- 9 A+ G; R% v* R" e. c
- #undef EDMA3_DEBUG
, {: B# N/ @) j0 z8 M" D - /*#define EDMA3_DEBUG*/
& ~/ c2 V( D/ G9 _5 Y t
# {1 c/ q" h( ]. t# |# x" ]- #ifdef EDMA3_DEBUG
! o& _' g7 U' W) V# J - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
9 I, z/ o" g. v5 h1 ~- p - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)$ v# t5 [* g3 f6 d" C( l, m5 c) |* {
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
: R3 p* T* N9 R& v( H) K - #else: p7 E0 c$ t. y4 _ X
- #define DMA_PRINTK( x... ). N9 N% m) O2 ?" l- w/ }& \$ [% b
- #define DMA_FN_IN$ S3 I4 @" y) W2 Y: x- J4 @
- #define DMA_FN_OUT
! ]3 s' j& p3 |( h8 ^& o - #endif
7 o; F- L+ |6 q+ B
- M. C4 z/ J+ [- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
& {3 S+ R# p& w0 N1 \# G - #define STATIC_SHIFT 3, s7 C. W2 k/ t. H6 `
- #define TCINTEN_SHIFT 200 @6 I" t: |7 O' S
- #define ITCINTEN_SHIFT 211 ^5 F% g* }' U8 z5 D' o& S; f
- #define TCCHEN_SHIFT 22
) o0 R$ N, C6 Z! x! W, I+ M a - #define ITCCHEN_SHIFT 23
* e) s1 R( G! x9 Z$ x" ^" u: Y - 4 f1 T" C: a1 [
- static volatile int irqraised1 = 0;
[1 F" e. N; b% a3 |; Z - static volatile int irqraised2 = 0;# t2 t ?2 D) t3 L2 y/ q# f
- # Z; v/ y- ] _
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" _3 @8 \; q6 n- S0 |: J4 J - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ m6 E$ X# N `8 k6 ^0 \6 s - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: Y! _' t9 z) o7 z% Q. x: A
- % n) }4 G) @5 f, _' x* \6 a. n: p
- dma_addr_t dmaphyssrc1 = 0;
# B2 p _' Z' T% v6 Q' Y - dma_addr_t dmaphyssrc2 = 0;" Y! D5 U. o8 q: q* [
- dma_addr_t dmaphysdest1 = 0;
3 u' c- G; O1 B' r - dma_addr_t dmaphysdest2 = 0;& N( I! E5 R( J3 | e$ {
$ i" V6 W; ]6 X5 Y# F' E- char *dmabufsrc1 = NULL;# W0 q( ~& b& U# X
- char *dmabufsrc2 = NULL;
& Q* M; u: a* B0 H0 T4 P - char *dmabufdest1 = NULL;6 d, d d5 W" [8 c& y9 d, h
- char *dmabufdest2 = NULL;
8 |# S+ A$ ^, n9 p
% s6 G, L% L/ E' V( W/ @- static int acnt = 512;
0 F, F# [& \7 @' B6 X - static int bcnt = 8;9 M* K; F% Q- Z
- static int ccnt = 8;
9 u/ F+ G4 ^' _, i
: ^; X# f+ ^: U3 V0 L# z' B- module_param(acnt, int, S_IRUGO);
$ |' j. c/ Y) u4 s4 y2 d+ X - module_param(bcnt, int, S_IRUGO);4 L* { P5 N% q$ V% o7 h7 O
- module_param(ccnt, int, S_IRUGO);
复制代码 7 w8 K) J5 |) m
0 Y7 O! w& C3 n: V3 }
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
, M: G; X9 s2 l1 K9 {8 yarm-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. s6 O) a+ T 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。% N2 I6 g: _4 r% _) S
1 ^) t8 t! `: M! r) F# j1 T) ^5 O* Q q/ g( s' j
|
|