|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, @7 E- K1 y5 _' l$ t( H- [code]EDMA sample test application, R4 x4 v& }) _$ }9 ]
- /*
/ q& e) {9 S' ~, e9 O - * edma_test.c
; _( R5 U* z3 @# B& A - *5 k$ b* V J* |8 y# }
- * brief EDMA3 Test Application* `( e6 o7 i5 ]6 ~& D
- *9 j4 I' w, ~9 c
- * This file contains EDMA3 Test code.0 p3 ~6 s. r1 m0 @- q1 x$ q N
- *; |3 x1 z2 L |+ X4 h& c# L
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
. `. s0 n& u$ y% h - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT8 n$ n7 x* S+ i" n
- * TO CHANGE.
6 m2 I L; b9 u6 k% K( Z - *8 V. ` C* S6 i& R/ {# k/ D
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' ^7 Y9 z) H9 A D: z, t* s - *
1 C+ ?- J& w# Y6 `, P5 E# t) n) v - * This program is free software; you can redistribute it and/or. @, a$ c8 M3 \- ^; v
- * modify it under the terms of the GNU General Public License as" k; [2 S" C! `4 P1 r' q
- * published by the Free Software Foundation version 2.* ^0 Q9 K+ B) S% H
- *& f8 e% ?1 J6 ~/ j- ? T
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 x, c; r) @7 f5 Q* C# H! U2 @ - * kind, whether express or implied; without even the implied warranty
) [, }4 k: ^' B) }. z- r1 @ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 P; _) F( j( z- k2 j - * GNU General Public License for more details., g+ ?7 f. ~" V& V4 B$ `- L
- */. `3 P% ~( G" F/ R+ t T
- & m5 Y D5 T! X
- #include <linux/module.h>
& B4 u( @5 q; [& K# S2 Y. y - #include <linux/init.h>
% p( Z' x7 `4 V: @" D1 L2 Q2 H - #include <linux/errno.h>
% H: B# M% _# P" X: \, O - #include <linux/types.h>
) v! q8 L/ C5 V2 h+ W; v4 z - #include <linux/interrupt.h>9 t7 K# {! k# p' ? {1 E% ?3 P& i
- #include <asm/io.h>' O7 o# y5 J( c) Y1 K
- #include <linux/moduleparam.h>
) t0 W/ v% q, l& X8 A* u9 Z \! u - #include <linux/sysctl.h>0 p ~; t0 M: N+ E0 x2 F9 }
- #include <linux/mm.h>& v3 A. f% Q* C& f$ b5 A# @
- #include <linux/dma-mapping.h>: d2 g }! c) |1 k3 }; L1 n
- ; P/ j8 `+ H# R9 b T+ b+ h
- #include <mach/memory.h>5 r) c$ S2 \0 ?7 v- P4 d8 `2 J
- #include <mach/hardware.h>
$ L5 T- M9 x# a/ p" p5 N - #include <mach/irqs.h>9 m; Z0 _4 T8 e# Z7 W, h
- #include <asm/hardware/edma.h>
$ x& v) _) f# X7 ] - : O1 {2 n9 v- H+ V# J/ |
- #undef EDMA3_DEBUG
; y5 U, w( N; a# C& Q - /*#define EDMA3_DEBUG*/
; X) Y/ m( H* u1 c& s# ^& c6 Y - 4 y X) C% R8 q) L. s* u
- #ifdef EDMA3_DEBUG
5 W. y# b5 M! K0 Z t% `& Z' o - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)( v: b' w7 `% [, A8 o: A! B
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)! Q; S7 ^( w, A8 c7 _9 ^' D
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& `% ~1 j, Z; _& x
- #else
1 Z( h1 D" A G& j) T" { - #define DMA_PRINTK( x... )
3 }$ u* m) r0 B7 H+ C - #define DMA_FN_IN
+ A3 f) s4 b" f7 m) O l. x2 S - #define DMA_FN_OUT: J: t' L8 `8 W, f1 O
- #endif
/ g- X |5 v0 W( @1 b5 P8 N6 q - 6 v, X9 w) q; |- W S# h7 q$ S
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ `/ K* j% m: N
- #define STATIC_SHIFT 32 M) ^( r. m) Q8 C
- #define TCINTEN_SHIFT 20
* y' n$ O3 W) k, D3 P8 B/ ^2 @, H7 x5 B - #define ITCINTEN_SHIFT 21
9 B n6 c1 {, c7 l8 O - #define TCCHEN_SHIFT 22
2 A4 Q3 P1 S' l- g% h l - #define ITCCHEN_SHIFT 23
& ^: w7 w0 E3 h! W
1 ^ h) G# C. _9 l2 u7 G% z- static volatile int irqraised1 = 0;( O# T( x9 f' V. F) L8 v
- static volatile int irqraised2 = 0;2 E* G0 d; [( I$ E
- # U$ h; J4 |- G- ?) K4 Q% A& l5 U
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 O9 E+ T0 P2 w6 f. P- c1 b - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" h8 g# L% n9 ]2 [& u! | - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( d3 j0 P9 R6 j4 M9 h
- # T( Q- P9 s% F, }" }6 L
- dma_addr_t dmaphyssrc1 = 0;# J7 P7 D# p/ o. F+ D7 f! `7 @
- dma_addr_t dmaphyssrc2 = 0;
9 g- q9 a* ^! g - dma_addr_t dmaphysdest1 = 0;
1 p" [$ N8 x5 I+ b' i7 r: i# V - dma_addr_t dmaphysdest2 = 0;
) e1 _: g- E6 k# V2 u0 j - ! |. X/ w- s; E! T# }- v! f+ U
- char *dmabufsrc1 = NULL;
# ?% u" L' ^7 G5 U - char *dmabufsrc2 = NULL;
. V: R0 j* X1 l$ S" d. r7 @9 m; E" b5 u - char *dmabufdest1 = NULL;2 T5 x, t9 O# o) q) |0 g; O5 o
- char *dmabufdest2 = NULL;: h/ b5 ]( u( r
! ` l' s; T! D: U9 N+ c- static int acnt = 512;
% L0 `% B* [ _0 k! a - static int bcnt = 8;! ?! N5 j0 J& X4 d2 {) }/ @' h
- static int ccnt = 8;
2 B) a! _7 B7 a4 C& @" y" i4 M+ q - / K+ \' `, i. U/ M
- module_param(acnt, int, S_IRUGO);; \6 n( Z q9 m; C6 v J* j8 X
- module_param(bcnt, int, S_IRUGO);" G9 x: V* ?/ d
- module_param(ccnt, int, S_IRUGO);
复制代码 + P8 N# L$ x' G6 `- r3 _
8 ]1 A3 j: ~3 K 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
3 {5 u" ?/ k- @/ rarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
* R8 z& Y3 K) }# ]- C4 a4 C 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
9 M7 E) }: Y- I$ ^! \3 d% n) J n% f
8 a+ }7 m% S; i: s% s |
|