|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, y% c" |8 P; D" }% W- [code]EDMA sample test application
5 [) V) W5 ~5 o2 ^) }4 q - /*
6 ^9 F) [" W: ~: ~ {; Y! g5 e+ u - * edma_test.c
& Z- \* k. z! R' F" z. `$ @ - *
+ }$ c! s% N5 O* z5 ^4 u$ d - * brief EDMA3 Test Application8 Z/ B: {( |- M9 [: \$ n- J
- *
7 M* W6 ]4 R2 t, v - * This file contains EDMA3 Test code.
( \) o% @* E9 }! P - *3 L' K$ H4 _3 y B7 t
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
& `5 e+ f5 x# g; |# x2 a - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT( X% [# k( X1 B# Y8 G( Z) w
- * TO CHANGE.4 P* o: z) g* q6 q# L9 q
- *: M. `& l4 j- m! x
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
. h! V5 n6 E" ~3 Y2 I. F - *
; ]+ K, F3 \" Q: ?$ M% `4 w' J* i3 [ - * This program is free software; you can redistribute it and/or
% Z! l1 X$ P" A C& }7 \ - * modify it under the terms of the GNU General Public License as% J! n3 ^6 m: v" [7 A4 o: G
- * published by the Free Software Foundation version 2.
! b; M9 J/ z# T0 h& H - *' U4 A( c% o/ Y4 {* J C) P. h) Y! W
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any3 z3 a+ d9 R# k+ C) W
- * kind, whether express or implied; without even the implied warranty
: l7 {# u" |# D - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2 @# F) M7 v' [2 w - * GNU General Public License for more details.
! Y0 M& e" @$ E6 ~! X7 H - */+ ^4 z) s' }% m
+ P4 j. I- F. x9 N- U1 [- #include <linux/module.h>
5 t! P/ r3 e" [2 D3 z% t/ | - #include <linux/init.h>7 X( c) E! X5 {
- #include <linux/errno.h>
# ~/ U, K6 a7 M- H' C% j/ [ - #include <linux/types.h>
% |4 i% o2 c1 F: M - #include <linux/interrupt.h>$ h8 I+ T+ ^ [" }
- #include <asm/io.h>: U5 c- Q) |4 w( Z
- #include <linux/moduleparam.h>& P) x7 r7 F% U& X8 ^( D& V5 s! M5 [
- #include <linux/sysctl.h>6 i) z' l6 b+ P& `7 j2 G- w; h& V
- #include <linux/mm.h>$ z, {* x' e }
- #include <linux/dma-mapping.h>
" N9 R4 d; o, s4 I% T3 J# n1 O
) |6 ?- f2 x$ V/ H- H; `7 U- #include <mach/memory.h>
) }- q* C) _0 l - #include <mach/hardware.h>- g2 G1 X3 b( E6 Z4 d! c) _
- #include <mach/irqs.h>, k+ a r% Y2 }0 M g- g1 c3 m
- #include <asm/hardware/edma.h>
. H5 Q. r' n( f5 R - 3 R3 G6 S& x. R
- #undef EDMA3_DEBUG
- u3 V$ t+ x. Q: \( G( L: L1 l - /*#define EDMA3_DEBUG*/
1 b" U0 i+ f) @' A" @" M - $ d* u* n5 q( c2 Z- K) f
- #ifdef EDMA3_DEBUG) z8 ^0 Y1 R8 G& z' ]
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)' a: h2 r+ ]3 n2 z
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 M8 I; ?7 L' s$ O5 ~' ] - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__); q* s0 L5 D" ~; b: I1 C; \" O
- #else
/ {! `) N+ L, _: S - #define DMA_PRINTK( x... )
3 D: B5 v$ f) F3 [- x+ \ - #define DMA_FN_IN3 d2 V- F" K% D g
- #define DMA_FN_OUT
- F8 ~0 N' Y- z; x H% J, T - #endif
% K; l T0 Q7 V& l2 P: h$ K& e
$ h; d5 u. _5 M- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
$ _$ H" ]: F7 E4 o. {# V, X - #define STATIC_SHIFT 3. F! Y* L5 p8 Z4 }
- #define TCINTEN_SHIFT 20
2 v9 W2 N7 E3 c6 b: { - #define ITCINTEN_SHIFT 21
2 K0 V. n4 ^2 \8 e1 Q7 t' O M) r - #define TCCHEN_SHIFT 22" h+ W" Y m+ i1 C
- #define ITCCHEN_SHIFT 23
I4 \. O5 c4 j9 b8 q - ) L1 G- O% \" l c% E
- static volatile int irqraised1 = 0;
! x& F, X; T' s2 h# ` - static volatile int irqraised2 = 0;: c( m8 y d6 I' S
# m2 l- |! i6 T( N5 V- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- [; i$ [1 r6 X. P - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ \, Q9 T. d( G
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' B, X# E6 e8 k& W. b( \
- 6 _/ Y: ^: ^3 D# Z1 E( b+ A
- dma_addr_t dmaphyssrc1 = 0;
4 m9 R* n7 }3 n8 b1 s7 d- V - dma_addr_t dmaphyssrc2 = 0;. H# `/ c# ?" D1 U
- dma_addr_t dmaphysdest1 = 0;5 Y/ ]2 U( r! P) a+ l
- dma_addr_t dmaphysdest2 = 0;
' Q. S7 x" x. ~6 o! E" ~ - 7 x% f5 p) T7 C* p) o$ V1 _
- char *dmabufsrc1 = NULL;
/ } ^& [- A* Y. J h - char *dmabufsrc2 = NULL;
2 \- P) L% I% ~) T) d - char *dmabufdest1 = NULL;7 ~1 }! B- A" j8 j! p% X4 d
- char *dmabufdest2 = NULL;
3 Y1 ?1 y+ |4 Z+ V& t' l3 R - $ B4 f1 C2 L1 u- ~
- static int acnt = 512;
- c' }. X, b' i7 \5 _ - static int bcnt = 8;
{) n9 u0 r6 o4 s5 H, c8 y" Z - static int ccnt = 8;/ L" L3 v4 p. b. p
5 n8 q" {& p3 C+ X d- module_param(acnt, int, S_IRUGO);6 @3 r$ J9 }6 O# b/ Z
- module_param(bcnt, int, S_IRUGO);
: m: `& C9 z: N# d1 p: N! G - module_param(ccnt, int, S_IRUGO);
复制代码 1 F1 V% G; }* }3 t. g3 Q; F7 M
$ C3 o+ f& @: I& X1 M. U
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
* Z/ v7 a0 o% }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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# ]1 Y) I* I! M& C1 E6 G" k
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' q3 N9 t$ ~* q/ q7 C& f: z( Z g
j; T+ L$ ^& a$ K2 u, N: U% |- d* ]' A& D9 n6 ?7 f
|
|