|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! ~, ~9 {$ d" C, t. K- [code]EDMA sample test application
8 l/ H4 v3 J) f4 A% Z* D% i9 q+ v% o - /*
8 I; W9 U- |& M8 r$ x9 ] - * edma_test.c: `: Z4 W0 P, W9 i) ?
- *2 }+ { S" R% O E f( W
- * brief EDMA3 Test Application
# C# R) p3 \) q - *( G% h$ n) Z' b# z1 O+ B Q; H
- * This file contains EDMA3 Test code.
' G# X- S( `8 [/ d4 l2 Z+ k - *
8 r; _$ T. g* X - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
: a* u( a3 B! o, w" ?0 z - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 Z; H; s- a/ O7 g7 T
- * TO CHANGE.
$ m$ q% k( m: g' D/ G+ [' h5 m - *7 A4 D. r* T9 y) p6 z$ F
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/& n) H$ s8 D; y- t* n$ |3 |
- *8 s: A8 G @7 e: q3 h8 D
- * This program is free software; you can redistribute it and/or" B4 d* q2 w% @% Z) s* g4 X
- * modify it under the terms of the GNU General Public License as1 l/ E5 _' B3 i1 F. T$ d# c& j5 ~3 g
- * published by the Free Software Foundation version 2.+ }3 r. |) O8 ^3 T, p4 X1 g
- *
8 e% |; M+ `/ w) q7 N - * This program is distributed "as is" WITHOUT ANY WARRANTY of any6 O0 W& t. x; \) k
- * kind, whether express or implied; without even the implied warranty
9 m: m) V- P0 o; }8 T- c8 _ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1 q2 S0 t7 E: z) G7 R; f
- * GNU General Public License for more details.
$ A1 b, z: I- m' j$ i) z* y' o - */
4 C1 D# V4 j, N - $ }. B4 U5 g% |% j5 T
- #include <linux/module.h>
, ^+ ]" V5 `9 {! z$ i - #include <linux/init.h>
7 W8 j5 t5 F' {" o - #include <linux/errno.h>
- U6 C2 X1 r8 E! X - #include <linux/types.h>
5 Q+ H' ]; A( F0 l - #include <linux/interrupt.h>
! X7 c1 Z- e. p7 @, H% a - #include <asm/io.h>. n7 V$ d) d- W, C; N
- #include <linux/moduleparam.h>) x; d3 L0 L, d5 f1 `
- #include <linux/sysctl.h>; D8 K* ~) O0 T6 |3 T
- #include <linux/mm.h>
- T5 v' c1 C: a9 O. J9 a( j - #include <linux/dma-mapping.h>* W( E1 ?6 I1 n
K1 `9 w w# a3 z2 Q2 J: P- #include <mach/memory.h>
S) N: |8 a) G. T8 Y - #include <mach/hardware.h>
t& T# B: V7 N7 x - #include <mach/irqs.h>
* h( L2 N6 Z \* Z7 | - #include <asm/hardware/edma.h>* g' t9 Q/ h R& N$ J
# d: I- i+ f' y6 s- #undef EDMA3_DEBUG
6 O7 W9 |. e0 G - /*#define EDMA3_DEBUG*/! J" W, A5 q' W
- . i* h7 Y! o, c8 G& J$ E2 U
- #ifdef EDMA3_DEBUG
8 }& {& l) p' X. {7 g8 f/ L - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)0 F& q& C6 J3 l! t5 l
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
/ I) Y0 K6 ?3 T - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)/ F3 v; Q- ~9 R& F4 T
- #else) b0 X. m1 ]% a3 j" b% n5 e$ ~
- #define DMA_PRINTK( x... )/ L- K2 ^5 A- X# @; `5 \! v
- #define DMA_FN_IN
5 ~' {% b5 e' Y& U+ D1 e - #define DMA_FN_OUT b# J$ X2 ?$ l
- #endif) ^* {; L9 F: o4 |2 H8 O
- / a3 C) l$ S- M$ B9 G
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" @5 T# L- q- ^+ t9 W8 | - #define STATIC_SHIFT 37 ?6 m+ L i" X
- #define TCINTEN_SHIFT 20! A3 } U6 h @& T3 X
- #define ITCINTEN_SHIFT 21
* ^' G0 W9 i; R$ t' @ - #define TCCHEN_SHIFT 22
+ K1 Y+ G# r* e% _, Z% X - #define ITCCHEN_SHIFT 23
$ P! R% S: a: t4 ?5 M7 y' c; U$ v - [4 e) N% H9 |/ M& Q
- static volatile int irqraised1 = 0;1 h4 [- Q5 Y( u4 t1 r
- static volatile int irqraised2 = 0;2 s7 [2 P! X/ f+ g
; w) r ?: L) n( M' I3 X- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 q6 z& x: B, D+ u - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, z4 K) X% S3 }& L5 I
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 z Z% d O$ H; D
- + k) F& I9 J% ], y" `( c- R
- dma_addr_t dmaphyssrc1 = 0;1 Y" u5 r2 Z5 l* M2 x) L( {0 i. N
- dma_addr_t dmaphyssrc2 = 0;& s5 `+ [7 a _/ j- V) |' a
- dma_addr_t dmaphysdest1 = 0;
9 G5 T3 a4 C' N - dma_addr_t dmaphysdest2 = 0;
6 i( J6 {0 l( A# p# V% P5 V- v - * f* A# P/ X* d
- char *dmabufsrc1 = NULL; W% E9 Z+ U% L
- char *dmabufsrc2 = NULL;
; o: G3 e. p: q4 ~; W - char *dmabufdest1 = NULL;( s5 \, i, e+ v* {' y% h; |! e
- char *dmabufdest2 = NULL;
9 M1 ^6 X- ^8 `" n! X* z* ? - ' X L9 y2 Z9 [; o' y5 e
- static int acnt = 512;
0 u, A2 T) d9 T _* X) F4 J - static int bcnt = 8;
/ ?+ p2 I5 T9 }* K: \ - static int ccnt = 8;0 u" o7 |' ?& ~! ?+ N% h, y
4 L. l2 q7 }) u' S! M1 L- module_param(acnt, int, S_IRUGO);
1 d3 T1 D( |+ B# B - module_param(bcnt, int, S_IRUGO);
5 u* ]" s" Q2 A& B8 ~ - module_param(ccnt, int, S_IRUGO);
复制代码 ' f1 s2 X, [* ?% C+ a
& p: S# h5 i- M 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
. G3 L1 P' q4 u* O E8 r$ [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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。' r" |- X, |* Z- B# Y3 a
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. M- P! W% P6 ^1 |4 x+ N
% K" @, @% v2 [. X) g+ e/ U$ N. ~" i }4 Z$ f
|
|