|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ) C2 f) g$ [, `' a2 f8 \
- [code]EDMA sample test application& P' t7 I- y" F/ d
- /*
7 p- f3 Q9 {4 ? - * edma_test.c
% s u4 z. D7 S! ?4 B3 B - ** y5 J' d9 F9 W, U# ^
- * brief EDMA3 Test Application r P7 [6 [. \- _; l( |5 ]$ W+ {
- *- l5 O. y$ T2 f0 c
- * This file contains EDMA3 Test code.- f5 L- O1 O5 T2 G8 V2 x' ?7 C
- *& g' j( m- G% p
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
; j# `- y: H% |. r/ } - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% V% @3 v( Y2 L
- * TO CHANGE.9 s2 C/ n: t: u! J) D
- *
; H4 E" O# \* v9 o7 ] - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# H& r, t- |: m8 V- y
- *
2 |: h6 |8 m! [0 c - * This program is free software; you can redistribute it and/or3 V3 {3 {/ Q% Y- D- M: }, H
- * modify it under the terms of the GNU General Public License as
& q& N2 C+ N. l) q! U - * published by the Free Software Foundation version 2.
. K3 g4 h( W$ s' O$ T! Z- d - *7 z5 d. H# [4 W- r: \+ N2 I
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any `/ Y- A* S+ d; y- T: r& P
- * kind, whether express or implied; without even the implied warranty
4 V/ J0 v7 ?- G6 t - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; u, @% R% }. |9 i. B: H8 I% B; A2 K - * GNU General Public License for more details.
+ @8 |0 Y. I& F+ ~# P$ l4 ? - */
$ D# f7 i! @/ ^$ N9 ] - ^8 P8 E5 y* _
- #include <linux/module.h>& E6 g, h9 t a) |9 `
- #include <linux/init.h>0 u9 |3 Y+ E% ]5 t
- #include <linux/errno.h>
, B& P" f3 Y% b& y5 S1 V - #include <linux/types.h>
5 Y( S3 }) ]8 g - #include <linux/interrupt.h>/ r2 N- r; d; n) l+ A9 h& m
- #include <asm/io.h>
- \, D9 l4 Q+ u( v - #include <linux/moduleparam.h># }) z% Z7 ]$ l* v- @5 u; ~
- #include <linux/sysctl.h>
- G6 S3 Y7 P4 V+ p* k) m - #include <linux/mm.h>( d {; J9 d" j$ Z& H* Y+ A
- #include <linux/dma-mapping.h>
) ?" B( M$ S- y% B0 T
! _& n/ D3 q5 s- #include <mach/memory.h>9 q6 O5 ^. ~4 E4 i. o6 `
- #include <mach/hardware.h>
. e( l" V) R1 `' h& O - #include <mach/irqs.h>
' f% J7 w) B# {) c - #include <asm/hardware/edma.h>
8 n0 v4 [0 H$ |+ m% k% A' @ - 9 N* B1 X& y j* Q. Z
- #undef EDMA3_DEBUG# Y2 n8 o& Z, R
- /*#define EDMA3_DEBUG*/
, {) ]+ n& p- i% v! y6 |4 R7 x ]
% d& k U& T9 B- #ifdef EDMA3_DEBUG
$ G, m9 E% c# b1 l& x - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)/ p4 X. r$ c* W! o
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)% j1 j! Z4 ?* B
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 _1 h& S6 j- u! R5 D; ^ - #else
: @ j) o( l8 l+ T - #define DMA_PRINTK( x... )+ G7 L/ t, Q2 s& k+ C
- #define DMA_FN_IN" \* y# Z) a) q: d+ y S
- #define DMA_FN_OUT
- L4 X% a) |' ^ ]# r6 o1 {7 ` - #endif
@, K5 p2 ~& V- v& q; s, @3 M - & W: l! w+ u3 |! U+ F
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)6 S/ B( t0 l' f9 n$ Z
- #define STATIC_SHIFT 3& R" O; M! J$ h
- #define TCINTEN_SHIFT 20
/ L- s0 z3 t$ t* n6 L& h - #define ITCINTEN_SHIFT 21
: t4 m. B' X$ R' N - #define TCCHEN_SHIFT 22
& N' |& @" I* W+ ]# V - #define ITCCHEN_SHIFT 23' l2 V" b* ^ N! e( [9 P
- " T$ E- T# c! O( x" T" P# K( ]
- static volatile int irqraised1 = 0;* @4 d) n( K. ]
- static volatile int irqraised2 = 0;* w. I* C- P" z) S" M# |
- 3 |1 W O! j# {# ~
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ ~% Y- n& Q4 V5 a- O - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" Z# q+ a3 t$ B* U
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; V# z; c% Z6 T+ l4 }3 z! P3 S9 l
8 d; \, n% I1 v6 D4 K- dma_addr_t dmaphyssrc1 = 0;" F3 {" R! Q) V& V" Q
- dma_addr_t dmaphyssrc2 = 0;
- b4 E; ?) Q( D; H. r5 r; o: `- C - dma_addr_t dmaphysdest1 = 0;
& \, y7 `" Z* b n - dma_addr_t dmaphysdest2 = 0;. H( q, ^7 A: Q2 w5 }
- ! Q# S7 @ y# x" g. w9 ^
- char *dmabufsrc1 = NULL;
( b' b% ?! u \& r) u8 {$ l6 ~ - char *dmabufsrc2 = NULL;
2 o& r/ i; T. @" u2 O$ m( L - char *dmabufdest1 = NULL;
* O0 }" @9 R0 M4 V6 G# {4 D - char *dmabufdest2 = NULL;
2 a: J7 p, k! _( N - 5 D* H" |$ |/ Z: r& N
- static int acnt = 512;! z7 [- U" {8 P" b7 p
- static int bcnt = 8;2 J8 j, L4 x. u- S( a
- static int ccnt = 8;
/ v: r8 D: V* O! i6 r
5 ~/ k* ^1 g# a, a6 i* a- module_param(acnt, int, S_IRUGO);' P: J7 c$ G. E3 _8 {, r) V
- module_param(bcnt, int, S_IRUGO);
" J9 A. [1 L0 ^- g6 [ - module_param(ccnt, int, S_IRUGO);
复制代码 : R# Q n. B. F/ F- }7 l
, I' ~6 |9 w7 d9 a) d
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用6 Y8 d" V7 a+ 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。3 i/ Y7 u6 u. u! ]0 _( n
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。3 R7 S1 s5 P1 `
1 `$ v( ]/ M9 j! D
: J# z# f/ _. U0 W; w( K
|
|