|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 g$ x6 t5 a2 [& S- l- [code]EDMA sample test application
( |: P I3 ^+ K9 a, k) D6 ? - /*
& l0 L$ U; K0 {0 m - * edma_test.c' c- |+ ^3 b4 P3 _& a: t. U5 W
- *0 }: a3 g" n8 h1 T! I; j* D X
- * brief EDMA3 Test Application
. t1 S! h# I1 G2 u7 R - *
# `' K* m$ p' l6 |3 G - * This file contains EDMA3 Test code.
' `! N5 L4 r7 u- |6 Z9 Z - *5 N7 I+ ?1 W+ G4 b
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE/ e4 X( J- z3 s! @, k3 z, L# I% P
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT! L* Z: F g4 c$ ?* G: D
- * TO CHANGE.
$ \0 K2 o1 z% \7 { - *( n l0 M) d! g
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
! l4 H+ M# }% d$ O, x) D- \9 K - *& e7 c- J% Y# ^/ k' Z6 F
- * This program is free software; you can redistribute it and/or' y+ ^5 w- q4 B- s! [
- * modify it under the terms of the GNU General Public License as6 u+ }; z8 w3 ?4 I$ T! K% T4 A7 X- O( a
- * published by the Free Software Foundation version 2.: s& o S+ D# |) {) l
- *2 E& S1 k3 u4 f8 F% J' A. L, ?2 ]
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any9 Z. Y$ u0 Z, z1 a4 V* H2 n- B
- * kind, whether express or implied; without even the implied warranty& Q c) W. p6 D7 ~( M' |8 J
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! z( q' j" j) R - * GNU General Public License for more details.
8 t: \# C: C9 \: ^" c - */
1 h/ W9 l2 X( w. s2 e, x: ~8 f - , Y8 H* Q$ Q$ |6 R o
- #include <linux/module.h>
# h& m% T# w# R- Q3 Y7 [- l3 y - #include <linux/init.h>
1 o2 t+ @% _( d$ E - #include <linux/errno.h>) O" J) g* {9 j+ I) N
- #include <linux/types.h>
3 ?+ n5 S, ~ H# }- i( p. A - #include <linux/interrupt.h>& h1 [# D5 {" J4 u7 E
- #include <asm/io.h>
% s4 O- H+ A% R1 E n& ?. h - #include <linux/moduleparam.h>
) D- a) I. z& i/ b' H0 K% Z* m - #include <linux/sysctl.h>
" O& H$ M' d* ?& L, z3 C' w" R - #include <linux/mm.h>
, A) a6 N# B, f3 U" \ - #include <linux/dma-mapping.h>
& q8 P. Z% i& i6 C
3 g' _# z/ ~4 O- v- #include <mach/memory.h>' \5 R$ [0 ^! x5 x C& Q
- #include <mach/hardware.h>
- K" a9 V% |: H2 N" O/ q9 V X - #include <mach/irqs.h>
: a5 ~& A0 {, U3 Y: A' h - #include <asm/hardware/edma.h>' _! H% K4 ~- b- O; _. _
* Y* U G6 U+ g9 e- #undef EDMA3_DEBUG J: j: ]7 X: N {
- /*#define EDMA3_DEBUG*/
7 j5 D, z* i4 @1 G
8 i/ J X1 U$ L% D1 i$ S% R2 S- #ifdef EDMA3_DEBUG
& }! A8 [+ |1 o, N0 X% ]. m - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
2 S# @. q8 B: \- i5 } - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
* v+ r. C- R/ X1 {0 u - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)% `+ j4 U( i+ Q# w4 J
- #else
! P1 D6 f5 h) U8 T( F! N0 U) `1 L - #define DMA_PRINTK( x... )
3 l! I& b( y8 h. V1 n* F - #define DMA_FN_IN# t T4 K( N/ o
- #define DMA_FN_OUT* F- [) q8 f# X I; p G* L, X+ j
- #endif4 f: a5 v( |* E8 O9 W
9 k$ k) m* M( f1 e( l) Q2 j- #define MAX_DMA_TRANSFER_IN_BYTES (32768)3 B$ j. |9 I3 @* f2 p
- #define STATIC_SHIFT 3; d+ G' }( j8 p6 _) F
- #define TCINTEN_SHIFT 20) N6 L7 A# _+ M
- #define ITCINTEN_SHIFT 21
( @5 T$ R" S& V- \% t' a - #define TCCHEN_SHIFT 22
8 ]1 q$ L1 d6 O - #define ITCCHEN_SHIFT 234 J5 x8 S2 P& x0 ?9 S
- ( U1 U) h- g$ x& N/ C" k
- static volatile int irqraised1 = 0;, S" @1 t& I9 \% \6 o- R
- static volatile int irqraised2 = 0;" m4 H9 p- q. b1 L4 t3 _' J" \/ e
9 b, ~! d/ u: s3 i- k$ s4 g" }3 q- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); ]4 U! m p+ G |& o# g# e
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( K P" m) J/ f - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 C( A" D y( E9 K9 E$ c
/ P/ c) B4 g5 H6 q4 V- e3 I- dma_addr_t dmaphyssrc1 = 0;
8 w. r" M7 T2 w - dma_addr_t dmaphyssrc2 = 0;
$ H$ C V3 {) \+ | - dma_addr_t dmaphysdest1 = 0;
! _% T( C6 S( X2 |& d - dma_addr_t dmaphysdest2 = 0;
: D( D$ s2 q+ \" z1 ] - / ^" A, i5 K/ ?8 G4 E* I+ c
- char *dmabufsrc1 = NULL;
6 [2 |5 p& ]" K4 |; Z3 J - char *dmabufsrc2 = NULL;
+ W1 G9 b' q+ z x/ m - char *dmabufdest1 = NULL;
. o6 [1 d, r! L/ E3 F% \9 K4 a - char *dmabufdest2 = NULL;4 m0 ?. l& b4 i+ t' i
6 A6 o# X( h+ b$ i, |/ W- static int acnt = 512;
6 P+ C) |+ E6 \- H - static int bcnt = 8;
9 _6 ^ M" Y; {5 ~5 \ - static int ccnt = 8;/ Y3 {3 R# d; x! i5 k# ?
$ ?* ]# g9 D3 J+ K- module_param(acnt, int, S_IRUGO);; }# d2 p- h: \6 }+ T' x
- module_param(bcnt, int, S_IRUGO);8 W7 [8 d5 j' z1 y5 n: n
- module_param(ccnt, int, S_IRUGO);
复制代码 & O/ v% H1 I G9 G) e+ Z; E
2 o3 m' U Y2 b% V, @' W 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用) d# F2 s3 m8 K& o
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
/ W& B5 t# ?; |( K8 f# r 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。" W! v, |1 s3 [! k! X! j' a
: Q z8 f- `: K8 J; u+ \5 _
2 c2 n5 o+ ?) f3 r: w. o |
|