|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% D* [5 m8 {& ^9 R; j- [code]EDMA sample test application
& O; o) n% I+ d3 T5 I - /*. y3 o7 _. ` P# z- E6 _5 O
- * edma_test.c
' h# M1 Q4 P9 z2 i - *' I" z9 s4 t6 `/ t: ? l9 [. c; F! d3 I
- * brief EDMA3 Test Application7 l. O& j: `$ p; B: e
- *
9 v+ [0 V7 j; E* ?9 w: E0 J! } - * This file contains EDMA3 Test code.
( I h) S" c& ^ - *
- r, |# X) S' K - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
9 N8 ?% m* o+ j. X6 p8 N& V; d; x4 f - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
8 h2 K7 X0 x. ?9 C9 |# C - * TO CHANGE.
T" D; r% ]+ D, q2 Y" D: g2 c1 o - *
. H. q/ o4 b! c+ e* f# e1 T2 z2 ^ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/6 R1 v" W& y6 Q( L& V, i
- *5 Y' f: s& p d+ Q
- * This program is free software; you can redistribute it and/or
) X1 a! l2 s! }5 t - * modify it under the terms of the GNU General Public License as" L- Z# P2 K; v" N) c& c) N
- * published by the Free Software Foundation version 2.3 Q3 I9 A: |6 ~2 u
- *' L1 R9 d" R8 d( O- l/ m. V0 Z
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any: e6 G* O, E p2 g8 ]
- * kind, whether express or implied; without even the implied warranty g4 n) _' v; ^) Z `+ R3 K
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
( v0 K! j% }) i5 ~$ r+ D" D - * GNU General Public License for more details.
- v$ b( ~4 X$ m9 u7 J - */
& s E# ~ \8 q& ^5 r% T% J7 b( P
! H1 z1 u, i; ]% F1 t- #include <linux/module.h>
! S( K: w2 N6 r/ A8 G/ v9 C2 ~ - #include <linux/init.h>8 L+ R+ r x4 y9 V, E
- #include <linux/errno.h>
4 M( K7 |; z. T6 Y0 h6 W, _ - #include <linux/types.h>0 g3 R) w# t3 R& |9 [8 s
- #include <linux/interrupt.h>9 ^) W6 t, [7 b
- #include <asm/io.h>1 c3 g- t0 Z4 R. x7 O$ g
- #include <linux/moduleparam.h>
* {! K8 K/ |$ B- N4 g3 B- n- E - #include <linux/sysctl.h>+ g4 `+ U( i0 _$ D; t/ j
- #include <linux/mm.h>9 v& S8 ] R( j: c! Z
- #include <linux/dma-mapping.h>
3 c/ D% a$ e9 G2 R' t3 d2 c/ \/ o - * c! i% {. U: p
- #include <mach/memory.h>
, p6 a2 R' x: q& k" \+ }! r W0 y" I# R9 A - #include <mach/hardware.h>( C% |' {7 T$ i. [
- #include <mach/irqs.h>0 K# U- }; I& N: ` s! H
- #include <asm/hardware/edma.h>% y8 W" ?. x0 O5 p, u8 F( I9 z3 u( C
* [% t$ @1 \# a/ g$ l! E- #undef EDMA3_DEBUG- O3 M+ S, v$ D! P5 Y
- /*#define EDMA3_DEBUG*/& L8 A# S' v) K3 o; H# o
- : ?2 o* W5 }8 m B1 p9 X
- #ifdef EDMA3_DEBUG
, R3 I( S, i( b2 ]& X - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)' R4 q+ Y0 z' N" C
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)- Q( q; n0 r: m/ X/ \% `. t
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
' s/ ~$ d4 X7 g0 |) C - #else K3 a) P8 @* B% x+ o: Q
- #define DMA_PRINTK( x... )" V4 n. z; d" G q5 P
- #define DMA_FN_IN
' V2 [! V) f7 G; m& h4 f/ A) Q - #define DMA_FN_OUT
- }) T; D( E& E; E - #endif5 r9 E9 g& T, o( d
- # k. M6 Z3 Z9 v+ J! K
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; j" R: j1 ^2 {" S - #define STATIC_SHIFT 3
5 Q2 j( L, A) }. Q& u7 o$ i - #define TCINTEN_SHIFT 202 e/ Q, p- K' ~& f& J
- #define ITCINTEN_SHIFT 21
. D8 e- b$ V! z4 b3 \: L" {/ S0 G - #define TCCHEN_SHIFT 220 i4 g2 I# l- Q/ r& F
- #define ITCCHEN_SHIFT 23
0 f$ F+ O- I* |: S( u
( n0 V2 X8 v2 f, X7 I- static volatile int irqraised1 = 0;- E) P' `; g I% W. L( n* K
- static volatile int irqraised2 = 0;% }) a, G) ^# }" u, V/ {. k
- 2 G5 C9 o" C, k$ }4 B7 H% H
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ b. d8 r' ]1 ^2 g/ y: o- M0 k
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" v4 I$ b4 S( Q+ w+ S% q - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) _: i4 r7 ^3 x& p2 ^7 C
7 V5 G- z3 X2 f6 z Q: \# j# ]9 c, V- dma_addr_t dmaphyssrc1 = 0;
0 Y( P! D$ }, O; w8 D( l$ i9 w - dma_addr_t dmaphyssrc2 = 0;
# J( {3 S; Q8 P. \: e. v: i" B - dma_addr_t dmaphysdest1 = 0;' W+ o6 G# F: z( {) e2 d2 `9 r5 T9 \5 ?
- dma_addr_t dmaphysdest2 = 0;: X3 e- ]% B: j# N9 n2 l
$ o8 N% D9 C/ g& y- char *dmabufsrc1 = NULL;
% H- x ~- P! J$ _$ c. Y - char *dmabufsrc2 = NULL;
% g& \% s6 {8 L1 i) t: N ^* ~ - char *dmabufdest1 = NULL;
' C# b! H4 ^" k. H! G# | - char *dmabufdest2 = NULL;
2 f2 n" L* O k1 `8 s; O$ N
4 P. D9 P$ w) ~0 _, G- static int acnt = 512;
9 M1 a8 J3 P1 r, L - static int bcnt = 8;' R; ^' Y% w. G) l
- static int ccnt = 8;9 t2 A* n9 `7 `5 d/ M9 g
) S! n" k9 S. a& P1 H- module_param(acnt, int, S_IRUGO);- o1 g+ H9 g z5 f" u \1 d) Y5 n
- module_param(bcnt, int, S_IRUGO);7 o& O$ F" g0 ~0 B6 |
- module_param(ccnt, int, S_IRUGO);
复制代码 8 V) u# I3 a0 C" O
' B. W6 ~. J5 M& [4 y, p" {" F
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! A- O/ f% d/ K6 U8 N- M. qarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。8 r1 k3 t2 P, r- }# u' `
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
- E3 G4 }0 R8 V( I0 _6 |
- D- ` o8 c5 [# c- _
( y% |2 v" ?' F$ g5 T, {- p |
|