|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, P4 I6 M& A3 \+ g3 q- [code]EDMA sample test application
# U* ~4 ~& g4 ^* i - /*0 l9 @* D2 [7 m" ]- W4 e( C Y. g
- * edma_test.c
# }6 \! t2 k% C: J& [( u# M2 B+ r - *6 n5 d+ W; d8 b0 c7 b0 s: N
- * brief EDMA3 Test Application
# |% ~% a- I7 b0 s* s! s+ V - *! v/ M% A5 Z- e/ o3 I9 `8 g
- * This file contains EDMA3 Test code.0 e! Z& S0 Q; C2 H( `
- * ?: X9 m& Z( S, [7 E# M, f. b
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
1 d6 D& } z) O - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
9 b( y% f5 M" h5 E# B3 f, P - * TO CHANGE./ i9 I5 g& P D8 D) d( I
- *+ Y1 ?* T5 q7 |; D
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/$ R$ P: g \3 l! {6 s Y
- *
" G# {; d; g. d7 E - * This program is free software; you can redistribute it and/or
& ?; C) n" U# w. b - * modify it under the terms of the GNU General Public License as
, Z8 C* n& O* G# t8 [2 R8 z7 L, @' S - * published by the Free Software Foundation version 2.
5 [0 n4 q: o; v+ f0 j9 G4 T - *
. ]& `% v2 c% H - * This program is distributed "as is" WITHOUT ANY WARRANTY of any4 p0 q+ f8 K3 z& ]* C# t1 ~* N
- * kind, whether express or implied; without even the implied warranty4 y0 @9 T6 i; p0 r+ n
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* l' o X! h {0 Q* n
- * GNU General Public License for more details.2 x1 \1 f/ o+ A" b
- */
6 Q4 p% j. I3 |" U9 P( c' d3 \
) P7 y) O y! F, E( @3 f- #include <linux/module.h>1 m- K4 ~& G+ R% C: n
- #include <linux/init.h>7 F" E5 B/ y7 e( X7 K7 c: R
- #include <linux/errno.h>
% I. n9 Q% n# t/ F4 ^: H - #include <linux/types.h>
9 f$ M8 M* Z7 Z - #include <linux/interrupt.h>
; a" Q9 \ I/ K6 i - #include <asm/io.h>
7 }- F, L. R" R4 \& P - #include <linux/moduleparam.h>
) e F: F& _; c/ F U - #include <linux/sysctl.h>
* ]+ _ R3 Z r4 F8 b1 }2 F" a; [ - #include <linux/mm.h>
+ A2 L6 R2 M, N- s5 a6 b - #include <linux/dma-mapping.h>
: V D& E- o1 U! ?$ S - * t3 a% }$ F) Y5 w$ O
- #include <mach/memory.h>$ K( @! |! E4 u+ d6 b0 [! z
- #include <mach/hardware.h>
3 e; Z3 |6 ~2 S' ?3 T) j& B - #include <mach/irqs.h>
; W9 x% s" r0 L N8 j) k - #include <asm/hardware/edma.h>
0 V5 w% e" F# F
7 P" V; T" C3 d- #undef EDMA3_DEBUG7 X8 v/ ]* t0 A8 b+ A1 q
- /*#define EDMA3_DEBUG*/
+ b# x: ], z2 m* d
% t$ K! S Y+ Z. z& L. Y9 Y- #ifdef EDMA3_DEBUG
: t8 H& t) o" y% Q g - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
& Y' _- k' E0 k2 X" A' x - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__) B: R' G0 O" j. B# \* A
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)6 H- J7 K7 @) A
- #else2 E7 F& s; i, t6 d
- #define DMA_PRINTK( x... )1 N, t7 d4 k0 N( K5 n4 ]0 @: n
- #define DMA_FN_IN
# g. T9 Q" u2 V - #define DMA_FN_OUT
1 t) w+ _0 X0 J6 J2 a9 a - #endif- V& q" R1 i' V" y
- % X4 P) ?0 \; r, T/ P: U4 m
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)' j5 Q# f4 [) t
- #define STATIC_SHIFT 3
1 b& q8 G" D8 H/ N0 ^$ c6 ^ - #define TCINTEN_SHIFT 20" y2 ]9 P+ X6 X( R0 j9 X( o
- #define ITCINTEN_SHIFT 21
+ Q% S0 Y% ^! K - #define TCCHEN_SHIFT 22
, n* y+ N4 K3 B4 t6 O5 i0 N - #define ITCCHEN_SHIFT 23
( u* \! i. {; H! g# H - 2 B" Y; B: s6 N
- static volatile int irqraised1 = 0;! i& q& j3 k7 P2 O# `& ]' ~
- static volatile int irqraised2 = 0;
% ?; ~8 y7 I+ T& y3 n6 q# I
, q/ r3 P; S, L7 \: O2 |8 h- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! `% k& R) X7 x# ` \' O1 D; N5 ] - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" [5 n" a4 f- `6 F
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* B5 H8 o( y3 u' T
* {5 t3 L! p1 |/ S% ^- dma_addr_t dmaphyssrc1 = 0;+ B$ O& D: U! g& g: r/ r( M$ k% m
- dma_addr_t dmaphyssrc2 = 0;. {# @* ~5 ?% ?1 m, `1 x
- dma_addr_t dmaphysdest1 = 0;
* k, F7 o/ ~/ u- @" h7 L/ @0 D - dma_addr_t dmaphysdest2 = 0; K& A A: S8 R, u- g
6 l E: W f; i- S( o4 F- char *dmabufsrc1 = NULL;
% A- P4 v/ p) N+ N - char *dmabufsrc2 = NULL;
* q% N7 \% K. W) n* ] - char *dmabufdest1 = NULL;( }3 J- I8 x8 ~
- char *dmabufdest2 = NULL;
f; u7 q& u1 F. ? d - 9 f5 C' b! [' r$ |. v0 |
- static int acnt = 512;
; s* G$ w! E! F) l& r* m1 |/ Q - static int bcnt = 8;6 y" X& {' Z& V( N; `5 J# y$ f
- static int ccnt = 8;
# Q o$ b# K' D' j7 J' [
3 W2 S; N+ T' x x: ^. W- module_param(acnt, int, S_IRUGO);
+ k7 i/ q9 O f- k0 A2 S$ B - module_param(bcnt, int, S_IRUGO);
3 ?" Y; E$ A7 g. s o" e0 b - module_param(ccnt, int, S_IRUGO);
复制代码
6 l6 @6 r9 s; D1 p8 B! y2 Q
$ S. h# b/ j1 f+ z 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用8 A, C- s7 R8 k/ T+ \; Q* G6 J
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
; V9 N8 r9 V' s m8 B# ]: ~ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。( u9 Q! Y7 }7 l. f
! @2 C2 W+ j. o3 b4 ~
2 g' E. j. R( y7 B; E* ^4 }1 O& j0 w |
|