|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( B/ S/ G; C5 N- [code]EDMA sample test application
4 u# p5 x# l$ z A' ^6 r" r - /*! W9 Z: U* I! i, W
- * edma_test.c
& I/ {3 h8 N3 [( t2 B - *
3 x! M1 a7 I3 n( j - * brief EDMA3 Test Application
# m" y. g" ^& L( S( s4 f. y8 i - *1 S3 |6 R- H2 p2 D' p$ G
- * This file contains EDMA3 Test code.
* R& r! e' W" b6 z - *1 Z8 i* b7 F, L( G; p3 C
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
" ^" }% a7 x" W( I4 h4 Z - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% _* w% }8 I: W6 X - * TO CHANGE.
) i0 b3 Q( a& E" c" V - *% _0 ^3 m5 p0 u8 b
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 R! z$ _& J1 y* y$ C" W
- *, t6 W/ F$ d$ y- c" d! v
- * This program is free software; you can redistribute it and/or# s% Y/ C$ S0 l$ N2 T
- * modify it under the terms of the GNU General Public License as6 _* A6 {8 T! H% i& u* g) l' _
- * published by the Free Software Foundation version 2.% o" g- @# E+ s. d
- *
% z3 s$ k. B- n6 z6 M - * This program is distributed "as is" WITHOUT ANY WARRANTY of any0 e0 B$ a/ x5 _+ `" l2 s
- * kind, whether express or implied; without even the implied warranty
$ C$ L- k) N" W. z; f* {2 t - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the. m( J; i( a1 f( o) p3 B! e+ V
- * GNU General Public License for more details.
0 P9 Q6 Z" R8 E5 z" } - */* K- d# m, L8 O5 a' D1 `
- 5 e, P' }# C$ \6 X+ z9 ]- r
- #include <linux/module.h>
% w5 J9 O$ ^& F5 n0 P" _ - #include <linux/init.h>6 `1 D. p- n% l3 S
- #include <linux/errno.h>
& {5 c7 o0 I; U$ o% U - #include <linux/types.h>3 Q# N% R3 s. l, N
- #include <linux/interrupt.h>9 S, _. m- X M/ ^# q( N& `' U
- #include <asm/io.h>
" N; o2 X4 _9 t( v/ y' j8 u - #include <linux/moduleparam.h>
3 B9 s: X9 Q/ T) J. ^( T - #include <linux/sysctl.h>' z6 b' F5 Q. ~
- #include <linux/mm.h>
v: b+ c! y' Y& u' x7 L. X( ^ - #include <linux/dma-mapping.h>
$ E8 L4 Q# ]) J9 |! } - / E" O4 s+ B& d& |/ E0 c6 X
- #include <mach/memory.h>. |# c+ ?) t, M$ F/ q
- #include <mach/hardware.h>
* e% F7 p$ ^2 V8 Z4 F% k0 u6 T6 ^& V - #include <mach/irqs.h>0 S) o2 k7 w, W2 h6 p6 i( q' i% t6 @
- #include <asm/hardware/edma.h>
2 V8 V; u1 M( ^+ M5 K5 c - $ F7 i8 y1 ?/ Z7 s) s4 M- b6 D; h
- #undef EDMA3_DEBUG& {- v5 M. a6 y+ w9 C
- /*#define EDMA3_DEBUG*/
7 y) \/ |( p `; O0 N4 h
1 j# h- ~7 S$ p. D$ X" k: k9 w- #ifdef EDMA3_DEBUG, J N+ w9 U: t0 V6 _5 \3 I: P
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
5 N% R* ?* l s - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). Q) ^ x! f/ L
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)5 y' W/ X4 t& l" K) e9 A k7 X3 U/ C; }
- #else
) L( u0 |- g6 t( c - #define DMA_PRINTK( x... )
' n& d* ]- y* s. U; W8 t - #define DMA_FN_IN3 j+ ?# {4 w, u0 G! A+ ]6 b
- #define DMA_FN_OUT
5 K- K& Y3 g! F+ _. H. D! X - #endif
+ L% U( J. l5 l, J3 f: y( \* x9 l* u - ) R/ e3 ^2 e: T; C; g
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
' @- }8 Q1 N5 ~7 f - #define STATIC_SHIFT 36 v2 Y- D$ F8 R# n+ z- {& h4 h
- #define TCINTEN_SHIFT 20
5 [2 Z( _. W( ?9 g - #define ITCINTEN_SHIFT 21# e3 h: @* k* d+ V
- #define TCCHEN_SHIFT 22
. J4 w0 X! i" p6 f: p - #define ITCCHEN_SHIFT 23( i$ n& f9 j% O" t y6 s
- 3 r- u1 L* G4 M& C8 w
- static volatile int irqraised1 = 0;
( l& O( n* x& F7 a4 G - static volatile int irqraised2 = 0;
! P8 a, B2 a7 C( Z* a! {! T9 i
5 X$ N' U' d( \3 b8 |- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! j1 V3 P% s& ?4 l. J9 ?- B+ g
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 L0 a3 d+ w' k( e& _; S: p0 \
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# I9 C5 d& {2 m$ I$ ? - 0 V; z# g: N- N2 d
- dma_addr_t dmaphyssrc1 = 0;) p, b/ p! A O5 O! g7 I
- dma_addr_t dmaphyssrc2 = 0;
9 f! t0 \, j( ?0 E& H - dma_addr_t dmaphysdest1 = 0;6 t& r+ W. x' |8 `, p5 B
- dma_addr_t dmaphysdest2 = 0;
. j" s9 e9 t# {% Z4 e
% p5 G' k+ Q& P$ z4 e Z% f( ]- char *dmabufsrc1 = NULL;& l1 w. e* V+ S3 \
- char *dmabufsrc2 = NULL;% n5 m3 J# `2 O& V0 \% c
- char *dmabufdest1 = NULL;
4 a8 [6 D* q% Z; I - char *dmabufdest2 = NULL;
5 [1 Q4 ^$ Y/ r1 s) N8 R5 G
* b/ D9 j9 R0 ]+ B2 L4 P- Y3 R- static int acnt = 512;, ]0 { b& I7 w) k0 ~
- static int bcnt = 8;0 E$ L( h0 ^. j' m5 [0 h6 z
- static int ccnt = 8;/ m: n. i1 Q6 U) E
- ( G/ I6 ^" E8 B& d) R a4 p' b
- module_param(acnt, int, S_IRUGO);; G5 n J% Z2 K* L
- module_param(bcnt, int, S_IRUGO);; Q @4 g) F A% R% X9 _
- module_param(ccnt, int, S_IRUGO);
复制代码
* @0 Y8 e: N$ G! D/ \
& ^' { {: m, X6 l6 T+ Y 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用, Z W4 k* e! R" @/ p" U
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 M4 p0 j3 O& ?. o: y& B
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# O- ]& q+ t0 @: o9 e& l/ m
* }: S2 B8 I1 e
* @. _! R' e' o9 S" p$ P+ U$ N |
|