|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; [/ j3 n, K: E7 t- [code]EDMA sample test application
, t% L3 ~3 }+ Y( { - /*& i& L: O* j' Z9 b7 n
- * edma_test.c2 N: a! F% U; I" k
- *1 z5 Q/ ?/ ~, q4 o$ ]4 s7 k' x( e
- * brief EDMA3 Test Application* t' e' h% U3 F+ w
- *
5 Q7 m1 Q' T4 ^- U$ N8 F* h& W6 z - * This file contains EDMA3 Test code.
, E4 J( ~' m1 B6 B2 i8 n7 G - *# P: K" v, X0 [4 z! D5 ~
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE4 _( Y" j/ G) M' L' c1 ?( t4 `
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT* G6 g- g- G( O: \) m' ~
- * TO CHANGE.
% F( n, N. F) Q0 n+ F% Q. K2 H - *
( S3 G- d; ~0 ?- ^- O" F - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
) }8 h4 Z' l. m' g7 l* B - */ n/ |+ E+ @# ^
- * This program is free software; you can redistribute it and/or6 p$ Q3 `: q4 k- s1 k- D1 E
- * modify it under the terms of the GNU General Public License as% [, f3 M* G R `; h+ E
- * published by the Free Software Foundation version 2.! d) g. q' {7 U3 D8 ^
- *
2 O6 w% I4 f$ [8 W - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
3 k" c" `( h: v - * kind, whether express or implied; without even the implied warranty
0 D% @6 t9 ~* O% W - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- M* [9 q, r/ F( E8 h6 e - * GNU General Public License for more details.
! i0 w+ p% k. n7 E7 E2 c. t - */6 @0 c. L' |, @' p6 |
3 P) K5 R4 e, G; p- #include <linux/module.h>5 Z. M3 G& s" M# S% w; a% s3 z
- #include <linux/init.h>1 `1 z6 l- b- d$ `+ v
- #include <linux/errno.h>3 R2 ~2 z8 I8 U. ~
- #include <linux/types.h>4 w2 \! _# b' [9 }8 i
- #include <linux/interrupt.h>
; `7 N9 q. f+ k2 z - #include <asm/io.h>8 k; K2 d" m3 k7 V
- #include <linux/moduleparam.h>
1 |8 I: o3 M* Z' L& U$ `- U/ _! A - #include <linux/sysctl.h>% `+ S6 V/ |$ q
- #include <linux/mm.h>
$ L8 S7 g C C+ O' @# u" X+ p - #include <linux/dma-mapping.h>
. O; l& b+ B+ j$ W) e - # ]# s0 Y, a2 n7 R$ i1 N
- #include <mach/memory.h>
( f8 o9 a6 ]6 D) T2 ^3 W6 K - #include <mach/hardware.h>" [! a! e9 G% M: b
- #include <mach/irqs.h>
9 D3 f$ ]; G' D7 f5 | - #include <asm/hardware/edma.h>' h( B9 V. E) K9 g! l
4 q: Q- _4 `* n9 }1 e- #undef EDMA3_DEBUG$ I% S6 ^; H0 j( ?1 [5 q/ ?$ S6 N. A
- /*#define EDMA3_DEBUG*/
j+ J+ j Z' P& y" Y% M
0 O+ _' ~9 V. l3 f% ?0 U% W2 |- #ifdef EDMA3_DEBUG/ }, i C0 g- Z' W, F
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
( z; k$ o$ q; s: c" o - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 E. o( k3 j- X& n - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
. `% C0 N$ n# G. _2 k - #else
1 y/ n S6 u3 G0 j( B - #define DMA_PRINTK( x... )' `& B# p2 R0 B9 I6 k+ `
- #define DMA_FN_IN
: K$ P! n% W: G; M/ U - #define DMA_FN_OUT
4 {* V; z; _7 G( V! ?; [8 S - #endif/ V* r! X8 ~6 Y
# Y9 y9 H4 o) Y3 r3 E! d1 l- #define MAX_DMA_TRANSFER_IN_BYTES (32768)% w5 |+ R7 k1 h2 h: E1 O" g
- #define STATIC_SHIFT 3
8 M+ G) Z/ \% @; z - #define TCINTEN_SHIFT 20
2 \+ j9 c' T( {- N# l& k/ U - #define ITCINTEN_SHIFT 21
$ @ w6 } J' }% V# k. ^ - #define TCCHEN_SHIFT 22 x0 {' Q7 B) g0 x
- #define ITCCHEN_SHIFT 23
+ Z0 f$ S# @) Y7 j - ! Y+ v9 Z3 B6 b9 @
- static volatile int irqraised1 = 0;
7 z! A( [! M9 H" U - static volatile int irqraised2 = 0;
- w$ H; A, ^. p5 [* |+ G8 u J - $ h% c+ I$ Q5 z; {* j
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! o. d# i; a0 a) T( Q9 z. l - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ e# I( @/ W' O: s6 k g
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 x6 V1 H! ?& c. \
- 1 v; a( |. k& B D/ m* ^6 W6 F
- dma_addr_t dmaphyssrc1 = 0;
2 H$ U0 y+ c3 M! O2 W- [ - dma_addr_t dmaphyssrc2 = 0;% ~6 }! Z k4 ~) \, Q h
- dma_addr_t dmaphysdest1 = 0;" p3 o; y$ z) V. j
- dma_addr_t dmaphysdest2 = 0;2 ^- s; |- N% E. L
2 t* v+ h V0 _' V* H- char *dmabufsrc1 = NULL;
% \' n% M* q6 A: X - char *dmabufsrc2 = NULL;
3 p. c* \( y& K- Z - char *dmabufdest1 = NULL;' y6 W) `9 V x3 P" n! }# U+ @1 h' H! F( M
- char *dmabufdest2 = NULL;: B6 B. ^4 M1 q) Z9 E7 T$ n
$ z% K( }" c/ t7 C) R Y5 O- static int acnt = 512;
/ U1 q7 c, V2 R# N6 X' k! q+ ^, V - static int bcnt = 8;
2 a& B- L F+ y% ^3 G - static int ccnt = 8;, [( K V7 _2 h* k( o6 {
- # J" B6 e7 j6 G! P T
- module_param(acnt, int, S_IRUGO);
# q8 w- Z: ^; E$ l, u q - module_param(bcnt, int, S_IRUGO);# T9 e: w; [! L7 J0 _2 ~! w
- module_param(ccnt, int, S_IRUGO);
复制代码 , o5 f1 R) t) }5 y+ i S7 M
& j3 |* ^, g) X0 D 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用. X/ P$ Y+ }. @! B+ Y, J- E
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。/ t- a% Z* e) E% C
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 N6 F: V% ?3 t
" @* ?1 k. a1 y8 `: K
6 B8 A5 I8 ]/ A/ u& U) \. ^2 x9 z |
|