|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! q+ q4 c4 u. \) Y: j+ p0 i, a- [code]EDMA sample test application
3 O' w1 T( c1 `( f2 ^ K: V - /*, ~' k: Y( J* N
- * edma_test.c/ ]8 A \5 m$ v' G/ l' M
- *; S1 W. J/ u2 r6 w" U" Q
- * brief EDMA3 Test Application* H. s$ @: l2 Z: r
- * F0 ?$ {4 G% N- ?* r: Q
- * This file contains EDMA3 Test code.
$ M/ x. h/ U- }' N+ k - ** Q3 M# `% z# w7 }* [1 |' ~
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE4 M$ Y+ Q6 ~3 A' C+ k F( Q
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT$ B( z6 l# r/ t) V8 C. p
- * TO CHANGE., c6 ? x% z- }
- *# }; r0 B& f+ g- t3 _, {: U0 J
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/" ^% ]9 i* d, f( G7 J/ ~ R
- *
# w$ @0 s! |) _7 Z0 ]: Z/ t! Q, M, m - * This program is free software; you can redistribute it and/or) e: h* i- G, L: V. Q! h, y
- * modify it under the terms of the GNU General Public License as1 V4 r& }8 A4 D2 ]) \, i2 z) E
- * published by the Free Software Foundation version 2.
# x8 ]: d3 i' }1 U - *
) a! y/ U9 n; T! h0 ~ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
5 s2 f+ {2 U6 q4 A+ b" V - * kind, whether express or implied; without even the implied warranty9 A# g% q2 _. _3 q
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' ~; A5 L4 q. u - * GNU General Public License for more details.
" g! ?0 B/ S* p2 f! v. {& q - */
& {, a/ s% p5 @4 H8 }
9 T# D/ u; E9 H- #include <linux/module.h>
2 D1 P* r! g f - #include <linux/init.h>8 I( Z# y# U! a( b* H2 \" L
- #include <linux/errno.h>1 S" ?3 i5 n( V6 J& @! d* [
- #include <linux/types.h>, Z* F, W$ H- M P
- #include <linux/interrupt.h>
$ Y- [1 m1 R: |1 B% f: \0 E6 u% Q - #include <asm/io.h>
& B: [ U0 l( A: b5 p \4 J - #include <linux/moduleparam.h>. o8 L% Q5 K" G8 i7 ? X9 y
- #include <linux/sysctl.h>9 m# d5 o6 Q3 i+ n# X6 L, i
- #include <linux/mm.h>
a6 m+ f/ q* j4 e1 }% c) |& q - #include <linux/dma-mapping.h>
$ Y* o! u% d3 K6 |" k$ } - 5 ] \% K, R* a5 E# q* I
- #include <mach/memory.h>
; ^, ]2 m n' \3 E# v2 k - #include <mach/hardware.h>! @2 f7 a% u8 ~3 ]4 p) M3 M i7 n+ E
- #include <mach/irqs.h>5 E$ z. i3 S% [! w. E
- #include <asm/hardware/edma.h>
9 J6 N3 i: g0 K" ~7 T - 8 A+ n2 J! d+ N/ M9 C% s9 E6 j
- #undef EDMA3_DEBUG
! H/ _# B, b, U8 {4 V - /*#define EDMA3_DEBUG*/1 ]6 X( c) H9 u* S8 j+ U
- . q8 a0 L! }. }, t* Y$ c9 U. V* Z/ T
- #ifdef EDMA3_DEBUG
' ]" c/ z( y3 d8 a* G9 ]& [' j - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)2 s2 `( f% v. g
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
# q' _! L+ Q- x3 i. i5 r% [ | - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)% d# X) O3 N6 \
- #else
% G' a/ l# U+ b3 `6 X5 G( x/ q - #define DMA_PRINTK( x... )* [" e8 W1 T/ \2 c/ L
- #define DMA_FN_IN- ~+ k1 X$ i+ t1 o% K" F
- #define DMA_FN_OUT
+ u/ H( T( a0 E: [- ] - #endif
' x; [ D4 N! k! A8 h - + K" b9 X( ?+ f8 I3 u& b; q
- #define MAX_DMA_TRANSFER_IN_BYTES (32768); i8 W0 G- n; u
- #define STATIC_SHIFT 3( W0 J. Z, E5 a* U Z0 b6 w% Q6 l
- #define TCINTEN_SHIFT 20) V6 E% ]4 \+ N: y
- #define ITCINTEN_SHIFT 212 W" ], w7 z6 e& y, c
- #define TCCHEN_SHIFT 227 f1 M1 E5 b7 V# ?( Z
- #define ITCCHEN_SHIFT 23/ e X G# @* S1 |
- ) q A- m6 T" z5 S
- static volatile int irqraised1 = 0;
- |( C9 f+ [) n, i. [ - static volatile int irqraised2 = 0;, g5 _. J2 T; s' Q- t
t9 i% x6 F4 [1 L( W8 o* Q- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& m8 m" ?; e0 `1 S. l6 E P
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; r- y- [/ N6 Y! e) W. S - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" v0 ? V0 [/ `# J& L: L - ) B* r5 A; K2 U7 P
- dma_addr_t dmaphyssrc1 = 0;* G9 E- @' T3 N8 ]
- dma_addr_t dmaphyssrc2 = 0; j* w( P1 r/ [1 [1 m0 k) J$ |
- dma_addr_t dmaphysdest1 = 0;
) H$ J: K T' f( ]) G9 b - dma_addr_t dmaphysdest2 = 0;
3 l! m5 X. U5 w1 _& h5 J/ l
$ T$ i, s f) y" ` l/ G) n5 H* J- char *dmabufsrc1 = NULL;) i( Y( V3 k4 @' L9 f8 L9 R- c! k
- char *dmabufsrc2 = NULL;
+ E y6 v" i4 g+ q+ x+ ~' s9 y7 t - char *dmabufdest1 = NULL;) D; k0 L3 S) d8 m
- char *dmabufdest2 = NULL;% a! \- [1 I' H: p- T, {5 V0 R
3 Q9 L# F2 g- I6 q0 L" R/ E0 o! p- static int acnt = 512;
- G. Y) }% J1 y- f - static int bcnt = 8;" v* a" ~7 p) l$ c% g& f. a
- static int ccnt = 8;
* a( m( T2 D% k& o - 0 |; w/ }" c A8 `
- module_param(acnt, int, S_IRUGO);
- R: y# I% q, w8 ]$ [2 ^4 f - module_param(bcnt, int, S_IRUGO);
: q1 U& I$ R4 `1 X! P7 W - module_param(ccnt, int, S_IRUGO);
复制代码
9 c& u. q' Q( g7 q1 t2 s4 G
- m, s j, y' K s 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! E3 d/ Z* m, H" x! Tarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
* M, \- e5 d" o. J9 X% J 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
) i7 F/ {! U2 Q
, A4 Q/ r. u2 p8 x7 a z9 \, r' ^: @0 Q0 |) M# C Y4 O v
|
|