|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, E4 ~& O- F! p4 v" ~7 D- [code]EDMA sample test application
. i2 }( b' F% a* m - /*
: s% t) L7 ]# _4 P# J6 F3 J& e - * edma_test.c5 s y3 w R* {5 J9 O t, q" x, J
- *
3 l! _# ~ E: Z9 K% T6 b& a6 O$ { - * brief EDMA3 Test Application3 A! X. p/ { P+ M$ w: ^( _/ o
- *
& f8 Y' |- H5 q f% W, W - * This file contains EDMA3 Test code.0 t0 H9 B4 r/ |! o0 ?
- *. t) g" r* D, i. v3 }" K0 V
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- H7 y4 b0 q5 ~' H' B - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" C4 Z: O) m) ^" x$ ]
- * TO CHANGE.) s. N/ g, n4 o6 f
- *
8 x g9 K1 s9 a - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
& J5 [* I* w# @( X; i7 e, }1 [ - *, c3 S4 Q& c0 d# |2 C/ O$ k
- * This program is free software; you can redistribute it and/or
9 D; \ M# _: U. J, n% l - * modify it under the terms of the GNU General Public License as
4 t* H8 T8 R/ y5 B - * published by the Free Software Foundation version 2.3 i4 r( v$ z. [4 ^, w; e
- *. w+ g p+ _ p3 d: Y) ?, ~. d: I( e* c
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any6 N1 r& V$ R. P7 w
- * kind, whether express or implied; without even the implied warranty0 X: r( s6 Z7 q- E! Y
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* x6 Z5 ^: F/ t0 I; x6 _
- * GNU General Public License for more details.3 x0 T# F1 x6 w' A' Z
- */8 Y9 t% k2 I+ w: |
! x% X' {7 s9 f+ }8 j" r6 G3 K- #include <linux/module.h>+ n6 `5 a3 N; }/ {
- #include <linux/init.h>0 _/ T }1 O2 m* k1 o; |
- #include <linux/errno.h>* e+ S# h+ L* m9 F1 F9 p
- #include <linux/types.h>
. F+ t% g# o$ G. {; i. B - #include <linux/interrupt.h>
1 j3 n3 o4 P4 O - #include <asm/io.h>
$ j( k& t! O3 f; ^! v - #include <linux/moduleparam.h>
) }: n3 a* i* B: x% X; B* W w- ^' H - #include <linux/sysctl.h>
- G5 u; }1 w- T/ Y) ` - #include <linux/mm.h>
, O* K+ }# ~& p0 A4 R8 F - #include <linux/dma-mapping.h>
- p3 B- s% C8 |0 ~6 H8 w
( ?/ ?! K7 [' q- #include <mach/memory.h>0 }" M x4 K! F3 Q6 ]- J7 M3 C
- #include <mach/hardware.h>, ~2 E( K4 l, x. q& G% p7 G' S
- #include <mach/irqs.h>
0 C3 G$ B. Z7 y+ _+ U* n* @; C% s - #include <asm/hardware/edma.h>9 J5 O1 S1 X" U3 ]
- ; I3 k6 @5 K3 G( \( O4 @ J
- #undef EDMA3_DEBUG" I& M3 x/ e `" [# ^: b
- /*#define EDMA3_DEBUG*/& Y, A( b0 Z5 A$ X! Q! q1 U
% m0 e$ S, e( c! M7 q' p ~- #ifdef EDMA3_DEBUG9 W: D5 B4 ^0 T5 w& E/ K* M0 p0 r; c
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
8 ^. L& N0 }' Y5 o" p. ] c3 { - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
& k* r" z/ S. m8 `, J g' k - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)0 o" n3 s8 Z) b7 ?" T& ^
- #else( m" p0 B$ Z% A/ _" g% C
- #define DMA_PRINTK( x... )' i9 z( d$ f# s, }
- #define DMA_FN_IN
4 y# n' {3 v: a" k2 R5 z6 W - #define DMA_FN_OUT
0 V. D' ] O4 f( ?7 c - #endif9 ~' R9 ^) c; D0 D
- ! U! k" Q" R q Q8 N
- #define MAX_DMA_TRANSFER_IN_BYTES (32768) Q3 T5 H6 ]0 U/ w q C
- #define STATIC_SHIFT 39 e: C' S6 S1 G6 a: P
- #define TCINTEN_SHIFT 20
) N7 Z; Y' Q5 |" [, H1 C - #define ITCINTEN_SHIFT 21* |6 I* x1 |: B/ e; R( F0 X
- #define TCCHEN_SHIFT 22+ N0 z0 h8 h" V7 p, Y6 W. n
- #define ITCCHEN_SHIFT 23+ Z) K1 b0 J6 f# Z7 W4 N% j
- 8 g* p0 t* U7 o4 ~% B8 j
- static volatile int irqraised1 = 0;8 d2 G3 F8 H: }
- static volatile int irqraised2 = 0;
" F: E+ f4 G* q! W9 r& K- W
# i9 Z- ?* {; M9 R$ T- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) s2 y7 b% o! S2 C m - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ i2 @! a7 F6 L
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% e' V* e( w2 t' S. j5 {- s0 j
1 d: G- M: T+ V7 V5 v) |: V- dma_addr_t dmaphyssrc1 = 0;! @4 J2 _9 i$ a: V) \0 _
- dma_addr_t dmaphyssrc2 = 0;! u, P0 b, V7 } V& \
- dma_addr_t dmaphysdest1 = 0;/ h+ ^% @" ?& y& h5 U* A
- dma_addr_t dmaphysdest2 = 0;% Z T# P T% P0 s. S9 D; `7 i9 X: i8 _
) B' F5 M+ p3 ?9 W- W. s- char *dmabufsrc1 = NULL;
% z3 {) c+ D( D& E% Q7 Q, s - char *dmabufsrc2 = NULL;5 s" R; E& c( ? a0 s
- char *dmabufdest1 = NULL;
3 r, o$ E3 A5 H5 _, m - char *dmabufdest2 = NULL;
- ?! r0 Q8 \3 ?$ ~4 N - Q* c$ N y9 {5 Q9 P) m9 ^
- static int acnt = 512;
6 A% [+ _ f: `3 u0 Q; S - static int bcnt = 8;$ C6 U% k/ b0 N5 w
- static int ccnt = 8;4 K, M5 v. l( w& m
6 n+ g" O( v! M) g7 ~- module_param(acnt, int, S_IRUGO);; i# E* r0 Z# B; M ~# W
- module_param(bcnt, int, S_IRUGO);* P3 U8 o* h8 W: m
- module_param(ccnt, int, S_IRUGO);
复制代码
8 r: s$ S# c! [) A' s% O- X4 ~; ], p* }
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
; ]# Z8 h6 s7 ]! G/ m6 a' Earm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。7 ?) p* z- @- a' W8 Q- D. K3 c
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' f! f3 ~2 }, M* p
/ I$ @, F8 ]% r- h$ { |: U( o: \* O5 P
|
|