|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
K1 R4 w+ @: p9 |4 v- [code]EDMA sample test application
# u; R8 q; r+ Y1 R- @2 k - /*
7 D& y0 F3 ]6 K& _# |/ ^8 { - * edma_test.c8 S2 H1 N" Z: S( k$ V
- *
9 ]$ G: s1 X" ~, f1 v2 S - * brief EDMA3 Test Application* B8 W: U$ ~/ [, M/ @! Q$ |0 G
- *3 K5 c/ }- L3 O" n3 D! S5 [$ t
- * This file contains EDMA3 Test code.! a; l8 D' q8 s. e+ N
- *+ L- g$ T+ F% C; ]' ~
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
( i/ \- o4 A3 N' R: U - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 K" h' j* K0 _9 G, H4 ?% _% R
- * TO CHANGE.+ C: x% I$ Q* q
- *8 j5 s: _1 g' h0 o) v( ^
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; z$ l+ W- i- C8 O5 v# H, U - *
1 P' W1 c$ M/ P& {5 N7 p) \ - * This program is free software; you can redistribute it and/or. P$ C) l- X. K* O) D# N
- * modify it under the terms of the GNU General Public License as9 K5 t2 O8 ]+ L9 E
- * published by the Free Software Foundation version 2.
1 M6 K: \; ~! R. Q, }2 K - *
% f" ?* D2 U7 C( T) s% h - * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 `5 K2 Q/ i X0 u* O, i; E
- * kind, whether express or implied; without even the implied warranty: Q" R2 ^- |: n' n- U8 D4 H5 }, z
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
: q! ^, ], h& F- h* | - * GNU General Public License for more details.5 c8 U9 m9 y- B. Y2 E
- */) ^5 }' ] ^# ]7 `( ~1 h
- * z* X3 k' U/ m& v' y+ B9 ^; C! W
- #include <linux/module.h>
0 \ d/ r- x; p - #include <linux/init.h>$ T ~/ y, M' u
- #include <linux/errno.h>
- L; L8 r: _' T' Q - #include <linux/types.h>
V: M$ ]% k) R" F. i9 L7 \/ q - #include <linux/interrupt.h>% c! n+ T% r+ o6 W m
- #include <asm/io.h> r1 O- U* l3 F/ d
- #include <linux/moduleparam.h>
7 \& n! f+ h' k* i, B3 k - #include <linux/sysctl.h>; g, }+ E& ~: E2 H
- #include <linux/mm.h># ]1 s5 [! _! [0 v3 x
- #include <linux/dma-mapping.h>
9 Z1 p# _! \ Q1 K, P
* C: d! {5 v' ]' e- #include <mach/memory.h>
6 m8 {* d$ a) D5 B/ r - #include <mach/hardware.h># a' V. s& T' _0 ]8 Y! R
- #include <mach/irqs.h>/ e! J3 I3 S! f
- #include <asm/hardware/edma.h>
( R0 q2 Z e) g6 u6 y - 3 ?& e3 y2 m/ K- |
- #undef EDMA3_DEBUG# F+ L0 Y! h4 [' i' u% N) a/ r
- /*#define EDMA3_DEBUG*/% o' n% Y+ g" [2 H, R5 t" K
- / j; B0 H# x. _; o; r
- #ifdef EDMA3_DEBUG+ C) W- J# x: c( u
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
. j# O, d$ Q* [- n8 w - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)# K0 T. K& b6 Q! o$ q
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
; H4 F& s1 {' c - #else
1 f! k0 r& t- X3 e6 f: { - #define DMA_PRINTK( x... )
2 g1 ]2 I# |) k Z# w; n - #define DMA_FN_IN$ |) h# _9 ~! Q2 [. U& a0 x* q
- #define DMA_FN_OUT" U+ B" x. h& V. I) J( J6 m
- #endif' A8 z& E* T5 {
: v/ q5 t% s& Z2 P- #define MAX_DMA_TRANSFER_IN_BYTES (32768)8 l" b% b4 e( G+ b" N9 M/ a2 w
- #define STATIC_SHIFT 3% L: @" @7 k2 ]( l) O0 Z. P
- #define TCINTEN_SHIFT 20
- {# ~* b- `% ?4 j! k- p. u - #define ITCINTEN_SHIFT 21
3 G5 |6 q) y4 t* S/ U& Y, d9 K - #define TCCHEN_SHIFT 225 o$ C# m8 k4 I7 o
- #define ITCCHEN_SHIFT 23
# O1 [% a$ W4 f( f, K4 O5 F
% E$ p. _) F$ t8 ?- d3 r* l- static volatile int irqraised1 = 0;6 b2 w# J4 K0 m; E& }# I) w
- static volatile int irqraised2 = 0;
- F8 w- @2 D/ v w
& m# @. T, u) K" [- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 S; j$ O3 ?% ?) Q
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, k& ^* K! v2 a; n i9 | - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# n$ B1 R. S1 {8 z+ N" X8 G
- - h) v! M7 J% l0 @' W
- dma_addr_t dmaphyssrc1 = 0;
/ j! t3 s# n* e" [ - dma_addr_t dmaphyssrc2 = 0;
M4 E- N3 z7 _" t3 ?8 l - dma_addr_t dmaphysdest1 = 0;
4 P) E( P; u4 m5 M3 h - dma_addr_t dmaphysdest2 = 0;1 e4 X1 T& V9 f( p: }
- ; J4 Z% {% I. i: r
- char *dmabufsrc1 = NULL;' R9 r3 [& d0 |0 P/ g7 D
- char *dmabufsrc2 = NULL;0 ~; B: v$ o: {2 W
- char *dmabufdest1 = NULL;' M9 S# h! _. M5 ^
- char *dmabufdest2 = NULL;* [7 J) g2 p% L6 [% u( Q, A2 T
@/ \9 E$ a. H* P q& g$ t- static int acnt = 512;2 N8 z' Y# _, ?3 D$ T+ }
- static int bcnt = 8;) e& O% V/ s/ v( o: s! I, @) d
- static int ccnt = 8;
v/ x& \8 c1 J [% I X6 ?
$ x6 r8 v$ m& F' R- module_param(acnt, int, S_IRUGO);
4 u: R, y9 L" A( t7 U9 [ - module_param(bcnt, int, S_IRUGO);
* X9 |+ _! o9 d- u - module_param(ccnt, int, S_IRUGO);
复制代码 2 [. J0 N. t) X* Z* r3 X$ k
, z' J$ i+ B, g5 P7 g. i5 A
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! x' b3 `5 Y* @- _0 P0 k; Zarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* O& N1 ~6 Y- [- T6 F: _9 o# }, x
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。$ O/ J0 w$ O, i. H1 L
7 [, @2 m4 H/ x# m( t7 |4 _4 K+ {3 p( L9 ?% e4 ]- F* K, w0 f. J
|
|