|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
- |- L2 f/ _0 b0 n L3 i: L- [code]EDMA sample test application
& Z( N- P. H' y1 c - /*
9 J. j/ S k9 y" L - * edma_test.c+ {# f5 r: W- S2 \0 |
- *
; @3 k" Q6 t4 m" k! ?1 M - * brief EDMA3 Test Application
/ ]0 k! V/ C% ^: x5 {! B - *
( I" ]; F0 y+ ]) N7 ^ - * This file contains EDMA3 Test code.
c; x' }- n( m; ~+ Q$ I - *
# b9 v7 \' ~; C/ T# l. O' J$ _, B - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
2 c$ J* l7 K0 U1 X8 S" e - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
- h) o: @$ A, m9 A1 v& w4 O8 E - * TO CHANGE.
4 f" V" [- H: ]5 c - *
' F- v5 y% Z# b' B0 m: L' X - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
# }$ w0 D9 ]- d M" [+ K - *
! C, G: ?6 C1 |, o0 Z6 T - * This program is free software; you can redistribute it and/or
& O Z3 j8 R: J/ i, ~ - * modify it under the terms of the GNU General Public License as
/ i1 F) D- ]1 o( j1 } - * published by the Free Software Foundation version 2.6 z; b/ {- d1 u
- *7 P; O W8 t6 z; \$ w
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
8 @1 e: Q; [7 C |1 t( e - * kind, whether express or implied; without even the implied warranty
+ t! c3 }* ?* C3 A - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# G# }6 w1 f1 f0 P8 f - * GNU General Public License for more details.
1 L" |- ^' f. m5 P8 u9 t* j+ M2 c - */
; Y2 B/ w- \8 \2 ]$ H4 g! ]0 W - 8 q1 @- g3 w7 \+ k
- #include <linux/module.h>
) e( G/ P8 G0 Z' M0 t2 p. Z - #include <linux/init.h>
4 y2 K1 n, J& r - #include <linux/errno.h>2 |; ^$ I4 [; H+ K! k
- #include <linux/types.h>
9 V' \: `6 m9 l - #include <linux/interrupt.h>
6 t, u3 t* E! Z# ~) H - #include <asm/io.h>! ^- `9 B- a: s. W3 g' Q
- #include <linux/moduleparam.h>
1 N9 T& Q9 V* ~ - #include <linux/sysctl.h>
- W V5 }8 [& I! ` - #include <linux/mm.h>0 {" T6 [. z, H9 {; _1 v
- #include <linux/dma-mapping.h>; }; G& J0 y) V4 ?- _2 \( o7 Q
" P$ P1 w( H4 G- #include <mach/memory.h>
; O7 } c& P: V8 j1 {" k - #include <mach/hardware.h>
, [& D& e3 _/ n - #include <mach/irqs.h>
: Q Z+ o5 R7 m; p; g2 Q - #include <asm/hardware/edma.h>
: b+ I- K2 Y; a3 h0 A% L, d - % A7 {5 Y7 x- F+ h
- #undef EDMA3_DEBUG6 P9 M3 |! k& r: d
- /*#define EDMA3_DEBUG*/
' Z9 c: i4 q T9 K6 ?
8 f, @- @2 _' ]& f2 s6 N- #ifdef EDMA3_DEBUG
) n# ]1 ^$ @: c7 o - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)2 d) o2 Y; I) [3 Z7 Z
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)& S& l! `) O4 a: P# N2 g' O/ j
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)3 J: l) R: }* O2 x% x3 y
- #else
- t# ^; t. [4 t( V- [ - #define DMA_PRINTK( x... )& D* L4 w i6 E3 _7 C
- #define DMA_FN_IN/ i: I9 V- p; L9 M; H& Y. t4 b
- #define DMA_FN_OUT( _& q% `3 c" L
- #endif
1 b' {- A9 E! A2 E5 k; I. d - 5 J( Q9 ~3 Q. `' \: Q3 B7 U
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)% \% [# j$ G& K+ a5 ?9 a6 i9 F( a3 o
- #define STATIC_SHIFT 3
& H R* c! c6 _6 _ I" c0 M) _& M - #define TCINTEN_SHIFT 20
8 D8 t6 ?. _' h! r: j9 n! b6 Z2 U - #define ITCINTEN_SHIFT 21- T. l3 c) e2 z3 e5 \
- #define TCCHEN_SHIFT 22
( d1 \* _/ Y7 \: Z& e; H - #define ITCCHEN_SHIFT 23& D2 K+ X3 T; i1 R$ `1 c" V
- 4 O5 _1 x) k& Y+ b9 J
- static volatile int irqraised1 = 0;* i/ d! a9 Q& J( _4 J* e
- static volatile int irqraised2 = 0;7 R- B4 V" c4 \
5 \0 ?* `1 s! f5 t5 c- @- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 G6 K- `. ^( O. B ?
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% r/ I1 H, B z8 F3 V - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 m$ o. R) \7 C+ h+ V% H/ G
$ ^3 z+ m% @. d+ n1 H. u" y) Z- dma_addr_t dmaphyssrc1 = 0;
2 q5 n* _ @' ~& b2 p$ j+ f" K - dma_addr_t dmaphyssrc2 = 0; Y: s5 t/ c3 P1 Y7 h0 [
- dma_addr_t dmaphysdest1 = 0;
! Y" i3 S1 Z c) w - dma_addr_t dmaphysdest2 = 0;
& Y# g7 S- \6 @8 y z/ q
2 b) u& y6 |( t5 J8 S' N- char *dmabufsrc1 = NULL;
# X7 ^2 N0 l. @8 C - char *dmabufsrc2 = NULL;
- @/ n+ n. N2 b6 h, { - char *dmabufdest1 = NULL;* ]& w; y, `* N) o
- char *dmabufdest2 = NULL;9 I) I% B& Q" R( g5 i
5 |, N7 L7 q( m5 c+ _' f7 B. S! f- static int acnt = 512;
8 b' W, B. @4 Q" j, g: U" i - static int bcnt = 8;
3 B% `: ]5 j# b8 V3 E3 Z - static int ccnt = 8;
2 Z+ ?) v6 Z7 X1 G u
% o& v1 {% c% J- module_param(acnt, int, S_IRUGO);
' O5 a, U3 E8 S6 j3 Y7 C - module_param(bcnt, int, S_IRUGO);
& H$ p) ? J+ }( \! _ - module_param(ccnt, int, S_IRUGO);
复制代码
4 L1 X/ B, f) ]. s, `
. A8 x" o, I8 a5 X 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用3 ]8 g, [$ c+ f0 r& c! |# a7 v
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* k7 i1 T: f5 F& x0 [! H4 T# G 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# N# Y4 j7 K2 T! P6 ?( @" I' r& E: b, b1 f3 {$ r/ s
' f5 q* a8 d8 A* v6 v& j7 S1 Q |
|