|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 % Y% S0 _# j' f" ?; S* O9 Z: w
- [code]EDMA sample test application
5 O0 N) g1 w1 y3 D - /*
$ W% Z& w1 t( J* {" A - * edma_test.c6 `! j \0 ?; H# M7 B# Z
- *
9 u' ]- E [1 b, U# S8 f0 q - * brief EDMA3 Test Application
8 x- Y/ O4 s3 r0 M% V- M4 z - *
5 U! `7 n0 Y' }! `+ C - * This file contains EDMA3 Test code.$ s# V( l$ s3 V0 i& b
- *
+ X, H/ R: f' |2 L6 u2 ~ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE; `+ T' N# S6 b4 _0 J+ V7 d$ f$ S
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 Q; M( ?5 y) l" `
- * TO CHANGE.
& P( Q% \9 Z5 p/ ^1 O* P - *
# x2 J- F2 i9 d - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/: e% N! k7 ^8 K9 Y
- *
9 c x9 u! f$ z6 Y$ H- N! B - * This program is free software; you can redistribute it and/or
2 f$ {8 V( ^, Y4 o - * modify it under the terms of the GNU General Public License as
) p# H" S. D1 |2 V - * published by the Free Software Foundation version 2.& v4 r0 H2 C# y/ V( j
- *
* U0 Q T7 L7 f: F5 V - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& d, o/ i. O( u" {% e7 y - * kind, whether express or implied; without even the implied warranty- b' m2 g1 g5 F( g$ B5 W
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 P7 x/ D: l S- f. n
- * GNU General Public License for more details.6 C5 w) v* B" S( v5 x3 M$ }$ ` g! ]
- */5 W2 Q/ E5 U, p" m# H, H# m
8 K3 u2 x$ x1 e3 A- #include <linux/module.h>6 t2 ~. b+ y, t$ e
- #include <linux/init.h>
; T1 R; U9 Z9 c - #include <linux/errno.h>6 G- a/ b3 r# V4 i6 `! x$ x
- #include <linux/types.h>! z4 t8 |9 l e: s1 I" O. k& K: }, t$ m
- #include <linux/interrupt.h>6 k/ C: U2 W' u! T3 \
- #include <asm/io.h>
" x V: W1 D0 \/ D" q+ n5 ? - #include <linux/moduleparam.h>
# y {8 Z% u, D M - #include <linux/sysctl.h>$ W, A( \# {; A) N3 Q; i9 K/ E
- #include <linux/mm.h>; \9 E" E; A4 ?, ]1 p' P2 E
- #include <linux/dma-mapping.h>* g: F8 F2 ]6 @5 Q4 p! ^
- # l1 `# {+ {" `1 P8 W
- #include <mach/memory.h>7 W5 _3 C9 {% p! J) c- h* K3 s
- #include <mach/hardware.h>: A6 I8 |; f- ~( d
- #include <mach/irqs.h>0 [ i& R9 ^- u
- #include <asm/hardware/edma.h>$ ?9 j/ h9 m; t5 i7 i
" P* R/ H4 B% p- u( m- #undef EDMA3_DEBUG% z3 e7 Z7 w+ Y7 m' j9 h7 N
- /*#define EDMA3_DEBUG*/
* S4 k+ s/ v# w1 ^! G! t - ( e; Z& u- K! D) u a- ^
- #ifdef EDMA3_DEBUG- }+ X* k$ }3 v1 I9 k
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
: P; Y9 Y8 }" m1 [ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)5 `( p9 F6 L& O& S0 K0 z
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 P! g4 l% x) k3 ?- d. R* C( j
- #else
! ^+ c& E, Y ]+ [8 M t+ @5 { - #define DMA_PRINTK( x... )
, |6 X1 Z% N+ s3 w% x) G - #define DMA_FN_IN3 F3 A: t$ F/ {+ G" f
- #define DMA_FN_OUT# @1 H' U$ C: ?! S- P- O3 A/ X$ _
- #endif
* f2 N7 J, K3 T7 _! y - 7 [- P% A$ V1 A& |1 G4 z: P% B
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
! d3 M* Y9 s$ q1 F8 Z0 v9 T - #define STATIC_SHIFT 38 E; {4 N' m; R! m W9 a& @5 E
- #define TCINTEN_SHIFT 20- k. x' i: O6 ?' T _
- #define ITCINTEN_SHIFT 21
' E- s9 p" v# M0 C8 [$ U - #define TCCHEN_SHIFT 22% f( ]; g. m; v$ [5 ^, k9 f' b% Q; F
- #define ITCCHEN_SHIFT 23
/ e* K/ z' |1 @' `
, Q7 R& X' f$ \, I# x- static volatile int irqraised1 = 0;
4 l7 M6 M. ^; y# z2 o- m - static volatile int irqraised2 = 0;7 ]5 m) I( J% ]; o7 F# m* d
- - o0 O' Z8 S9 O
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 |9 e* X+ F; _3 O
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! K6 g A/ _" m
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- x: H+ b H3 T, u! {2 ]/ r0 y; l$ x4 ^
, T) Z4 ?4 U+ q0 O' @# _- dma_addr_t dmaphyssrc1 = 0;
; I- v' E% l- {* R1 m; v8 c" s - dma_addr_t dmaphyssrc2 = 0;+ J2 w! S+ i' v$ J3 A5 B P
- dma_addr_t dmaphysdest1 = 0;
) a( P3 i# _; w! H* \ - dma_addr_t dmaphysdest2 = 0;
+ ~. u5 T: s, D& f - 0 o3 r9 T# r7 U! D3 Y% H' D6 `
- char *dmabufsrc1 = NULL;
7 L! h- E3 F7 i- X0 ~8 r( B. } - char *dmabufsrc2 = NULL;# S/ B6 N4 p& M
- char *dmabufdest1 = NULL;
# I0 o3 b) ~3 E - char *dmabufdest2 = NULL;0 A* p7 u) J( _- k) j
2 R4 W% U4 J ~( l% V- static int acnt = 512;
+ _# M2 d& P$ i- _! f& g - static int bcnt = 8;
2 {4 M- J+ q( m$ p5 Q: u) j. B - static int ccnt = 8;! c& F: ~9 g2 X% f! J( Q/ E
1 H% O2 I. n T, x- module_param(acnt, int, S_IRUGO);
2 f/ J! i# h8 v; t, F& o9 c4 _9 O - module_param(bcnt, int, S_IRUGO);7 o9 ?* V. y% q6 U
- module_param(ccnt, int, S_IRUGO);
复制代码
, Y7 w) w2 Y' Z+ z# S5 f8 m5 c, @" ~: G4 |* I& s. N
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用) E( @( | S; g' S3 U- i) ?
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 c# ]. k$ e% N# `8 Y$ x# H( F2 i 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' C! \- W J; Y4 z. H- p8 Z: T. C# l. P
: a7 c+ J" T9 V& s
|
|