|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
" r: p0 _; z" Q: k2 F( j y- [code]EDMA sample test application
# i' ?0 o, U* ^5 Y0 a, D - /*
7 P' w# @( V- W) X# { - * edma_test.c; S1 H* c! {$ H3 ~$ s: l
- *6 g; i X, |) S9 T( K7 U) }
- * brief EDMA3 Test Application Y) m. |# X& X T c% a. ~# F" l
- *
7 I3 x# h, I5 z& S3 B% L3 E' x4 t8 ] - * This file contains EDMA3 Test code.
$ \9 d a) |8 [4 g" J2 Z - *) @% ?+ @! ]1 e7 r% h
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE5 G, t0 i9 K4 _* P
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
: O3 x t3 e2 f2 R" s - * TO CHANGE.( P& c: N0 E! p& _- l: U: T# j5 s* L
- *9 i i+ I, m; A! {! u7 v
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# z5 J$ b# m* N
- *, }6 @5 V# ]8 h1 p. I
- * This program is free software; you can redistribute it and/or
7 E# o6 [ ~2 \% a) {$ w - * modify it under the terms of the GNU General Public License as
# d6 c5 m0 l6 c, @2 j' x1 h& l - * published by the Free Software Foundation version 2.
2 F4 C( ?* b! a) I - *
/ U; V0 k7 O/ i5 W* D e: L) h - * This program is distributed "as is" WITHOUT ANY WARRANTY of any( V) H' p n1 J1 M
- * kind, whether express or implied; without even the implied warranty' j- A- s0 M9 E' {# z
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the7 V9 G( c5 `) [0 }
- * GNU General Public License for more details.8 G c) A c1 R
- */
. E' F- t" m" y( i2 o8 X7 w - 2 i- m7 C0 [ {# M# L
- #include <linux/module.h>8 L, J7 c, \ C8 U3 U+ }
- #include <linux/init.h>
% T/ k6 [& D/ @ W - #include <linux/errno.h>6 a2 S: k+ ^6 E( P+ \/ R- z' y
- #include <linux/types.h>
6 V# ]6 @" r3 u4 g8 B0 n( ~ - #include <linux/interrupt.h>
4 f- [6 M$ f4 F% y - #include <asm/io.h>; d9 A- R7 m4 A% e3 z6 R" V" B8 O
- #include <linux/moduleparam.h># r* P. w2 T" k9 e% Y
- #include <linux/sysctl.h>
2 n4 f. H8 i1 B* o9 M - #include <linux/mm.h>/ Y* z; u/ B7 G U
- #include <linux/dma-mapping.h>1 F- v5 ^2 l; E0 @7 S3 D \
- ' k4 h7 y5 \. d! p' o$ Z B! [7 D
- #include <mach/memory.h>
, T1 F+ j/ z& H5 y3 V9 p( ? - #include <mach/hardware.h>
. e- g/ p3 k( b$ \; _4 ~" \, w8 S( F - #include <mach/irqs.h>
& K8 R" D* A' ^8 ]) t6 X$ Z - #include <asm/hardware/edma.h>
7 q& c& {0 ], T' x- R
/ ?2 z6 R$ o% \3 \- #undef EDMA3_DEBUG
1 y! O. o) L3 x$ y1 U' z4 `" J2 K9 Y9 ^ - /*#define EDMA3_DEBUG*/
( C( ?1 `" p0 C/ C6 c
$ p' V9 V1 A4 M8 Z; R3 i! X- #ifdef EDMA3_DEBUG( b$ |8 t+ ?7 t% X4 E
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)% v* U1 u5 j: D2 [! _
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
# r, n: D5 _$ e - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 b6 W6 ^$ S' l: V" h2 ?/ t4 |
- #else2 r& ~% A5 [8 Q& p; e! i
- #define DMA_PRINTK( x... )
1 `# D- T$ N# D - #define DMA_FN_IN
- Q2 F0 }* S( O( z - #define DMA_FN_OUT
3 w/ s0 e9 Q4 O2 n8 Y2 i - #endif3 z6 D8 } }: f5 r- Y
6 r8 s) |0 [# W4 p5 B# }+ L- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ X1 J- E) S# m: D- v* Q- b
- #define STATIC_SHIFT 3: P8 Q( E, ]. m) k4 x5 d
- #define TCINTEN_SHIFT 20
4 l" m- I% d: e# ~5 } - #define ITCINTEN_SHIFT 21
& w+ e' w: m1 c, W - #define TCCHEN_SHIFT 22; O# p1 j: U* c: Q" a* _3 Y% |
- #define ITCCHEN_SHIFT 23
( t% ~- ^ Y- k Q8 O - & Q# m6 P' ?2 R. @. s
- static volatile int irqraised1 = 0;1 ?8 j! P4 o9 s( Z/ j& A
- static volatile int irqraised2 = 0;
7 M. h; N( a7 R& C; L# m
' {. ~6 K c+ [' S9 x* q- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: ]: Z) @- q( ]$ ~5 g: q' g% j- B( Q
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% h3 v. V, i! T+ |, r t& d* Z' U
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); Y7 v8 l- N: E& \
K- a6 u3 e' Q s6 i7 s L- dma_addr_t dmaphyssrc1 = 0;
5 R# W3 S( D3 C8 o" e1 A - dma_addr_t dmaphyssrc2 = 0;& O3 {% Y B G
- dma_addr_t dmaphysdest1 = 0;
& q2 g: ^+ D, A. t7 p - dma_addr_t dmaphysdest2 = 0;8 w& p" Q1 K3 X8 M& n" [
/ }! ~* e# H. z4 ]6 j- char *dmabufsrc1 = NULL;9 x4 ~2 \! a5 n) T4 H$ F
- char *dmabufsrc2 = NULL;
9 i3 g h2 H! ]9 f* P8 F8 A; @! ~ - char *dmabufdest1 = NULL;
8 u0 X. q! n9 x2 R3 q* C - char *dmabufdest2 = NULL;
/ `7 t! x8 x# k5 t, ^0 S
0 W4 u7 b- X2 a3 r- static int acnt = 512;( P# r5 _; V3 o" @9 ], B
- static int bcnt = 8;
! N, }6 Z5 c; _8 S0 r- A( R5 x - static int ccnt = 8;# ^ c9 J l. d! Y
* g' |; X6 c" i& |9 Y# V/ B- module_param(acnt, int, S_IRUGO);
) r5 m7 t) I" `) w8 ]; g0 R - module_param(bcnt, int, S_IRUGO);9 C+ Z9 d9 A* o/ k1 y6 x3 s
- module_param(ccnt, int, S_IRUGO);
复制代码
" b- l9 b* @; h" k- g' W8 m
; F) Y3 l) @& k# m* Z( r 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
+ \& M7 @/ L! u- C- w% oarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。. f$ u! \9 A' T4 n' n& z
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 ]. ?( @. p2 `4 t
. H5 s' I7 Q2 a, n$ h
' `; t" u0 L5 a; L7 o( E
|
|