|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! h; U4 N" Z0 p, w- [code]EDMA sample test application( R/ y) f5 a. W1 M; H
- /*
T+ C) Z, f# W0 E: ?3 {, h! d5 T - * edma_test.c
6 R$ a; v. `* V5 `4 R* e - *3 n1 F: r. d4 J6 M4 r/ n
- * brief EDMA3 Test Application
3 i* k' o2 Y+ Z - * e5 H6 ]- ^$ K8 S7 i
- * This file contains EDMA3 Test code.8 T2 v; u& E" C4 _& f( \ W) T2 q
- *
9 y x" J6 V) D1 T6 h* h - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* p; v3 {( d; v% n - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT) X. u" [. u8 B9 [3 v
- * TO CHANGE.4 g; j( |) z, r8 a
- *
& a5 s, ^1 t9 @1 Z2 x - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/5 @, Z2 ?0 z/ w! y7 _! C9 |) F
- *
1 |8 e% H; O0 m5 V. f8 Q7 o1 L2 I - * This program is free software; you can redistribute it and/or6 V1 I4 U; M: Q, d7 P
- * modify it under the terms of the GNU General Public License as3 p: _4 M, F* f3 C" ]
- * published by the Free Software Foundation version 2.- m- ^3 T& h0 c* e3 ~
- */ F* I, c" N- ?6 d! F# `
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any0 `! T# k$ }; X- K8 X2 p
- * kind, whether express or implied; without even the implied warranty
) h4 [ ~" {& C; |; l2 ^ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# V) v/ Y2 ~/ f Z, w+ P - * GNU General Public License for more details.$ H0 K( L) T0 `2 M
- */5 r6 c# q; d/ b0 g
- $ ?/ N' G7 Z# Q/ V& _! A! v! f
- #include <linux/module.h>2 b& H4 A* {4 o
- #include <linux/init.h>
# ~- ?' F ^& M* ~* v, D% A, O A - #include <linux/errno.h>+ \( I0 n4 b! F2 {8 c0 @) W
- #include <linux/types.h>: F+ [/ k( G# [8 ^' z) h1 o: ~
- #include <linux/interrupt.h>
$ j6 I) i, G/ K3 q d - #include <asm/io.h>
* T$ c% G9 n3 o) h; F: k6 D- ] - #include <linux/moduleparam.h>+ t% d$ d, ?0 @% h2 E
- #include <linux/sysctl.h>
% u u9 h* T2 w - #include <linux/mm.h>2 t% l" F3 p5 O% q
- #include <linux/dma-mapping.h>& n4 c& K- f' o3 p9 A
- : ^' p( c _1 x7 u
- #include <mach/memory.h>
/ `& U& ?% g9 m! q - #include <mach/hardware.h>
+ e! x8 M( R' P- l- [6 Q! F1 I - #include <mach/irqs.h>' x8 }2 v2 ?6 L1 n
- #include <asm/hardware/edma.h>* U8 M6 c- w4 V4 l( B/ c2 T, }
- & b, y; X, Q4 t/ d7 Y/ r3 y5 E
- #undef EDMA3_DEBUG: Z, T! H9 y9 k1 ]
- /*#define EDMA3_DEBUG*/
" v' W% D5 A7 i& \0 B0 ]. O) {8 k - / @6 \. P2 e* L& s3 e& J7 z7 j
- #ifdef EDMA3_DEBUG' s; S/ ^1 I) n4 Z3 C' ?
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
5 I- n* n6 p: m8 }& f; M# A - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. U6 U3 G U$ \! k - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
9 W% L$ B x7 R - #else( b3 x$ ]7 b# d
- #define DMA_PRINTK( x... )
. }, l/ U/ X8 n+ Q - #define DMA_FN_IN0 }( Y d: C) A J! G
- #define DMA_FN_OUT
: T1 t0 b5 s& j1 H - #endif
4 v) G1 j8 w' H" s8 u - - |6 `9 I* Q: g' k
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, [0 a9 }0 f) A - #define STATIC_SHIFT 3- Q) n- M8 `( @0 b
- #define TCINTEN_SHIFT 20# s3 I0 @6 R& [" Y
- #define ITCINTEN_SHIFT 21
- n* A( {& a5 x - #define TCCHEN_SHIFT 22
1 A5 ~& t+ d+ _/ O2 P - #define ITCCHEN_SHIFT 234 d4 a! y+ [+ f- ]0 ^
- . c5 l( @+ f) l
- static volatile int irqraised1 = 0;
2 E% f" i1 b' K - static volatile int irqraised2 = 0;0 H! p7 h% }: A' u: n f+ P; H
* ]9 m) w! ?5 u8 v$ I9 S6 O( O- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" P a2 l* ?# Y: r6 I; ]; T
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ T/ r; F' d: e! z - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 m1 q* }8 k6 J! M2 h3 [. q3 n* D
- . J) j4 E+ y1 @4 T9 K8 n
- dma_addr_t dmaphyssrc1 = 0;
' J% m9 f" u( M8 \ - dma_addr_t dmaphyssrc2 = 0;
) x9 R% {% [4 I. @# m - dma_addr_t dmaphysdest1 = 0;
1 t0 s f( x, ]/ V m - dma_addr_t dmaphysdest2 = 0;
: r, ~9 r3 {( e! ] - 5 A4 R) e7 f- t5 s Y; @3 C
- char *dmabufsrc1 = NULL;0 V) |3 z: M! f3 [% o9 w/ w
- char *dmabufsrc2 = NULL;9 L/ L B) V2 p: `8 o! k4 f
- char *dmabufdest1 = NULL;2 G$ u- ?8 z' b a( r& z. T
- char *dmabufdest2 = NULL;% I) E7 w! I% Z1 e: l4 z' J9 N! n
: R7 l, f$ N, F. d1 f9 Z; K7 X- static int acnt = 512;
* d4 w7 \+ o: p/ U" ] - static int bcnt = 8;9 ^6 T7 p9 a0 ^! Z3 d$ v0 \$ X
- static int ccnt = 8;
0 x$ I8 g( I. j+ E0 | - 6 N& h6 ^" H, e, }2 j5 {
- module_param(acnt, int, S_IRUGO);& u! g; Y, z) P
- module_param(bcnt, int, S_IRUGO);
) n. L5 a4 g4 y - module_param(ccnt, int, S_IRUGO);
复制代码 ; M) B) F. e* }# a2 p$ p) ?& W# `
: M" e7 m6 L5 y3 k9 K) C" e8 ?
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用( |3 O$ I! u; V( b
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 e U# A o9 a" j% i 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。! Z# f) O9 p4 `" k: y7 j( K
" k$ F$ U; b6 O }9 C$ V! O; l
" m" N1 b; q; |/ o. u; ?' C; Z |
|