|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 I) c- g% J" V, z: z; z- [code]EDMA sample test application! r% T/ D" k. V6 a1 L( r/ N
- /*0 W8 D* L, A& Z, K
- * edma_test.c2 w0 E% t* S; r1 T7 v# ~
- *
) y; A0 G& A* u - * brief EDMA3 Test Application- h" A( L* e3 S. Y' }+ o4 M
- *7 G% s ]0 n3 ?) _. h9 \
- * This file contains EDMA3 Test code.
9 z+ [* M1 R; O& U" o8 [ - *$ ^9 ?& M- U) m' x
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE! s& q( R) E) n' {1 l6 _) r4 q
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; C2 [$ f& W F q
- * TO CHANGE.
$ Y- b, _& L5 r1 M - *
F% C+ A3 C9 m* S - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# B$ o1 {# p# i
- */ [7 h" X. {7 e( ? i& a7 A
- * This program is free software; you can redistribute it and/or
, Z- T+ z2 u* |$ u - * modify it under the terms of the GNU General Public License as6 \/ |1 f. J" v# f2 U$ h
- * published by the Free Software Foundation version 2.
' y1 k. O& x Y. U1 L p1 e7 {0 j1 w8 g - *8 U1 K& [+ T# i$ m) t; y
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any1 u( w7 P0 g4 e4 Y) [' h/ m. l
- * kind, whether express or implied; without even the implied warranty
& r! l: P- `" D$ W/ K+ G - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" Q; X6 S. Y- v, {6 T - * GNU General Public License for more details.) X* {2 @% k3 a9 v1 }" j* d
- */
, r6 ^' [3 k# _. {$ I6 i, ]
4 U. e1 Y% V2 A2 V4 S- n/ E- #include <linux/module.h>
]& }4 ^" E4 c8 L ^* v4 i - #include <linux/init.h>
7 J* ~4 j$ A2 D: i/ D& Q - #include <linux/errno.h>2 J8 D* ^7 ~7 G h1 b
- #include <linux/types.h>: _# ~8 B! ]! i$ H2 n
- #include <linux/interrupt.h>
# z8 j5 ^5 l6 F z: h - #include <asm/io.h>. c, v5 R! W+ q1 E- b# o
- #include <linux/moduleparam.h> C& Z8 q) a7 t( ~" U
- #include <linux/sysctl.h>! x- c" c- Z3 z- ]. N# e7 |( t/ A. a$ c
- #include <linux/mm.h>/ ], ]% i" p) \
- #include <linux/dma-mapping.h>6 c$ P& r" M$ P& B8 C( M( f
+ r7 N5 [' F3 o- t- #include <mach/memory.h>
/ R- f' {! o7 @) I, J - #include <mach/hardware.h>+ ?! v$ Q. Q& }' }) x
- #include <mach/irqs.h>
% W8 Q' ?$ Q- x$ w/ f. B - #include <asm/hardware/edma.h>
/ E% u1 C l4 s- e' J, H - 1 B G% ]& Q( w3 Y x. w
- #undef EDMA3_DEBUG+ R) t7 M0 A0 d7 V9 K" M/ d
- /*#define EDMA3_DEBUG*/$ U" O4 y$ _: u' y8 K. T; w
- ; X9 Q0 B( W5 @: \. R5 G' g
- #ifdef EDMA3_DEBUG
" W0 j4 {" V, E: x' p6 G - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)2 d4 p$ B* `6 J6 v+ c; l7 `( q4 K- R
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)' B2 q: |- c# P$ x" n* _
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)5 g4 _ c7 C. c5 a
- #else7 m s. p, V5 y6 u& F6 U
- #define DMA_PRINTK( x... )
% j% Z0 Q+ \- w# g$ B - #define DMA_FN_IN
: X& @$ D+ t. J - #define DMA_FN_OUT6 s2 s8 n8 r z& N) Y
- #endif, V- J- j- @ v1 m( D: l+ m
- # D2 t) n G8 |' K/ U
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)4 Z6 A5 ^0 Z" \1 Y- ~ w
- #define STATIC_SHIFT 3
" P7 |: P/ d( Y* A - #define TCINTEN_SHIFT 20
$ f9 D' z7 ^4 V - #define ITCINTEN_SHIFT 21. R' i4 q: K6 K1 |# y
- #define TCCHEN_SHIFT 224 ]/ K9 m; K* {: V9 O
- #define ITCCHEN_SHIFT 23
1 \$ F" t# z& h6 T
* u& z3 e' k' {& {- static volatile int irqraised1 = 0;4 g: w7 G2 S+ x2 J$ r
- static volatile int irqraised2 = 0;
9 {8 b o( r, {/ t- n
, h+ e$ [2 j9 h- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- e1 U0 B- n" F2 S! w% i - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 u- Y% [ m+ N3 t3 A
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! d7 d' u, o- H - " S+ I0 J- y* C2 q/ s& U# ?0 W& Y
- dma_addr_t dmaphyssrc1 = 0;1 |* I- b8 ^. m1 o, ^9 d8 o
- dma_addr_t dmaphyssrc2 = 0;/ N$ x1 }( q$ @: R
- dma_addr_t dmaphysdest1 = 0;( ^" u& C$ \( w) r! H1 |8 \1 @, T
- dma_addr_t dmaphysdest2 = 0;
+ v& M* o# j3 i% r+ ~
+ k7 A* } i; G- char *dmabufsrc1 = NULL;" @+ v# c; f- _7 O( i( Q3 `5 R
- char *dmabufsrc2 = NULL;
$ T# N/ R/ h( \1 l - char *dmabufdest1 = NULL;
" t7 @, t( e3 |6 r, l3 u2 e. l: _ - char *dmabufdest2 = NULL;
, f. @7 S1 U M
. Z$ g9 o; l, i- A$ a- static int acnt = 512;& p5 I% y1 c& v$ y3 v
- static int bcnt = 8;
- T5 y- m# d/ o - static int ccnt = 8;- V8 D4 I# ?0 r$ r- u$ i4 `
6 v; |$ D6 e9 K2 p/ {) g: d! v- module_param(acnt, int, S_IRUGO);
9 Q/ f; I P6 d1 g' r4 }* ~: y1 } - module_param(bcnt, int, S_IRUGO);
7 `( A3 J' T! k% P - module_param(ccnt, int, S_IRUGO);
复制代码 ( U6 o" m1 ]3 w# ~4 z4 Q
* _2 ^* c+ g& q) j 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用, ]1 f; a6 o0 N# X' W3 Q+ |
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
: b1 d2 r. E w0 G7 {9 _) b( g. R 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
6 H5 w( O* }8 Z! f/ h9 ?5 [8 M
0 G6 _+ C2 ]4 g% I% }
$ f3 X( f$ M2 {# w7 { |
|