|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 v* q" u" y8 s5 N2 ^( `. L- [code]EDMA sample test application7 s8 q4 q3 A% }* {
- /*
4 K, B" M c% v( n5 F - * edma_test.c
[) G. Q$ ]. z - *
2 W0 k" k9 |9 ?9 b% m: K1 l - * brief EDMA3 Test Application
! Y$ @4 p: \( H$ L+ L - *
. d5 H% v8 J* R4 b: r3 }# Q7 E - * This file contains EDMA3 Test code.
! w) f4 r6 Q0 M$ l, ]+ G! h9 C - ** C4 H( X) N1 f X/ W
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
' {* U& G) u: a! h0 B. M4 M2 @( r: b - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
3 {! R | a; e3 i& Z - * TO CHANGE.3 G+ o( U( }5 W
- *# S$ G$ f" L* T4 q' R% b4 @
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 U( X: ?0 R; c! Z
- *8 u3 R5 F! e! _/ g* T8 R0 U) ?
- * This program is free software; you can redistribute it and/or9 A3 A! p, ?, L2 J3 H
- * modify it under the terms of the GNU General Public License as
/ e; k/ F+ m x; R* b- m - * published by the Free Software Foundation version 2.* |/ W. g$ W Z: m% X
- */ q7 `4 G S4 D
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, \7 r- p9 G/ \+ ~* `0 I0 B - * kind, whether express or implied; without even the implied warranty9 f! s3 u2 g0 m6 u
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 J1 ~* @7 ]; }- L/ p& W3 S( V- Q* i - * GNU General Public License for more details.
3 q z3 n- G y9 q: B5 O - */# N" A/ \5 g& ]1 S0 z5 G
" }$ r7 i6 J5 \0 Y- h& l- #include <linux/module.h>
/ E% x. _0 d# `0 B, c Y - #include <linux/init.h>
) R3 r3 l0 Q5 w6 ?( |+ V; \ - #include <linux/errno.h>
1 C# a. W) O+ }% ~, ] - #include <linux/types.h>
' j6 E7 r x1 l - #include <linux/interrupt.h>: b: [: g. y4 o' C* N
- #include <asm/io.h>3 D2 w$ ?1 F. F7 Z S
- #include <linux/moduleparam.h>7 }; \7 Y' `3 T* u9 T6 o
- #include <linux/sysctl.h>" {1 l7 s9 @3 R4 P/ K \* J, G
- #include <linux/mm.h>
U- \% H* _) [4 N3 z8 B8 d0 p5 u - #include <linux/dma-mapping.h>
: j" H, V& X" F$ }' Y7 g/ N3 L - + J! G' _% P4 `
- #include <mach/memory.h>9 P/ h/ S& t0 V" Y
- #include <mach/hardware.h>
) [3 H2 I( X0 \: g& }( h, ~5 M - #include <mach/irqs.h>
" D5 U" [5 _0 }" u9 S% ?0 [( u - #include <asm/hardware/edma.h>% g# c& |7 q# [' f( m+ B F4 T
- - z7 m1 g' f |) q4 |5 q, P. M. S
- #undef EDMA3_DEBUG- r5 Q' F: r5 g- b9 e
- /*#define EDMA3_DEBUG*/
, G/ x6 l* m. a' t - 6 |: f4 A; _9 J1 F4 m. t$ s
- #ifdef EDMA3_DEBUG& ?! O: |/ N4 ~
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)7 u. C+ ]8 o# g) Y
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)! ]# B" f+ g+ [7 U4 |
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 t6 i( a7 E# Q, j# e7 | - #else
/ |8 S' r- n/ m& ]1 r4 d8 P$ I' [ - #define DMA_PRINTK( x... )
( K0 @3 f6 h; a3 G4 J# h) R# W - #define DMA_FN_IN2 Y' ^4 l: k; [% |* e
- #define DMA_FN_OUT
0 e2 ^1 c6 ~& @, W' W4 p - #endif
9 w5 B$ d' y$ s6 W& Y+ i& s% F. A
/ ~4 q7 f1 ?8 B: v" B- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ X0 w" U% ]& X0 A
- #define STATIC_SHIFT 3. W6 g) ^& L( K/ D$ |, y- L0 {. ]
- #define TCINTEN_SHIFT 20
* i- b; E% l- V. i7 R! [" o - #define ITCINTEN_SHIFT 21+ Y, Y2 z. L; v: j( G6 C
- #define TCCHEN_SHIFT 22
* F) j8 G- y. i [) [ - #define ITCCHEN_SHIFT 23
& t- M& d- f4 l F9 K+ i- Z: f* X( j0 C - 1 i% I7 A5 K- z, I% @8 R+ T
- static volatile int irqraised1 = 0;
3 P$ x7 I0 t5 s2 q" n' ` - static volatile int irqraised2 = 0;0 N# ~. L+ R" T
3 C) {) ]* ~' z8 G# i- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 C) v9 P0 v0 o; Z5 P. w/ I
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- E1 E0 O9 Z9 O& W; n
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( [, r- ]; h( C
- M* v/ w- g6 E/ Z: K. l! L
- dma_addr_t dmaphyssrc1 = 0;" v l$ H3 _5 Y/ S
- dma_addr_t dmaphyssrc2 = 0;
# R$ c7 h8 U' x% |0 O, _ - dma_addr_t dmaphysdest1 = 0;
$ h# a& O! x* ^; d - dma_addr_t dmaphysdest2 = 0;& b- Q. m5 [( ]. B
$ L) e) V4 |# d B- char *dmabufsrc1 = NULL;( p& N' _( c" j/ u& q4 ]
- char *dmabufsrc2 = NULL;
9 s# ~$ I, f% i8 `" w- w Z - char *dmabufdest1 = NULL;3 T: d$ v* ]4 I% g) D
- char *dmabufdest2 = NULL;
2 c5 Z6 w: F0 r# F - ; G# H, y; q0 [
- static int acnt = 512;& ~. l4 y' r( z0 q
- static int bcnt = 8;7 O' r+ |/ b( o- T6 O' V$ i
- static int ccnt = 8;
1 [, R# v& @* q8 l* g. ~ - . b9 j2 Z1 f7 t, M" {) o
- module_param(acnt, int, S_IRUGO);3 D, U% a) i. c l0 L
- module_param(bcnt, int, S_IRUGO);1 H- P; m: M# B$ P; I: n) M K
- module_param(ccnt, int, S_IRUGO);
复制代码
3 f; B N5 e1 v( u% x" C4 o" V/ Q5 V$ U: h
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用+ E" X C: g; ~- m( X: V
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。2 `# t. X! U& m$ [& ` m
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。7 d# ~: j0 x2 v/ a" [$ _" `1 {1 J4 p
. D: G& L! Q* E
, S! O# _. ?( k- Z
|
|