|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
8 C1 |- N7 V# j$ h. O5 P- H- [code]EDMA sample test application0 ]* Y5 _' W" Z L
- /*' y* X) W' ~( _7 ~7 Z# ^
- * edma_test.c# z6 h5 Z8 p$ E6 ?
- *
# J5 G3 q. ^- _# w - * brief EDMA3 Test Application
3 E- }5 X' l' p5 u; A% K - *
4 z( Q3 B: |# V2 D - * This file contains EDMA3 Test code.
n {8 K. t+ x2 q - *
+ Z \6 D( j3 r9 Q, X& K# Z7 ]. R - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
. `3 e2 ?0 P3 W# ?3 W3 c( } - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT- ^- v& O1 u* ~0 X
- * TO CHANGE.
- Y. h7 L9 I) [5 m) J' u - *
. U! H% ]- E5 ?2 G. J - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 \; n! ~4 A! {. j - *+ y7 W+ k0 |- ~: A& o5 f7 Z. e; \
- * This program is free software; you can redistribute it and/or
/ P3 w: ]7 I& s - * modify it under the terms of the GNU General Public License as2 x( }$ f% f! P4 |% a
- * published by the Free Software Foundation version 2.
# l9 K! X) f# I+ ` - *
( `( A. Y" [6 L* X* C - * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 Y9 i& s' n& s% e$ X
- * kind, whether express or implied; without even the implied warranty
$ l: `/ E. [& [: f% I6 h1 b- O - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
, d4 v( m! T5 g2 u - * GNU General Public License for more details.
p. l* J; K k, j! K$ A! e5 p - */" a+ z! b* r( H
- 3 _) [# d$ k( s8 M( i! O) k
- #include <linux/module.h>& s, ]4 d7 i1 R5 p
- #include <linux/init.h>
' M9 a3 D* V# o9 | - #include <linux/errno.h> `( d4 |! i, ]% L
- #include <linux/types.h>8 Q+ x% m: X' P5 j/ P
- #include <linux/interrupt.h>
# l) T2 Q: f; I" c2 K% ]. m - #include <asm/io.h>1 B8 Y1 d7 n) z0 S) I$ @
- #include <linux/moduleparam.h>
6 _, i2 @# `8 i) S - #include <linux/sysctl.h>$ d+ z- H. C6 [; [4 B, R
- #include <linux/mm.h> n" v% o4 w% l; \# C3 M4 `
- #include <linux/dma-mapping.h>
- a$ }' d9 i. n$ N - : m7 j4 b. f0 Q. \# {+ {5 m
- #include <mach/memory.h>
# [8 G5 \* p1 H* o& x - #include <mach/hardware.h>4 g3 \( Z8 g- D& d; @8 K/ _
- #include <mach/irqs.h>
$ V9 T4 Z/ X! D; c" Q/ m6 G - #include <asm/hardware/edma.h>) V6 I% J4 v4 n' v! s
5 Z8 S# x# @5 D& i2 t- #undef EDMA3_DEBUG
. J; n4 D. N, J9 S( f - /*#define EDMA3_DEBUG*/
' t" {9 t% B0 r! E3 g# W
( z9 F+ F7 u, \4 l- U0 Q9 |; R- o) R- #ifdef EDMA3_DEBUG4 P$ ]! z; c A# b
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" S( g5 J1 T$ |
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
3 E3 ^1 m/ E7 F; H+ z - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( n( q/ o7 A7 \) ~ d9 _
- #else
# R |& o4 S9 e% {5 c - #define DMA_PRINTK( x... )
- b4 k! w+ U* g. D& P4 U - #define DMA_FN_IN
( e, i8 O' @/ J, U& G/ f" S# K( h1 f' g - #define DMA_FN_OUT3 F7 T0 x0 g- b0 [- f
- #endif8 e2 }; ]1 S0 P
; r# i& e% [7 _5 v# Z( F- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
4 A2 X" N4 ^5 A8 I1 V - #define STATIC_SHIFT 3& \( e7 o* e3 B/ x+ V, d
- #define TCINTEN_SHIFT 20
( Q, F$ A8 T- x @; W$ a/ H - #define ITCINTEN_SHIFT 210 W) O: C% X! v& I7 _
- #define TCCHEN_SHIFT 22
; ^4 j; M% ~$ C) d+ f& j! c - #define ITCCHEN_SHIFT 23
" i. s2 O2 _1 K9 z/ ]* }' A8 ~' @
) N. n0 Y3 u( T+ u. ` M- static volatile int irqraised1 = 0;; P2 o+ G' J- ?! j" Q/ e9 O2 R X! Z
- static volatile int irqraised2 = 0;
5 V0 T/ ^4 W3 U4 n0 C8 @! e - ) { D: f8 l- E! T. \
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 Y" P5 D0 y' k* s! H: Z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ i a/ F, D' V1 r: X8 Q1 |8 w
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! w* z* }$ K" M/ ^- ]4 X1 m
- " F8 x: B2 I5 c$ A) f- U _
- dma_addr_t dmaphyssrc1 = 0;4 M: a/ _8 Z4 b! i
- dma_addr_t dmaphyssrc2 = 0;; L: d8 i, q5 O0 @2 w
- dma_addr_t dmaphysdest1 = 0;/ e: t& X8 W8 C2 P
- dma_addr_t dmaphysdest2 = 0;2 p/ o. C# T+ H" L; |2 @1 l
/ [' M; N1 X. S) `! l% L) Q% f- char *dmabufsrc1 = NULL;! ^0 V, O% |8 h& ]; Z( N
- char *dmabufsrc2 = NULL;3 p5 q7 O" [, M1 ]% E# O
- char *dmabufdest1 = NULL;
* e7 k' C2 I$ b* `$ Z* m - char *dmabufdest2 = NULL;, y% _# Q" i7 k1 T. ]
0 N/ ^+ F4 K9 i9 {- static int acnt = 512;
- K* c/ c+ l' |" M - static int bcnt = 8;
4 c) h" Z# `2 i; S+ v5 v8 ] - static int ccnt = 8;8 k; ~0 O1 m) R
- / _" z: n2 c" }. q: {) j
- module_param(acnt, int, S_IRUGO);
* y. s& c4 |, w3 j7 b# s$ g - module_param(bcnt, int, S_IRUGO);7 \2 N2 f2 V Y2 \9 Z3 I
- module_param(ccnt, int, S_IRUGO);
复制代码 4 W; x" m# T2 D; R& o
! P0 z9 l& T5 ~# P1 ?$ n
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
. {1 c: L2 e! b6 b3 o- }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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
% z7 |4 v# [5 j6 l3 q/ g, u6 D, k 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
, s8 A+ _+ ?9 Z; e: }2 w. S' C4 M. v/ N
7 c1 s, h# k, W+ Q7 t/ Q* W
|
|