|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . J4 {) `5 K0 Q& }) l8 r' |& n2 E; }
- [code]EDMA sample test application7 a I+ L% r& {6 U, z, k
- /*
. F1 w' o: E y/ f - * edma_test.c* j' F2 [" K; f, G. h
- *, O2 U) I5 k3 C) \+ F2 Q
- * brief EDMA3 Test Application
, v5 d/ r2 Q& W' c - *
) N; G" ?, u3 s; d - * This file contains EDMA3 Test code.
! U. A5 R( Q# T3 q( D" l - *
/ ?5 r8 C0 m+ m" y' m% ~ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
, T- t7 O1 X; i, P/ M( ^* f - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
# M8 c8 q/ y4 q- F - * TO CHANGE.
& k- Z6 ]; [/ X7 k" {; f( g - *3 z6 C6 i9 \! o0 ]! S$ o! w
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
" l3 y& x: }! y6 r( O- v - *
: H. T6 ~' r! \9 x" W - * This program is free software; you can redistribute it and/or
+ |& ]; k2 }- @/ `6 t! v& _3 N1 V3 g - * modify it under the terms of the GNU General Public License as0 x( b4 ^- I0 S
- * published by the Free Software Foundation version 2.% t" k) m/ ]& G% w
- *
1 _' f5 V1 ~% F( g1 I4 a - * This program is distributed "as is" WITHOUT ANY WARRANTY of any- `8 Z/ g( z, d9 I
- * kind, whether express or implied; without even the implied warranty
9 n$ ]. K" Q+ I5 W$ A5 \+ x - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! k) Z3 w7 ^) H% z+ U# m. G - * GNU General Public License for more details.0 v7 Q8 Z9 H0 |
- */
7 i5 _( Q+ }+ T, S
4 Q( L ~" C9 Z e0 }9 @" _- #include <linux/module.h>3 H8 C9 g ?. t' U' p1 | U
- #include <linux/init.h>- z0 l' S/ T; X
- #include <linux/errno.h>) v/ u0 K: f3 \# b: X' i D
- #include <linux/types.h>- \9 S& O; W7 P* w4 F f
- #include <linux/interrupt.h>% ^) L# \+ ^6 j( g7 \* I. W" n2 g9 Z
- #include <asm/io.h>. m$ C6 g$ x( w+ A E! ^ Q3 [
- #include <linux/moduleparam.h>; ]; g/ L/ S% D* S
- #include <linux/sysctl.h>
" Q) l- F: |8 L - #include <linux/mm.h>: Z' _( V3 C$ O. X* Q; m; N
- #include <linux/dma-mapping.h>6 K k5 i- J% t
$ i0 V( G8 D4 x" K) C- #include <mach/memory.h>( x$ v! B7 x2 V/ e+ T
- #include <mach/hardware.h>% o& u1 k% {5 f2 N y' `, O' W
- #include <mach/irqs.h>
2 k4 f: C6 O* ?8 T6 C/ W - #include <asm/hardware/edma.h>) y7 }4 `; e$ X3 G+ R$ O# n! E7 _
( T9 L: E% B/ K% Q2 S% L1 G" d- #undef EDMA3_DEBUG
' O$ S& K5 Q& L$ w' h- X6 z - /*#define EDMA3_DEBUG*/
7 y; e2 S3 z7 U4 g/ M - , r. L3 v2 l0 B5 r
- #ifdef EDMA3_DEBUG
8 u7 d% s' m3 \' B4 q3 s5 K ~ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- c; |, k' Z- c+ \/ p - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)8 D3 w$ R" r4 b
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
7 G$ g1 ~5 W: f: N8 K K - #else/ ?, C4 \$ X0 L4 F
- #define DMA_PRINTK( x... )
& o# K. g" c/ x* p9 j% H! \# h - #define DMA_FN_IN9 e6 i8 U+ d4 @6 f: X% U
- #define DMA_FN_OUT
X$ X7 q6 E7 d; I" ~! L7 V. s - #endif* O+ ]1 @, @ X0 H; C: F
- 6 b( [3 g- @# w) ^
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ {# `( B! ~3 R: E5 `) C) I
- #define STATIC_SHIFT 3
" A; u% X8 t, `0 Q - #define TCINTEN_SHIFT 20
9 j+ C. q+ E6 d' q8 V4 A/ v ~ - #define ITCINTEN_SHIFT 213 e1 S) Z* }, ^; x3 i7 C7 g) ^
- #define TCCHEN_SHIFT 22
/ |3 I4 }; i4 e9 [. k, x" l - #define ITCCHEN_SHIFT 23
0 E1 Y! t7 r9 a( l( e - x$ w6 L i9 H9 l6 F) Z/ A
- static volatile int irqraised1 = 0;! k3 |6 W6 m- [8 B5 K! \
- static volatile int irqraised2 = 0;* [# C1 t \! b% s: f
' j2 F) I+ H. z V7 F- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: ~; Q* b0 V( n
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* }, o3 O8 G) K' P! k5 |0 E# L
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( J0 p% ?5 \- t; p) Z
- + Y8 c- L. B( k' J
- dma_addr_t dmaphyssrc1 = 0;( X* g9 O" Y. O$ K; L( ]
- dma_addr_t dmaphyssrc2 = 0;& d2 W0 y7 x' C/ B- ]# S
- dma_addr_t dmaphysdest1 = 0;
v9 a$ e% z- N) Y# S - dma_addr_t dmaphysdest2 = 0;
' x2 C- ?5 }. M& @, ?
4 U+ W: r r+ j- char *dmabufsrc1 = NULL;9 W; X C* m4 J
- char *dmabufsrc2 = NULL;' G- N3 j4 H& j2 J) N
- char *dmabufdest1 = NULL;
% C7 X# J3 W$ _- K; w9 I9 f - char *dmabufdest2 = NULL;
" y# c1 B6 T2 M( N4 _ - + o S5 R$ Z1 u4 l, M9 ?
- static int acnt = 512;- X4 F0 w j! E$ `* d; ?& Y
- static int bcnt = 8; S+ q# t: x7 A; a& z# i
- static int ccnt = 8;
, p$ ^$ [0 f, @8 A9 r, B2 {
+ ~$ U% u+ ~; Z+ Y7 x; e0 q- module_param(acnt, int, S_IRUGO);7 ]' n+ @/ v Y2 E3 C
- module_param(bcnt, int, S_IRUGO);
3 _7 L; j6 ~6 {: u( \% T. F9 p - module_param(ccnt, int, S_IRUGO);
复制代码 - B8 n: L" z: V
m3 ?3 B# t, r
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
8 R3 f$ y1 m# ^' ~1 c. P) Rarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。) K- }# d. Y: ~ c: s9 G
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。9 J$ x0 ^# o/ H' Q( `
# E3 [4 n+ |# H% }* f! L; a+ M9 K2 Q% n. ~0 E3 D& h) s
|
|