|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 U" E" c1 L& E% }5 _
- [code]EDMA sample test application
) G; B6 @0 c% U8 |8 ?, T. q - /*
; L6 f! y$ @; ?- ~ O& J& \$ v - * edma_test.c
" n9 ]! h: C4 B - *
! O7 Q# s* x4 N. A- M - * brief EDMA3 Test Application7 [8 l) H3 J2 ], O+ Z
- *0 ]$ M; e: C6 v; B9 c/ Z
- * This file contains EDMA3 Test code.
! x8 |6 |/ \, Z ~ - *
; P6 g# O2 o. u# A$ Z$ m - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
, z( T( d. r8 x+ I - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT- x1 n- x. s1 [5 P: O+ |
- * TO CHANGE.
9 v+ T. u+ v) Z7 P. C - *
2 L! j9 J' S5 V% o- V - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
$ v7 v& w% r" p" R) Y4 K* A - *
( ]& l9 b: K4 X8 r# _ - * This program is free software; you can redistribute it and/or! h& j" i: P8 g- a) Z7 @
- * modify it under the terms of the GNU General Public License as
7 Y* b8 R1 X0 ]% _4 H( N5 e - * published by the Free Software Foundation version 2.8 I* x* E: ]1 h8 a
- *
' }: D5 ^ ]. W+ T" S: g2 Z6 M - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
. ?) B) \4 X. @2 t0 f9 V - * kind, whether express or implied; without even the implied warranty
; e1 }% `( Z: d, }2 G* }- V% H9 @* R - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the3 m" O9 N9 d# z- ^# V- p
- * GNU General Public License for more details.
& _$ X7 c! A: Q8 e/ R% C - */
7 u* A& o8 R# E
' P2 e# x4 @; u! q- #include <linux/module.h>
$ Z6 p3 ]! s: ~4 l - #include <linux/init.h>
" w9 L) M3 N, C( m* Y; `( U e* ? - #include <linux/errno.h>
) b4 ?9 J% `6 Y2 } - #include <linux/types.h>
: J. ^! D& V5 [2 U& V$ o - #include <linux/interrupt.h>
' v2 h/ {; ?! b e. C, \; ` - #include <asm/io.h>: W2 H, j" @) t) B" F! P) R1 J
- #include <linux/moduleparam.h>, p0 P+ e( U4 x/ i1 n" B
- #include <linux/sysctl.h>
$ r& r! H7 H4 A3 m5 `5 Q - #include <linux/mm.h>
( X4 }- L2 J3 P* V! j - #include <linux/dma-mapping.h>4 R5 y' v) R: b# A3 ` e( F9 q$ s5 B
0 b) {( |0 A4 a; g- #include <mach/memory.h>
$ J6 |* X0 p) ^' Z( b% G; n' O$ v) p4 o - #include <mach/hardware.h>. a/ k, Z- p2 n: K. @! Q# v. q; J1 r
- #include <mach/irqs.h>& a9 _7 f \" O8 A7 L' S7 X2 j, N
- #include <asm/hardware/edma.h> J: X! T6 }$ ~! {% |: J
- / Q3 O7 g7 u& y/ K% {" u
- #undef EDMA3_DEBUG
' _& R" ]( K8 l& X2 [6 o; n L - /*#define EDMA3_DEBUG*/( x k T) J1 r) |3 A5 a
- ! T' T7 p3 ]3 s2 K4 |9 n
- #ifdef EDMA3_DEBUG* i& a7 _1 n/ Z5 z
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS) L2 F6 I, T- W& n& u
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
# y. V8 [3 _) r$ _9 u( _; y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! Z0 A/ _+ @ `* ~
- #else* t3 }7 y% q6 B8 o: Q; A% M9 z' ?
- #define DMA_PRINTK( x... )
$ y. ?1 o5 `) k5 p- ^, _3 f - #define DMA_FN_IN
% v- f# F# h( x% ]# {: ?+ { i - #define DMA_FN_OUT
8 k( n2 N3 o( v- A% O3 ?1 }) ] - #endif
( _' P; y- Y" B `- z9 @
6 v6 R: w4 A& d" F$ W- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
9 N4 S C5 {2 C7 \8 G& E - #define STATIC_SHIFT 37 v6 b( P2 z4 f5 e+ k5 G( b
- #define TCINTEN_SHIFT 209 R2 Z2 U- O9 m
- #define ITCINTEN_SHIFT 21
; k7 o# ~; y; z# p - #define TCCHEN_SHIFT 228 I: W- F$ \- p5 I9 f1 y
- #define ITCCHEN_SHIFT 23$ H0 ?0 `% i5 R5 z; s. t$ r8 a
' V# L$ R0 k Y! y$ q5 i [/ M) w6 f }- static volatile int irqraised1 = 0;1 |" W+ ?' o9 t, n& |1 n
- static volatile int irqraised2 = 0;: N1 t) O- y: R; ~. k& \2 O/ r
8 U+ I- I4 Q, E t* O# H. r- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. N; o# H0 W+ S$ x! i7 {
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 U+ ]8 J' Q" z- p9 p
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 J4 D/ z6 x! c. h2 @/ o2 w
$ t/ N, M% u; w- dma_addr_t dmaphyssrc1 = 0;
% t9 x4 W0 b9 u# v! u - dma_addr_t dmaphyssrc2 = 0;
, u0 X" W; z1 v - dma_addr_t dmaphysdest1 = 0;
' L2 I+ i* {7 Q0 }/ Y - dma_addr_t dmaphysdest2 = 0;( ] a+ t+ R ]- q% k$ |
) _* X. o" p$ b. E5 a- char *dmabufsrc1 = NULL;
8 M. T7 s+ T M - char *dmabufsrc2 = NULL;
2 u0 D- w" s% U- N" V* ^( s - char *dmabufdest1 = NULL;
7 w$ J8 c( ?7 `7 v - char *dmabufdest2 = NULL;2 P" C4 Q+ _9 ]/ g7 i
- & }1 M" ^& g& `" R
- static int acnt = 512;- k6 Q" o5 H3 H$ r' Y
- static int bcnt = 8;
3 Z7 c/ c8 Q, g" E$ K; l# U4 Y; Y - static int ccnt = 8;! a* b2 g. j4 F. b% I3 }9 P3 _
- . @* ?# ]* U# N" d% [& U# D
- module_param(acnt, int, S_IRUGO);
. {' s) i( O8 j5 c1 r - module_param(bcnt, int, S_IRUGO);8 D( v- {' U; y* n A3 U- j. C
- module_param(ccnt, int, S_IRUGO);
复制代码 5 S$ @9 c1 N' P* v
" [3 q4 C' b9 ^ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用' @7 k' H& x. K$ |
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
# K$ O% |2 g4 B! V- A: } 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
9 r9 g- }* m" F+ o9 m4 J4 r6 Z$ z( W5 M X
0 S. F& j: p! u+ R- f7 ~3 x) e5 t |
|