|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% t1 q- E( F9 b( N& n3 W- [code]EDMA sample test application
2 P" }0 [3 s0 R6 a3 X+ E" F+ Z2 G - /*
" k" D5 B/ J! N! K* o( K: G - * edma_test.c: W- S, G8 K) h; L( S$ `' y
- *# @/ c- h- q/ |' d9 p+ p6 L
- * brief EDMA3 Test Application
( F" E- U+ N: b/ [+ }, ` - */ Q* n! V/ A0 G/ s7 V
- * This file contains EDMA3 Test code.0 s6 f2 Z* w6 |+ V% N$ S
- *
0 O' f) {! v9 e' Y) ]) P/ x - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE7 q9 ~& }* o w' ?$ ]) g
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT# w$ J' S( _' |& ~. j/ ]
- * TO CHANGE.$ z" L( e, I2 c) ?
- *; h: a: ]! k% r: H1 F5 q
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 H+ X6 l! c* n9 Q
- *, J) M$ }8 C4 p; r
- * This program is free software; you can redistribute it and/or# L8 g1 ~9 f: {7 W y9 W0 Y
- * modify it under the terms of the GNU General Public License as
" @. }" M D8 l' l$ I7 [6 f* R0 J - * published by the Free Software Foundation version 2." S; S% B2 h* V
- *
; P3 `4 o8 {" z" o - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
4 L; J* ^5 z3 F' V7 m% ~- _ - * kind, whether express or implied; without even the implied warranty5 `: n" C3 G% a L
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ P: u' z& q, |* W) u - * GNU General Public License for more details.$ Y0 Y9 ?. b1 \ |8 P9 _. R
- */4 R4 z9 V$ ]1 D( T
$ P3 \; o7 |5 `) _/ \- #include <linux/module.h>
( q' l' t. u$ S, @1 W. s$ m - #include <linux/init.h>8 B: E5 f4 `5 d7 w
- #include <linux/errno.h>- W5 G: j; ^# [ J; m0 I
- #include <linux/types.h>
5 n1 O: M: O5 E$ ]8 Z. d - #include <linux/interrupt.h>, W, h% o/ R- S7 K
- #include <asm/io.h>
% c P# |2 L9 b# s: Z* j' S+ L- o - #include <linux/moduleparam.h>( V" o) |- ?! I6 F* x' w2 W
- #include <linux/sysctl.h>* P) u% F& M4 U5 a! b, B: b
- #include <linux/mm.h>
8 D9 ]. Z# V' j( L4 t+ `7 ]) \6 I - #include <linux/dma-mapping.h>
8 E. ]3 z) ~8 w) c1 X: U. L - r; x; W2 r# j8 C0 C: d7 a. X
- #include <mach/memory.h>
8 X8 O. i: W4 q2 X$ {' Z/ i5 w6 V - #include <mach/hardware.h>
& r/ B% R( H$ \ Y- F - #include <mach/irqs.h>. y* i8 l# Q* K& B; K. e( m9 i. J6 E/ Y
- #include <asm/hardware/edma.h>1 |* |5 n8 { y
- 4 X K$ d, m0 I! N4 `
- #undef EDMA3_DEBUG/ Y% i5 ?8 |# W2 X3 A
- /*#define EDMA3_DEBUG*/3 {6 s) P: y/ f+ p9 l; t
- 2 L8 E; j; q& s7 D% j! ]- K0 ]
- #ifdef EDMA3_DEBUG! O* _. F) |3 l
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS). A- _3 T9 C' n' ^! | o& c2 l
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 L6 v4 O+ f; X2 t+ C - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
1 S3 [0 m5 Y; A - #else. b& t" j( l* x* B
- #define DMA_PRINTK( x... )$ O( [0 y0 s: e9 S ?. R2 k
- #define DMA_FN_IN! i3 E7 h; c6 x! p6 d
- #define DMA_FN_OUT
5 y- R. e ~' k2 V1 n - #endif
. w; I- J3 ^$ Z: C9 _! R, R5 B# [' @* | - 9 W# q4 Z$ I! E% v# `& E4 k
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)6 o$ m9 g7 m! ]) D# f, A
- #define STATIC_SHIFT 3
- J) E( d6 a! D6 P. n - #define TCINTEN_SHIFT 20* `; h p: p% \/ _9 w& s( N
- #define ITCINTEN_SHIFT 21
- A! u, |4 _9 ]4 v8 ~6 w, z; J; ]( l8 ` - #define TCCHEN_SHIFT 227 V1 o* ]; n4 l6 a5 d y+ w
- #define ITCCHEN_SHIFT 23
+ p9 j% K( O# s7 |5 v8 b
. F! C+ @* M" M8 ?) s- static volatile int irqraised1 = 0;" g: s& A' v3 s- G
- static volatile int irqraised2 = 0;
3 E# v/ Y- c0 m- {8 |
7 m( U1 ~" H; D6 v1 w% a# x- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: g1 r- A+ [6 ?
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 r, V! G1 U7 J! u
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% l1 |; G+ D- t- n$ K+ i2 [
* r3 k. B/ H: M, e3 H0 V3 A/ q$ `- dma_addr_t dmaphyssrc1 = 0;$ m" T( S2 l7 \+ g
- dma_addr_t dmaphyssrc2 = 0;: r/ Q6 S1 a5 X# u/ R3 B f6 d
- dma_addr_t dmaphysdest1 = 0;+ \: j* j2 ?7 I7 W* s9 [9 ]
- dma_addr_t dmaphysdest2 = 0;
; N; g; g7 ~# n+ n- b4 A. s - : L( h0 N' J0 T& W2 ]8 I2 e6 M5 B
- char *dmabufsrc1 = NULL;7 O2 d; Z! W2 O, D3 \
- char *dmabufsrc2 = NULL;: O% k" ?" A }% \: H* o0 `
- char *dmabufdest1 = NULL;# d) U* m8 W7 R' `" l
- char *dmabufdest2 = NULL;$ U4 x" [. G+ [9 B
" l4 G( j# B1 c- N6 f- static int acnt = 512;1 W+ [' l# V, f0 m: B9 p
- static int bcnt = 8;/ m4 `9 l0 T& n9 l# U. \" g
- static int ccnt = 8;( D }1 U( A: y5 k( _
. m6 J% U8 r, D6 |* k- module_param(acnt, int, S_IRUGO);$ j5 A0 A k' Y! {* D) f4 b$ Q
- module_param(bcnt, int, S_IRUGO);
, [/ y3 ^. Y i& q; i& p - module_param(ccnt, int, S_IRUGO);
复制代码
" f @ \2 s1 w" t8 ~, q/ ^- Q* e0 x1 X
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
* n- m4 R, w: {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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
6 l& ]. F% a! {% g9 k# G 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% F2 B" {; }8 f! n5 f
, f% Y, h e, O+ [ P/ v# U% x4 @6 R
|
|