|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
0 V' z$ P8 m' D1 g$ l" L- [code]EDMA sample test application
1 @) N+ F; o% n2 w3 N* I5 ] - /*
& a+ ]' M: s) I6 P# p8 g% c - * edma_test.c( d3 _; ?9 E6 c% E, Q
- *
% Y: j8 ]/ d+ D - * brief EDMA3 Test Application% J% u8 ?# g& X- P% E6 z5 _
- *1 C- K( S7 c% ]3 \4 q3 V6 s' T5 u
- * This file contains EDMA3 Test code.9 N) J1 L! {3 [- U+ I; I
- *
6 m1 k, n: o0 l: W/ o - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
; e0 ~& d2 [; u! y - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT2 S* n( e# d7 T7 v
- * TO CHANGE.4 p" V5 \0 L" R, X
- *$ v4 M( |- ~2 k4 e8 u
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
$ v, h+ f- L' W$ S - ** y4 u0 u) G$ M( w9 Q
- * This program is free software; you can redistribute it and/or! t# _5 F0 B& A/ H: S
- * modify it under the terms of the GNU General Public License as9 s9 f$ V; R0 j- l6 _
- * published by the Free Software Foundation version 2. O! r: f, @% h0 e; T( ?6 a4 o
- */ k, t- X( y* \- M
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
3 x; I X% t* I/ F# d; V* q - * kind, whether express or implied; without even the implied warranty
; E: ?1 H. I1 C. ?- { - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& V; I- ^7 @& f- o, ~ - * GNU General Public License for more details.
6 ^* g$ K( x* N) M - */
: ?+ H4 W4 Z1 a% `4 }3 e4 D+ r4 Y - 8 ^* B- \9 X/ k$ ?* w, M, t
- #include <linux/module.h>, P2 ]: J) |1 B( \1 k
- #include <linux/init.h>% q4 ~, }* G+ s- ^" h( G
- #include <linux/errno.h># m3 w+ i, {' k. i. F( A, }5 Q, U' i) {
- #include <linux/types.h>
/ J) O8 n- Q# {* v, C; R# P2 Q& V - #include <linux/interrupt.h>
9 `0 a. t" U5 R$ [# a# f% `# z - #include <asm/io.h>
6 r6 M5 e' i* g" k) X3 X - #include <linux/moduleparam.h>, J8 O0 x' F# h+ F) W$ q
- #include <linux/sysctl.h>
9 f# T- x! M; y! ]& Y/ n - #include <linux/mm.h>
7 a9 @* K5 X: U; [ - #include <linux/dma-mapping.h>
4 K0 V6 h& t! X1 a! F. C - 5 b0 W1 A) K3 k
- #include <mach/memory.h>
* X3 Q L* a( E- x - #include <mach/hardware.h>
; t" E1 |/ h6 b% s# ]9 B% L6 S J3 R. S - #include <mach/irqs.h>' } g5 V. ^+ ^) h: Q" p5 Y
- #include <asm/hardware/edma.h>! n; A t+ {4 H
- 6 h4 d2 d/ n$ ]4 p% \, p( c
- #undef EDMA3_DEBUG
% ^; \6 @4 R. }$ v% F* k - /*#define EDMA3_DEBUG*/% }# v/ I6 ]# Z* u: P8 O+ R
- . d6 B6 T" M, ]% r& C3 I
- #ifdef EDMA3_DEBUG
% v7 g6 W/ ^6 J5 f& r5 t3 A - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)6 F! z) e$ U( |; E$ \7 k6 i7 l+ K9 G1 [
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 P t c" a4 q9 E - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
3 S) [2 ~- C) t3 {, x. x- A0 n - #else
# B4 N! I1 `4 F% a; S* l - #define DMA_PRINTK( x... )
/ z) K& c+ `& w$ C! j6 p - #define DMA_FN_IN' G0 z* x; [+ \& w! R+ @* g
- #define DMA_FN_OUT
Q% C, F6 O8 t* j - #endif/ t' S: f1 N+ Y- y9 T5 P
- ; C" P1 P6 i9 d: F; }
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 _! m8 E" x" E1 v" v - #define STATIC_SHIFT 3' i }& \" d9 E: |& p- u6 {
- #define TCINTEN_SHIFT 20$ P; t% C1 V$ w A
- #define ITCINTEN_SHIFT 21
: ]" m% K/ S+ c0 \; w" G+ g7 ` - #define TCCHEN_SHIFT 22
) k$ R$ r2 s8 `" j1 j, `5 ^ - #define ITCCHEN_SHIFT 23' q' d5 ]/ g/ {2 \$ c. C/ g
- 7 Y4 q$ k* _5 b/ Z
- static volatile int irqraised1 = 0;, n4 j4 S" f, u4 o
- static volatile int irqraised2 = 0;# Q$ F; M$ Q5 z8 T# f) m2 a! B
- . @* e" ?" ~/ _4 @1 ], |
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! I0 j8 @; k- E
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; y) f! t) Z& t - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" A2 e1 l! M# B8 X - 3 l9 e/ i$ J. B" ~+ a4 G. {
- dma_addr_t dmaphyssrc1 = 0;
5 O9 g# w0 L. q2 g: N0 P - dma_addr_t dmaphyssrc2 = 0;& K4 j7 P( F) w: I K& j
- dma_addr_t dmaphysdest1 = 0;
9 ? |* u" P& p - dma_addr_t dmaphysdest2 = 0;
+ }1 Z& T: E- f' o - / r5 p0 N X/ H( F$ M1 q+ R3 @
- char *dmabufsrc1 = NULL;9 l* |5 w& h, e* N
- char *dmabufsrc2 = NULL;" D. Y& F' N5 z, v- v" y: H1 F9 P
- char *dmabufdest1 = NULL;
0 e: g/ q' `" F4 L0 Y - char *dmabufdest2 = NULL;
@, k( K: i6 j% Z4 O6 N$ ^ - , e7 w$ l) C( @% P6 v. P
- static int acnt = 512;
M9 S: G% T9 ]4 _0 Q! F8 E) U5 v - static int bcnt = 8;
. D3 ^8 V0 C- h, |2 o2 r2 J - static int ccnt = 8;
! _2 q# d/ i. U5 T; b% [ - 0 L0 R3 P6 N/ p3 N: m2 e Y5 ?0 f
- module_param(acnt, int, S_IRUGO);$ f$ d5 N# m$ D% q8 s) C) s
- module_param(bcnt, int, S_IRUGO);
' @4 M% O7 P# f - module_param(ccnt, int, S_IRUGO);
复制代码 / c- U+ K! ~! _
8 U, ^0 W9 ~7 |
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
0 {- u& v$ O. X4 Y# ^9 M: }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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
# I1 w0 _- X+ J0 [/ l% l1 j) X9 z 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。, j* r) R4 o, J8 j& _2 I4 m: ^
: E6 `) C' [% S& t8 b U1 Y) O( J8 \% s" X
|
|