|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 i1 V9 G( ] x; ?- [code]EDMA sample test application7 l( @4 N4 b( W p" r9 B
- /*
* T3 b& p Y) I. w( l" O# W - * edma_test.c
. Z$ w5 f8 M& w; V) z! J4 S* Z - *
! {& v( s2 B6 U! X6 Y! H/ N; V - * brief EDMA3 Test Application
6 l$ O/ j2 j [0 W - *
' B. i2 c9 D( h8 o: a - * This file contains EDMA3 Test code.
: n& |/ l0 f! F - *7 {- f. p2 }8 k
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
3 u" x1 x9 j [$ `' T! Z' W - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
! g3 R* A5 u! D) ~ - * TO CHANGE.
* w6 G6 T( y6 b+ E2 {/ T; c - *
1 a- U8 {* g8 _% I: p - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/* Y5 |$ g; A& Q+ h5 J/ h) Z! b
- *
$ I/ W9 {) G* R9 v- I9 |+ K - * This program is free software; you can redistribute it and/or1 |. O# g! N8 }7 K
- * modify it under the terms of the GNU General Public License as- J% f# s$ ^2 d2 K A8 o9 W* t
- * published by the Free Software Foundation version 2.3 G2 v# q) ~* f
- *0 ]. |# R, b$ V* s _; Q( j
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
/ F' w# t% g8 \; a% c4 w - * kind, whether express or implied; without even the implied warranty
# y3 ~' n- O- Y+ @ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the/ `: E' N# O* c1 X% W8 X: g7 N
- * GNU General Public License for more details.
9 H P: R8 P% V) r - *// K) o4 r; \! a- b
6 { [& J$ K' }# j, n& i) N* l+ T" |- #include <linux/module.h>0 H, X6 ?0 V, u, a1 ]5 t
- #include <linux/init.h>* \1 a" B5 K8 L2 }: L3 d+ q% e
- #include <linux/errno.h>$ V2 @! o, P6 @8 [7 ^& O- Y
- #include <linux/types.h>
* A* Q' Z* Z3 u0 J# M/ p - #include <linux/interrupt.h>
: }% W' r* c/ T6 L+ S - #include <asm/io.h>1 q1 ~, g) \8 u2 {- i. B+ U
- #include <linux/moduleparam.h>4 K) W6 e4 F5 S b6 W
- #include <linux/sysctl.h>
( o1 L! ~4 G( m8 ^% N: V - #include <linux/mm.h>2 x' x" ]+ y3 Q! T7 z, }, k. E
- #include <linux/dma-mapping.h>1 @" f' `6 m! ?! a
- $ w- A8 [2 ~: l. b( `4 `( S
- #include <mach/memory.h>7 D1 b) N) m5 I% y& N
- #include <mach/hardware.h>- Z; o/ |1 E+ W( q* V; T
- #include <mach/irqs.h>
6 A# F/ X3 m/ N S6 @' Z' T& y9 f& { - #include <asm/hardware/edma.h>
@7 ^4 C9 Z2 C2 c
1 T; Q0 _( U3 i" |7 K5 O7 [1 N) I- #undef EDMA3_DEBUG4 U( T: X; @# U* k: H
- /*#define EDMA3_DEBUG*/# I4 t7 e! K" `; Q" |$ ]
( l) P G+ w m% Q- #ifdef EDMA3_DEBUG& \* U7 x' D1 j }* x7 D
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
% ^9 [) u" ^, N' d - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)! M9 T2 @; f& F' k4 ~3 l
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) Z2 H9 R6 \0 T V5 x5 X$ m' d% x - #else J6 o9 T6 I( f- r: }1 w) A
- #define DMA_PRINTK( x... ) }; x/ ~% M3 Y- I* e
- #define DMA_FN_IN/ x# B& ?8 i; Z6 j5 g+ u8 `: S
- #define DMA_FN_OUT
. E9 A% r% l! g9 x- y: x7 ?7 E! N - #endif
0 J( S' A6 c! T+ } q - 3 ^# Y/ T6 ~- P: E* j' ?, N
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" R, r9 w# f( ?$ r: |2 R7 i7 t# ]# K
- #define STATIC_SHIFT 3
, `; F X8 L6 k0 e* ~6 y9 i* J; I - #define TCINTEN_SHIFT 20( ?9 A; W. b% H1 L
- #define ITCINTEN_SHIFT 21
& \% X# H( }4 t \( s8 X - #define TCCHEN_SHIFT 22
1 Y8 v2 [0 A2 ?* F. s: }' F; C - #define ITCCHEN_SHIFT 23
9 Q1 u2 Z/ I$ t: G, ^/ R9 V$ @
% l" T1 m$ n$ l- static volatile int irqraised1 = 0;/ C; o+ f* i6 k3 I2 V% l7 t
- static volatile int irqraised2 = 0;
\& I0 x/ U# N q: x4 `
) _% @2 {2 k$ m5 @3 t( S" W2 o0 p- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 G" H8 R, U9 T+ j' T - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; ~; C+ E" r9 [9 l" h9 A+ v
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; m% l0 k6 |9 p" {! h; R9 B - - r: j5 g8 L+ _+ ]" J( M/ O
- dma_addr_t dmaphyssrc1 = 0; q" |" J! N; ~ _! n2 e; |- S0 p! w2 X
- dma_addr_t dmaphyssrc2 = 0;
# ^4 B1 M. L7 b' A: o" p1 ] - dma_addr_t dmaphysdest1 = 0;& |5 }! Q/ k7 h0 o8 @0 v; P
- dma_addr_t dmaphysdest2 = 0;
7 Y. ?, ?" N" T, u2 b
! [9 Y- I4 Y* S# T( B, p7 Q5 C7 L- char *dmabufsrc1 = NULL;
' H: Z2 i# a2 t6 G/ J - char *dmabufsrc2 = NULL;+ }1 D: @, \# K! H/ M. h
- char *dmabufdest1 = NULL;; @/ f" A2 ~, M9 [ V) t8 \
- char *dmabufdest2 = NULL;
% T$ b# Z! i4 Q D5 U, W2 {6 K! X6 g* J
, R# |( ?2 c1 B; r. ^% P% g- static int acnt = 512; G% J- x, y$ e- N5 Q- _
- static int bcnt = 8;" ? F) G, Y& r2 b3 I6 }4 ]
- static int ccnt = 8;
5 @ `, w" Q) I# U2 a
1 ]8 C! Z* c% L, J L$ B- module_param(acnt, int, S_IRUGO);
: u8 g' X! m6 u K - module_param(bcnt, int, S_IRUGO);- x( F2 s9 \7 ?: |2 \. M) \' W4 c
- module_param(ccnt, int, S_IRUGO);
复制代码
5 e T/ g, p3 x" v( T8 t( ?% q5 f# V& ^, C8 s
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用0 o0 ^8 `2 [# u1 i9 ]4 c, K9 U0 ~
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 m4 l! Y+ H' n7 }. }- U
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。2 \; M6 T" B* A6 Q: u. C1 [
; O3 n, Q5 Q# X* g
) S7 w3 J% \0 v. z9 H' M |
|