|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 % ?! q+ k$ D! h3 _+ N# Y% H
- [code]EDMA sample test application, o) d3 p5 e: Q% ?1 ~
- /*% n( r5 E8 v) `3 T0 D" a t
- * edma_test.c1 O0 \7 g4 d$ S: o
- *
- P7 T% T+ y2 n8 C - * brief EDMA3 Test Application
0 z- [& R# }7 g5 c - *
1 r% A7 z, I" s - * This file contains EDMA3 Test code.4 p8 F7 `" Z3 j: s
- *
0 G7 E; Z7 g1 \1 C5 i, W - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE8 v4 ]0 R. g( | K# N. x% h
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" D1 I# P, ?& |+ c; J
- * TO CHANGE.* E& D: K3 ]% c0 N; s8 i' W
- *1 p# D: v% Q8 v# K" a0 H
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; Y; u( |4 ]$ ?2 ^. x' n - *
5 ~% k+ A% R7 B" f+ g# F5 w - * This program is free software; you can redistribute it and/or
+ x5 c# n6 \" c - * modify it under the terms of the GNU General Public License as6 |. V2 h8 ~% D/ f3 p- V K
- * published by the Free Software Foundation version 2.9 |: }- b+ }4 X: i6 \
- *
- U q8 G* A0 n7 E4 ^1 n: r - * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 @. j; f1 N# u0 r# @
- * kind, whether express or implied; without even the implied warranty
& f. d: a/ o$ P. c6 D - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the' G0 F2 p4 Y/ A/ _% C
- * GNU General Public License for more details.7 y; D8 o+ c- j2 V
- */5 U- N( `. x9 l5 E4 _7 B7 } H$ E
- , E9 ?7 g( i+ t% `, L* n
- #include <linux/module.h>+ X% x- u& j$ S2 u5 J
- #include <linux/init.h>
( Z$ _0 J6 `* j8 g - #include <linux/errno.h>
5 G/ K- c' O1 e9 a! U$ |% Y6 y% ~ - #include <linux/types.h>
3 Q4 o1 t8 [) T4 R& P/ J' \ - #include <linux/interrupt.h>8 g- h& ^) s! c, u7 C+ S
- #include <asm/io.h>! C* d- z6 H6 t6 ~1 V
- #include <linux/moduleparam.h>7 f: G3 `& O! Y# I C
- #include <linux/sysctl.h>
5 o: f" z: @* N5 v0 I - #include <linux/mm.h>
3 X, G) q) k. R+ N - #include <linux/dma-mapping.h>
4 M f- T& }1 U3 f! r$ m
: @4 W, l/ V; a- #include <mach/memory.h>$ o( {2 b8 x5 T+ h3 ?( e. I
- #include <mach/hardware.h>
# i/ o% ] ~' D9 h: S4 y" u3 p - #include <mach/irqs.h>
K7 q5 b- U6 o - #include <asm/hardware/edma.h>. X9 `1 y, l' M8 n/ n* z
' s2 y1 s5 n- t1 I2 N- #undef EDMA3_DEBUG
- n9 m( R5 j: c) b3 ?, l/ C0 b - /*#define EDMA3_DEBUG*/
7 {8 T: H' a6 a7 ~
' O& U- P9 l, J. ]& f- #ifdef EDMA3_DEBUG
& B, f2 D, n' E* X7 b5 `; ` - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)% E+ T6 k d. V: c
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)1 S3 U; ~) |$ y' ?) W, p
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 B. q& }' L. j# h& v1 l$ X+ n - #else* Q2 b; ?. W$ [6 Q4 @ g
- #define DMA_PRINTK( x... )# S( ?; M0 _+ x8 _) W8 o% Q! s
- #define DMA_FN_IN
9 m( n' L! f7 w - #define DMA_FN_OUT
! K4 M! z1 o2 A+ F/ q - #endif0 y$ o$ @0 P8 S) c& f) A& y* t
5 @) e5 S0 I! e6 i9 B8 @9 L- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ J1 T& [; P; W; ~4 O3 i% y
- #define STATIC_SHIFT 3
$ T" K& h. u( r+ o! h - #define TCINTEN_SHIFT 20
! T3 H$ E; }. x5 {$ V, R - #define ITCINTEN_SHIFT 21
8 y/ ~5 R6 u( [/ F - #define TCCHEN_SHIFT 22- b2 m5 L5 H2 f& W. H+ [2 o6 D5 w
- #define ITCCHEN_SHIFT 238 y2 \; Z9 e: K3 k, h5 I
- ( ]* d: k8 M8 Y
- static volatile int irqraised1 = 0;" s; `7 W3 C e$ e, b
- static volatile int irqraised2 = 0;0 ]2 T3 _$ S. ?2 _+ ~9 }& @
- + i2 a2 v/ x- P& i- A7 |
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; n9 G& x% [% D3 H7 N0 ] - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! P* J. \8 p7 H' y9 O ?: q
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, g' a0 a) ?- v; @4 i9 w
, t7 c- l1 Z' n3 i+ S9 f }& H- x( [- dma_addr_t dmaphyssrc1 = 0;# l, Q$ X* b7 e# H8 v
- dma_addr_t dmaphyssrc2 = 0;1 R5 g |$ ~% U& f2 D
- dma_addr_t dmaphysdest1 = 0;
; @5 {6 o3 A& ^ - dma_addr_t dmaphysdest2 = 0;- f! A* s) W! S
- . s/ @+ A! V9 D% }
- char *dmabufsrc1 = NULL;
' t* j( F; d6 i4 M2 ?0 F0 L. s - char *dmabufsrc2 = NULL;
! t3 }$ {) n* q) N; \ - char *dmabufdest1 = NULL;9 z! y; t0 a7 O& K; _
- char *dmabufdest2 = NULL;
6 b4 W# o, r$ M# f) i c - 3 s" r6 ~0 F# E" w9 b- l
- static int acnt = 512;! h# [6 b, F& B
- static int bcnt = 8;9 m$ |7 U1 h) \5 [$ t, i S
- static int ccnt = 8;
9 }4 b& `) R! e8 J5 o4 C
% Z4 {& h% W, f; o2 P, R* K- module_param(acnt, int, S_IRUGO);
( e: f! t# ~& |" b' ? - module_param(bcnt, int, S_IRUGO);
& p8 d2 m, a6 W$ w/ C2 P - module_param(ccnt, int, S_IRUGO);
复制代码 # [ ?4 F4 D4 ]6 z3 s
" y1 \% `1 O3 W u# W 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用3 ^3 @2 @; c) @! U* W$ ]) R3 y8 r
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
$ v) m6 o- o+ v$ F/ B5 y3 \ l 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。0 h @9 S5 G0 M
8 ^. C) l P" @9 t* T. Z) d3 K) _) P5 P
|
|