|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 B, Z* `: ^8 Q: u3 D8 s x+ {- [code]EDMA sample test application
) y& v2 f9 \6 j - /*8 w3 t4 L! n2 ]( ]; p% u, [+ f
- * edma_test.c
( S$ [' a$ z" `. I$ ` - *$ N/ Q# {9 I3 i7 g" h
- * brief EDMA3 Test Application
& `0 \, J# t; P6 b - *
7 Y$ _ @% I$ v, c3 H - * This file contains EDMA3 Test code.
* ^7 ~: d4 J7 N" m2 o3 o3 D - *
+ k% d( @2 u9 l. s8 j( t7 L - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE c3 {' _4 H) a3 v1 k
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT ~7 g' J4 f, M" I+ l- _4 e) ]
- * TO CHANGE.4 A$ s3 }, O3 g5 p
- *
7 b3 H- P) `$ r) E( v7 j2 k - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* z4 _7 s: {* H) Q+ U- z# ^8 i - *
* Q8 \! `7 f3 b7 A$ x2 b/ M( e - * This program is free software; you can redistribute it and/or; F9 A$ v1 A& d4 v+ t
- * modify it under the terms of the GNU General Public License as2 B8 k1 T9 A1 X) E$ Y* u1 M6 O
- * published by the Free Software Foundation version 2.
6 G6 [& H. d" d4 h% L A - *
3 a4 y* e9 q( M4 O9 d) i7 Y9 B - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
/ g' d+ R- g3 Z1 S! q8 a! h/ N/ R - * kind, whether express or implied; without even the implied warranty5 p/ ? n+ C4 n
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
E% w* i7 B( ?3 H' i ]! V - * GNU General Public License for more details.
- [5 H5 i, E& X# R - */
! r& J- e) @* S3 e4 G) S& s - ' C5 T i" \! q; m+ B: h$ j, E/ h8 W
- #include <linux/module.h>
0 u5 {8 a9 v. a" t, l2 r( I - #include <linux/init.h>5 c/ m9 j! y! R @" O" O7 c& |
- #include <linux/errno.h>
7 P# C" n+ _) Q4 _# U2 n - #include <linux/types.h>
7 \0 J+ j+ f4 q& D9 U - #include <linux/interrupt.h>
+ C1 T2 m( e9 A( @. h - #include <asm/io.h>; i# B. U3 _% _- S! M, y4 B
- #include <linux/moduleparam.h>
* W: r" Q7 H ]; H - #include <linux/sysctl.h>: j: `' E3 ?4 b4 r" c: c& d7 m# I
- #include <linux/mm.h>3 z3 Y/ ^, }, U0 t$ \# Y) b, z1 ]
- #include <linux/dma-mapping.h>
& S# ~1 B3 _/ `
! L+ k$ t. E* G# D2 O3 h- #include <mach/memory.h>: F$ q# V2 v) y
- #include <mach/hardware.h>9 l# {/ e3 ]7 X
- #include <mach/irqs.h>
, B' O- e+ O; X. y) [+ p# V6 ~ W9 V - #include <asm/hardware/edma.h>0 w" {- D7 f/ Q) `$ J. V$ w
- ) \+ R. M( a: u0 t( E$ p
- #undef EDMA3_DEBUG7 Z, D4 w7 u: M5 ]9 [& O
- /*#define EDMA3_DEBUG*/7 H# J/ o3 o0 }. P- x( V
- 0 }. `, _# @# p: r* h; `
- #ifdef EDMA3_DEBUG
9 C9 [* ~6 N% N3 O9 l - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)0 B- \; ~: n* b2 P3 S' m! [
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)/ _+ s7 G2 a* I. T+ q
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)$ B/ y# W& A& T: V% K6 s
- #else
1 s7 Q' g8 E4 _ C z& V0 v# ? - #define DMA_PRINTK( x... )0 a7 n" i& `, |' }
- #define DMA_FN_IN
9 j; L2 r2 o5 y1 L1 a$ H4 M - #define DMA_FN_OUT
8 G2 h, C U' C: k0 [8 w! w - #endif% f: M6 X4 L2 W' ^( d
2 V1 i# g2 r2 b, x- #define MAX_DMA_TRANSFER_IN_BYTES (32768)3 L2 z) l" `0 b8 n2 M; M8 t
- #define STATIC_SHIFT 36 j% }$ A) l5 i
- #define TCINTEN_SHIFT 20
8 d3 q v( t* t( F - #define ITCINTEN_SHIFT 21
( i. E, J( e9 O, U Q8 U! o - #define TCCHEN_SHIFT 22( m/ x7 E1 E2 N
- #define ITCCHEN_SHIFT 23
- A, F% X$ y. g - 6 ~$ ?* U+ Z4 Y; y; t4 C
- static volatile int irqraised1 = 0;. X8 _0 d3 M+ X ?5 u3 @
- static volatile int irqraised2 = 0;1 y# D1 v2 w0 V
- I: P$ E5 J! l) M' N) }! P% ]
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! J- o; K6 V2 J9 ^
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# ]0 f+ y3 {. B& h7 _- z$ n
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ S+ D O# n+ T! _8 x7 x - # L% ?5 O5 h% `$ V/ C9 Y8 S4 P
- dma_addr_t dmaphyssrc1 = 0;
$ q$ ^ y: f; p - dma_addr_t dmaphyssrc2 = 0;) t# A' W& I# d) M# D* S- c3 ^
- dma_addr_t dmaphysdest1 = 0;/ J6 F8 u% R4 G7 g
- dma_addr_t dmaphysdest2 = 0;, ]$ @, Y1 b0 i% g
- 4 m. ? J# n- k2 J/ K
- char *dmabufsrc1 = NULL;1 X9 H. R7 C/ D2 E. Y' y( _
- char *dmabufsrc2 = NULL;
5 p5 L, v" x5 ]" M( U0 ? - char *dmabufdest1 = NULL;
B, v9 ~' F# k6 D - char *dmabufdest2 = NULL;! Y$ ]0 c5 K6 j/ h$ Q$ C
1 Z- D0 D+ v. p" L( e+ V- C- static int acnt = 512;, t% l, j$ E' |: g5 S
- static int bcnt = 8;
& k, D% F( V8 G# H0 F - static int ccnt = 8;
9 n) G% {- k% l/ h @/ w
/ b( l' F- z- b- module_param(acnt, int, S_IRUGO);- `/ W' d0 g8 X3 v7 G' I5 g# e6 p8 F
- module_param(bcnt, int, S_IRUGO);) w J B8 b* P; y% `
- module_param(ccnt, int, S_IRUGO);
复制代码 . }) j* g7 E# c! b0 Z5 t
. m/ E4 D& U* U" {7 [8 x 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用 s6 M3 u5 w/ g
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。3 [: L( b. `1 u2 ]2 m% A( ]
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ j7 d: y, \3 n& _. L
% P b {. F9 R; k+ @8 K4 z7 B7 T$ u, M( O1 t( w
|
|