|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 " L- @/ l7 b& v% ?8 Q. o
- [code]EDMA sample test application
0 ]5 {0 s4 ^$ H9 C - /*
5 s( A6 A* T, {; Z3 D+ x: q$ h$ E. ] - * edma_test.c" k) E3 X6 [8 P, y) H6 v, Y4 n
- *8 w3 U! y. U/ P; ~- G4 T& m
- * brief EDMA3 Test Application# O1 u5 Q) v7 D5 T
- *
- X# j0 \/ X. e x - * This file contains EDMA3 Test code." R# I( b: W: p1 _
- *4 n2 F6 g1 d4 C2 f" a5 G& D$ G
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE/ j5 L3 t4 m! T4 _! @2 z0 [
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT# i- U6 A" h5 L1 T r
- * TO CHANGE.
5 j# j' W( K0 M, e: B7 b, ~8 n - *
3 v; J' x! t; n7 I" r: M/ r( V - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/$ J h3 r; L; F0 c# m& z
- *
* i; m5 u8 X. N3 P - * This program is free software; you can redistribute it and/or2 ^* J+ ]1 T3 W4 X+ }
- * modify it under the terms of the GNU General Public License as. B$ z# C. U O3 S; w: F: E$ Z2 P0 u
- * published by the Free Software Foundation version 2.
% H$ i6 W% z1 O; k, A$ n - *
" X R5 _/ m# x0 }+ { - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
4 _- c& o; o; V - * kind, whether express or implied; without even the implied warranty, w. a- L# Y1 f) D& C. ?
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* b9 V' {8 x: {. B1 Q
- * GNU General Public License for more details.
: K+ }+ \6 N' R - */( T F6 J& ~4 y0 N0 Y H% r
- 5 @, b' J W" v/ ~! V
- #include <linux/module.h>
1 u, H+ h8 v" {- Y) H) K - #include <linux/init.h>
; U( y5 |; C- x6 e - #include <linux/errno.h>; u& D- @# p# h/ f9 ]# n. Z* j
- #include <linux/types.h>0 M4 x; F7 s4 q N ?. O
- #include <linux/interrupt.h>
$ ^& T% F- ?0 f/ P - #include <asm/io.h>
" s) h/ W# _5 A: W: L1 U l - #include <linux/moduleparam.h> `# R. G( ^8 {! y, M) P( A
- #include <linux/sysctl.h>
5 `5 U; t7 v% Q# n! l - #include <linux/mm.h>2 O! q/ {# T/ C6 R: H0 j
- #include <linux/dma-mapping.h>6 c& a: C8 c' E* f5 Q
- - L- ^! R. D+ _; I: M/ z
- #include <mach/memory.h>
/ ?" D5 L# }# _/ o# C - #include <mach/hardware.h>
: R4 c% {2 u( [) i: @/ a* A# t, s - #include <mach/irqs.h>
. H M( u; D" V& |! i0 S - #include <asm/hardware/edma.h>
9 f% V: M+ d7 ?' G5 a3 Y% @ - / _# c4 ~& L- x6 [
- #undef EDMA3_DEBUG
) U2 \: D- B/ V- j' S6 R - /*#define EDMA3_DEBUG*/
: M0 m6 L+ [! {/ F
8 _) W7 Z* t8 }5 A- #ifdef EDMA3_DEBUG
: I. w# z+ z X, z' i - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)& ]1 x, B# y0 K+ Q$ T) s
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)1 F0 d0 w* W1 t3 K+ i8 ~+ j
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
2 C& @. ]8 h# e* g u# U! O' x - #else
( Z( ]2 `. H8 V# | - #define DMA_PRINTK( x... )
( i* ~; y' y, \ - #define DMA_FN_IN
3 }9 t' G! \+ j d8 y! I - #define DMA_FN_OUT% i; \6 S/ R( a9 q2 d
- #endif/ u& D8 X7 y+ E4 |
* Q; H+ g. X/ D' u- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- m6 d. j' t) ^. K# }6 f5 O. T - #define STATIC_SHIFT 3) }- \/ {# `6 s0 g# Q9 k
- #define TCINTEN_SHIFT 20+ _/ [: I" z7 @& t
- #define ITCINTEN_SHIFT 21: |. o5 j. ~! F& A
- #define TCCHEN_SHIFT 22
4 |1 B) ?6 K; y - #define ITCCHEN_SHIFT 23
' }( F+ J" r/ D0 ]' S2 k - - s( E8 O$ \- c6 w
- static volatile int irqraised1 = 0;
" x& @4 a7 j9 R% D$ o, x* ?8 Y - static volatile int irqraised2 = 0;& h# H. _1 w: z0 F" h+ D/ n y l
- G8 Y+ \) q8 O" n$ \+ l7 Q P
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& F# n' l U& }/ \8 x' _2 ? - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# z8 Z% i+ V+ I% |
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 _$ `: D7 S' M4 T# P6 s; \: y
* e6 M" ]- ^7 g1 M5 e! e7 D- dma_addr_t dmaphyssrc1 = 0;. g: C2 y; o% B' i# s8 S U
- dma_addr_t dmaphyssrc2 = 0;+ }+ Y) I: v$ L* I ^5 n: l
- dma_addr_t dmaphysdest1 = 0;
T3 O: t+ W; i! C, K* h$ q) c - dma_addr_t dmaphysdest2 = 0;
2 t1 M3 n/ f5 |
1 p+ U, }- |2 p2 w" P- char *dmabufsrc1 = NULL;
) s# Z: k7 T; k+ l2 K8 ` - char *dmabufsrc2 = NULL;- i# n1 ^* S; O) u5 c1 q' p0 Y/ A
- char *dmabufdest1 = NULL;/ M- ~% f4 q- J- L4 U" Q6 i9 i
- char *dmabufdest2 = NULL;
8 x( T4 O% q+ e! B
0 X- j3 U* n# B- static int acnt = 512;# A% ~) w& O/ f8 w+ H! i* H
- static int bcnt = 8;
" N4 k9 _1 ~; \% E - static int ccnt = 8;" I+ j" H' } D' k& M, n5 Q' C" R
- 6 l& J$ {: J$ {
- module_param(acnt, int, S_IRUGO);2 L3 q+ m7 N9 g/ B3 E
- module_param(bcnt, int, S_IRUGO);
: b' `8 y+ V" O6 H# J8 h - module_param(ccnt, int, S_IRUGO);
复制代码
2 X |5 B# _2 m7 Q- s$ S
' Y( p) K9 Z: X7 c& ] 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
3 k5 ?* K& n2 Uarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
+ k9 w' ^; K* z2 \- V2 Q& p1 N 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 q( H3 a# C& P, X
: W" L( }- {: P2 B
9 Y7 P" D& K3 S# G) ?. Z
|
|