|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; @* r! X, f$ Q4 M t# P- [code]EDMA sample test application2 k/ `8 j7 f- c& W' V& `2 {
- /*
/ G' Z6 C: Q$ a7 ?" E2 c0 G6 k& U - * edma_test.c
) d6 n0 C* x z; y: z/ ~ - *. Q- Q( G* V9 f8 F
- * brief EDMA3 Test Application
' b0 e" Z! y! I& t - *
# T4 N0 {- Y7 @% l! \6 h9 [ - * This file contains EDMA3 Test code.. ?) B' B% S c n
- *
0 G9 [9 X, \) n0 ]7 _. }( ?" H. o - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
, r6 \; w0 @' p2 i5 I; V- K - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
/ F! u2 w7 H8 T1 T2 f - * TO CHANGE.% _# Y, w( m. R6 m+ m
- *$ m" \; K( x. n/ G. B
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
( ^/ {- {. T% { - *; k# m4 ?! U+ w" R5 W4 F+ P
- * This program is free software; you can redistribute it and/or- D. o5 Y! @! ?
- * modify it under the terms of the GNU General Public License as
9 j8 ^5 h8 [0 x/ F - * published by the Free Software Foundation version 2./ E( P1 _+ I. y- G
- *
& L+ Q. {% Y6 M( L: j6 F - * This program is distributed "as is" WITHOUT ANY WARRANTY of any. u; y/ V0 ]* ]" J& ?
- * kind, whether express or implied; without even the implied warranty: o4 L+ [: o% c6 N
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) Q4 Q: F# R7 M B - * GNU General Public License for more details.
& b3 z m% L/ R. \5 ^5 b - */ K; F4 T9 x) r5 Z/ p3 u
0 M1 R1 y1 z: y' e4 Y/ Q- #include <linux/module.h>; s" N* i* L9 I2 ` P: ]% A
- #include <linux/init.h>8 D4 i* K9 o |
- #include <linux/errno.h>( ~5 @8 r- c1 Q- H* M! y% y7 R
- #include <linux/types.h>
8 Y; h# a( k7 w5 }& W. g# F - #include <linux/interrupt.h>
( w# H) p% t1 F8 T - #include <asm/io.h>9 s: s5 r: U3 K9 u
- #include <linux/moduleparam.h>9 Q( c/ R- H# G3 b
- #include <linux/sysctl.h>3 [ e3 B4 v' U
- #include <linux/mm.h>6 \1 g; X5 l; {. H; F
- #include <linux/dma-mapping.h>( V0 b: q" Z- \- p c6 ^
- p) t/ z; |0 O& m8 w
- #include <mach/memory.h>, k2 i3 y2 C3 e& z4 q
- #include <mach/hardware.h>
$ N/ c* v+ t/ P6 P - #include <mach/irqs.h>
+ i8 X9 h2 k% s! e" \# c - #include <asm/hardware/edma.h>! B1 s) J9 T: @* J
6 h1 X) i& }3 }' k% O8 N( M- #undef EDMA3_DEBUG
- I4 ]* o; C. T Y+ s# y5 w+ b - /*#define EDMA3_DEBUG*/+ t- `" {* N3 S# |5 T+ |% f: E7 j
# v. e, R( O7 ]3 R' h# ]9 }- #ifdef EDMA3_DEBUG, X3 }" q' t3 P' n Z2 A0 n- O K
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS): \8 Y$ p3 t4 p' F3 b }
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
: _: a6 ]8 A1 A - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__); r& |8 ~) u# }0 j7 O, E
- #else
+ |) q; {9 Z2 S7 ?; \9 T" J - #define DMA_PRINTK( x... )
, P0 ]2 A F- s& {$ N - #define DMA_FN_IN1 H- i) v7 v% E [
- #define DMA_FN_OUT- J8 c4 U% S1 v7 H! X4 a9 a/ K
- #endif" G* \3 c4 u1 s; `; r* x3 c7 J! ]
- - i4 ?! S# Q- C9 C6 _2 x
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)& B5 ^5 ^2 u1 O4 q; P7 @9 @6 i# Z
- #define STATIC_SHIFT 3
8 b+ [2 L1 W* I9 `- P, v - #define TCINTEN_SHIFT 206 \: x# g, H0 T p3 @$ ?' t
- #define ITCINTEN_SHIFT 21- Z0 I- D1 D- |& j8 h: Y5 t
- #define TCCHEN_SHIFT 225 H) p0 ^9 k) d, C
- #define ITCCHEN_SHIFT 23
" |; U# o2 H1 \) } - $ A: L/ H2 W' q
- static volatile int irqraised1 = 0;
- A1 o7 e! Z' |! q - static volatile int irqraised2 = 0;7 O4 ~+ D5 s8 j+ s
- $ d/ u, D% [: r: h# e1 V& G
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* V9 _" e/ p, k4 W3 @0 u( a3 a
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. }7 f6 p% y% f/ N. T/ A, ]2 E - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# m2 I% m% Q- w3 g% B1 Q8 t& L+ e) L - # e0 s% B0 E: I
- dma_addr_t dmaphyssrc1 = 0;
P3 P9 U+ Z" s% ?4 l$ x - dma_addr_t dmaphyssrc2 = 0;
% Y1 ~. i6 q5 e$ U0 _5 f% l - dma_addr_t dmaphysdest1 = 0;
$ n V& s3 T# I1 ~8 e/ R0 F# ] - dma_addr_t dmaphysdest2 = 0;
% `+ R5 ^4 F# x: e* {. g. }7 F - - `' P, [# H4 F1 V
- char *dmabufsrc1 = NULL;$ Z: ^5 f8 b1 h7 C
- char *dmabufsrc2 = NULL;
$ x- d. e9 M* v' c3 f - char *dmabufdest1 = NULL;
4 T. E+ s& t5 o. L - char *dmabufdest2 = NULL;
$ |. d+ }7 F4 Z% D! H2 V7 J
; @/ N7 V% N$ c4 z; j; c, t- static int acnt = 512;# _* g( I0 d4 Y7 R0 {5 r1 y
- static int bcnt = 8;
+ X: ~/ }2 E/ ?" z/ D9 S" w - static int ccnt = 8;
$ J `1 k: @/ l% A0 ?) e# t - ; A! }5 X) N7 b
- module_param(acnt, int, S_IRUGO);7 V* b$ y+ u! {! c5 z
- module_param(bcnt, int, S_IRUGO);
7 m3 x, a1 [3 k, u+ ?( J( s+ g3 X8 E - module_param(ccnt, int, S_IRUGO);
复制代码 9 }( M& B; C% Q9 Q( N' b( Z
$ G$ y: \" K4 S" X; @6 X6 A 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! b+ @- Q# [- l8 Q4 x* d, r( Varm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
% R: g H- _* j2 _1 P 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' K+ y/ D0 \/ k; Y0 S/ E
9 X, J* l a0 n5 L% I; G# G
! [. ^. Y: |- O
|
|