|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 Z/ v6 l, q: X' l. u- [code]EDMA sample test application
( m# [9 l* X ~4 V - /*
$ y0 Y( r7 p$ @6 ^2 l! i4 E - * edma_test.c
# n f/ X8 J: K. f5 O7 U - *2 ]* Q/ N! K$ d# C
- * brief EDMA3 Test Application
- u0 B: u0 }$ o, U7 e& `% n - *
6 K6 [/ }( S2 ?) ]5 i; x: ] - * This file contains EDMA3 Test code./ ?. {% b' {2 [
- *, t4 {# j4 A+ t
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE2 B" ?1 o: E$ Q, o( K/ S" K
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" c2 `& O3 `5 Q% w* P; N/ D ^ - * TO CHANGE.1 t2 Z% P1 v4 |4 l3 P3 U& H* {8 s
- *
' v( @, o: R6 N# t! u - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ T: ?# S5 a/ P$ `6 X
- *
2 C S1 S' F/ E$ { - * This program is free software; you can redistribute it and/or
. v2 a/ ~, t0 G1 Q - * modify it under the terms of the GNU General Public License as
, T: n# W# r" x5 S$ r3 R0 A7 | - * published by the Free Software Foundation version 2./ W+ X1 J; a# X# }' B3 ?$ U- n7 G$ J
- *
" m9 q h# E6 ^+ ^' ]5 x+ y3 y - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
1 I: u# q# z" S; G% E, a - * kind, whether express or implied; without even the implied warranty
& q$ r. A0 l# }" Q - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ C7 E1 V7 K/ ?+ t" m& P" ^' D
- * GNU General Public License for more details.& Y" D! X, F/ [; J# P- h; t+ X
- */
% ], Y, x* C3 b. x% @5 {
0 D# T( V. Q! v( K' L9 W8 S- R- #include <linux/module.h>4 J) Q) O6 `& F9 S0 c
- #include <linux/init.h>
0 w: k! J+ h: H% }, G8 @" Y6 ? - #include <linux/errno.h>
$ U6 [! T' d$ j& E - #include <linux/types.h>; D. g2 ^% d% c8 [0 {
- #include <linux/interrupt.h>3 O$ `8 d7 X: f9 ]% c) y( F2 A
- #include <asm/io.h>( a) W; }7 k# T. S
- #include <linux/moduleparam.h>
$ y- ]+ M" s8 x0 f - #include <linux/sysctl.h>
3 l3 i1 J5 ^! @4 A/ r4 C- V - #include <linux/mm.h>
) j( @) A V; S5 e - #include <linux/dma-mapping.h>
$ N5 X. r1 m ?- P( J @ - 0 u; g- T/ X# M6 f
- #include <mach/memory.h>
" ]7 D. a$ \0 m [ - #include <mach/hardware.h>
- R% N( ^( v; n! K, H1 [" f - #include <mach/irqs.h>
4 J2 y0 }: t$ c; O8 q2 Z - #include <asm/hardware/edma.h>/ |5 p& T5 K/ z
- 0 u, I2 K0 ]( ^6 }
- #undef EDMA3_DEBUG# L8 G6 e- L. a8 @
- /*#define EDMA3_DEBUG*/
9 D5 Q Z" ?) V2 k" @' m
; I8 n+ ^; L+ z- #ifdef EDMA3_DEBUG
( d3 x) C) T; l. r( m6 |* m3 [9 Y5 I - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 M3 k' U# ~) r" s - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
+ n, G, T' H, K% B: O0 g& `* L - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)- |1 Y* F) g8 I0 F" f7 \+ ]
- #else1 w0 y1 B! \' z( q
- #define DMA_PRINTK( x... )
& }; t/ m7 ` ^% I+ b0 }# x, P - #define DMA_FN_IN
% m- r3 A. i0 Q T - #define DMA_FN_OUT' I+ U/ R+ @) y! r' e3 M% Y! l3 H2 f
- #endif( m+ }2 D$ L4 m
- }1 ^' l# ^8 n# ~- #define MAX_DMA_TRANSFER_IN_BYTES (32768) C/ r6 n9 ~7 M m1 d3 ?9 {; S
- #define STATIC_SHIFT 3
9 x' K2 q; {: O* n& |7 I" O& l! L - #define TCINTEN_SHIFT 20
* M" V6 w: x9 h. N1 t - #define ITCINTEN_SHIFT 21
1 E0 D: A- o- i. [ - #define TCCHEN_SHIFT 22
& E: [& z; N$ S - #define ITCCHEN_SHIFT 23
6 Y$ W# C: L( r7 a
( R- U p+ J, ]' j; \- static volatile int irqraised1 = 0;9 R' N1 y4 Y+ V% ]4 }
- static volatile int irqraised2 = 0;
. k% @5 B6 C4 h2 R& A - ) }/ R; e$ y6 u5 g
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 @( k- Y M1 C& x! N/ e% v
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 f0 D& E1 e: e0 i( u1 u - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' F2 C r5 r+ w$ K+ U# s+ {" y# J5 x
S$ }. D9 v0 ]" M2 [- dma_addr_t dmaphyssrc1 = 0;5 }, r- Q7 J' ~4 ~. v8 S
- dma_addr_t dmaphyssrc2 = 0;
6 [, I2 g2 n1 U - dma_addr_t dmaphysdest1 = 0;
2 Z# @4 Y2 G& ~' Y6 u; b) a3 c& x - dma_addr_t dmaphysdest2 = 0;1 N" j' E4 R; w7 _9 }2 f. {
+ O0 f1 y% V* F9 C2 V0 k' _- char *dmabufsrc1 = NULL;& O: O S- N0 }3 }
- char *dmabufsrc2 = NULL;
C9 j8 f5 h g8 K0 a) w) K( \ - char *dmabufdest1 = NULL;
V) }* f- Q6 c/ s - char *dmabufdest2 = NULL;, y% b% M8 F: p# @) w3 H5 v" Q
4 `( }7 Q' d$ {5 R# w$ b- static int acnt = 512;
5 v4 q+ L" g% X9 H' {6 q, F7 | - static int bcnt = 8;. N f: a5 O% t9 X7 x4 E( D" D# {
- static int ccnt = 8;
. M$ x; b2 X3 J& m+ m. s# [
3 C/ P. O. a0 ~: K7 [1 R3 B- module_param(acnt, int, S_IRUGO);
1 E G6 O* W6 G - module_param(bcnt, int, S_IRUGO);
, _/ Z5 D& H! u$ f% { - module_param(ccnt, int, S_IRUGO);
复制代码
' T/ X, a: [% T. m( j. {1 N
; C. W; a& w# R' {0 r; r 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
( u# N/ l2 |6 k' Marm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
( A( M* y1 y' D W 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
. K7 A5 q$ i7 Y, ^! F* P
9 u7 Y9 H0 }' l: c' n o% ^3 U8 v
, d6 j. ]' X; K- y4 L0 J% F$ I S |
|