|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 # Z3 f5 z8 M5 {2 D5 L3 y
- [code]EDMA sample test application
. P8 Y! A7 }# i: {' Y7 o - /*
1 Y ]! m" n5 p1 X- z - * edma_test.c
/ n; R8 E. `- h5 Y: E0 I- C, G5 \ - *2 {5 C. ?* l: z1 q: N) k' [8 l
- * brief EDMA3 Test Application
1 b3 ~( @0 S6 B7 t - *
/ L& W1 V( Y7 T2 d N - * This file contains EDMA3 Test code.. b3 P' ^. X+ V, Q. N
- *
; i6 Q# ^/ r# r) r - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE& r' `( {! z7 P! u- ]
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 {) m+ Q% j( ]# P0 |, W2 x8 \
- * TO CHANGE.
/ i+ U3 u5 ^* o6 V - *
; ^/ Q- h/ R& a, Q1 ~ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
9 q5 D1 B7 ^( w. y+ a/ Y5 I; v - *
3 g. t* Z! X2 Z, x. y - * This program is free software; you can redistribute it and/or
5 e. a: r3 b, Y, b$ D$ x% K- x5 x - * modify it under the terms of the GNU General Public License as
& o5 P% R/ h& T- m; s5 w) p3 l - * published by the Free Software Foundation version 2.6 Z5 o- t# v( F1 L. }
- *4 x, q) V/ M7 P
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any) S1 l, G: i& J( X8 y& g0 D
- * kind, whether express or implied; without even the implied warranty
- A: {4 r# w' {; B - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the g+ w* N1 r5 v- x
- * GNU General Public License for more details.+ ?% h" w! {. s" K8 }9 [: ?
- */
B9 J0 }6 k U8 K- O4 r8 I$ B- g - 3 K3 J# y/ M. A) h- d
- #include <linux/module.h>& I4 j* ~# H/ }; K
- #include <linux/init.h>8 s) e3 b8 {$ X/ |2 o
- #include <linux/errno.h>
$ P# I' `3 T, D* A" q2 M2 ]% n - #include <linux/types.h>
4 ?4 j2 h( e4 q! _: E6 R - #include <linux/interrupt.h>( `* Y& J& [" e, n. p
- #include <asm/io.h>) s; l4 T# o/ C0 n' {( L8 K
- #include <linux/moduleparam.h>
9 ~! n% W) u- Q - #include <linux/sysctl.h># J3 j+ I! X [. F! g
- #include <linux/mm.h>/ s2 c5 X, i. q5 K; v. }' x- a
- #include <linux/dma-mapping.h>+ r0 t3 {! o, p9 g+ m: M
I; e e' G4 n, z- #include <mach/memory.h>
; W* Z1 F- K; p6 p5 C - #include <mach/hardware.h>
' z! r, J7 \8 g - #include <mach/irqs.h>6 G* h) H9 b O; c5 {% c
- #include <asm/hardware/edma.h>+ B, f0 |" q) @$ ]) ?
- t. S& q. v1 g- #undef EDMA3_DEBUG
`9 W& o. N8 j9 I" {8 w - /*#define EDMA3_DEBUG*/6 _: S$ ^: \! L% `; _0 W# Q
) R7 u4 g7 J- X- #ifdef EDMA3_DEBUG/ e! r. D( ?- R G+ D/ d
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
0 v* C9 f! Z- A# X) s - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
c& o' p- }- l0 D/ ~5 I1 o - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__), Q1 E8 N2 C- l$ U3 z7 l3 B' \
- #else
2 n/ O5 z0 s# N, ^" e1 s4 y0 h+ C - #define DMA_PRINTK( x... )
1 x4 ~6 R5 }: z2 h7 Q - #define DMA_FN_IN! u, c8 s' F: V& u4 f4 B& ?
- #define DMA_FN_OUT
" O8 p) D# @3 R* P0 T3 p - #endif( g; U" f6 E( F! F o3 Y( z
& b6 ^; Q, ^6 z" M, S/ X- #define MAX_DMA_TRANSFER_IN_BYTES (32768)6 f9 t9 J( r! `% r9 K
- #define STATIC_SHIFT 3& W' ~' T4 V) T H0 p3 A
- #define TCINTEN_SHIFT 20
5 R& K c; U! K! @* |: T' W - #define ITCINTEN_SHIFT 21
) t1 U" H( F d R+ W7 U& B - #define TCCHEN_SHIFT 22
3 H+ i) b4 M( I1 |; F. T - #define ITCCHEN_SHIFT 23& s3 I2 Q: j0 P8 K9 s4 {; y
- 7 S1 |$ b# K) D6 W
- static volatile int irqraised1 = 0;) T. V4 r" r8 m* J8 V7 y F$ x2 p
- static volatile int irqraised2 = 0;
2 a1 G! b, ^; d3 d- I
. z. _" V$ R7 ^# G! i$ ^) y+ E- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: p7 R6 ]3 y" c7 T6 F, Y
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 I3 X2 n5 a# E/ _. @) K6 ? - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* N/ F/ z% K/ f8 o# \" S
) S0 ?% P# _7 \- @- dma_addr_t dmaphyssrc1 = 0;! p: g$ C3 e8 C8 {
- dma_addr_t dmaphyssrc2 = 0;) a2 @! e: A5 y0 t+ \- U) ]
- dma_addr_t dmaphysdest1 = 0;5 E( Q ` H9 c8 W0 A
- dma_addr_t dmaphysdest2 = 0;7 D! T) |) j. f- f0 P
4 B8 o4 q/ a2 f' S- char *dmabufsrc1 = NULL;5 l0 U' V2 m: s" e8 t6 ]
- char *dmabufsrc2 = NULL;
, Z& U/ Z* _. S- e! F - char *dmabufdest1 = NULL;
0 D& \9 {' R" ?8 Q - char *dmabufdest2 = NULL;; X0 b; ]+ ~' |% C/ i+ R
- 9 g) G7 ], T1 D4 u2 o1 f/ `
- static int acnt = 512;
0 O* a1 b+ {: E, g - static int bcnt = 8;9 t7 j' I2 r8 C# X$ J W
- static int ccnt = 8;( o( [) S/ l' g$ J+ R, u3 g- T
8 j S& U# B+ ~( J7 ]- module_param(acnt, int, S_IRUGO);
k& X0 U# }0 S) A' K. x$ ~ - module_param(bcnt, int, S_IRUGO);
8 Z- X) @4 B! W; T& G: V - module_param(ccnt, int, S_IRUGO);
复制代码 " x* G; p" M \, F- f$ }+ ]
2 ^. Z/ f- _% u9 N E* Q& U7 `& w
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用4 I" i! z5 \( ^( g
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; ~0 p* O1 f2 j. i+ L' m
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 s; W) w8 O3 g4 F- Q( ^
, W" L. R, m, k% k
' c! J% j9 R7 p4 i* g$ `1 R |
|