|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
+ ~9 f; I4 o8 q- [code]EDMA sample test application; A; h* d9 J' y5 |6 B
- /*. I1 N: `- q$ y& L. e
- * edma_test.c
: c7 K# Q: x k: |) k& L - *
) Q1 @8 {5 M( b) S1 x - * brief EDMA3 Test Application
}; g f- ?! V. c, N4 t- x8 v - *
- b- l! R8 u2 |# L; M" Z& X - * This file contains EDMA3 Test code.4 T( g/ N/ [; @( O1 z( w% q D5 a
- *5 F9 _. v4 ?5 d" @+ w
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
) v$ B+ C( U+ Y% T% S8 } - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
, `, P1 P; N- b - * TO CHANGE.' I5 W) v- ^3 Q7 j5 \
- *
1 g& V* `: x6 M( h' N, o - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/6 @3 b; e- h- \4 h0 R1 x& e8 W5 J0 B. z
- *
, W5 ^; u n3 o4 `+ t4 F - * This program is free software; you can redistribute it and/or
/ C* m5 J$ p" Y! J9 \5 M - * modify it under the terms of the GNU General Public License as* a- Q& K- f+ |
- * published by the Free Software Foundation version 2.
% ^ w( S5 E' \) |" n5 E U1 c - *
$ J9 n$ q4 A" Z* U; D - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, P9 t& |2 {4 ?( s5 M - * kind, whether express or implied; without even the implied warranty; ?5 }' G7 Z! V7 d" K# j2 [
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the: ?2 N7 O# i/ h; Y7 G
- * GNU General Public License for more details.# l* O0 m' A: m! P- _" H
- */ i' f' v p3 Z! j
/ ?8 C b @4 \, [6 s8 Z- #include <linux/module.h>
1 @( m, J5 o8 ~) u _' E - #include <linux/init.h>
, O6 Y, ^; Z% b: o8 x - #include <linux/errno.h>
' f q) v8 C3 Q' t - #include <linux/types.h>
% y& h! ]$ G1 N. c, z P - #include <linux/interrupt.h>( |# ~- ?4 G7 S; ?0 a% m5 S
- #include <asm/io.h>
$ S: a+ {/ v, Y$ y7 i- a; l - #include <linux/moduleparam.h>) B+ H( C4 b2 L9 `4 ?0 M( |
- #include <linux/sysctl.h>; J% ?3 Z# {. N/ z( Q3 z% N1 c
- #include <linux/mm.h>
& t; n) Z% ~" x - #include <linux/dma-mapping.h>
2 m3 {9 _% i U# K5 Y/ w7 B
2 |& o/ g5 U, ~/ K s5 Y- #include <mach/memory.h>! B) b4 f1 y) y
- #include <mach/hardware.h>
1 c8 `* \( p. |# \# G - #include <mach/irqs.h>
; T0 O- ]: G a+ Y* W - #include <asm/hardware/edma.h>
4 B' R: [) m1 d* x: n& O
' b# r) P" P1 `1 `! o2 ]9 M; i. I- #undef EDMA3_DEBUG
$ \* x( v: ?) W1 f - /*#define EDMA3_DEBUG*/9 [, c+ {' z* x- B
# e. c, V% W8 ^$ e2 o6 ]+ L- #ifdef EDMA3_DEBUG; _7 K& f7 s, D
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; [! @4 H; m1 r - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__); @ C' p2 l2 q6 G2 f) W" \
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& N( b- i3 W8 t" w' {
- #else
' H/ W7 p. e& O+ y Y+ B" A - #define DMA_PRINTK( x... )
2 i* W: B9 U |) m8 F - #define DMA_FN_IN7 r( h: l$ T b1 _$ ]
- #define DMA_FN_OUT! z# M% L8 R' H6 f# L" {
- #endif
* m7 U/ m6 r8 O3 G5 Z9 W# Y& ` - 8 z% o$ N: G7 V" D, I
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" O" J, o+ O5 K, Y - #define STATIC_SHIFT 3
) L$ n T% G2 W5 l v7 Y+ C2 p - #define TCINTEN_SHIFT 20
; k0 U3 a, y# G9 D. \ - #define ITCINTEN_SHIFT 21
0 f8 H! ^/ {9 v4 |1 X - #define TCCHEN_SHIFT 22, f: ^9 Y% ]# r/ a; u* {- R: t
- #define ITCCHEN_SHIFT 23
& B M3 Y) B# Z - - [! _5 `4 Q0 b( U
- static volatile int irqraised1 = 0;! ^7 C+ \5 v! l% I% _! `( d
- static volatile int irqraised2 = 0;- Q) h K# Y: I* P# s) s
- * e4 M( R% B" ]' x9 I
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 S1 W- X1 C% [" q
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ V7 Q/ f. x2 H6 a
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( C# m+ p- M4 S9 I, b5 [; N
2 O, n s+ e9 c8 [- ], z- dma_addr_t dmaphyssrc1 = 0;9 E. V. }* d) a8 ]* \
- dma_addr_t dmaphyssrc2 = 0;
& k2 i+ h' H/ R2 N8 m - dma_addr_t dmaphysdest1 = 0;6 P; G. v6 R9 V+ j2 b0 O) W5 P9 j- \9 V
- dma_addr_t dmaphysdest2 = 0;
, j) x$ t, a1 ~: J4 L6 A9 V' |, N
( z: D0 j6 C- {" e- char *dmabufsrc1 = NULL;! X* v! \& ?2 k' H3 I
- char *dmabufsrc2 = NULL;; G! P9 h9 t: T' [
- char *dmabufdest1 = NULL;
r9 q5 T1 S8 a, e - char *dmabufdest2 = NULL;# w3 D; y/ {( L! Y. X
4 F" U' g# N! t* v- static int acnt = 512;/ y* e/ G& c( `1 x7 M' X
- static int bcnt = 8;
+ q( M* Y% `9 y; E! u2 M - static int ccnt = 8;
& [- v5 a- c8 ]6 i6 B% c - . P# \1 O& X- d# F
- module_param(acnt, int, S_IRUGO);' P! h2 e% V! Q& M w/ w
- module_param(bcnt, int, S_IRUGO);* ]3 C/ Q' m8 Z& m* q2 r' s, F! d
- module_param(ccnt, int, S_IRUGO);
复制代码
/ ?( B' G- @" X+ \2 |" v. q7 _; Z7 q+ l0 z- \) \( b; q% H8 \
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
1 J( g% e/ }- }: \5 J# y( Jarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。' @4 M6 c. z6 }
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。! p* Z$ o/ G, U
0 B8 j9 J( S2 K- \3 Y
( g8 Y: Q* y. l; } |
|