|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 / |2 n; h8 ]7 ~3 Q' ~0 a8 b, n; V
- [code]EDMA sample test application
2 Q* w+ u: _$ k0 i - /*
+ O/ h' @$ l; O( ? - * edma_test.c! C3 W3 l$ W/ K/ Q) a5 b1 \: K; R
- *( A- B$ R6 I+ I1 s# U
- * brief EDMA3 Test Application# X |: @8 _/ l5 b5 o1 c9 F* y& [ J
- *
" p, F" P6 W) e- P - * This file contains EDMA3 Test code.
# q$ H/ }* t! a$ ~" q% V" J) _ - *
4 z+ Z( U( w" g4 D0 F$ S - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE+ L& W# ^- B( O; P
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" L+ ^% J) v( A% Z
- * TO CHANGE.; V3 e+ y# ]; W" L0 m3 n
- ** I) p+ `' r" @( s
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/% z5 @ R; }# G0 O# ^* g1 O
- *
' i0 ~6 ?2 ~: i8 a - * This program is free software; you can redistribute it and/or
& g/ h9 g! u0 G$ @( x - * modify it under the terms of the GNU General Public License as; y7 Q2 Z- d6 b; h. \1 f
- * published by the Free Software Foundation version 2.: F9 ]- M) g8 B" r4 B, F
- *
2 f8 t5 u# T& Y* f9 l6 T+ C - * This program is distributed "as is" WITHOUT ANY WARRANTY of any- ]5 O J/ B& ^
- * kind, whether express or implied; without even the implied warranty
8 ^( B' w+ r6 R% W# E6 y$ t - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the: \3 W1 U: N2 z3 m5 m. U: L
- * GNU General Public License for more details.) o' g K! C% r! ^7 R1 H; q8 w8 K
- */& a6 ]! n" @0 _0 C" e9 j0 y! C; h
- . a! C0 c# u; i$ @3 @, a7 q) Z
- #include <linux/module.h>
6 L8 W) Y! t' T s - #include <linux/init.h>
; E; _4 F7 U$ X& ^3 n$ m- R - #include <linux/errno.h>5 A8 d$ M' ~- T; v0 g
- #include <linux/types.h>! F5 z! E( B- T- V/ a2 R
- #include <linux/interrupt.h>
5 i ^3 `' m: K9 e3 ~; ]3 }* U' M - #include <asm/io.h>4 c& `4 \% a6 ?/ D7 R
- #include <linux/moduleparam.h>1 M( g3 \8 Q1 h h! P9 d
- #include <linux/sysctl.h>$ k% i4 X: f4 M4 G
- #include <linux/mm.h> K" f) _. S# f F$ h7 j1 R9 c
- #include <linux/dma-mapping.h>" _( n6 e" I& |+ T) |* X
, Q4 c8 w) ~1 Z X W* x2 h- #include <mach/memory.h>: J2 l+ h6 q9 G- N1 z
- #include <mach/hardware.h>4 l3 Y5 _* r4 u) m' v
- #include <mach/irqs.h>; V# ]( Y8 C# M# h% k7 ]- U$ y& J
- #include <asm/hardware/edma.h>
; n+ m, T1 q' n$ {8 z5 j+ b5 {7 Y
( P) L3 T+ j2 i# q0 p9 V* F- #undef EDMA3_DEBUG
9 n) L5 n! P& D1 a9 ^9 u - /*#define EDMA3_DEBUG*/1 l3 W- ]. e% w X/ q0 a2 W
) H8 D' i1 _% W2 u- #ifdef EDMA3_DEBUG. l7 V* x) |5 D! a' s% L8 D
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 F3 Y% F- O0 v2 B! B - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)) k/ n0 [8 u$ R' h: Z6 k
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
3 @+ t0 W& D; v! f' C" w - #else+ m& O9 `# d& A# i+ O9 m
- #define DMA_PRINTK( x... )
. z1 d+ D+ \, F4 x! L - #define DMA_FN_IN! F6 F+ V# V* z, a
- #define DMA_FN_OUT* J* A4 Z$ _$ I4 Q7 h* g
- #endif4 G) E* N1 \; `! q* e6 ^+ M( S6 _5 T
/ [* g% e: p4 l4 P# j- #define MAX_DMA_TRANSFER_IN_BYTES (32768); ~- O' S! q/ z* t2 W9 x+ X
- #define STATIC_SHIFT 3" I3 m) l) N+ _
- #define TCINTEN_SHIFT 20
! u8 o" g$ W( u1 t5 S - #define ITCINTEN_SHIFT 21
$ [8 S# r h2 I- ]: q - #define TCCHEN_SHIFT 223 f/ O5 O% @3 C9 b, C
- #define ITCCHEN_SHIFT 23$ v3 z) P$ u) M" y& n$ ?1 ~ d6 A
- ; f% _2 t% W0 `1 v9 ?& f
- static volatile int irqraised1 = 0;
! N1 P" B7 g: T0 a - static volatile int irqraised2 = 0;
9 u3 D; ^5 I3 y$ v - & B: ^+ `+ X# n6 i/ {
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 N( z1 v! N# O' S; g
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# X/ K3 B# ]7 x, J2 W( |0 R
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ |: l/ N3 p: X8 ~ I2 a( T; c4 ^( C
. o! ^4 a+ g& m5 V/ Z: m; [- dma_addr_t dmaphyssrc1 = 0;" }8 V3 l) q6 D3 R% X' h4 B! P
- dma_addr_t dmaphyssrc2 = 0;! M' S9 I% v! Z
- dma_addr_t dmaphysdest1 = 0;
$ ~! Q ?4 C0 P) G0 |- {, V& P! h - dma_addr_t dmaphysdest2 = 0;
9 P% y+ ^- K) X V& N
1 }& x$ q# ?0 d; a M- char *dmabufsrc1 = NULL;
: a$ w( ^+ u2 l. ] - char *dmabufsrc2 = NULL;, @0 p. v3 a; h0 i! t# j) ~
- char *dmabufdest1 = NULL;' k4 y4 H/ J! n" e- d. ]
- char *dmabufdest2 = NULL;
* y( i: j& l) K; Q - # x3 a) C# P7 E/ F
- static int acnt = 512;" j' A5 @, ?2 ?# w& {; e1 ?
- static int bcnt = 8;4 Y# q# I+ o @, i2 T' t1 `
- static int ccnt = 8;
+ e8 b+ _8 G# k5 O( ?. i8 B( F - @- k) ]9 y) W
- module_param(acnt, int, S_IRUGO);
$ U- `9 q2 [) j5 r- x4 X - module_param(bcnt, int, S_IRUGO);* E% F5 E, z+ `5 L" \& s5 ^( z
- module_param(ccnt, int, S_IRUGO);
复制代码 ( U( [5 L9 m0 e: f! ^4 u3 o i
1 ]1 X9 Q4 A" ~% L
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
3 B! {- N+ v- z7 |+ {. K$ n. Jarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
. k# g2 O* D6 _) I 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
, T" H: X9 T# Q; |% V" X
: l2 \- H7 {- s! L* }
3 o6 [8 g* N9 x2 W |
|