|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, }( \( z( g7 m# D3 G- [code]EDMA sample test application8 c( S h3 d0 \; F6 ^
- /*) f+ P2 L9 h( D7 x4 R+ ?: J
- * edma_test.c
3 l3 p( ?# D: n. w7 A1 J2 P - *
5 r) L) K. p% A. d- v/ O8 h" e - * brief EDMA3 Test Application
7 L" L. e# E' C5 Y% _. d - *
9 \ `: w; M/ A6 }( H - * This file contains EDMA3 Test code./ J1 ~6 t1 p% H- a7 z# e
- *9 p$ v0 R0 d7 K
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE7 ~1 C! z8 f0 o) ?4 g8 `
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( ?0 C' }' ~& u/ X& ? [' V3 ~ - * TO CHANGE.& k0 Z9 j1 M3 O- Q! ?
- *
% Z, {, g- @4 @, M9 Z - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
c& b9 b z+ F7 [* P9 z% U - *
/ @7 o0 f2 L$ Z9 U7 q7 w - * This program is free software; you can redistribute it and/or
/ I! J4 [0 {% F W# N3 P2 `2 H - * modify it under the terms of the GNU General Public License as) ^! E% ^; {- ]1 X
- * published by the Free Software Foundation version 2.
; c) z8 k' R7 Q+ _ - */ C% F9 r5 F5 I3 [( m
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
2 B+ A/ t% |/ Y - * kind, whether express or implied; without even the implied warranty
# N; R0 R/ s" f+ ` - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the& Y/ I) h5 U8 a
- * GNU General Public License for more details.
$ z' K% {- O9 f3 V' h - */4 g5 R# t9 w- B0 T2 \/ u$ r+ e W& E' h
- - G" l' |( R( h
- #include <linux/module.h>
$ Y& r, M( v$ o: }0 I - #include <linux/init.h>6 i' N* {' G3 i
- #include <linux/errno.h> N0 a6 f G( J8 s0 }8 X' w
- #include <linux/types.h>
; n h' q$ [& z - #include <linux/interrupt.h>
) b& N$ c( p6 H3 S6 h - #include <asm/io.h>; x; D# z3 h$ f! Q; J
- #include <linux/moduleparam.h>
/ W M& f1 J5 B/ { - #include <linux/sysctl.h>$ A8 r2 q6 K$ U! f7 Y
- #include <linux/mm.h>! N; i1 t& k4 J! O% M) [. C6 `
- #include <linux/dma-mapping.h>3 i+ G& ~; a' F2 a- i2 u; a
- 7 G. R$ q; s& u( h: v
- #include <mach/memory.h>
3 F( [$ x7 b2 n - #include <mach/hardware.h>$ R" R, {- E3 O* I, y( k( u$ C( |
- #include <mach/irqs.h>
# J) m+ e0 F3 j. E* q# [ - #include <asm/hardware/edma.h>& S5 O. N+ [; u4 E$ c! O9 f1 L$ ]
- * {0 E& j2 `3 b8 R! l% O" C
- #undef EDMA3_DEBUG
0 Z, J. U4 C2 f, Q" M# e - /*#define EDMA3_DEBUG*/4 A3 I+ c% E9 o- V
- 7 T5 ?0 R" {7 {6 E K
- #ifdef EDMA3_DEBUG
( f$ |, \( E, X( u0 J+ a5 }) l - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- e, i2 ?8 T7 w
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
$ \- I- Q; G! w1 _4 D% K" S! V - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
+ S$ u+ Q9 d% @5 h- v" ~6 A - #else
" M! p* s$ b/ V7 @! v - #define DMA_PRINTK( x... )
0 N: A& s4 v/ R5 {$ Q! k - #define DMA_FN_IN
7 u7 i. C* t/ M c7 c- B - #define DMA_FN_OUT. |9 p/ k R) Y
- #endif% h8 A* E* w) C! n% ~8 K
! q3 m% Z5 V0 f/ B. B- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" J# d, o C' l' U4 ^9 M
- #define STATIC_SHIFT 3 t4 }" i- g4 L( _
- #define TCINTEN_SHIFT 20
. U0 B0 U! J J+ t8 w# `8 c2 \ - #define ITCINTEN_SHIFT 21
/ O- v' }2 a1 N" A; b h - #define TCCHEN_SHIFT 22' E: X+ z1 O/ t* {% K# M
- #define ITCCHEN_SHIFT 23/ |# Q' R2 F- e. d; ]& m$ g
- - {7 c; |( b8 o+ Q
- static volatile int irqraised1 = 0;
) ~2 s1 F+ g8 z9 [: t - static volatile int irqraised2 = 0;5 @& X5 C1 W$ t/ L& b7 Y! |4 J
- 7 m4 Q7 O7 ]5 b
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 `) Z S' k: T$ u5 c4 Z* n - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 V) m: p) ]* ] - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 }7 ?, R5 _9 C1 P3 Q
- ! k4 I2 \3 {$ l/ t% ]
- dma_addr_t dmaphyssrc1 = 0;
$ `4 }7 }- K! Z, P& ^! \1 L! a0 } - dma_addr_t dmaphyssrc2 = 0;5 G; s" ~' E4 j; i/ P' }1 P* `1 h
- dma_addr_t dmaphysdest1 = 0;9 n+ E9 E) W9 h3 E% u8 @( k& `$ W5 d
- dma_addr_t dmaphysdest2 = 0;
/ Z- I& F$ ]0 k& |- C) F - 7 ?+ H2 F9 [$ {- L; e1 @1 P: [
- char *dmabufsrc1 = NULL;% u y' ^$ e8 c8 v" b6 T# P
- char *dmabufsrc2 = NULL;
% @0 G6 |1 k" s2 T - char *dmabufdest1 = NULL;" R3 m0 L0 y9 K( E4 g
- char *dmabufdest2 = NULL;
/ d3 Z) j1 x& P" I. w. |
0 z& C: V! v0 W: q# U- static int acnt = 512;8 o3 F6 g+ X" X+ Y# v
- static int bcnt = 8;. m: S5 t( e* _) ^
- static int ccnt = 8;
/ Z- ]# y! T& A' d' Q) q1 W7 J
7 ^/ y8 S& {3 q- module_param(acnt, int, S_IRUGO);$ E* U9 ^9 S8 X$ j2 x
- module_param(bcnt, int, S_IRUGO);% L, i" M" O0 D" l! y) p! i
- module_param(ccnt, int, S_IRUGO);
复制代码
- @) l/ P2 z% y/ @" T* B: M _# c- L$ G2 Z4 {/ [! I3 O4 t
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用" S% X# [# a% T0 J! q4 Y
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。7 p( K8 z; E0 k/ ^
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 A. C1 L! A2 d W: O
/ I2 M) t8 g$ W; l0 Z
$ w4 Y i! ], H l( i- f4 G7 l |
|