|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
/ C& x: l3 f9 a- x9 x- [code]EDMA sample test application
& H7 p! O( E* e5 T: r - /*+ e: w" r1 _) Q7 l
- * edma_test.c! ~" b- F. i4 D& m5 q
- *0 x( F9 `; c$ O3 c2 A1 B% ~
- * brief EDMA3 Test Application
/ o; Z8 G7 U3 f4 t M - *7 J( L. t- G. l/ e2 c5 O
- * This file contains EDMA3 Test code.4 w2 T" c0 [8 j3 {: E
- *
* T9 f2 j5 f) S: H - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
8 f3 \: D7 R0 L9 ~7 g" z - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
5 a6 i0 i' {* ? - * TO CHANGE." B7 m$ l9 u+ L" Q
- *
6 g7 ^0 P m6 C- H - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/4 ^+ J& }: {) I( i
- *
/ M- Y' b, j# Y0 K3 A- f9 y - * This program is free software; you can redistribute it and/or- x& L0 h- A# w, F
- * modify it under the terms of the GNU General Public License as' ^ r0 Q/ r1 ?& h! R" V F
- * published by the Free Software Foundation version 2.
; O0 p8 z$ [) V7 b+ Q - *
- ]+ b. F# R. L% Q. x' z$ G* d - * This program is distributed "as is" WITHOUT ANY WARRANTY of any4 h* L, U1 X$ ~8 F" w$ [* S
- * kind, whether express or implied; without even the implied warranty0 u! z3 L Z( x9 W7 ?4 q" f
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- K- h& B8 H) I: o
- * GNU General Public License for more details.
- q6 f7 G2 J; ]0 p6 l) D2 S7 W - */1 @ b0 D4 Q3 P6 y/ S+ _
+ I7 N I" j* e1 s1 P/ a7 m- #include <linux/module.h>
" v' `; q$ Y v. l7 x) R% q - #include <linux/init.h>: R/ {" s: `- N/ F H3 h. H
- #include <linux/errno.h>
# M) E% n; G) k - #include <linux/types.h># M/ }2 q$ x% C, g; t5 b1 @
- #include <linux/interrupt.h>
5 G1 O6 i; Z; h - #include <asm/io.h>
/ C6 F! Q1 |) { R9 i3 s) Y - #include <linux/moduleparam.h>% a: m/ ^+ }4 e3 _: o g
- #include <linux/sysctl.h>. z" f" ^& g2 H' G
- #include <linux/mm.h> C, b" y! h5 L; Z" X
- #include <linux/dma-mapping.h>
. |4 h1 w( C+ `: y1 P" @# ?
# S& ?; |) }7 Z1 Y! e' f. ?: ?- #include <mach/memory.h>
* Q4 I7 K( U( U# q - #include <mach/hardware.h>
, L1 ~" {& ]1 S - #include <mach/irqs.h>
' V9 `: @& A+ N9 t5 z - #include <asm/hardware/edma.h>
8 B( Y& N! B5 {' ^ - 4 R& V# T* s/ j7 V5 X1 J# V. S; y2 r
- #undef EDMA3_DEBUG) U3 j0 u9 I, |4 \
- /*#define EDMA3_DEBUG*/1 p8 _$ _' B2 r2 n4 a1 s
- 8 ?) O; {3 a, e$ }0 X$ B
- #ifdef EDMA3_DEBUG" U6 H, x1 @# }9 i
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
7 }" {# e r( M0 m% X3 | - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
( k) y m; e9 h - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 y& w( f2 G' v6 ? - #else
. m, D/ ]; E5 E" e6 {: T - #define DMA_PRINTK( x... )$ n$ \- _$ }) k/ v
- #define DMA_FN_IN
; j6 U7 v+ p! U- W; X - #define DMA_FN_OUT
4 ~$ M! D4 T# ~7 D - #endif
: u V0 F/ D" N" a# {6 `* l+ X
; S" L' q, ]; f& C8 U' T! A- }- #define MAX_DMA_TRANSFER_IN_BYTES (32768)4 G- n3 R5 U: B
- #define STATIC_SHIFT 3' C6 q5 T, [/ F! s* O
- #define TCINTEN_SHIFT 209 V9 u& v; ^2 I: g: _5 D: w3 B2 F
- #define ITCINTEN_SHIFT 21
2 M' j9 }" @& h9 v& z - #define TCCHEN_SHIFT 22& O3 }+ `! O% h7 N6 l' [# `
- #define ITCCHEN_SHIFT 23' [# y: p! E6 H2 t! n
- 5 w8 c; f# s6 V6 _
- static volatile int irqraised1 = 0;0 k* w: P. R$ C
- static volatile int irqraised2 = 0;
, ], p% C2 L* A7 O! X - 4 T( W7 E0 z) t& _5 S
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& |9 E% M# p* A6 Q - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# W" N1 e4 t+ z* ~2 T - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! Y+ e( u0 s& y: r0 i- {
- 1 n) z: A+ X" R* G
- dma_addr_t dmaphyssrc1 = 0;
B7 {5 f. u3 T4 B0 Z/ M+ S$ t) A! H - dma_addr_t dmaphyssrc2 = 0;
3 z7 q+ I- U' Z$ z - dma_addr_t dmaphysdest1 = 0;1 `% Q- ]5 k4 ?- Q: _
- dma_addr_t dmaphysdest2 = 0;9 a" Y6 c3 R4 z- |* E4 |( Q( n _( |
$ e, d, b7 k& ?( q1 u6 O- char *dmabufsrc1 = NULL;
8 c& p8 _) a2 `6 _; O7 X9 } - char *dmabufsrc2 = NULL;+ Y' v9 \( B) n. U+ z
- char *dmabufdest1 = NULL;
, g! G, m" N; L7 h; {0 j R0 P7 d - char *dmabufdest2 = NULL;2 s! l! u& d) G
- # ^* Y0 x7 w! T* g" C
- static int acnt = 512;, B& S, g! _: F. q# S" j
- static int bcnt = 8;
& x, U5 c u0 p - static int ccnt = 8;
# w2 Y/ T& N- z3 i; F
9 f' F$ u1 @" ? P# |- module_param(acnt, int, S_IRUGO);
5 H5 l2 O; T# a8 X' e: b- q6 e - module_param(bcnt, int, S_IRUGO);. N1 k6 h; C6 ?9 H' g1 \3 B
- module_param(ccnt, int, S_IRUGO);
复制代码 4 D M& D6 k9 d" Z" n
3 h: [ l, [/ X 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用/ B% C( E( f: A. R5 d
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 A0 Z1 T- u2 J
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。$ p* F, `! n9 ^) T: G* Z2 F! b
7 q) W" r. ~0 C9 [9 G- t( o) x1 m6 K" W& l9 U; o* a
|
|