|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 i7 [1 U1 S( N8 W$ K; Q- [code]EDMA sample test application( F0 G v& ?9 m b* e! ^6 O- v! J
- /*; O6 X' G7 M. J% v' [0 J. z4 R+ X# T
- * edma_test.c
a- t4 d1 f9 i* e' {) e1 ]% o - *
' ^- J- Y4 P+ I5 _) M* Q, H - * brief EDMA3 Test Application
# [5 @# Y( h. z% n% Q. A - *5 F" X: j% x, Z% ^0 V0 J# G
- * This file contains EDMA3 Test code.
$ F8 K7 y2 I$ i: N5 j! h - *
0 d/ U( K+ F9 { - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
" O+ [- @6 |1 R& k5 _& } - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 d% C( W* ^% i7 @) M: `2 W2 U* G - * TO CHANGE.* X0 i- r B* E- U
- *
6 w3 {) e- g* q Y( G, [" C - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 T) l8 u* c, ]1 y/ w, Z6 z - *. c. \3 c+ Q9 G7 {
- * This program is free software; you can redistribute it and/or2 r( g4 z! H# X
- * modify it under the terms of the GNU General Public License as3 E5 O6 c9 \; j
- * published by the Free Software Foundation version 2.1 b; [* Q# }9 f6 T) e; x
- *
6 A/ J, a6 Q( \4 t2 t0 W5 M' S& ` - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
) e, M `6 }) s2 o - * kind, whether express or implied; without even the implied warranty* ^3 w+ @( a; {
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 P% `$ J: l q/ ` z# V1 ]
- * GNU General Public License for more details.
; {* c* v7 V& ~7 d: M' a# C6 ^ - */( O, `. A# M# _3 r
4 ^( b- b8 i3 f* u* ^1 N" V& O# U- #include <linux/module.h>: ?- E; c1 b4 `+ f7 {8 w6 o
- #include <linux/init.h>
% `* B' p6 r9 |/ S- O! l" m - #include <linux/errno.h>
W% ?0 R1 W' A$ F" r% O - #include <linux/types.h>8 I8 j& x5 g Z9 N% R3 P
- #include <linux/interrupt.h>
! @) c v1 S* K5 ~- \; m - #include <asm/io.h>
# _& S, Z8 l7 N - #include <linux/moduleparam.h>
, l! z2 A* s1 ?1 L S3 U0 |+ D! H - #include <linux/sysctl.h>
3 }/ d+ S& `' m& f: V4 x - #include <linux/mm.h>! `2 X- e; Q- R! {: _1 l
- #include <linux/dma-mapping.h>7 U% r/ C7 ~! G% A+ ^7 ?7 I" K
- 5 n9 z7 p, g( Q5 _* Y* h
- #include <mach/memory.h>: L9 `9 E# N7 E2 x- l& T% J1 Z
- #include <mach/hardware.h>
7 v" ~+ D0 Z# Q _, d - #include <mach/irqs.h>/ c4 A0 T/ h3 n
- #include <asm/hardware/edma.h>
& D4 _) F4 ~! B& y: F! e) \ - 4 B( J9 K. |6 e0 R% m& `+ y
- #undef EDMA3_DEBUG
0 O! o; _7 Y1 t4 `5 a3 E: q. O - /*#define EDMA3_DEBUG*/ m: o! n/ g8 X1 H, T! P+ i" r
- ' [3 _4 y7 ]& f3 W- l7 r
- #ifdef EDMA3_DEBUG
+ w v: [6 [0 P$ q, n) ]0 E. N - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
. y- R- C2 N- g - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)' d+ G* }7 S. [: F# {0 H
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)0 P2 @ Y. k. Y9 E
- #else% a. a2 q" i% _% l; H1 Y$ C! ?. u: @# Z
- #define DMA_PRINTK( x... )
# X3 Q7 h: f/ V O* s$ c - #define DMA_FN_IN! J0 S+ I" n: T# Z, ~9 N
- #define DMA_FN_OUT" }" A! c9 H: m4 g
- #endif
, W" k- ?# ]) r2 N4 P! q0 r - 7 l3 i8 B+ c. f0 c
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ q% P+ k+ o. m - #define STATIC_SHIFT 3" \; L7 ?2 d. _6 H2 N
- #define TCINTEN_SHIFT 20+ g3 Y/ b6 F& m( V( D3 t# j7 u
- #define ITCINTEN_SHIFT 217 q4 S. M2 c* i' b4 s: s5 ]9 a
- #define TCCHEN_SHIFT 22
: G7 e4 g1 R1 V' M5 z! V" J/ k - #define ITCCHEN_SHIFT 23
?5 P7 s% n3 i+ |: u
, b% e5 X! N6 P: D4 ]- static volatile int irqraised1 = 0;/ F/ i5 e, D# _# A+ a! |
- static volatile int irqraised2 = 0;: t& F( {" n/ F. ?9 |) b/ h+ ?
# n b' l3 q5 K" k( `% `: H- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" y# _( j4 c7 ~; `, r - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( }9 }2 f6 t1 r' r9 [' G B$ s - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: E' o. ?( v$ @1 q( ]' T - 3 c% r& }% z' c9 Y( z7 w4 J$ [
- dma_addr_t dmaphyssrc1 = 0;
# ]6 v+ c _+ }* h. o - dma_addr_t dmaphyssrc2 = 0;
- d6 Z0 s7 l$ {$ { - dma_addr_t dmaphysdest1 = 0;
7 V0 Y- z U6 D7 S - dma_addr_t dmaphysdest2 = 0;- c7 P' L2 d6 C. Z% U
- 2 c. L/ v1 W' ^9 l+ s
- char *dmabufsrc1 = NULL;2 R; N7 v- M n. v& B! F* N
- char *dmabufsrc2 = NULL;
: W9 S% \5 r9 t7 ^- P - char *dmabufdest1 = NULL;
, c4 c5 f) A* r$ {$ t4 _5 d$ l - char *dmabufdest2 = NULL;: y; W/ ~: l$ _& M+ a
- " i3 d$ G( x1 l6 N
- static int acnt = 512;
; ^4 E: d2 Q N! E( ` - static int bcnt = 8;: G0 L H- d/ A! L6 D' S
- static int ccnt = 8;8 R0 Z! y# K6 J3 `
- ; u; p7 W9 E% H, r( j
- module_param(acnt, int, S_IRUGO);. B& z6 T" _' V" u! ^
- module_param(bcnt, int, S_IRUGO);
6 u1 T$ p- D! S+ b7 e0 H$ g* `2 ? - module_param(ccnt, int, S_IRUGO);
复制代码 4 q6 \! z1 d! \2 J1 C9 G
; {7 I7 u2 _' W- G/ D
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用; b4 H0 K4 k3 N3 [3 z8 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。0 P W$ A! ^. @4 V& z
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
6 g' a$ R* f! H
$ k; j7 U% T- ]) Q9 o/ G" N$ x7 e8 b7 p
|
|