|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 2 E: w& u9 \7 f2 w* z
- [code]EDMA sample test application
6 H" O/ j- Y2 `7 I, l$ s - /*
0 r: @7 s4 h% b" r - * edma_test.c7 v4 r$ I" O, \0 W, Z6 K
- *$ J. L `3 T1 v# t- z1 i
- * brief EDMA3 Test Application7 V/ U$ ]$ ]! p
- *
' R4 t4 K$ z, H7 B9 H, s: W0 a - * This file contains EDMA3 Test code. O- X, X0 F' }7 O
- *
A3 Z( S7 K# O/ Y" C6 Z% M - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
( F& Y2 O# f! b! v1 O9 ]$ b - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% g" H* v1 ]. R. X
- * TO CHANGE.8 j- l3 J0 Z) ]6 j" B, ?' G- m" t
- *
7 K: R: n8 _$ c2 H$ H, e - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
% b& I# a& B+ J" F1 q7 V - *( J6 W4 k0 n% l0 {% I. O
- * This program is free software; you can redistribute it and/or x/ j" M& v& y1 N/ e) _- m4 h# S
- * modify it under the terms of the GNU General Public License as
& H; Z( V! Q4 w7 v) ^6 m2 h - * published by the Free Software Foundation version 2.
8 W1 L( K+ T, j |& W# w - *
( W3 G, c. ` C7 a0 R, i) Y - * This program is distributed "as is" WITHOUT ANY WARRANTY of any) V% c! Q: _ @% s5 v
- * kind, whether express or implied; without even the implied warranty
$ t9 V+ ]3 E5 E3 C - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 H% M5 c; A7 u1 ]& P& K: D/ S - * GNU General Public License for more details.
1 w& O9 }- K2 n% B+ I* r - */
9 E0 d4 K5 N! i1 f- `8 F
9 e r" Q$ l7 D# G- #include <linux/module.h>9 _5 Y5 n) x" o" @
- #include <linux/init.h>
9 a* I. e; M3 {8 j - #include <linux/errno.h>; `7 N3 C9 x6 [- U; }( `! z, l
- #include <linux/types.h>8 Z% A3 U; [" p
- #include <linux/interrupt.h>
( z, k4 z( h$ X' q; s3 t - #include <asm/io.h>, _! y; f& Z$ D& G; F" V
- #include <linux/moduleparam.h>
1 @2 A1 ]7 h0 J: \ - #include <linux/sysctl.h>4 k- _( ]0 Y5 J, o1 [
- #include <linux/mm.h>! W5 T3 |% }6 M1 w0 b7 M( J
- #include <linux/dma-mapping.h>5 w$ V) J) p: b" r" V
8 ^/ o2 w7 V5 f* _& x6 z- #include <mach/memory.h>
, N! T8 Y( i& T: v' n - #include <mach/hardware.h>0 O# `8 V! d7 ]& m7 e3 G
- #include <mach/irqs.h>4 z9 V1 Y& e" }. e
- #include <asm/hardware/edma.h>- ~% ]/ f5 A: p' b8 G7 y
; c" ~; v* S, I% o+ P- #undef EDMA3_DEBUG
3 ]. }: u7 v3 r K) H% L/ Q - /*#define EDMA3_DEBUG*/$ [: A2 j4 a' w$ l* y A% T
- # d0 X. {7 f; Z f. k7 @+ f
- #ifdef EDMA3_DEBUG/ J0 T2 I. E. `0 z" c
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)( L5 z, J! f4 I# m% h, S
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)9 z8 k; j3 @: X2 f6 h
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): P3 d* r9 I! c, q0 c
- #else) I0 T* ?- t& c* ~" A
- #define DMA_PRINTK( x... )
5 A' t* _4 D' v% e* O% k - #define DMA_FN_IN$ @+ b+ S! o9 }7 E; N1 G+ R& g
- #define DMA_FN_OUT! E3 d9 u% n# ]. s) P. W
- #endif
1 A0 _# r- h$ P
: K, G: g! K1 Z0 ?* m% @/ U- #define MAX_DMA_TRANSFER_IN_BYTES (32768) E* d$ o& E. _; U
- #define STATIC_SHIFT 3
5 e2 ?9 a" Z7 ^. ? - #define TCINTEN_SHIFT 204 C2 @* A6 U3 p( q' ~ `8 W
- #define ITCINTEN_SHIFT 211 ?4 d, |2 A- `2 A$ s- y
- #define TCCHEN_SHIFT 22
' I4 | V5 B5 g; t5 F* O$ o# m3 I - #define ITCCHEN_SHIFT 238 ?6 u" q6 k- o/ p
; Y; f; X8 S6 Z* ` m7 F- U- static volatile int irqraised1 = 0;
( U; e+ o7 a! U; l$ x. l" J, B! J" g' M - static volatile int irqraised2 = 0;
# \; r, [) ^0 ?) a9 E. Y2 T' e8 j6 u
- L/ {7 Z) R# q4 Q5 z- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' f4 U4 c/ l1 T- i1 w
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, \9 q' E& |$ X* z2 ]" } R2 L6 J - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ J" x7 Z9 j1 g4 ^" P' L: c9 V; ~& V
% V( T& {5 _3 B4 I) r$ ^: y5 J- H& G$ p- dma_addr_t dmaphyssrc1 = 0;
. P N( H; {$ h( d$ u/ a) T* z - dma_addr_t dmaphyssrc2 = 0;
3 B- f [5 w% H8 J+ a! | - dma_addr_t dmaphysdest1 = 0;
( Y- K% ?: \3 R2 a - dma_addr_t dmaphysdest2 = 0;
, E8 u$ l# P6 A+ ~1 ^7 \" ?6 R" n- N - + {/ \; Y! z% u, c7 e7 A, H
- char *dmabufsrc1 = NULL;
5 l$ e0 o( f' X% E1 ^6 ~ - char *dmabufsrc2 = NULL;3 a! y* r6 C( p9 Y+ L5 u! w
- char *dmabufdest1 = NULL;: C8 ^4 O3 i: H) W* e* M# d
- char *dmabufdest2 = NULL;2 o; r+ E2 P1 N2 w, O' Q
- 7 u& o) M5 ^/ c* d' h
- static int acnt = 512;
+ l% s, |: G& P7 x! `* x/ N1 h/ @# N - static int bcnt = 8;4 E' w1 q5 r M+ a
- static int ccnt = 8;7 _ J# A* u. o! o" g. d1 M$ I
5 o5 l7 A' Q5 E' U0 |/ i- module_param(acnt, int, S_IRUGO);7 B1 U2 _: o( Q7 C& U, a
- module_param(bcnt, int, S_IRUGO);
; A ]$ m: I) C - module_param(ccnt, int, S_IRUGO);
复制代码 & K% H" a- c h1 G
( m# |: f+ P2 g
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用) T: v' p; g# a8 x5 P1 ^
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; E q/ D/ g 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
$ k$ Q; ]2 a# Z# [
6 N* e/ b' L1 P4 V' _) Q- t9 u) d0 V$ h/ |
|
|