|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) W2 K+ O) H$ B+ N* ?. W( P- [code]EDMA sample test application' Y$ T% i$ T# J2 s* B- i8 e! x
- /*
5 p2 ~$ F4 a7 L2 p' V/ e - * edma_test.c8 Y1 H* Z- v ^) A
- * L% |+ y' B- H2 ^0 q1 D0 ~
- * brief EDMA3 Test Application
; [8 @. E; I7 P - *6 z I2 V8 g( |. E& P: P- [3 u
- * This file contains EDMA3 Test code.0 G5 z5 P, t' q# M/ A! y7 J# R% z
- *
2 X$ Y4 }* L9 t" d w* t( t# \ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
, m( O0 m$ x3 F: ^2 s( M( h/ u - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
+ X' L' F" W" A3 X - * TO CHANGE.* a8 o y3 w. }4 r; [$ f- D% |0 y
- *( J" t' D/ i- G: [7 E, x$ h" T' |/ M
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- p( \- A1 g5 o4 \& d6 s2 @
- *6 }6 R' r5 D+ L, a% {
- * This program is free software; you can redistribute it and/or$ ^4 W L. D7 s9 D1 L/ Z3 m
- * modify it under the terms of the GNU General Public License as3 @0 G' O7 m" G: g; |0 ]4 h$ j
- * published by the Free Software Foundation version 2.# _8 b1 K) d% ?" F1 @) h" Y
- *
3 `5 p4 S( ]; a& c5 ^$ B0 w1 M - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
" c. U: I/ t* ~* k: G3 O1 X( X - * kind, whether express or implied; without even the implied warranty3 ?7 L m" H2 S+ Q. z
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" @1 a( \' x" _3 V8 T
- * GNU General Public License for more details.4 J3 i1 S+ [. w+ D4 Y4 S
- */
, f% C9 S; h& B- J) {- C - + P N7 l+ I( M% {1 v* J+ v
- #include <linux/module.h>8 V) t$ R; |1 Q; S
- #include <linux/init.h>
& E0 g4 h. y( i) E. X - #include <linux/errno.h>% |6 S! j0 a% R
- #include <linux/types.h>/ r. C, `9 Z: n) Q: M
- #include <linux/interrupt.h>( s) m# u. d7 G, l+ M
- #include <asm/io.h>
+ D( U8 G6 X8 {, ? - #include <linux/moduleparam.h>6 D3 S9 }4 i1 A9 |
- #include <linux/sysctl.h>: t5 \6 i# [/ H/ R$ X
- #include <linux/mm.h>
: m: O4 `: [; L: G- V& g) h; B - #include <linux/dma-mapping.h>2 U" S9 l: W. U; I) D$ f" L
' s" A8 ^6 a$ z/ X6 L$ f2 l( S- #include <mach/memory.h>$ m; P3 j' X0 A1 f+ b3 f; t# f0 H9 M7 ]
- #include <mach/hardware.h>
# W- b+ H/ o# J9 h. t ~ - #include <mach/irqs.h>& b* s+ u9 K- T5 H+ ?$ \/ J
- #include <asm/hardware/edma.h>
0 Z2 @% |& v% d# }
j( H; s' d. d0 r+ ]- #undef EDMA3_DEBUG
$ N. R0 C4 o% |# k% u1 e5 C - /*#define EDMA3_DEBUG*/, C0 s! q; Z- ] V u3 e! B
- , _2 n" B" X' {
- #ifdef EDMA3_DEBUG
$ n6 w' n- V5 U+ P! b - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
9 s7 ]2 K7 O, M& ?* o# m' c - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
0 ]& Z- ]& H s# o& Q4 q: g - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)8 q0 K, Q1 E4 } B: e7 X E
- #else/ L2 W1 l2 m5 `: |
- #define DMA_PRINTK( x... )
* c) p& G& Z6 t - #define DMA_FN_IN `1 T, H% t, f# e
- #define DMA_FN_OUT
* d& |2 O( a: ], Z7 i' y v - #endif
$ B0 h' @- g! K1 t& c
D3 O* m0 o! L0 A _' l& L3 }' z- #define MAX_DMA_TRANSFER_IN_BYTES (32768)$ P4 h1 L4 K/ B, K) E
- #define STATIC_SHIFT 3: S: _+ \: A$ _
- #define TCINTEN_SHIFT 20
3 O' I. R$ o3 U0 K - #define ITCINTEN_SHIFT 21
# ]/ E! ] s" j0 N: r - #define TCCHEN_SHIFT 22
- f1 N& ^( D* h) u, w; W - #define ITCCHEN_SHIFT 23
/ w0 ?: f) \' U" ]5 W$ J* V2 A" n - 1 e$ J, d$ B/ Y% U+ W
- static volatile int irqraised1 = 0;- _& Q( @. j$ M: Y- t6 n9 r
- static volatile int irqraised2 = 0;% z# a: z/ u. z, K) N
- ! u7 B0 L, ^1 [6 ~7 ^
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ h+ a) E" X- a3 m" C z7 b/ d0 T - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ V9 x" V) `. O
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, W V! X k. h1 i. E
" q) k1 Q0 R9 N0 c1 ?. `3 e- dma_addr_t dmaphyssrc1 = 0;
( y& ^, H: B+ I( _ m3 D" W6 v - dma_addr_t dmaphyssrc2 = 0;
8 t# c' ~2 v: ~ {+ ?' z - dma_addr_t dmaphysdest1 = 0;
) s7 k+ Z+ ]' F* f3 B0 R. U9 @ - dma_addr_t dmaphysdest2 = 0;
# }$ z" R* R* W9 s3 s$ x( ] - 4 ^% h! k6 e! m4 M
- char *dmabufsrc1 = NULL;
) c: p% q3 u; k* H - char *dmabufsrc2 = NULL;
, j5 f( P% t: k2 O- e - char *dmabufdest1 = NULL;
. C7 x- t4 C2 ? - char *dmabufdest2 = NULL; ?* P5 c/ v7 D* {
- . m1 a, H3 E/ S a2 E# p
- static int acnt = 512;
, ?( Z) o# L9 H% l/ j# J - static int bcnt = 8;% t* Y! p T' P" M( C# _ E; \) j
- static int ccnt = 8;
3 T5 N# T' j: o6 \ - ) M5 k6 Q* A) P: t) m4 z; T- |
- module_param(acnt, int, S_IRUGO);
" Z; v' x# N, v6 W$ t - module_param(bcnt, int, S_IRUGO); S& j# t0 ]: y ] N3 ?* B
- module_param(ccnt, int, S_IRUGO);
复制代码
7 Y+ @4 A& e) g# c& m+ Z) }
5 S3 z7 H; L$ [; z2 v. a% t; ]% F 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ D# J( i q8 ]7 ~! T7 n# b6 t" Q( ]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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
8 @4 i$ X7 u/ [! B) V: x1 ? 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。3 r$ n& [8 `/ Y+ ?! u
( {3 m0 P2 M; F
& d9 C( J/ K6 q |
|