|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 # f W1 Q4 \6 c% Z2 T0 @1 I( ^
- [code]EDMA sample test application
& y; G x6 e |2 g" X - /*( q g% L d9 F5 v5 G
- * edma_test.c
- W/ N8 L3 O; \& M - *
, p+ A$ A9 V0 J* y+ t - * brief EDMA3 Test Application' q/ b7 P9 U D1 C% T: Z
- *
& [) k+ M7 M( I# `4 J5 d - * This file contains EDMA3 Test code.& @) j0 G! R3 M$ N' O
- *4 M" G9 U0 d2 |) U
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% b, X5 y( E# L( d9 A @ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
) j, b3 ~3 Q7 }/ ?1 l - * TO CHANGE.
/ k2 p& w4 L. m+ p) @; Z - *
; p* B! u ^# A4 T+ |! v/ v - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
) O: h: y P" N1 |9 P0 Y - *& e! G- d+ a7 z
- * This program is free software; you can redistribute it and/or; F, L& ^! s: m9 Z
- * modify it under the terms of the GNU General Public License as4 H" t% [/ w0 R
- * published by the Free Software Foundation version 2.
, y. r% s( D+ q" u; b8 }1 I - *
$ k2 E. ^5 ^' K0 E1 j7 u6 i5 W - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
8 l1 J/ S7 U9 _& u - * kind, whether express or implied; without even the implied warranty8 {! _% N' r1 G( g6 L
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the& M, {* R5 |. V$ Z6 @
- * GNU General Public License for more details.* ]: [( P2 X1 n V2 l
- */# t9 S: O6 s9 v7 ?' Q# O
- # L7 r* `6 E- \, G9 T$ \+ G
- #include <linux/module.h>6 p' j2 e! p: u. O) d( C$ [
- #include <linux/init.h>
8 \5 k% f) J/ S3 H \2 w0 z - #include <linux/errno.h>$ O+ F u e% ~: @
- #include <linux/types.h>
% [# K0 d! c, h. W - #include <linux/interrupt.h>9 q* g2 m9 X$ ^. B# l
- #include <asm/io.h>; K6 J+ d1 ~& t# x4 M3 {6 ~
- #include <linux/moduleparam.h># h, z' g' {# k# E
- #include <linux/sysctl.h>
/ z$ T- {8 y7 j) \4 \6 ]; E7 P) X! E - #include <linux/mm.h>: a- l* C; M4 C C* d
- #include <linux/dma-mapping.h>2 X! }' R8 {1 K& F% U9 Y3 ?, t
* X: F- Z3 Q. S0 ~5 A x" h- #include <mach/memory.h>
! g0 w( J( Y% i% m' j - #include <mach/hardware.h>
8 {9 K# D# H) H7 c1 @' J9 v - #include <mach/irqs.h># G* T% ?+ Q+ A; R# I+ l Y
- #include <asm/hardware/edma.h>+ p3 t G1 p, K, J4 f( s6 W
- & {* J* o9 V4 J
- #undef EDMA3_DEBUG
$ \9 O( ]6 Q7 D; S" P: q - /*#define EDMA3_DEBUG*/6 b! i/ x+ S/ I& x; F* o7 G( B
3 C' D: A. E' I0 `- #ifdef EDMA3_DEBUG
4 T: F% c6 @. m9 G - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
4 E3 p# }3 n; @/ G; l - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)* U1 F, C: F& F- F. N
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
1 u/ \# X* @) ?( Y0 W+ p4 t - #else. ^. L* Z& [! f0 _5 R
- #define DMA_PRINTK( x... )& K* F# _1 T+ `, A# {& z: q
- #define DMA_FN_IN, J+ `9 x; u$ }: S6 L3 M
- #define DMA_FN_OUT
, u9 C4 h9 r6 R, R$ Q0 y+ J+ P2 g - #endif
V/ V' v7 O! [+ U - 8 D6 B! Z$ G6 N6 ?
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)4 l+ u4 C2 m6 H5 N1 ^) R
- #define STATIC_SHIFT 3" e8 ^' e' ~, k2 b9 I
- #define TCINTEN_SHIFT 20
. b8 t. a' U6 l# ?' Z2 N4 v - #define ITCINTEN_SHIFT 21
# M7 Y' d7 o ~$ b! x - #define TCCHEN_SHIFT 221 _1 w9 k- |; k& M) i6 N
- #define ITCCHEN_SHIFT 23" Y. c. E- F; _2 E
: I1 T) b* m+ `: }; T- static volatile int irqraised1 = 0;
+ @% W3 t8 b) [3 {: C - static volatile int irqraised2 = 0;
8 i, M" h' ?) ^% y: l, d" s7 A - , I; p0 s% _! c/ N; S
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 Z8 J( m3 `$ J: k - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 _( S! \- Y3 x3 y6 m - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 M* o% q. i. u1 s
, p, _0 d& B0 F3 _0 w& J6 S- dma_addr_t dmaphyssrc1 = 0;2 q- }9 u4 M0 z
- dma_addr_t dmaphyssrc2 = 0;
' }6 s5 U: o1 _2 |2 t+ X3 v# r - dma_addr_t dmaphysdest1 = 0;1 t6 _- }* `4 D6 N! y0 G5 W6 b
- dma_addr_t dmaphysdest2 = 0;
6 M1 a5 G, j y% Q8 G
! `' p0 b; R7 M/ f- char *dmabufsrc1 = NULL; ?: w7 P& e4 R6 w
- char *dmabufsrc2 = NULL;" H: Q8 N' ^7 u; d
- char *dmabufdest1 = NULL;# C, p+ y7 q& U& R0 r, t; h
- char *dmabufdest2 = NULL;
/ @! I, {2 F6 C4 Y7 u
" f { o2 C! \. J6 R- static int acnt = 512;4 ]0 q) S4 E& ?% [
- static int bcnt = 8;
; e( |8 w& f2 o, F* K* I - static int ccnt = 8;
. ~/ G: s5 i p, B' K4 t6 j2 q
) P! M: I& x& o5 P! j- module_param(acnt, int, S_IRUGO);. R0 m: K9 o9 w7 q1 v
- module_param(bcnt, int, S_IRUGO);# m9 S+ X: l8 H0 I- c# m
- module_param(ccnt, int, S_IRUGO);
复制代码 + S {$ T: Y& A
W- o( A2 ~: c$ W4 s ]% P- b* v9 j8 e 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ R1 g! K4 k& A. ~( Darm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
" G9 _7 q" K3 E, l4 ?0 [1 [' N 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
) w X% v: B; }% }7 ~+ c# _. g8 ~9 }1 i) \6 O) j
5 }. N4 r- j- ]% p |
|