|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
* C& Y4 t/ h4 }3 A- [code]EDMA sample test application7 Z) `5 p+ p2 f4 D1 i: w
- /** ? Q* ]4 h6 t; G; E! X
- * edma_test.c
; q% A$ \1 s% [% c& i. ] - *
; _: N# q+ ~4 v" Z: i - * brief EDMA3 Test Application5 W8 m* J$ [2 ^ k2 g4 R2 o+ r
- *
; l) j% e- }1 G- [$ S - * This file contains EDMA3 Test code.5 p- J; }1 M9 S- h
- *
, I) z! K8 _ E: b) n - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
& N. k" n7 L- |8 R* [' c - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT0 P$ {. n, p- T8 W1 d
- * TO CHANGE.
2 F) h; V( }3 L4 Y* D/ z- r - *2 ?+ x. Y- Z e. {3 A
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/1 y% N9 l/ s# Q5 m
- *
% L9 s2 s3 |7 Q' b! i; p - * This program is free software; you can redistribute it and/or% s1 H1 ?4 K4 e/ V+ K6 g& L! C( O
- * modify it under the terms of the GNU General Public License as6 B9 l( D: b" {( Y
- * published by the Free Software Foundation version 2.. L- J) l* [4 o! X; T* k
- *! r% D3 B' D \% Z# D
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
4 L- D- S: o5 D P - * kind, whether express or implied; without even the implied warranty% `4 h5 d& H2 S _
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% d) O( v: h( B/ g5 C/ k5 y- @- M - * GNU General Public License for more details.& a3 J$ t7 @0 k
- */
8 [# n# R. Y! Y6 N, ^% o - 8 k \" m+ A2 _
- #include <linux/module.h>
( c# o. U6 P% Z - #include <linux/init.h>% b" o& t& [; k. O( Z6 Q, c; T
- #include <linux/errno.h>
E- A" U" ?. h9 g: j' ` - #include <linux/types.h>, C B( \7 R6 {+ G* J* w) v% n
- #include <linux/interrupt.h>3 k+ o4 w7 e ^; E
- #include <asm/io.h>7 ~4 E7 [$ m5 H: A
- #include <linux/moduleparam.h>
f' @8 d/ t" k+ S; R - #include <linux/sysctl.h>& o( k4 Y1 n1 p
- #include <linux/mm.h># \6 e! U! Y5 E
- #include <linux/dma-mapping.h> Q7 u% e8 ~. Y- v, @
7 ]9 p" k. q( m- #include <mach/memory.h>" I: \: w) E% W, S4 V4 D
- #include <mach/hardware.h>
: \" Y: M" b8 {. g6 j) G7 ?; w5 t - #include <mach/irqs.h>
3 c6 }$ g3 p0 e - #include <asm/hardware/edma.h>
- y2 r" ~; ~7 w2 H
0 j! V" s: `* K# ]# ^4 j3 y- #undef EDMA3_DEBUG8 P4 N7 a- B4 b2 m- R- ]3 y% _1 a& N0 Z% J
- /*#define EDMA3_DEBUG*/
' w7 k Z' t" B* L/ ^
+ ], b% r7 I. h- #ifdef EDMA3_DEBUG
8 T/ ~2 V x6 G - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- Q; s" r: D' o4 s7 H* F
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
+ y( O* V9 V- U& A' I$ w - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
3 ~0 K) w! Z2 r - #else2 B) Z+ t' m) G" w: U( S
- #define DMA_PRINTK( x... ); U+ n2 j( R: p' ?6 ~ k
- #define DMA_FN_IN! A6 ~1 n6 H( z9 s
- #define DMA_FN_OUT
0 |! w& T3 O* }. _0 _6 v - #endif. H1 L& F/ G: a" s) ?) d
! y2 E0 A+ C5 c6 w5 u5 s- #define MAX_DMA_TRANSFER_IN_BYTES (32768)9 ^' c' {( v5 _ m2 x6 c
- #define STATIC_SHIFT 3
7 i( l8 u. W' V' J1 n - #define TCINTEN_SHIFT 20 e) _2 M$ Y+ H% a0 F# b( Y2 a5 w
- #define ITCINTEN_SHIFT 21
. Y/ S8 \0 o. z - #define TCCHEN_SHIFT 22
7 B4 n# R- l& _( K. _( S4 u - #define ITCCHEN_SHIFT 23- E& o+ A. w4 d+ M+ V6 h% d
+ m1 O6 J) J3 V- static volatile int irqraised1 = 0;/ r- u: o( S7 ~7 ~* I5 \3 x
- static volatile int irqraised2 = 0;0 Y. ]' z! m9 b# D) D3 _+ v& r1 r
' `8 V! W: ^9 b0 I$ D- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" b K% z! |$ y' Y' d _ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ H4 E, m$ u8 }/ w - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) O7 Z+ h1 n$ u. r/ ?$ _
* {8 `& ~" u, T- dma_addr_t dmaphyssrc1 = 0;
1 S3 w* `$ a, q# A) f6 y - dma_addr_t dmaphyssrc2 = 0;
$ m0 o& J; L- r5 B( \1 ]: N - dma_addr_t dmaphysdest1 = 0;
# e- l' g- h) J - dma_addr_t dmaphysdest2 = 0;: q6 G$ A1 e3 c, J# Q3 r4 X
- : X! w. x+ O0 G5 C
- char *dmabufsrc1 = NULL;: v, O' s; z& G; B8 ^7 \
- char *dmabufsrc2 = NULL; a' m) z0 M! L4 P3 G# ~
- char *dmabufdest1 = NULL;
O: D$ \8 Z! P4 i - char *dmabufdest2 = NULL;4 ^0 H# N% U! i4 u; ^+ V7 Y+ J
- + ^) U/ Y8 ^6 q+ V
- static int acnt = 512;
4 }( H, r/ F( ^: H! q! A: D - static int bcnt = 8;
. }/ B! H3 V- p# c: s5 h - static int ccnt = 8;1 y' `) h% y! b
- 0 i/ { a0 K! L
- module_param(acnt, int, S_IRUGO);5 l: W% P; Z+ R* \
- module_param(bcnt, int, S_IRUGO);4 y1 l9 E* M% o0 C4 J8 X3 L4 R
- module_param(ccnt, int, S_IRUGO);
复制代码 ! v8 `! S2 G* g9 P& k
1 l, e1 R! U* D! V! |$ H" x. o! M 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 @9 g9 @7 ~+ g% R% @% warm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
3 e4 R6 J8 F) G M 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 r1 b7 s$ ~' Y0 n/ i
9 D2 x4 ?1 Y0 L9 O% f9 x ^8 J( j9 A& j8 y. u: X; T
|
|