|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
/ v6 f0 O+ m1 M: J# d. l" {4 b+ A- [code]EDMA sample test application! h0 Z. W' X: c0 j* l+ ^; I
- /*/ h+ ?: p# i: E. ]# h" c% g
- * edma_test.c
9 G; s- H9 h. z/ g6 V - *5 { H2 s* L g4 g5 L* d: q* ?
- * brief EDMA3 Test Application
; L3 C1 _0 W; p) r$ I2 t* n& I - *. H3 Y% o1 v: a7 W4 O6 c
- * This file contains EDMA3 Test code.
' C# d: ]- C/ [% B4 r - *3 G, }; O& }/ e
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE3 j' \; F4 u0 o
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
. S2 {9 t) A8 c5 v+ W) K7 f - * TO CHANGE.
- A" j1 c V J) ^2 g( f - *
5 f. V4 E+ e: g5 n3 N* D' W - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
: h5 b1 \8 y z1 O9 M - *
2 _- ?, i9 m1 w' |( x) ` - * This program is free software; you can redistribute it and/or0 v" Q# Y- _9 B5 k
- * modify it under the terms of the GNU General Public License as; c4 b; f4 O2 g, P5 V% v; i7 H
- * published by the Free Software Foundation version 2.
- O- n% R( V) Y7 y9 a - *3 Q# H2 ^/ h$ `" s) C) z2 J; V
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any; x' K, C& I& ] x: Q. a
- * kind, whether express or implied; without even the implied warranty3 R' z5 b4 b1 k7 a' {5 s
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% N9 t( m: u8 H4 V% \' _0 E
- * GNU General Public License for more details.
7 `! D7 ~* K' f8 L% X% a f - */
* _5 m6 k; ~+ ^( T9 D, p* y - # i: D0 {+ l# }
- #include <linux/module.h>
5 r+ M& r3 c% c4 b' S - #include <linux/init.h>3 G4 ^4 `' d; l7 C6 r
- #include <linux/errno.h>( u1 p' ?# {' s' \0 y3 U/ ~
- #include <linux/types.h>
0 s& X# N8 `! j# q - #include <linux/interrupt.h>$ {1 ~, |1 C/ T! W8 E: w% e) O
- #include <asm/io.h>
$ h! j& t+ Q2 U5 V% ^! C2 y+ K- B - #include <linux/moduleparam.h>: d! S% p8 f1 w- K* O9 ^
- #include <linux/sysctl.h>
, `+ N* S2 Z; r9 H) ^3 J: r - #include <linux/mm.h>
& {; I% w! `- x: _' R# u; W - #include <linux/dma-mapping.h>
; U9 E) {3 Y4 G0 E
1 @9 G. ~# c2 I$ p/ F6 |- #include <mach/memory.h>% b! d9 q' i/ A1 W6 h
- #include <mach/hardware.h>* M8 G( _, o9 |3 B
- #include <mach/irqs.h>- p8 u$ O% d+ M, C# v' Q$ I
- #include <asm/hardware/edma.h>
/ Z1 a4 D# T* V: d - & R* J7 p/ j$ N. j
- #undef EDMA3_DEBUG9 i3 }" g6 q9 K6 m8 U
- /*#define EDMA3_DEBUG*/
; m7 r* `) F: ], _, e& u# f
" i; r; K9 E/ w* [! N- #ifdef EDMA3_DEBUG
* J- c2 s- X+ w# G6 _$ V - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" R3 T5 j- ]! m1 O4 W, J5 ?
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)8 O3 } F+ [6 o8 X5 ]+ S
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__); |' ]4 O% r/ ~+ J9 ~& W
- #else
" J7 x$ p" t& @( w& v - #define DMA_PRINTK( x... )3 O8 h4 a$ |4 o! z- N
- #define DMA_FN_IN
& a$ F1 \$ @) N9 u6 j4 ^ - #define DMA_FN_OUT
) B* U% h! U7 g" ? T* R1 F+ e - #endif
' h; b9 P, h" B. N( H+ d% N+ m - ; S! K1 b I! l. l2 k/ ~, P8 z/ m
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
! `# |6 q5 ]% h, q1 u - #define STATIC_SHIFT 3( V' a. |6 L8 [0 v
- #define TCINTEN_SHIFT 20
0 V* a- m6 L: `: P" M& f8 R" H" W0 L - #define ITCINTEN_SHIFT 21
+ B4 O! T5 |8 V' ?6 U! A6 L - #define TCCHEN_SHIFT 22
+ u1 |/ W2 d' e2 r' ^, t - #define ITCCHEN_SHIFT 23
" p7 h6 V3 g3 h2 K# {6 D - ! M- H4 R2 w# [; s& c2 Z# Z8 G
- static volatile int irqraised1 = 0;
' j7 o6 q4 O7 h5 G2 ?2 D - static volatile int irqraised2 = 0;
7 r' p3 l* a8 S6 | - " i; {4 h: X Z# F" h) ]) N! v
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. f/ _% P, _' L0 i* a. {" V
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 i- H4 Q* D/ h
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 E6 @/ H+ I$ q; W; K - 5 o) H3 r5 Z1 k8 y5 a2 v
- dma_addr_t dmaphyssrc1 = 0;
- u9 k+ u% a) x - dma_addr_t dmaphyssrc2 = 0;
4 o2 b. T$ {- j$ p8 ]6 j/ K5 ? - dma_addr_t dmaphysdest1 = 0;
6 i3 k: t$ f. } H. I( f - dma_addr_t dmaphysdest2 = 0;# S1 \" V7 S# ?( j
, j8 z# {7 l% @6 T9 e$ Y- char *dmabufsrc1 = NULL;
8 o7 W+ ]( c- D5 v& b; L; j8 J5 o - char *dmabufsrc2 = NULL;
# y& s: y' M+ x - char *dmabufdest1 = NULL;& ~! s. f2 A. c" s8 O; a8 \, E7 w
- char *dmabufdest2 = NULL;
8 M- p3 X5 n. q8 _# O$ d
/ z" [' ~+ u1 G$ u& K6 `- static int acnt = 512;; ]+ \5 G1 \1 `' C
- static int bcnt = 8;
/ B X: C2 x/ d6 q4 D$ A: R" b5 g - static int ccnt = 8;
5 ?* O' m! m# f( P, I - % F# U: |+ y, v" J' g
- module_param(acnt, int, S_IRUGO);
. N0 `8 I* E/ Q& ~ - module_param(bcnt, int, S_IRUGO);6 a8 E. h0 U* {. j
- module_param(ccnt, int, S_IRUGO);
复制代码
7 }) y# F" M# T8 N$ r$ q1 z' `- q$ ~# e/ \+ P( {/ o+ J
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用9 z8 ~" H8 q' Q: B# D* Y- f
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。: I* X F* h8 E, T4 w2 g4 ?
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。( s* g/ S% H ~) Y7 K
& ^ z. d# |& m+ A# e$ z
- s: [0 `6 E7 o+ F; Y
|
|