|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 5 `9 D2 x" Q: h* s9 q+ h
- [code]EDMA sample test application
: F ` y" J0 k& i' A: }4 T - /* v8 S: ~/ q7 v; Z5 Q- m
- * edma_test.c
4 W* [4 B6 A9 a4 F2 R. X7 W- q- Y - *
9 N$ e0 c/ f9 c# \5 W: Q6 u - * brief EDMA3 Test Application
- d; |; M9 s* i k. s: m) M! Z - *
: N& |. S" f; W1 N2 _; W8 L - * This file contains EDMA3 Test code.0 [5 Z0 D6 Z- s6 a
- *
+ O/ N0 t+ L0 C1 G1 b( h - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
" Z; c) A9 Z6 P8 v" h - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( K7 K0 P9 X5 h' `9 a - * TO CHANGE.
3 c- ]; F8 ^; L3 V$ q - *% D! R# e" ?" L* i
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' E6 W& r" L' t) J4 ~ x6 y. ]. i - *- |8 F% H. ^. b; T* W* h
- * This program is free software; you can redistribute it and/or3 A' Q( d3 j8 j; I9 }, w" a2 f" C
- * modify it under the terms of the GNU General Public License as% u2 f5 Z3 D! Y8 z5 @+ u
- * published by the Free Software Foundation version 2.
. D/ I/ A( j4 Q: F% @9 k - *5 c! k" q4 l2 v. Y7 ?
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; R+ _+ K" b# o' e+ W4 A! B4 N4 S% | - * kind, whether express or implied; without even the implied warranty( T! ^; _: d9 G* C
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the: u5 s# [. r6 J& [; V' j; O
- * GNU General Public License for more details.
- U7 \8 h1 U x2 [& ~7 Q$ q - */
' U* w& x$ m/ V2 H; k
1 z+ | b; P1 W/ f- u, w9 y: d: @- #include <linux/module.h>! P8 I2 B1 M5 e6 N. {6 s
- #include <linux/init.h>
6 W& t. o& U" \9 C7 U# D - #include <linux/errno.h>9 p3 n8 V/ L$ G: N9 [( @
- #include <linux/types.h>/ y. }3 `3 q% p3 X* z0 E# r
- #include <linux/interrupt.h>7 L! h3 I3 W8 a, P
- #include <asm/io.h>( {* M1 I" h) {( ~# f0 r; `
- #include <linux/moduleparam.h>
$ i, p4 z2 n. }8 i% w! k# F - #include <linux/sysctl.h>
+ W8 ^1 ^4 ]4 m* ]3 @! n - #include <linux/mm.h>
3 F5 p+ | L& V9 ^ - #include <linux/dma-mapping.h>
! }$ h1 e$ D5 f) _* { - ' m) _4 ~6 k H' K1 O) E4 d7 j
- #include <mach/memory.h>
5 s; }. @4 I! W - #include <mach/hardware.h>$ t' |1 Z% x9 a
- #include <mach/irqs.h>" x: L/ X7 e+ Q& P, Q9 J
- #include <asm/hardware/edma.h>; p; E, e! m2 |9 e
- 4 s) W! l! ~! N5 d
- #undef EDMA3_DEBUG
4 a: T1 ]( l) {5 B - /*#define EDMA3_DEBUG*/$ P+ _# P' X6 u* ^/ K, A
c6 N l, Q4 W( ~; R+ o9 t- #ifdef EDMA3_DEBUG' q2 B+ J% A0 N) h- a
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 w' N: j: O7 J7 I - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): I2 h# W$ Z% Z6 r. d* N
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
% L8 |( K' w! q+ X6 N3 J) P& w - #else) y% M* o9 q9 {* C& ]# l
- #define DMA_PRINTK( x... )
. a: E, u5 D: F) i$ H, ^: C" w - #define DMA_FN_IN
: e1 {: X. V b* [ - #define DMA_FN_OUT
4 c! I/ `6 @4 q1 z7 g8 ]6 h - #endif5 c1 l1 [3 c* t6 @: a, ~
- . h# f1 j- D3 M" }+ |' I3 C) R7 O) v
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)' s% H% [4 C; H
- #define STATIC_SHIFT 3
: r% C) m3 M. P% Y( S9 Z' |# F - #define TCINTEN_SHIFT 20( ~1 `6 o# Q6 \
- #define ITCINTEN_SHIFT 21. Z T& U- K6 B, @, G( Y" N6 P+ r
- #define TCCHEN_SHIFT 22! k- ^& s. [' q
- #define ITCCHEN_SHIFT 232 I( d2 L& B6 Y: p1 G
- . t' S$ L& ~, }# y' g
- static volatile int irqraised1 = 0;: ]# i7 C2 a! B W, m4 C/ l
- static volatile int irqraised2 = 0;
5 t' d- T. E2 T, p' M - / N z: e, v: g: [
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# w2 y, M' h! p6 o: P
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 p' {2 f0 |+ K8 z - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 c% e+ z2 v8 P4 W
: Y, d3 ?- F t h9 |- dma_addr_t dmaphyssrc1 = 0;' R! ^: p8 j, [! @& \9 o
- dma_addr_t dmaphyssrc2 = 0;
) ^' s1 E3 g8 P- v$ I( W. A* f - dma_addr_t dmaphysdest1 = 0;
: w: W5 v" ]) u! j9 W - dma_addr_t dmaphysdest2 = 0;) Z! {2 C* O" i( R+ n& z9 \. d
- $ t; l; s& B/ \/ E) \
- char *dmabufsrc1 = NULL; `) U: d" N; t* h
- char *dmabufsrc2 = NULL;. @$ J% s1 L3 B4 N: u, |. U
- char *dmabufdest1 = NULL;1 T) w& r+ ~6 z% Z$ o7 c
- char *dmabufdest2 = NULL;- c$ a9 p* Y, B5 J
- + c3 s. D+ ~; r8 `% J, g/ ?/ ]
- static int acnt = 512;# |4 F6 }/ }# L
- static int bcnt = 8;* F9 [' W1 D8 v! k# u- d
- static int ccnt = 8;* e4 T% G' j W! r4 f
- ; N9 w. O) I/ y
- module_param(acnt, int, S_IRUGO); \9 p) `" n$ g* y. a
- module_param(bcnt, int, S_IRUGO);
- Y9 _( k( j5 y: s - module_param(ccnt, int, S_IRUGO);
复制代码
: s/ S0 P+ ?$ o `- m* I
/ F: ~1 f7 K2 q* \& K$ U 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用5 [* B) n) u1 f- s) {& S J3 ?
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。- y8 p' k# C# Y- n9 Y! l7 t
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
& _' `3 g: \$ l7 w6 R/ e3 \8 ?9 e1 V1 U
/ l* w! f4 ~* ?. y
8 }$ N; ]( V* X) v. t0 f |
|