|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; [* Y& y9 L9 q( v/ h- [code]EDMA sample test application
5 n9 d: R: p$ z! n - /*) E! L+ N' w! I
- * edma_test.c+ J! P$ N9 w& I `
- *
2 M/ G1 E* h/ ] C0 y: U - * brief EDMA3 Test Application7 r R3 H( y: Y( z G" N3 T
- *. u) n5 P/ J6 |* [( X
- * This file contains EDMA3 Test code.
4 E" x p+ H! L8 m - *. v. q( E3 B* G. k8 s0 S( l3 T
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE+ F$ T) M7 Y4 P- P8 u
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
) b4 E2 ~2 ~. D! y - * TO CHANGE.
/ A0 H4 a! C2 |& Y: K: g2 E$ X - *
% b6 e, ]* ^6 w6 p! a( _/ } - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
7 v* J) b" R2 M5 p - *
@' [. c- P2 d0 L& i - * This program is free software; you can redistribute it and/or
8 Y3 n" K7 Q# C' ^ - * modify it under the terms of the GNU General Public License as& O! H5 U; g) Z5 d8 o8 O0 ~
- * published by the Free Software Foundation version 2.* e: s; ^& H6 q9 |; h
- *' c: w! I K, S$ `; L7 b8 M
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
/ E' j" F- [' a: q - * kind, whether express or implied; without even the implied warranty
, g% c; B0 Q$ e$ m H- d. U0 `. P - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4 z* }9 R. E6 \: L - * GNU General Public License for more details.
% {/ x% e: O4 | - */
9 _0 `8 F+ t1 A, A2 Q, Q - ( ?# J! k+ a7 K7 O5 f
- #include <linux/module.h>
2 S) T l3 d, h- G - #include <linux/init.h>7 P0 {6 i( @; O8 L% W' J# p
- #include <linux/errno.h># Z2 a( ?+ I) M' }: @: G& M
- #include <linux/types.h>
' f) E1 N. U& X1 Y. Y1 } x4 W - #include <linux/interrupt.h>2 Q$ `) @/ c" V. |, {) c2 a
- #include <asm/io.h>$ @- i, t5 l0 I7 H
- #include <linux/moduleparam.h>0 N8 G- Y2 L3 }) }9 X
- #include <linux/sysctl.h>: O- z, p( _7 l
- #include <linux/mm.h>6 b1 l0 Z! U6 _: `4 t; o$ x8 ^
- #include <linux/dma-mapping.h>% X8 k( N. v4 r l* s N5 C3 z
- " X/ E6 O1 k" R- s7 D
- #include <mach/memory.h>: ]" s M. o+ y9 K. T
- #include <mach/hardware.h>
! w0 _( n: ]. {6 m - #include <mach/irqs.h>
, u4 i& j8 c6 K+ S) B - #include <asm/hardware/edma.h>
" t6 L3 H' L" e9 R# N4 g1 o! h+ h
8 E/ r) N0 Q2 G" H: ~# H) L- #undef EDMA3_DEBUG
) ] N' M, E, N) w, S) D1 L+ b: c - /*#define EDMA3_DEBUG*/8 |1 p+ t& N1 U, k) \$ ?
+ s+ ^/ ^) ^, S' d {- #ifdef EDMA3_DEBUG' D9 \; A! T. P3 Q! `: {+ \
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS); ~ R6 o* ^ o9 y. u6 M
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
, }7 r* u! k K% }; k - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
G/ B4 j+ X! z: Y z# s - #else
8 v5 w- f) h; |& \9 P" T8 f8 I" f - #define DMA_PRINTK( x... )
$ o* A$ Q6 [% o- v/ ?! h' T - #define DMA_FN_IN% s8 h/ m9 V" d# [1 s
- #define DMA_FN_OUT
" V8 L3 d2 g1 s' y - #endif
! y# J9 E) P: G - ! O+ }# x& V8 h+ t2 c9 R
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, x: x5 b( T- S' u - #define STATIC_SHIFT 3/ ~ T5 I( H; s
- #define TCINTEN_SHIFT 20
) \% i. A/ G! w: s, @ - #define ITCINTEN_SHIFT 21
- K/ w7 R3 U7 Y$ c - #define TCCHEN_SHIFT 22' R) Q+ I4 O; E! `" W
- #define ITCCHEN_SHIFT 23& b, j# A/ Z. Q! r$ |
% T6 u/ X4 ^! W1 p% R- static volatile int irqraised1 = 0;# N( l/ A3 ^& \: n- D" m0 p, |
- static volatile int irqraised2 = 0;
9 e3 _$ S2 W& d$ w0 R0 v - # Z' C! h* e7 O, M( I
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 N9 p# |. F+ T! s! q/ w! i
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# o; _9 @( ~7 }, I5 H: } - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 q( r. q4 x5 g4 @8 d9 N: H
- 5 }6 _" `2 k' [+ Z0 z
- dma_addr_t dmaphyssrc1 = 0;9 s: k: v. Z, Z0 e$ q) |
- dma_addr_t dmaphyssrc2 = 0;0 H. {6 K0 F& q
- dma_addr_t dmaphysdest1 = 0;/ C' [+ I. b$ r" _! H
- dma_addr_t dmaphysdest2 = 0;9 U/ I2 R, M7 Z& x2 i- X
- : K2 I5 c' ]0 G- J
- char *dmabufsrc1 = NULL;
6 s) u2 u+ A* I; j! m0 `, D0 D - char *dmabufsrc2 = NULL;* N2 L1 Y9 H9 d G
- char *dmabufdest1 = NULL;
$ Z3 U% x; G% N5 ^/ {6 ?) N - char *dmabufdest2 = NULL;
u8 a# V0 z' X - j) A" K. O/ w
- static int acnt = 512;
2 i0 V' ]5 X1 D3 w* s - static int bcnt = 8;3 Y: ~+ K7 i( p! s3 o j
- static int ccnt = 8;, U1 L3 B* C3 d+ N* \0 X! g7 l
- 3 s5 [: s# F8 x8 A
- module_param(acnt, int, S_IRUGO);
6 m- s1 G. k/ e K - module_param(bcnt, int, S_IRUGO);
3 G: n8 N: N6 x) T2 _9 _* ] - module_param(ccnt, int, S_IRUGO);
复制代码 1 p, l7 _; E# b' ?
+ ~* M, S; E8 x5 o* D9 Z 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 z7 L! r! h! |) r; W6 S+ `$ p1 narm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# A% \, A3 q/ C$ ~! ^: r r
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 X( D$ ?- T1 ~. ?" v
! } W) y3 m/ `' V* n( D: M( r
|
|