|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
- Y' N0 ^+ H( x$ S- [code]EDMA sample test application* A$ n; Y9 a0 x3 ^2 @
- /*$ P, E: ^$ t' H( Q
- * edma_test.c4 X: [, o, A" P0 r' B
- *
7 C: |# Q4 s, V# S: Y. I - * brief EDMA3 Test Application
" z# P7 \2 Z1 p* ? - *
* J3 B+ o. i$ g/ | - * This file contains EDMA3 Test code.% M4 v/ ^) ]- A' P+ K' f4 B
- *
2 A! m7 U# l8 V4 h- p - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
& W# {* ]9 [. a. v' z9 y5 a - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 I/ l& n7 K3 u- z
- * TO CHANGE.* q( q a' @/ Z( S! s. l q
- *
3 `7 t( {% r8 A0 z h N - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
! l# B3 C" s( k) j - *
1 x6 K2 `- J& t( F7 Y0 {0 w - * This program is free software; you can redistribute it and/or
. X: U4 T) K' O" Y& E6 r6 A - * modify it under the terms of the GNU General Public License as- ?2 O. H: ^4 i5 l/ P( M% F5 b) g c. ^
- * published by the Free Software Foundation version 2.1 L+ i1 D+ u$ R9 @! e
- *) M+ ?2 F# _, o" Y" a
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 z: L, U. ?4 [% k2 q
- * kind, whether express or implied; without even the implied warranty
. h! @+ w. ]" s& q/ [0 R - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1 \" S2 T9 C' g. X8 o/ y: H; e - * GNU General Public License for more details.. x; s- |5 D1 E: o# b; c- _
- */# O! b# F3 Q: [
' m2 w1 Z! B" [" b, h+ E7 ?- #include <linux/module.h>
8 B8 W, b2 ~9 i1 X; g. j - #include <linux/init.h>" {( B0 m$ `; a- _, Q. b! u
- #include <linux/errno.h># D( J0 T. e( c
- #include <linux/types.h>" @) A0 A& B& G! Y2 O
- #include <linux/interrupt.h> Q& i9 x" Y4 ^5 y H
- #include <asm/io.h>
/ w$ M+ o$ {' t2 M' }- U4 N6 ?5 \( d - #include <linux/moduleparam.h>& o, _4 H: W9 F+ m
- #include <linux/sysctl.h>
3 z/ s( ?1 c# A6 V$ @3 B3 }/ | - #include <linux/mm.h>
! \2 e+ g E) L& r1 Z - #include <linux/dma-mapping.h>
7 Q9 V k, v" E+ _
- v$ U; O4 o s6 L: k- #include <mach/memory.h>- { u& @3 S0 ^& K! \' @- a
- #include <mach/hardware.h>( q) g5 H* c7 C# j3 X% {
- #include <mach/irqs.h>
( W- t' g. R w F7 u; k - #include <asm/hardware/edma.h>& F Z5 A! ^7 g5 g5 _8 h$ q5 [
- 5 V5 F) X) ~% @' ~' _
- #undef EDMA3_DEBUG. `, ^6 m# B+ {* ^' }3 g; t
- /*#define EDMA3_DEBUG*/2 v9 Y+ J9 n G' u; x; Q
+ ]2 O3 B1 Q7 v; c- #ifdef EDMA3_DEBUG1 p' L1 O: W. Q/ r* D% J
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
. \: j1 a4 K! n. v& J - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)& ~! S: ?* M6 n
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( W, A ]6 Z* T9 k
- #else
7 @: k, \# b J8 F - #define DMA_PRINTK( x... )
0 n; J) ^5 d4 R' u/ J* L - #define DMA_FN_IN! {6 ? o. o( V1 G$ S, S
- #define DMA_FN_OUT. L# x" A" d& F4 ~# W9 q
- #endif$ }! {6 M( D8 I' N5 w
- % _+ d/ ?, x+ l& I8 f0 {/ U: {8 i
- #define MAX_DMA_TRANSFER_IN_BYTES (32768) x2 e* u5 m; w, H+ P
- #define STATIC_SHIFT 3/ R! P3 x+ `# K2 c5 B2 ~
- #define TCINTEN_SHIFT 20
+ o" p* c# X7 r' w! n; Z6 G r N - #define ITCINTEN_SHIFT 21# B/ d" t1 X2 r' Z! c( w$ ~3 b
- #define TCCHEN_SHIFT 22" o: C1 H! h) @: ?9 @
- #define ITCCHEN_SHIFT 237 F, Z; H; `; x4 S4 H
- $ J1 S5 p; d, |) H3 F6 v7 x+ J
- static volatile int irqraised1 = 0;
+ C! o- E0 J; ?/ Y: ^; A - static volatile int irqraised2 = 0;
! j8 ~- Z3 W* U# i - * t* M7 Z# |$ Q$ ]3 ^/ Z+ V7 K
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& b6 Z5 a( T9 c- K9 P- r: ` - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 I h$ \# f" {
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 T* Q1 j% L5 J" l! }) y
4 R; [7 b# e ` I- dma_addr_t dmaphyssrc1 = 0;: h) T; s' t/ @* H" H
- dma_addr_t dmaphyssrc2 = 0;
" K; D5 G+ r X/ `) m - dma_addr_t dmaphysdest1 = 0;8 u! C. E |0 R6 |. Y
- dma_addr_t dmaphysdest2 = 0;
6 |# C! Y9 ?9 {" K" Z
7 j, R8 I7 I3 o. K) c- char *dmabufsrc1 = NULL;+ v( C' h/ l x4 l6 R7 A- X, C
- char *dmabufsrc2 = NULL;: g+ u, t4 I, [, _6 w+ @) k
- char *dmabufdest1 = NULL;' X9 N" Y2 p$ _; D7 S. K
- char *dmabufdest2 = NULL;# J7 e) \! h7 I+ `
' p* s" o) V! A- static int acnt = 512;0 r, C/ y Q! y7 a
- static int bcnt = 8;2 P$ U) Y: Q8 G0 w3 t# X
- static int ccnt = 8;$ l7 B, Z/ ?3 a) ^. b6 V- N
+ o' I" e' j1 U4 Y% \4 Q* s1 K- module_param(acnt, int, S_IRUGO);$ F3 @2 Y: P0 q+ s1 L
- module_param(bcnt, int, S_IRUGO);
% Z6 r' |/ F' Y1 `* ~ - module_param(ccnt, int, S_IRUGO);
复制代码
# V% ~/ a& i" Z$ B; O! s, D$ N% ^4 ^+ { x; ~3 H: U& U9 K
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ [0 C1 _. D4 Uarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。+ M* X" Q2 Z+ `
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
9 M4 e) r4 e+ ?1 W! {% Y: o5 c# @' C0 h; r
: l4 V+ U. b5 H4 l. C" m! a
|
|