|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 ~% [; U' o. h$ O+ ^, s; E
- [code]EDMA sample test application
- O' j1 m4 A8 @' F" w. J - /*
8 b( S2 p7 A, a' ^( ~+ j( s; t3 f - * edma_test.c
$ U- _- U( u, J) A - *$ t9 N; p4 p# D6 X* k. u
- * brief EDMA3 Test Application
. \3 |/ }. f/ s! s - *0 i) l4 G( h# f% {
- * This file contains EDMA3 Test code.
: O1 o. Z1 N; }7 y* {# i - *5 I% t4 h: Y3 @2 Z
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE! A/ m5 n5 }- E: i. ^# ^- x1 k
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 h' }' y3 s1 }0 V: R6 w- L
- * TO CHANGE.: f5 E% e: b) w8 b$ m% n6 k3 A
- *) `$ h* Z; j! `/ V$ ^! R2 c2 G
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! U' j9 y# q7 o+ U! U
- * @- d( _2 E& E
- * This program is free software; you can redistribute it and/or
: F. B5 M1 U- {2 N. l1 U/ A6 u - * modify it under the terms of the GNU General Public License as; F, R7 l1 G1 X5 g* n) G
- * published by the Free Software Foundation version 2.! Q$ B5 t3 c6 O4 Q
- *
( z( x- @$ \& d; \ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
. H% ~ I, _3 ~2 i/ ] - * kind, whether express or implied; without even the implied warranty% A* G, G$ ?3 j# ^+ B7 J! j
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the$ Z4 D v' m8 [- h
- * GNU General Public License for more details.2 P3 ^' Q% W. U) a( ?; @) q
- */5 A i+ `( [6 ~! H1 A7 w
5 K* m. f! G. O, t, R- #include <linux/module.h>
" c* O4 S h6 U. N" y8 t' a: u- n6 E - #include <linux/init.h>
# s0 d# {- @4 K |# t, Q - #include <linux/errno.h>4 t& r5 E' A# O7 `1 M0 B
- #include <linux/types.h>
& c8 B& d8 m/ I# H% I2 `* S: p5 P2 ? - #include <linux/interrupt.h>
. _) ~' y: r. }& s8 @ - #include <asm/io.h>4 r1 ]$ {" r8 M* p* \5 [
- #include <linux/moduleparam.h>" M: U4 o [$ k
- #include <linux/sysctl.h> z% {1 F8 t* p
- #include <linux/mm.h>3 Z7 S& M2 t* T1 }2 o+ E% S
- #include <linux/dma-mapping.h>
8 m8 W& r2 j3 g
3 Z3 e1 B6 W/ |: W/ |- #include <mach/memory.h>
, @6 K( d. i* B8 D, j0 {( Z - #include <mach/hardware.h>6 e& A+ C& m+ w( D0 l
- #include <mach/irqs.h>3 r0 N$ C9 G' C) {
- #include <asm/hardware/edma.h>
7 Q! M3 H/ Z V4 ] - , A2 ^, V6 g; O8 K: {! T
- #undef EDMA3_DEBUG
6 ?9 F! q6 j% ?: z; P; Y f7 t - /*#define EDMA3_DEBUG*/6 C8 d1 N0 J4 K8 X4 O$ H+ }+ @) g
8 k& ^6 A% |. V. i! }- #ifdef EDMA3_DEBUG
% J8 v& b$ Y6 ^* n" M& ^, f1 Z; D) v - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)8 C+ ` `% e( V$ U
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)3 O+ K: s8 I9 a' g6 p% k6 T) W
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
* }! L- K6 G- X0 z* H* C$ b - #else
* H3 M q1 r4 n0 b' u - #define DMA_PRINTK( x... )
: X( E8 o- k$ b0 U2 _4 n - #define DMA_FN_IN
3 ^" b- Q/ B( P* d. H! W - #define DMA_FN_OUT* I" n& s; t$ K5 U, x3 d$ x8 I
- #endif; n6 Q+ W! V* }- l p; Y6 X1 |/ z
, |, b8 X- g ]& W! r- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
/ }# P5 h+ n+ s! d - #define STATIC_SHIFT 3# Y- C7 @8 A1 e6 ~6 W! D+ @. Q
- #define TCINTEN_SHIFT 20
; k2 w4 q/ Q1 N# l, V! O# u. z - #define ITCINTEN_SHIFT 210 }$ m; l2 t( i. U+ W0 c5 Y1 f' ]7 J
- #define TCCHEN_SHIFT 22/ h1 x5 _# {7 Q( @/ j$ [
- #define ITCCHEN_SHIFT 23
7 q1 f" d: Z6 ]% X, y5 e - 1 t, G, n |) D& z- U
- static volatile int irqraised1 = 0;
) t# y' T4 b: E( O( [ - static volatile int irqraised2 = 0;" _ O" j3 T2 A _- D) ?
n! F) j, L" m. w" y: T }- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 R/ B8 d, n# J; D+ n, ]# N- _
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# j* H) ^! ]$ R* t - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); f. a4 u( E9 ?
- + @& m1 ~/ M# }/ z' d* Z4 \
- dma_addr_t dmaphyssrc1 = 0; W( k( v5 L! d1 K }9 ]$ @. p. a. i- e$ o
- dma_addr_t dmaphyssrc2 = 0;9 I# t6 g8 m! @8 Y7 g7 b% G
- dma_addr_t dmaphysdest1 = 0;
; x9 b) l' `. u$ R' ^8 v7 | - dma_addr_t dmaphysdest2 = 0;
5 r$ R( J$ o. |) W" w* p0 f9 y
/ m6 r6 J E+ Z& I# G1 t" x- char *dmabufsrc1 = NULL;
7 Y% ~" \& s" P& K - char *dmabufsrc2 = NULL;
2 @: K3 q4 U" \7 a' o0 O7 F - char *dmabufdest1 = NULL;2 E" Z2 _- ]( R6 w6 v- N
- char *dmabufdest2 = NULL;( _" \7 x+ \- q
/ m) o& B! T% x4 x; h0 D; ?- static int acnt = 512;
/ g+ ? G5 W$ M: v- c- i - static int bcnt = 8;1 O2 k/ V, W5 m4 K; A5 o
- static int ccnt = 8;3 G# B9 Z5 n% p1 G4 K
- $ d% r. i( H0 e8 ]; _8 u3 H
- module_param(acnt, int, S_IRUGO);" U& c/ n- M# Z; ~
- module_param(bcnt, int, S_IRUGO);
; z/ U# F' Y0 ^7 r# P - module_param(ccnt, int, S_IRUGO);
复制代码
* x- C) I9 I! o- | j$ ]$ M9 Q% Y0 {- D
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用5 V A7 y! d" e: u" T
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
5 i8 a1 j) i/ s 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。, o5 M6 Q# w1 J( {2 r
& y' p' o9 C) T9 ~6 Q) n
5 e9 w, \1 g) y2 _ |
|