|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( Z/ @( \$ N( D- U- [code]EDMA sample test application
" G/ P/ K; }9 P" l) b q0 w5 {- P4 L - /*$ F% W, q6 ^6 M. T9 Z" ?2 @
- * edma_test.c
) b0 A* Q' |2 V' h - *3 p# `# D* s J( ?6 V
- * brief EDMA3 Test Application9 I# B# T/ w7 O8 B4 }; u
- *5 V3 a+ I6 f! l6 V4 e2 h7 ~
- * This file contains EDMA3 Test code.
3 U, \) [! L7 d. B' h - *9 X7 C! w: }3 R
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
g. c. Q! J( |9 k- l+ E8 O8 f3 f - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT0 Z4 P5 ~/ X) C k
- * TO CHANGE.# M) L" ]; V( I, Y7 {* N$ Y
- *6 e* K) s# U. S
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
. U7 k( t! t1 P" O5 ?" \1 o& c - *
) A: r5 ?% {$ ~ I" G - * This program is free software; you can redistribute it and/or
" {% P; u) M4 r' w0 F2 Z k1 ~+ }* p - * modify it under the terms of the GNU General Public License as; D( E- F v4 t! x, O
- * published by the Free Software Foundation version 2.
4 W S; e( z1 a+ ~% V; i3 ^' w - *; s. V/ l8 S% O) A
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any ^" y; i) R( y
- * kind, whether express or implied; without even the implied warranty R' R9 X- S9 E( X; R) A
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 X' c5 F# y. X3 b+ |) n2 |
- * GNU General Public License for more details.
+ l/ R$ \3 {" ^2 I# l - */* |4 m- ]# ?* g5 W; `: \
n7 ?( r! H" Q% U) N; d1 I- #include <linux/module.h>
+ o, M5 D) \1 }4 o5 z ` - #include <linux/init.h>4 v0 v- g$ X. m9 r" Z$ r7 k
- #include <linux/errno.h>9 {; x' T( j' }: l4 O" U
- #include <linux/types.h>
$ I1 ^ K' _, b2 j. t - #include <linux/interrupt.h>
. i* h& q# W2 z) C: z - #include <asm/io.h>
: i `" y7 p' T+ _+ J& [ - #include <linux/moduleparam.h>
) R- l4 ?" i% t - #include <linux/sysctl.h>
4 o! Z2 y+ C& H; s& c. {5 o - #include <linux/mm.h>
. j& @) `' c& J1 C" P# ~/ Q - #include <linux/dma-mapping.h>
( V5 G+ Q! b' p7 a7 z6 Y
& I2 y0 H& k* q- q( G- #include <mach/memory.h>
1 H: G6 V d; j' `, g; x - #include <mach/hardware.h>& m* s h/ L r6 b2 N* Z7 s8 S4 ?
- #include <mach/irqs.h>
5 j# b: P' e; y5 r; O - #include <asm/hardware/edma.h>
2 t1 r# X1 J6 J# U. f- ^8 e
& S* f2 I1 k+ F, n5 I2 u7 w- #undef EDMA3_DEBUG2 } G% ?3 Z( I8 o
- /*#define EDMA3_DEBUG*/
4 M+ r4 R3 B) K8 ` [ - 7 H4 l" ?- T5 w$ n6 d
- #ifdef EDMA3_DEBUG
. k8 c; p0 t7 h' o - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS) h5 @3 O% o# C- u& ~" p! t
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
6 p0 `8 H; x$ F - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
& l4 V2 K- y3 \ - #else
4 w4 c% d) [" t k0 m- @. {9 X - #define DMA_PRINTK( x... )$ d# Q' k1 `& t# t
- #define DMA_FN_IN6 a h* M8 M8 P H0 D" n! A
- #define DMA_FN_OUT
$ I* A6 i x6 Q# T4 j. E6 M - #endif1 u2 e6 g( H+ y/ F2 x/ _3 J
- ( P6 {0 q1 Q4 e
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; d1 ]( V3 n, I* w- L& Y& o* a - #define STATIC_SHIFT 3+ X- ?8 j( d" n/ z" x
- #define TCINTEN_SHIFT 20. _" Z. E$ M" w4 ^, V! X
- #define ITCINTEN_SHIFT 21; }# t3 b. i0 {" y$ e' ~
- #define TCCHEN_SHIFT 22/ V3 u7 X5 y, j, a
- #define ITCCHEN_SHIFT 23
2 ]7 M. D: X0 V, n; F3 y! A - - P8 k4 d( |8 F" n
- static volatile int irqraised1 = 0;
5 A" \5 ^: f+ |! }- p - static volatile int irqraised2 = 0;
# G Y, |9 G5 J( x z* @1 k - ) T! d6 `3 f) ]; i: M/ c: b$ Y: |8 f: l
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) z( x2 [( A# T% E2 ]/ j& J3 ^
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# W% E/ q: O/ D6 Z( S - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 k( V) N& X. Y
, i! g/ v7 _" y% S# O( e- }3 ?+ |- dma_addr_t dmaphyssrc1 = 0;% @0 G1 T' q- h, g
- dma_addr_t dmaphyssrc2 = 0;
a- M+ I5 g9 K' R4 J9 C+ G6 r - dma_addr_t dmaphysdest1 = 0;& z+ t( q) c. [) z6 E0 F. J+ A- Q
- dma_addr_t dmaphysdest2 = 0;) U0 W7 t3 P) s! }$ T: n
- 2 u8 I6 z8 h" }
- char *dmabufsrc1 = NULL;
. o7 k: e4 Z8 s0 A2 h. e; Z |! ^ - char *dmabufsrc2 = NULL;. A; s7 M) ~& Z) \/ E6 @
- char *dmabufdest1 = NULL;
; r) O! ?+ W$ ~6 \% h$ H - char *dmabufdest2 = NULL;
' T$ e0 J- \$ G6 z - & J$ c) \/ \; _7 G$ s
- static int acnt = 512;
+ K/ n% K9 \7 P1 }2 o - static int bcnt = 8;, R$ n6 R$ f0 c6 x8 O; x5 j9 h6 l
- static int ccnt = 8;
/ u' _! |% N( o( ?9 `7 V - 0 x% g) Y. V( ?) s" a
- module_param(acnt, int, S_IRUGO);
$ z, w% Y7 H9 y - module_param(bcnt, int, S_IRUGO);+ P, m" V/ ~3 j: S2 w+ W, J- W- i
- module_param(ccnt, int, S_IRUGO);
复制代码
" f% O9 M! _7 [1 _
) a. {6 n$ @( P) j 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用5 X$ l; }: T+ R7 p8 j
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。6 M: d% `7 z, I- z8 S
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
: a: r. ~9 ^- C$ t1 `2 `% i# [/ D4 r! O4 R8 m
, |4 h% R) Q: Z2 Y7 C9 T |
|