|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 q+ S0 @ [( M7 n1 y- [code]EDMA sample test application
) J$ b4 W5 s0 E0 [ - /*$ h1 B) D2 w! P' o
- * edma_test.c
; G. A0 |; ?5 D - *! O: b/ @+ q5 K' Y6 j0 O
- * brief EDMA3 Test Application
! u/ D& l5 x0 q" G& r# K; n - *
) _3 ` a9 @4 [% ?1 a1 E - * This file contains EDMA3 Test code.% S: `( E2 L/ f6 \' y# R- X
- *
7 L" N" s7 H6 l% z - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE3 i3 f( c( F- H) A1 m; W& B5 ?* s6 g
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT+ W4 v! B4 z' ]/ `
- * TO CHANGE.
0 M8 E/ u! h z2 w: u - *& j- f1 W x( D9 |! [* L; ]
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! h! x1 Q; g6 q/ c8 Q
- *7 H! C* l2 O' j8 V: k0 G
- * This program is free software; you can redistribute it and/or
$ i% s: E u" f; g* E) H - * modify it under the terms of the GNU General Public License as
" p2 E( R& v2 l3 {' ]: T - * published by the Free Software Foundation version 2.
. x' Z6 I1 b: D) _ - *
) }& V% \6 z; A - * This program is distributed "as is" WITHOUT ANY WARRANTY of any4 h6 c! e+ }5 E- m) I9 B
- * kind, whether express or implied; without even the implied warranty2 A1 [- ?$ L" p+ m R: I3 z
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' @) k, \, U" A! O; |/ u2 B# p, x- L, Q - * GNU General Public License for more details.$ U# A( O7 r4 O' U# M/ ?- |
- */
9 u+ @, E4 x# A/ Z4 p4 ^: W/ r
; T8 |& R7 r8 I7 \" t7 C- #include <linux/module.h>
# Y, v9 C5 x' M* ]2 x - #include <linux/init.h>
( D7 y# q( [- \; b, N$ z$ Q - #include <linux/errno.h>
" d2 I3 Z1 P7 L! J - #include <linux/types.h>2 z+ c+ v2 x! ]/ V- {
- #include <linux/interrupt.h>. H/ E8 l' r; G6 e I
- #include <asm/io.h>2 w- Q6 h; y7 p; h
- #include <linux/moduleparam.h>6 c1 E' S u; v: W" n( k
- #include <linux/sysctl.h>
$ q0 _/ q! F8 }* d - #include <linux/mm.h>$ U" b9 E5 a$ A; g' W
- #include <linux/dma-mapping.h>' x; R- P8 |1 P3 ~4 l1 n; g& C
' `* O% j- v; S- q6 S- #include <mach/memory.h>
& X S) J9 W5 R" n& Y3 q* w9 G - #include <mach/hardware.h>
9 Q* e# v; S3 P& Q& A - #include <mach/irqs.h>
7 Z( p; {( D- [- ^6 T8 X - #include <asm/hardware/edma.h>4 w* }7 b5 ~" s9 Q
( b" ?- b, r, }* S3 A2 o$ Q- #undef EDMA3_DEBUG9 l- X$ _+ K6 Z W5 i* m
- /*#define EDMA3_DEBUG*/
+ n8 p* [/ A# X
5 y( a* Z4 n3 K$ K- #ifdef EDMA3_DEBUG
6 r6 T7 Z, }" d7 @+ H: d8 D - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)& y5 p0 ^9 {8 z- y9 G% x U
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). M" {2 b3 Z" H& X5 G, \
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
7 H+ L9 P, |! k6 \7 H - #else2 W2 R! v9 P4 C& e0 A
- #define DMA_PRINTK( x... )4 U6 Z7 q/ M, P% N. s8 o* v5 V. \# B
- #define DMA_FN_IN
( t7 ~# Z' L, q8 Q" l* o7 I! [# l - #define DMA_FN_OUT, a9 F$ z) ^, X# z/ m' C* Z
- #endif0 D& k! K5 l% Y- y3 b+ N2 ?
- 2 M# Y: o. @% A. d. W/ a7 k5 I
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)% ?/ B) q, H7 A/ _6 e; ^
- #define STATIC_SHIFT 3
6 {' ~3 |: {' K. F8 D/ {& v% T - #define TCINTEN_SHIFT 20
3 G% c5 D) g3 O8 X7 }, w P - #define ITCINTEN_SHIFT 21
5 `! T- T$ Q8 H8 s9 Y4 f - #define TCCHEN_SHIFT 22) {3 C( c( B x& T8 z
- #define ITCCHEN_SHIFT 23
T h, p1 n8 g7 M - 9 E2 S+ b* R% W; y4 p: @
- static volatile int irqraised1 = 0;
6 v5 u9 o5 h. Q) y4 u - static volatile int irqraised2 = 0;$ E# H: {% M0 L' Q7 X9 b1 y9 T
+ i; q: o4 ]. t, E6 H1 k- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 H1 I/ T* t* v% t2 ]
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 o& _5 D0 y) e& R* ]5 E7 _
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ \5 \/ C g' Q% b3 ~
- $ Q+ w% D5 U# O! b/ t
- dma_addr_t dmaphyssrc1 = 0;# `' W' E0 Z6 b9 z
- dma_addr_t dmaphyssrc2 = 0;
6 b( g. o0 `# p) p+ r0 q - dma_addr_t dmaphysdest1 = 0;# e+ b3 d6 j) N% i- T: Q ]
- dma_addr_t dmaphysdest2 = 0;# M3 J! d3 \: C( h4 `# R/ X
( K5 B( T7 v; D# I& l- char *dmabufsrc1 = NULL;2 b6 L/ a) h& l3 o2 I: j- [
- char *dmabufsrc2 = NULL;+ [9 ]; Z! C# K; N1 Q! J! A# S
- char *dmabufdest1 = NULL;
* u7 L- R2 ^- C3 {6 p) q9 @# d - char *dmabufdest2 = NULL;' q8 s; _2 K, [! g5 q4 l7 }
- 2 M' \7 M/ ~ j' s
- static int acnt = 512;
0 }. c: _* \6 ] - static int bcnt = 8;3 e/ p3 t; B5 Y+ Q
- static int ccnt = 8;4 Y6 q) h+ a! n8 Q5 a7 ~% g
- . ]$ v+ D: ^6 F
- module_param(acnt, int, S_IRUGO);
2 K' s, o& r O+ K8 ^; \2 i - module_param(bcnt, int, S_IRUGO);3 j; }) C w6 ]2 s1 F6 d0 P Y! h
- module_param(ccnt, int, S_IRUGO);
复制代码 # J: J5 P- g- r- Y
1 v% ]: t0 [7 ?/ p* D 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用0 j1 H: F. I6 g4 x- u4 |+ ]% c8 P
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。% o0 |% F4 l% G, x+ d
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。* `3 b) F8 L6 G8 }, u( B W5 V
2 N8 A0 I2 ?7 U! G$ m9 W* Z% Y N8 b
+ b6 P. ?3 K8 d |
|