|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 * }! l- ?3 w$ l! f, T: v
- [code]EDMA sample test application/ f' b* u8 s" B2 {. m/ H) ]
- /* g9 _6 f9 G' H- t
- * edma_test.c
0 Z E) Z' e, M( R' i. M* C - *4 u3 v* Q! ^; y5 n; W
- * brief EDMA3 Test Application8 ^: T* H0 g4 J) \3 I
- *
n6 H3 G& U1 E4 N5 a4 u; z9 w - * This file contains EDMA3 Test code.6 ?. L) d0 Y# a5 P1 u
- *! B% K: h m' |; \5 j! G% Y
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
. n4 u5 a6 n( I1 i: [8 Q - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
0 R6 e2 G" k1 Y8 F& k( d0 t, W" N, D - * TO CHANGE.
8 `# Y) V1 h! T& s! v6 j - *
( V7 Y9 v2 h2 @2 X3 i - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
3 {! ^% W0 {# l6 @ - *
( ~+ F3 Q) J# h0 | - * This program is free software; you can redistribute it and/or1 l) `2 F- y' b" G, A0 w1 f
- * modify it under the terms of the GNU General Public License as; c8 L' M! e7 V+ X
- * published by the Free Software Foundation version 2. K2 `% j* G( E! y
- *+ S2 o3 W2 V9 m3 `3 {
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
3 b' u& ]4 P. a& o2 C' n - * kind, whether express or implied; without even the implied warranty
# U. P; r v* N( ~( t. n7 ]/ U6 O - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the& w' K7 ^, r* j2 U* Y
- * GNU General Public License for more details.* P% |8 E0 q! h" R
- */7 f" P ~1 O. C: a) {' b2 {
- + i( S; V8 ^! I# n; E
- #include <linux/module.h>( ~7 V" C0 ~" t h) f: ?
- #include <linux/init.h>0 q! Q4 _- H" [8 W9 O
- #include <linux/errno.h>
! k1 O- x! X+ o. {) i6 R x3 s - #include <linux/types.h>9 X# e3 f n R$ `( Z" J$ C* Q
- #include <linux/interrupt.h># B- k$ Y8 _/ Q( ?
- #include <asm/io.h>
3 ~ t. e9 C4 ~1 W - #include <linux/moduleparam.h>2 u; n5 c: C0 o& K7 F
- #include <linux/sysctl.h>
8 |7 A! _% S! a; d% ?, o - #include <linux/mm.h>: A! [4 X. u3 `3 Z2 A; W
- #include <linux/dma-mapping.h>0 E0 N4 M/ b' o! Q) o2 g, V; r
- 3 G- }- G: E. i0 O u: u
- #include <mach/memory.h>7 r$ M1 U: o3 \" g* o5 C& F
- #include <mach/hardware.h>
$ c$ X) _( v7 ^' c) _+ ^ - #include <mach/irqs.h>
. C, b p" P$ ^' y - #include <asm/hardware/edma.h>, t8 t. {9 ~% M+ K$ R& L$ ?
: e8 k0 W1 I" e$ K$ G- #undef EDMA3_DEBUG
: r3 }! n+ V4 }& F) G0 F - /*#define EDMA3_DEBUG*/. z2 h9 v1 J( b' ~
) ~2 |# G- T3 X0 f+ N- #ifdef EDMA3_DEBUG2 A1 g" j* T# N9 P+ v" v# d( R- G
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)1 a& ]2 @6 ?( D) J: |* \
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
) q& s0 h) ~) u) q2 q' H& z5 T# W - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
3 @; ]- R' D4 j! c5 @$ ]- r8 l; T - #else
; D2 S7 g) X& _ - #define DMA_PRINTK( x... )
) P! d) ~( Y' Q+ K- z: _ - #define DMA_FN_IN3 o, s! ?. F4 D- m4 e. D, q% ]
- #define DMA_FN_OUT
6 P6 ]# q( W% F/ t - #endif/ F# W/ _+ a5 v) p. f- N( T4 f
& k$ H9 }8 z6 ?0 V5 {* t1 t- #define MAX_DMA_TRANSFER_IN_BYTES (32768)7 f2 U' o) P# r
- #define STATIC_SHIFT 3
# c* G& A# ^6 Y) X0 a" _, d) U& t - #define TCINTEN_SHIFT 20
, l D3 s; r" |5 B1 t: ~5 g0 p" Z - #define ITCINTEN_SHIFT 21% u; _7 N5 o1 c
- #define TCCHEN_SHIFT 22
6 N/ \' H) _0 x5 H2 a - #define ITCCHEN_SHIFT 23" t# g2 ^6 k$ g6 o* t8 Q. H
- 1 c. P9 ?: o. M7 F! j) |4 q
- static volatile int irqraised1 = 0;
" ?4 ?! `' j9 J W& D - static volatile int irqraised2 = 0;
! k7 j% |/ c9 S: d4 \
{+ @9 B& {0 F7 }1 @- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, P: s% |4 p/ h3 m
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ U$ @: F, v+ t! `- \$ a% |
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 n( Y# I# J# y. a
3 ^! C7 W$ [2 d# x7 b1 s- dma_addr_t dmaphyssrc1 = 0;
2 o$ q: o8 r1 k0 V/ h - dma_addr_t dmaphyssrc2 = 0;
4 X$ w6 x) s0 u+ J$ P! D6 o! A - dma_addr_t dmaphysdest1 = 0;
8 v; Y- o7 W9 k5 k - dma_addr_t dmaphysdest2 = 0;
. _% H' P" X* R# M
: q* p# M6 c( ~5 V% n: `4 v8 Z& }5 O' C- char *dmabufsrc1 = NULL;
2 m! `' I+ _' y; |& b/ [ - char *dmabufsrc2 = NULL;1 @3 x' o6 N) \9 I
- char *dmabufdest1 = NULL;
, z5 |& \! b( h, \; m" U; T - char *dmabufdest2 = NULL;3 L* s# m$ [7 L q
- ' [" U, X- M" F# E8 d
- static int acnt = 512;
$ S q, e3 v" c$ ~. G9 i% n+ y# | - static int bcnt = 8;: M w" A) V _' B0 G. x
- static int ccnt = 8;% s. i' A2 U0 T2 C; c- L; f
^3 H" q# P6 A2 Y/ `- module_param(acnt, int, S_IRUGO);: g/ G" b/ J0 O& j1 r% Y* Z6 v
- module_param(bcnt, int, S_IRUGO);
0 p2 o& \5 i& r3 @6 G! r2 z - module_param(ccnt, int, S_IRUGO);
复制代码
7 x9 b) @# @6 U* D1 g7 k; G/ |, a! N( M3 t2 P" X2 n( f
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
% U7 \8 ^( @% E; Z0 ~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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
9 s3 c4 ^/ @" A 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。% b& C! ^+ l- w) U: N6 }* V4 c
$ {6 {' L8 J' R0 R. z9 ~9 g
A/ e. Q# ?& N- t5 d$ n |
|