|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
" o3 Y$ V; R! c* L- [code]EDMA sample test application
5 [' x7 d* |* [ d* ~' B - /*0 x7 \5 H/ z, _
- * edma_test.c
/ a; R3 E4 _! r( ]# c. j l3 _ - *
4 F0 i: _* f; t - * brief EDMA3 Test Application/ _8 {6 S A8 h" f2 f% c7 M
- *$ Z) h! U/ D4 F/ v
- * This file contains EDMA3 Test code.
2 T1 t: V4 o& X1 c( O$ } - *8 R% Y( i5 l( u* E. p/ q
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
: K- A, A) A" a* e - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% l6 x# F2 \. j3 d! V& R - * TO CHANGE.
: ~* o& h6 Y& V - *( c/ W m$ O0 D4 x% v0 ~# c$ w) d+ D
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 t2 \5 N( `7 j( e; B, W6 g- F7 N - *
4 v/ |& V/ _, p4 c* I, I8 I- D' X - * This program is free software; you can redistribute it and/or
: W" s5 Q& Y" ^3 ` - * modify it under the terms of the GNU General Public License as
7 J2 Y5 K) b- q - * published by the Free Software Foundation version 2.4 ^ {5 X! ?; |# K* B& C Q
- *0 ~$ e9 ~% d; ?4 w* O
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
f$ o/ X) ]9 x - * kind, whether express or implied; without even the implied warranty) R2 Y1 T; \& b2 Z* L$ v
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the6 V9 T* R1 w0 D5 I5 z: O% q
- * GNU General Public License for more details.
) x5 h$ n/ M7 H9 m - */
; {/ M2 b; H2 i/ c# H. F; x
& Q7 Q$ e' g2 Y+ z' J4 Z; D8 O- #include <linux/module.h>; X$ g6 o7 p; {
- #include <linux/init.h>+ M" @9 E/ }1 V' T* O
- #include <linux/errno.h>
! p* A/ t9 _. F2 R - #include <linux/types.h>7 P$ w0 Y8 F2 ^6 y6 f
- #include <linux/interrupt.h>
. Q: K: H1 L6 B* q - #include <asm/io.h>5 V0 o; J% T, E0 B* g* q
- #include <linux/moduleparam.h>
3 u( i; Z% a! ^+ K! e - #include <linux/sysctl.h>
! ~) }) k) _" `3 O) E' i; j( r8 t - #include <linux/mm.h>
8 k+ y& {" x- R8 s! X' b - #include <linux/dma-mapping.h>
$ j \; F Q4 c3 w3 i% N. V
4 d9 W! Q/ F n9 S8 ]) U( H- #include <mach/memory.h>
, f. i* S- L, l: e" [ - #include <mach/hardware.h>
# H5 \/ y. @0 \# a - #include <mach/irqs.h>
7 O( I, v- n8 T" j0 h - #include <asm/hardware/edma.h>
( u- F' [* c# f C8 d7 C
/ g6 q# j2 N% o; E Q: V- #undef EDMA3_DEBUG
$ Q' J( O \9 G$ B- }$ X9 S - /*#define EDMA3_DEBUG*/
* K+ T4 @( C9 ` - + n& p/ X$ [* z! D2 a
- #ifdef EDMA3_DEBUG2 c$ B- B% t' L. _0 e$ T1 C A! ]
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)8 R& Q' @; M Z4 d0 I" w
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
4 u; S/ W* N2 [# o - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)$ @8 z9 K) }8 S c
- #else
8 y i. L( K9 m - #define DMA_PRINTK( x... )6 S) E5 k6 r- J% b% f) [
- #define DMA_FN_IN8 s7 `% @) I: A
- #define DMA_FN_OUT
$ S9 Q% [: E3 W$ e/ j - #endif
! f. g5 Y7 E; p, G7 `7 n- C
* B* U9 l% E% W% R/ C- #define MAX_DMA_TRANSFER_IN_BYTES (32768)- B. d* H3 D# u4 z2 j7 P/ h
- #define STATIC_SHIFT 39 B: \3 a8 C( u2 W8 m. s8 I" y; I
- #define TCINTEN_SHIFT 20
( T# _- I1 g( o - #define ITCINTEN_SHIFT 21; y! k9 v0 v5 f, \: U6 k
- #define TCCHEN_SHIFT 223 k t) R' n8 n4 j' w
- #define ITCCHEN_SHIFT 23# n% ]2 B! G; n" g T
9 N* h8 j# F$ u( x/ M- static volatile int irqraised1 = 0;
& Z T. g3 k' ]# e - static volatile int irqraised2 = 0;! v+ ~ g" @$ k1 n8 q2 t- j
3 T+ p* M9 A ~& r5 C$ }: C- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# N; h, P! y& S8 e
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 _# f9 d* _. ]& G$ ~7 }+ X; S
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% r" Q1 o* }! @$ c) N; O. ]& _6 x& n
+ d9 r7 C! _: N- dma_addr_t dmaphyssrc1 = 0;/ a8 v5 @. \) Z& U4 G2 L1 g
- dma_addr_t dmaphyssrc2 = 0;
; T8 C6 y3 g. ] - dma_addr_t dmaphysdest1 = 0;
& I1 W' v. A- ~& F- R/ T - dma_addr_t dmaphysdest2 = 0;
x/ N: h4 s7 L6 A2 P& ~ - $ H0 P2 e+ q9 Z. K. f
- char *dmabufsrc1 = NULL;
6 K: M; J/ r' H8 ^! @9 P' z - char *dmabufsrc2 = NULL;
# t8 R5 F8 N) t5 { - char *dmabufdest1 = NULL;* c3 ~, C0 {4 M: Z/ T! o) O
- char *dmabufdest2 = NULL;
: p, u- M" Y! Z! i0 n3 Q5 {: R
/ ]4 P- \6 D! D1 M6 p- static int acnt = 512;$ \$ b3 a4 z% r. _% x$ t$ U# d
- static int bcnt = 8;* @% C6 t6 J0 t4 v
- static int ccnt = 8;/ `% V0 \! V$ ^2 ^8 h' \
( ^4 H( w5 D% [4 g$ @- module_param(acnt, int, S_IRUGO);
" }1 W- @6 ~" b0 k9 l. o$ q - module_param(bcnt, int, S_IRUGO);
" ?4 @" O6 Z' Z. A9 ] - module_param(ccnt, int, S_IRUGO);
复制代码 9 o9 o2 ^" q. {0 T
1 o7 w# `4 d) L/ F$ u 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& a# ~( L: ^ n8 j) K1 _
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
1 N) k$ d% J% p; O% y7 _+ K8 A 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 q3 I7 I4 A6 B) a
7 m4 u* d6 ^9 Z9 M9 w
2 n& H( {4 p1 I0 l |
|