|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
0 r: b1 y% c. ~, I6 t3 ~# A- [code]EDMA sample test application
* a4 A1 s2 o) G2 I! q3 q1 J - /*
1 Z/ u! j2 i: n, D1 Y' v - * edma_test.c5 z& w& F3 q& B! W
- *# k$ { t$ @8 u& F. I/ a
- * brief EDMA3 Test Application i3 X4 T D8 K7 }; d
- *1 z, u0 ?% m5 _+ y
- * This file contains EDMA3 Test code.& d k5 w8 o6 G6 H* N
- *( g2 _4 m( D8 Z) s6 k4 H7 T* i
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
+ ~3 o7 k9 Q& l2 ]$ e; v# j - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
; t( y- o0 S* H+ c2 D1 I - * TO CHANGE.
& a* g1 u' C* `: {$ J - *) Q; k* L* _9 C* T. Q' N% I. k
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
& f% ?, }0 w! B3 v - *
- a8 `4 c: I: y2 t1 k/ m9 d - * This program is free software; you can redistribute it and/or% n# s$ @. g: b/ F& T
- * modify it under the terms of the GNU General Public License as* r! x0 d1 m+ @% v t+ Y0 M
- * published by the Free Software Foundation version 2.
v/ w* {3 D2 l$ B: o - *7 ]0 V0 v3 v1 X; |* | b: `
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any! C) h- ^+ |% Y+ C
- * kind, whether express or implied; without even the implied warranty
) |, D K/ k( y7 \' F - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' A2 u5 x7 O/ L7 r- i; i - * GNU General Public License for more details.
6 d! n/ W$ |6 E - */
) M; M/ E" G8 a: d) I/ M, g - 8 P, t$ F4 J6 r# w' U
- #include <linux/module.h>
, R8 e5 y& }" J, P - #include <linux/init.h>& l' b% [! l) c4 c4 Y- S/ `
- #include <linux/errno.h>
# k5 E# I9 u* [/ Y9 C - #include <linux/types.h>0 b+ Z3 ~* {. H' x+ A
- #include <linux/interrupt.h>
2 I( D8 G* g |! |( T; l - #include <asm/io.h>
. H% O" `+ B0 `2 A- F) t - #include <linux/moduleparam.h>
+ U O8 @* F* N# C& Y$ t3 x0 g - #include <linux/sysctl.h># t& ~: e* N1 k
- #include <linux/mm.h>4 u0 _$ `" g3 `6 ]3 x
- #include <linux/dma-mapping.h>
) F" s4 F5 E0 Z" r1 F8 e9 y! t
6 y. }( w- Z# v1 t- #include <mach/memory.h>+ t& f, w7 v" |4 J. \, `7 `1 W
- #include <mach/hardware.h>
0 \7 I9 j* i# W) A - #include <mach/irqs.h>
, [3 [) r1 y5 x - #include <asm/hardware/edma.h>
6 }0 L7 }' L) X! Q- ^5 Y2 r D( ~9 Z - & A- ~) R7 t9 L# a8 z& @$ r, |
- #undef EDMA3_DEBUG
+ w1 D; m. a; T z/ P3 t4 | - /*#define EDMA3_DEBUG*/
* v9 X) h0 T8 [8 w J
7 T1 F+ N) M# e( d" W- #ifdef EDMA3_DEBUG
$ X% e _* [. }" P+ l, I3 y& N - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)4 F: s/ y( y* O- K, p1 i3 V
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
6 k; Y& c5 g6 K- r - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
[% ~& U* p0 n( Z - #else
# d5 `8 r( n @/ N" n: ? - #define DMA_PRINTK( x... )
; H" r+ o7 h P9 c/ {- ]3 J9 L9 g - #define DMA_FN_IN- D' y1 }6 I, N
- #define DMA_FN_OUT/ G7 v7 n) I% a7 A, m
- #endif( \: j! ? U' Q" t; P8 o
) a4 n/ D% c: E" Y% J% B4 f A- #define MAX_DMA_TRANSFER_IN_BYTES (32768)8 ~# E( {: H( {( A
- #define STATIC_SHIFT 3
! v& @1 Y7 O6 @/ v2 Y; f* ~ - #define TCINTEN_SHIFT 205 g# J/ F {$ b$ u7 ^* i! ?% E0 h
- #define ITCINTEN_SHIFT 217 A+ B8 F& }- M8 J$ _6 S/ Z
- #define TCCHEN_SHIFT 22
% P0 v$ e$ J% q5 _! Y - #define ITCCHEN_SHIFT 235 B) _5 I+ g/ I9 l7 c
9 q7 v+ O: V. ^- G- static volatile int irqraised1 = 0;
8 S/ _( E0 r8 X( A& P - static volatile int irqraised2 = 0;
0 o+ D8 F) f+ \ - & d. b) W: Z# m
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 F1 G! X+ \& v' n0 s
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( {/ a% h2 }4 e" A& t/ n# f! L8 G - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* [8 E! X1 J y+ G# i0 W" a. a
. c% B Y$ ^: H) ^- i- dma_addr_t dmaphyssrc1 = 0;1 M9 _# b$ {# x- X$ }" x; h4 Q
- dma_addr_t dmaphyssrc2 = 0;- n0 y) E! U* S; F0 u6 d4 m9 T
- dma_addr_t dmaphysdest1 = 0;' H& Y; X9 I2 l8 l0 u4 D
- dma_addr_t dmaphysdest2 = 0;
8 v2 ]3 i" C% T% ` - 2 t1 V6 p; @: g
- char *dmabufsrc1 = NULL;
. K9 ~4 V: L* l4 M9 b. ? - char *dmabufsrc2 = NULL;/ ~- u: Q* C. ]& ^9 I% C* `6 |7 y
- char *dmabufdest1 = NULL;
( v X6 v3 d. k- @$ ?6 x - char *dmabufdest2 = NULL;
: X: U) C P2 Q
% ~' h+ `/ n% x- O+ ]. [9 G! [ H% C- static int acnt = 512;
8 ~" s# u" m, U! B. q: k - static int bcnt = 8;
" J* B4 B# i3 p/ l - static int ccnt = 8;6 c0 ~2 g' p' s/ T( H5 W
- 4 Y! T+ ^/ k2 N% H
- module_param(acnt, int, S_IRUGO);
# k6 v! T: S# h - module_param(bcnt, int, S_IRUGO);
' N$ u: \ g9 D. O; }5 Q. h$ Q - module_param(ccnt, int, S_IRUGO);
复制代码 2 }7 ?) y6 Q, s7 @2 \
" S! {* J# V" O
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) Y, q+ {3 c. ?# e6 ]! b4 t1 @" _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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
# l' v0 {2 o, @) Z 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' b, x/ `& m7 W3 v$ w5 S+ }
" \2 i! A/ x5 G- T; |" Y
* f- O) n3 c- K |
|