|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 d0 ~3 s9 O2 E7 c- [code]EDMA sample test application
' I3 s9 t3 y" O* A% @. b$ F; W - /*
% R4 G/ U i" d: I - * edma_test.c
& \4 J7 _; M$ P - *
% \. b2 f0 n- X/ ?8 J& A - * brief EDMA3 Test Application
9 o8 z1 c# J" l+ d. x) l - *. |$ C' S6 e& s, V8 y+ \, ~
- * This file contains EDMA3 Test code.
" D+ E. m8 S9 ~! K4 j5 n( D8 C H& _ - *8 B5 Z8 f$ ]5 y2 _. C1 M
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
/ W# y' M! G& U - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT' }# V' n* F& ], S1 C( E
- * TO CHANGE.
" D$ b- @4 N ~! q) ? - *. {( E u2 a9 e; C' S+ }) s
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 h; `) t% t0 i7 ~ - *
5 Y o( k. A) B- Y7 S6 _ - * This program is free software; you can redistribute it and/or) V9 `9 t" j, k. L
- * modify it under the terms of the GNU General Public License as
7 u% ~: u% S8 j. s6 Q. t8 I - * published by the Free Software Foundation version 2.) x% _/ g6 v$ t: D, f& ?
- *" B% ]+ B5 i3 R8 \3 }+ H
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any Y" ]% H* f. {, n \
- * kind, whether express or implied; without even the implied warranty
% d7 Q4 [3 L7 ]9 S1 w9 o" s+ ?0 @ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* j1 | e7 ^5 s2 @- C8 m: d) q1 r) J
- * GNU General Public License for more details.
! Y6 l; B# ]- d+ o* } - */( H7 h. U3 p8 ~" b& V0 B0 o
- ! Z: c6 Z5 V2 ^) {# ]3 `
- #include <linux/module.h>% ?. ^- {! E. ~& @% l0 k5 @
- #include <linux/init.h>2 g) d' e9 [$ J7 @
- #include <linux/errno.h>
% T* z% q: R1 u% z - #include <linux/types.h>
* g' S& ~" |+ O; H - #include <linux/interrupt.h>6 [# E2 s- l% B1 Z
- #include <asm/io.h>1 n8 S- z9 L& j$ M4 z' _
- #include <linux/moduleparam.h>
5 r* U1 b" `% k! K - #include <linux/sysctl.h>
% n) m9 Y9 G( k2 K9 l# G - #include <linux/mm.h>0 ]# u+ j+ L5 T% ^3 `
- #include <linux/dma-mapping.h>
?4 d& g5 R- e3 D( m% J/ }9 ]
5 G% t& c4 x0 v% P. A- #include <mach/memory.h>* u8 f/ x9 y( s% m v7 X7 l6 m, n' r6 X' M
- #include <mach/hardware.h>& x3 N, v: H9 Z# y
- #include <mach/irqs.h>8 l1 X% E( W, f( b" w5 K
- #include <asm/hardware/edma.h>* w+ {) Q; V) l, n
- 1 D0 C% w% f$ b+ J$ A' b
- #undef EDMA3_DEBUG% F( D$ w+ N" I) p/ m1 M
- /*#define EDMA3_DEBUG*/- G$ A$ x6 L* K6 T( [3 r S
- + M8 r3 ]/ w, o4 o G4 K0 I5 q& x
- #ifdef EDMA3_DEBUG
# Z5 w, R3 @+ H% ?4 Y/ k - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
, G% t3 `" r: V - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
/ d# K; L2 f f ~8 k - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ y$ `9 F& Z' w4 i+ e( y - #else
7 C9 j8 q/ I% u9 t$ A3 E - #define DMA_PRINTK( x... )* n: [, Z( m6 y6 B
- #define DMA_FN_IN
* @( v1 n- J5 W! F# ` - #define DMA_FN_OUT
/ B. v& r( O. |6 m( x9 z! ]' w' a. n - #endif |) V/ F" _) _+ f& n0 _# J
- * d, Z2 o. _4 E2 T7 M# ^* @* F( q- o
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
3 c8 f, T: a) y% w - #define STATIC_SHIFT 3. X. |3 ]6 E4 s/ E. s7 k# S
- #define TCINTEN_SHIFT 20
" j5 `0 z+ T' f1 [ - #define ITCINTEN_SHIFT 21
, W9 V/ C0 {2 J, d - #define TCCHEN_SHIFT 22
4 `+ e9 k% N D - #define ITCCHEN_SHIFT 23% Y0 L/ u% i& s$ Y0 u8 [3 U$ W1 Y
* x4 c8 m1 D7 V, ~( L- static volatile int irqraised1 = 0;
$ Z" R8 X( ?( Y - static volatile int irqraised2 = 0;* w$ Q$ U, b" t: w) t$ w' p
+ v" B2 x* K' F/ ? T! C/ f/ X- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% d( `/ Z* } |$ \; f! v, e2 [+ \ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& x# |) Y& t8 Q" x. u - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: \. I- T7 a( x, a5 A% v5 A
* ]' X8 ]) |# V& w4 a, B8 B- dma_addr_t dmaphyssrc1 = 0;
( l( |# x n) V: z2 r - dma_addr_t dmaphyssrc2 = 0;
* i) ?2 @/ M! A8 ~ - dma_addr_t dmaphysdest1 = 0;
* x* }( ^- J" `- G2 ` - dma_addr_t dmaphysdest2 = 0;
( K: M! c6 [0 G1 u) ? j* I6 N
9 ^" I! i% e u& s- char *dmabufsrc1 = NULL;; D: K: h( z( O4 q
- char *dmabufsrc2 = NULL;
; t; b# H$ r/ n0 ?/ C, k" a - char *dmabufdest1 = NULL;2 F$ H* o9 t g- X" e3 w. L
- char *dmabufdest2 = NULL;
& S" x8 Z+ V- f/ t: p6 U
/ q, y& e6 Q. T' V: l% E- static int acnt = 512;
- v+ r" |7 N. A/ X8 K+ y - static int bcnt = 8;) F! h& l. I% a$ o' i+ n2 S# v
- static int ccnt = 8;
/ Q* J' c/ N! c3 m, P
$ W2 d0 K0 E8 s- module_param(acnt, int, S_IRUGO);+ C6 ?, D6 ]. M
- module_param(bcnt, int, S_IRUGO);$ z9 p9 a0 B1 ?2 h* v$ u6 R0 R' j
- module_param(ccnt, int, S_IRUGO);
复制代码 & ~3 ?6 R+ `+ y4 P$ J3 [
6 w; O5 w. U4 J; U 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
8 W/ v9 L! T- jarm-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 B$ l+ Z5 j- l, O% T2 u5 |$ F1 i
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% R& `. ^+ Y! ?
7 m- |- Y U9 f9 Z1 s7 y
3 k' I# _1 A7 G; v4 Z, r |
|