|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
# G: w( K* [( f- [code]EDMA sample test application
$ [% C0 a/ c; j$ @' @/ _ - /*7 V( [. S& Z& m: B' E+ g& v
- * edma_test.c
+ `9 |" E c! x" [ - *
' @) y- ?$ A) E7 U3 i - * brief EDMA3 Test Application
0 O( ]* ~9 F/ `& q5 [ - *. G" q( z, F5 i' f& L1 S
- * This file contains EDMA3 Test code.2 {' d- y+ \8 U4 S: a0 k
- *
$ e/ q. E: `9 N; q8 `- T - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
; g- h( v0 z) c8 Y3 ?* m - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
9 x3 D0 u. J. M+ L1 B6 _4 E& b - * TO CHANGE.
* e+ H. i8 M& }: G - *7 G; Y" C( d, A
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; h. y. j) N& [5 C
- *0 o. K& x/ T+ |) P6 W- T
- * This program is free software; you can redistribute it and/or* |) L1 t, z. U# e- ^
- * modify it under the terms of the GNU General Public License as
: s2 F; R" P; R8 ~1 N" x4 L6 {+ N - * published by the Free Software Foundation version 2.7 V2 ?/ { h8 \5 n: ~1 D
- *
; f, n$ u& u( W2 Q# r$ d - * This program is distributed "as is" WITHOUT ANY WARRANTY of any4 N& a p: g8 e
- * kind, whether express or implied; without even the implied warranty& H8 M' v7 p2 O- C& g
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the. I1 [' O0 y% A4 l& d
- * GNU General Public License for more details.2 k2 b4 s. N8 A; [) u$ m/ r1 Q2 ?
- */5 o& s( k2 i$ K! d4 i v
2 G: ^, J0 \9 n, r. `' {9 ^9 x* A. H- #include <linux/module.h>
8 f3 X" ?5 s+ g7 } - #include <linux/init.h> A1 h( j" T; P/ x) L1 }; P9 Q
- #include <linux/errno.h>" z0 X5 T1 @9 @6 ?
- #include <linux/types.h>
a4 C8 D+ u/ n) w7 ] - #include <linux/interrupt.h>0 ~6 V9 S1 q* M% Q7 M# Q$ w
- #include <asm/io.h>
8 W \ O7 b0 @' u - #include <linux/moduleparam.h>
0 `1 G0 _4 @' _ - #include <linux/sysctl.h>$ g! J# k1 U n7 {8 {7 u; ^1 P+ N. v
- #include <linux/mm.h>$ a. N" K' b: r" A( e
- #include <linux/dma-mapping.h>
& f% a% {1 D( }5 x/ i - $ Q# G. W2 C; h5 T& M
- #include <mach/memory.h>
# H- V6 U# m- F ]/ k& y, G - #include <mach/hardware.h>
2 x' w' R+ Q! x4 {" E - #include <mach/irqs.h>
7 \ J' z5 Q, w. J- v+ I - #include <asm/hardware/edma.h>& B4 O9 ~8 ]3 o, ?7 R
; Z" \- P. J9 u' ^- #undef EDMA3_DEBUG
/ x, x# _1 J5 W8 O) u - /*#define EDMA3_DEBUG*/, L/ ^1 y# |. U# |) K( u2 p
- # ^" O& t; j0 Y5 F% _6 _: W; m( ^' A
- #ifdef EDMA3_DEBUG2 D6 P B6 ~8 r
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)) C+ |- a S$ @3 ^' z/ P4 ^
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
# [& V$ L3 p/ ]9 ~5 F1 t& h - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
; R' `$ i& f: F - #else
/ n. n* H& l5 P4 u9 l8 Y, U5 B - #define DMA_PRINTK( x... )
! X6 K& V. S# J4 ]8 x4 N - #define DMA_FN_IN2 {; T5 n# w q8 I
- #define DMA_FN_OUT* i' C4 S8 h/ n7 I4 q) v0 n
- #endif
% M) X! L% \, ~1 c5 e
* ~/ f/ K' g; n( L1 M' v' F- #define MAX_DMA_TRANSFER_IN_BYTES (32768); }1 B7 |" ^, `2 p; v
- #define STATIC_SHIFT 3
! Y3 y e/ g' n$ P4 p T0 b - #define TCINTEN_SHIFT 20( z# Q( C$ ]- Y$ t( U& {
- #define ITCINTEN_SHIFT 21
6 m9 B3 x" C( v3 p! z( D: h7 M" q7 L4 u: p - #define TCCHEN_SHIFT 22, F% D! a2 k. D) s" I! Y8 Y
- #define ITCCHEN_SHIFT 231 Y% ~" f1 I `* A2 f
- $ Y" A+ v0 ], w1 S3 ]' p5 S/ u& \
- static volatile int irqraised1 = 0;
* H- C; V; I$ z8 T) M" C, c% u - static volatile int irqraised2 = 0;
( B4 _. u# j( m- y4 K" h5 Y G/ z - 5 q* Y1 O3 z. ?) ~0 b5 W* Z+ X
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" U' s( V! ^& M# G2 V - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, F* ^1 X5 L, b- u
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, k& _' j9 N3 e- Y6 I
- + d/ t) P7 J: `2 y* ~$ v
- dma_addr_t dmaphyssrc1 = 0;6 H& S) P( \& T
- dma_addr_t dmaphyssrc2 = 0;3 `& Z. e: |' D3 m1 B; I( a, c
- dma_addr_t dmaphysdest1 = 0;
1 N5 O! ` g9 y - dma_addr_t dmaphysdest2 = 0;2 j4 B3 W5 h- P1 ~: c1 i; L
- / y$ h0 ~" b3 H1 u# J
- char *dmabufsrc1 = NULL;! u! a1 t+ \! L h
- char *dmabufsrc2 = NULL;. D# l3 [+ C/ ?: S
- char *dmabufdest1 = NULL;
: T, B) d% `: J - char *dmabufdest2 = NULL;
+ D7 ~* ~- \+ |. I* Q' x- s - . n: b" s. O2 v {
- static int acnt = 512;" V1 m! `4 k' T$ D
- static int bcnt = 8;
( Q6 N* n( l2 }; h) V - static int ccnt = 8;+ `3 a/ t8 j- q. u
2 M8 h$ L3 R ~5 Z, O- module_param(acnt, int, S_IRUGO);
0 P, ]! q4 z2 G. V+ l8 h$ i - module_param(bcnt, int, S_IRUGO);( f" B T: j# `6 B
- module_param(ccnt, int, S_IRUGO);
复制代码 $ p. J$ ~5 O% l( U, Q5 i$ _7 @
2 M; B6 [( g) I6 W( x$ u 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ G& | |6 K6 Q/ b% Karm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。% h; W7 }/ q+ U0 X$ F6 |
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
- X" z) M$ ~2 t5 k4 e5 |4 C
1 i. e/ \7 f2 m: q! Z8 C& C4 ], x$ X3 C1 y
|
|