|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
/ Z/ S2 h3 T) G- `- S9 B- [code]EDMA sample test application
3 w" o- E8 v" h - /*
, i; q- A: P: f - * edma_test.c! f7 o: g) l4 U0 C5 O
- *$ [5 H0 v% i" m z+ V# @
- * brief EDMA3 Test Application
) E# Y4 f( s& n4 H; g. W4 Z0 E' n9 J - *
# n# o' @2 S: W; M - * This file contains EDMA3 Test code.% I# z1 s K! B6 S
- *9 I6 z+ O! u5 C5 ^1 T
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE* I% G3 a- n5 I, e6 w. E" ^' H% J
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT2 k6 e) C7 b1 B1 ]4 u9 [7 j6 ]' m
- * TO CHANGE.
: X* U- L4 p0 T7 C O - *0 v% \* T( _/ \+ d1 F! m
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
9 X3 `4 v- S9 Z+ T - *2 p" Z# S( z0 i: k- b4 J
- * This program is free software; you can redistribute it and/or
' ]/ N4 F/ Q; X( M( I - * modify it under the terms of the GNU General Public License as
# z9 V! t7 N9 }5 e. ]1 `% ~- F - * published by the Free Software Foundation version 2." g" F6 d, B1 r/ g1 \
- *
9 f9 P! m# S- ^9 @ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any M8 i) R. L/ L1 Z5 ^. ^% P
- * kind, whether express or implied; without even the implied warranty+ y% G7 Y% B; R# a: ^, K, |4 a
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- T! _) l& ^% J/ o2 r0 w - * GNU General Public License for more details.
# W% n$ [: b1 `6 v( D5 P+ G - */
+ E. X# J# Q& ]" p, B' s8 F - 0 f- Z, G0 j4 M) n, B [
- #include <linux/module.h>
# g+ @3 s6 {( g$ h& f - #include <linux/init.h>& j, v% s# [, u/ |. V ]6 f; s
- #include <linux/errno.h>
% D* S. b9 ~' R7 k9 q - #include <linux/types.h>
# l) Z0 Y( B$ k2 b4 e7 e& Z( A - #include <linux/interrupt.h>
/ x3 }7 ?) j: \0 V9 T. G0 w - #include <asm/io.h>
" W2 Y) l( |: @: P" T+ O f - #include <linux/moduleparam.h>. l' [& F, D) _% S5 Z
- #include <linux/sysctl.h>0 ^+ n7 T( t% m: B0 x6 c. S
- #include <linux/mm.h>( ], O% j( a' I
- #include <linux/dma-mapping.h>1 G! f+ ~- D; L, |% l5 J" \! R
- ) m6 [6 d1 S( q1 S7 o
- #include <mach/memory.h>
% h: U( A2 }; W: O2 `8 N - #include <mach/hardware.h>
6 P- ~* B. Z2 K4 F - #include <mach/irqs.h>
- ]/ g4 j2 W- S! Y7 \1 q! W - #include <asm/hardware/edma.h>* Z5 `$ B* S& U7 @1 f# g4 Z' a
$ {& d% }% |. n- #undef EDMA3_DEBUG
0 U) ^& a6 {: v4 ?! Q - /*#define EDMA3_DEBUG*/* U( y! }4 q- s! {, W
; a& k# |& G" ]7 ` D+ c& g- #ifdef EDMA3_DEBUG8 A7 F7 P' P0 |! F) ^
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
$ n% m {4 h6 [: ]2 a" c' X( K0 W; p - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)% ]/ c' D' G8 O$ ^/ n4 g
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* V2 B7 [8 Y$ R+ ?; ]: o" z* {, q
- #else
/ t0 [3 y' {3 d- _ - #define DMA_PRINTK( x... )2 N. k. o5 d% {' d g
- #define DMA_FN_IN
3 _/ p3 G7 j8 z$ x- O - #define DMA_FN_OUT. B+ f A! O6 ]5 Y- G4 U7 `
- #endif: F+ Q6 n2 S6 H/ h
- 8 m3 a. Q- Z5 N. [
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
) g" _; f3 A: c/ v. y* P0 U - #define STATIC_SHIFT 3
, r1 H2 J4 c7 r - #define TCINTEN_SHIFT 20
: d, G, u0 a5 I! E1 G - #define ITCINTEN_SHIFT 21
& j2 ?& | B) s1 M: H3 v- G - #define TCCHEN_SHIFT 22
& T v8 ^5 s9 D1 c - #define ITCCHEN_SHIFT 236 m, B" s0 s, B
- ! u8 z4 h9 G( s6 y1 t
- static volatile int irqraised1 = 0;
$ |8 N* i _1 y - static volatile int irqraised2 = 0;6 y4 ~$ q% T& u9 Q
- S, n) E3 z% S5 \4 o, D- o- G' u- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" ^: g; ~4 Z: t0 z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! c1 R4 Q$ L* ]4 I0 \6 A
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 n9 a0 ]# W- |; N/ h, F
! k& B& _9 l: i- dma_addr_t dmaphyssrc1 = 0;
9 O& T) M; ~+ D8 y- Y* M - dma_addr_t dmaphyssrc2 = 0;. j0 V! Z: Q7 t: {. v* y4 w
- dma_addr_t dmaphysdest1 = 0;# D* [' T& G' z& M
- dma_addr_t dmaphysdest2 = 0;$ R; U- |8 \& b4 j
- 3 g# n$ R/ m1 I" a* A8 m7 f) _
- char *dmabufsrc1 = NULL;
& C2 K, V6 ]$ }. W- J. u- a" X6 \ - char *dmabufsrc2 = NULL;, u7 ^( p! F! F
- char *dmabufdest1 = NULL;
m) o9 {- q; K K( N3 ~ - char *dmabufdest2 = NULL;+ r; o5 s3 L7 Y$ y) q9 C" b
) e3 c0 m+ r c* }* r3 W- static int acnt = 512;
2 Q! V" H- z1 v8 ~6 T0 ?6 y. g7 k - static int bcnt = 8;
x5 K5 e P3 B! b8 @# z - static int ccnt = 8;
/ `( w5 x$ Q7 o5 `! b9 |7 ]
. m& ^0 t& A' R( |0 b- module_param(acnt, int, S_IRUGO);- t. ^- e/ e! b J5 [* M2 ^
- module_param(bcnt, int, S_IRUGO);
" W9 u% T+ Y3 V. u" _. C - module_param(ccnt, int, S_IRUGO);
复制代码 6 y* O( @8 V4 z$ C
1 s4 @' M0 Q+ B4 a8 c
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用/ e/ S6 q0 J5 X2 Y
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
, p8 h+ u5 F* H. \" r$ d 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。# Y) b* a, E6 n1 a% A
$ I7 ^! H3 y7 N5 Z/ ?+ J5 W' d
, N3 N4 N6 o n. n4 K* R+ J |
|