|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ' X2 j, R9 R) Q8 c4 ~0 l/ L
- [code]EDMA sample test application
- `) n9 y7 [& q* v: X* j$ z - /*& ]' R9 _3 y4 R; q4 w2 X) }) Z; M, G
- * edma_test.c
; q. c3 L8 q/ c - *
3 v; ~2 i( q- m" n3 G9 a - * brief EDMA3 Test Application
( l: i% v' q @" a0 @) `5 g# Y: K - *5 p S! K, E' q* d3 m
- * This file contains EDMA3 Test code.
' F+ Y" T/ S8 h - *
4 y5 I% o7 G" `, G) v - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
) I* a; @+ A! J) h - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT. S- F7 O( F1 J5 [
- * TO CHANGE." a6 j. b6 H7 P- K) R
- *, V' i& ] Q- Q. ]; \1 a2 S6 J) [
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; h! B" r9 y$ y2 a6 N+ z - *
. b' V" l } J - * This program is free software; you can redistribute it and/or
5 [8 c9 T# }$ C5 ?1 I - * modify it under the terms of the GNU General Public License as) {: s _+ D* [
- * published by the Free Software Foundation version 2. z9 o: U# g1 }4 a* K
- *
, R" Q6 O7 v. J/ h" A% ?2 [# o - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
' v1 j: K% [' |" Y - * kind, whether express or implied; without even the implied warranty' \, @: S9 l% p4 I" a$ u
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 C+ O- P, K6 Y- U" w - * GNU General Public License for more details.
& j* R \9 B- }" h - */, ^6 @7 T9 z m: n: T5 l
4 ~ S9 [) n4 N) N- #include <linux/module.h>3 K( W9 n# Y6 P3 s4 E8 F
- #include <linux/init.h>0 l/ G; i5 z0 l% K9 O
- #include <linux/errno.h>/ ]$ T& m5 R# V |; p
- #include <linux/types.h>4 I$ H+ N+ _% e1 O: i' G! Y, ~
- #include <linux/interrupt.h>
2 k0 ?4 {2 e# C' W9 d6 ~! K - #include <asm/io.h>) q' p7 d* m4 K! s- D6 J
- #include <linux/moduleparam.h>. M5 C' K t1 Z' Y7 U/ d, L2 w
- #include <linux/sysctl.h>2 G: m8 i* ]8 |/ \
- #include <linux/mm.h>
; L! l0 s$ H* a- V) z - #include <linux/dma-mapping.h>
+ s! H7 R/ m% l7 s. @2 Y7 o
3 b1 F6 N' _/ w8 N8 h1 |- #include <mach/memory.h>
9 M4 l3 e+ X4 A# |8 i - #include <mach/hardware.h>& r% i0 K5 m" o) w
- #include <mach/irqs.h>7 t( e1 Q7 X( S8 s4 }
- #include <asm/hardware/edma.h>
# r1 F/ M2 |/ h
t- ?3 ~/ P z' K; B' o/ r$ _- #undef EDMA3_DEBUG. h$ f/ p0 t- C7 J
- /*#define EDMA3_DEBUG*/
& }$ E E# p. b
6 L% o: z9 R" k9 H2 b& q- #ifdef EDMA3_DEBUG* p; p& S) q3 S$ n' G) D0 j
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- |3 @: j( \9 L' U8 ]+ \ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)' z |$ R& i# d* Z- h% F4 h
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)- i/ v& x m! y' A! U( C
- #else
" @5 ]# J7 @( W+ j l2 J+ o - #define DMA_PRINTK( x... )
) ~8 g) @9 _: e# K7 ~ - #define DMA_FN_IN% e8 H$ q7 f# v7 L) A9 {; ~+ \
- #define DMA_FN_OUT
' o/ n' t& K1 L4 `) Y1 Z - #endif0 }+ v2 D3 y8 v. j% r1 p
1 F* p, d% ?- _8 X3 B4 z9 A- #define MAX_DMA_TRANSFER_IN_BYTES (32768). [& \! E3 ]" Z! }, F0 _" g
- #define STATIC_SHIFT 32 G0 D* p6 A, \$ h2 e
- #define TCINTEN_SHIFT 20+ x5 |' B. H9 {* E3 d ?
- #define ITCINTEN_SHIFT 218 T8 I0 @( x& W$ E E
- #define TCCHEN_SHIFT 22+ @7 a" ?' c5 v9 U8 Q9 S2 C' \
- #define ITCCHEN_SHIFT 23
( ]4 `1 E: C+ V, W- ] E; L
) O# T2 f( Q4 T8 a) H4 m8 h, m4 @- static volatile int irqraised1 = 0;
+ |2 G* v0 y% C1 H( N9 q1 f - static volatile int irqraised2 = 0;. V3 Z" N1 a0 \1 y8 m4 W8 `- |' @
5 ]1 f% \( R# b4 e- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 L. C5 w- [3 T
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. V; x7 V" L' z; q% g2 n
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' I: t; m. T, Z( z2 N1 W3 b - 0 n! d3 W" Z2 T9 f
- dma_addr_t dmaphyssrc1 = 0;
8 f' C% |. P1 j3 T4 f! X& b3 {2 G- w - dma_addr_t dmaphyssrc2 = 0;
% G. Y; N% G) L) A+ Y# z - dma_addr_t dmaphysdest1 = 0;) N# E( W, t# d3 l
- dma_addr_t dmaphysdest2 = 0;/ }; }6 d( {% @( y4 Q+ r% ]
- H, Y* S2 ?( Y
- char *dmabufsrc1 = NULL;
8 b: y1 L& F' c( c+ @% S - char *dmabufsrc2 = NULL;
$ z- r/ \* Z/ I H r - char *dmabufdest1 = NULL;
+ W+ f% V Z' X% i$ \- |% }, H - char *dmabufdest2 = NULL;
( J' _$ h7 Z; e" ~ - D6 {/ y# J1 Z& K2 E- s9 @ V5 I) z
- static int acnt = 512;4 h: P+ r4 Y5 d& Y) I+ i
- static int bcnt = 8;) m8 S0 R7 O! u. H- B* |: @
- static int ccnt = 8;2 w r0 F! E" l
- / ?1 D' F2 o1 y8 K7 i
- module_param(acnt, int, S_IRUGO);4 @* m0 y: t. H, [4 Z3 |' S( T: p
- module_param(bcnt, int, S_IRUGO);
7 R" o* h- i1 ~! m - module_param(ccnt, int, S_IRUGO);
复制代码 1 P9 D+ g# ?3 L
! V* k4 ]' i0 w# s" l0 J
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
# V4 J7 n. x! f: v1 zarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。- l4 e7 o9 V* ?1 M0 m' ^, u! B
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。% P/ Q) u, d6 [/ Q! t
- t# }4 W ]2 W0 J
; R3 u& q0 t1 |0 l. G, T! _ |
|