|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 & S) \% y1 w1 E: g: M8 P( C+ I
- [code]EDMA sample test application
8 k0 A1 P* A9 X/ I/ Y - /*
! D2 h% S8 ^2 ] - * edma_test.c
; P; B3 M. u+ g - * v: |- T( G! F1 l$ n8 g6 E
- * brief EDMA3 Test Application9 k- u5 ~3 V$ `$ _
- *
- K: a8 ?% C% y; r% ]( F - * This file contains EDMA3 Test code.
6 O, u9 D3 F: v# a! l9 S - *
! E. z0 t9 e- n6 q. y7 f; o - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE: v; Z" b& {) L" m6 y7 J8 ?
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT @& K1 N+ Y* N, S0 P. r- J# s
- * TO CHANGE.
], T, ^/ A! f; j4 E* Q& r - *
% R" J K! O1 t. k0 w - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/6 L9 d; _! x; e o
- *
4 a' J2 z" [/ c, s5 X% s - * This program is free software; you can redistribute it and/or; \- [$ f3 N5 k8 @3 u7 e# `5 l/ i
- * modify it under the terms of the GNU General Public License as
' Z7 i4 P* n1 K9 V# n1 S( B - * published by the Free Software Foundation version 2.; T3 F3 R$ H% Z7 D! c
- *
' a2 O t: K. ^3 ]% g7 D1 \* @, _ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
% l9 L' V% U0 W3 g. o - * kind, whether express or implied; without even the implied warranty
$ m3 w, N' _" h! V4 ?& L - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% I) G" ?% z3 G* T% t. r - * GNU General Public License for more details.
( G/ L, W7 Q! P/ m6 \' D& H - */
/ Z3 _# Z! s9 R7 `) P! ]
; H' R+ u& f ], B: s- #include <linux/module.h>" e: V) k$ X: r
- #include <linux/init.h>
" ]/ _* h1 K- n% P - #include <linux/errno.h>
6 p* H% |3 y/ q/ Y) j+ P1 h: o - #include <linux/types.h>
/ u9 [# @! h; Q+ M I7 T' ? - #include <linux/interrupt.h>
0 E3 I5 ?- }; |$ F - #include <asm/io.h>2 d3 L S. Y7 v
- #include <linux/moduleparam.h>( }- Q6 |! i7 v9 V8 ^
- #include <linux/sysctl.h>
( U1 J0 S: K2 o! K- u- M - #include <linux/mm.h>4 O* k/ d3 I9 Y+ l( h
- #include <linux/dma-mapping.h>
" o* R4 |( ?3 x5 i. l4 j
1 w+ E; C! h: ~. l) b; a- #include <mach/memory.h>
/ e8 [3 Y( o6 @3 n' v/ | - #include <mach/hardware.h># l" v# t, v. q( X+ Q9 m; `/ I
- #include <mach/irqs.h>
5 y! u# V% s% f; p% v1 w4 m( h0 f1 P - #include <asm/hardware/edma.h>5 }5 U& K; ^# E2 u! _
( I( z k+ H6 N- \- #undef EDMA3_DEBUG
1 v* _# P+ j4 b. r5 H - /*#define EDMA3_DEBUG*/
+ V, {. k4 W# g8 G
" I( R3 B! ?* |# F- #ifdef EDMA3_DEBUG
$ b) j Y. |0 Q; w. D - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)' u" x/ N4 p) k0 W6 W/ Y. r k
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
% a2 b8 S* t; T. `/ {2 l+ {% J - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)- X; V5 x8 f) [- j& z; }
- #else
# X- E2 z( C: k3 z X - #define DMA_PRINTK( x... )
( I) J+ U) S2 ` - #define DMA_FN_IN
% n1 N2 J4 ?6 v' o3 R7 v* |! h- `5 ~& s - #define DMA_FN_OUT6 @, e+ p' U* S# W
- #endif
1 L* q( Y) o% [/ A
7 o2 G( s* F' W2 K5 a$ ?) z: U- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
9 |$ P! d1 l- T$ C1 t. O - #define STATIC_SHIFT 3
. j' u+ Z4 A# A0 S2 G - #define TCINTEN_SHIFT 208 |0 p% F( T" t9 i7 g
- #define ITCINTEN_SHIFT 21
$ c7 a$ `7 w7 q/ \4 } - #define TCCHEN_SHIFT 22& g& v: m$ ~2 A% N B4 f. b
- #define ITCCHEN_SHIFT 23
5 o, [- i* R: t/ o+ U5 P: [. w - , ?' a# x" b( o- [0 k6 ?
- static volatile int irqraised1 = 0;
9 \/ l) p$ d& V& s9 Q0 d( P - static volatile int irqraised2 = 0;
9 t _* {' {% ]& }5 \" {( |
( _6 F# B7 R+ t$ k) {- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- \; O% o4 E8 j2 C - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 D: p3 m8 D! a( V
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) a4 ?# J/ Q, r* s: X
1 a8 e5 W4 F& A/ Q% g" K, O% c- dma_addr_t dmaphyssrc1 = 0;4 i$ }4 l8 w0 @
- dma_addr_t dmaphyssrc2 = 0;: x _: B5 l$ A' n5 r3 ?( }, W3 Z
- dma_addr_t dmaphysdest1 = 0;
& @( |, ]' g$ S A& e% D+ S2 ~9 x5 h - dma_addr_t dmaphysdest2 = 0;& }2 c( @3 P! X1 S4 a9 k
0 H1 r" V2 \$ e& O- char *dmabufsrc1 = NULL;+ u C7 N: s) w0 @1 b
- char *dmabufsrc2 = NULL;
3 v# y4 M) X# K( f+ z - char *dmabufdest1 = NULL;
( Q* u: y% d2 w( l+ B - char *dmabufdest2 = NULL;
# `* h) s( `0 |# r2 E7 ?' h O0 T
) T1 _0 B% S* t- `- ?& }- static int acnt = 512;3 V: l2 c* X1 M& E
- static int bcnt = 8;3 u& e% b! c: O' v
- static int ccnt = 8;
' M, T0 R6 G' ^+ G6 t - , b9 Q( b- ]) Y. y, c6 v! }! H; T
- module_param(acnt, int, S_IRUGO);1 r% [( C8 `5 C2 [4 Q% @
- module_param(bcnt, int, S_IRUGO);; @7 j7 \" h% |& k
- module_param(ccnt, int, S_IRUGO);
复制代码
0 J$ p& `2 V7 M6 O$ I0 D7 _. s
5 h* V6 t% Y1 k. a, d* C" i0 G 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
2 P$ X1 n+ q) P& \+ |; e" i uarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
# V" x; _8 I& h0 \& Y* K+ E 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
* o( b4 r+ E) V. |8 D* W+ U
, Q* N0 F0 r* m2 e8 k x' ^. D8 z/ W; V
|
|