|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
8 x# T: G) R* _$ z- [code]EDMA sample test application
& q6 n# B9 Q# l( h8 N% d# E& C ] - /*
+ t4 t' \2 \8 m/ v0 }5 i2 b - * edma_test.c
- S+ _5 [7 B3 R. g1 [ - *
3 ^3 }. e) i+ i$ `6 v& R2 { }5 F - * brief EDMA3 Test Application: T4 Z0 H0 C1 u) E' \; m6 q
- * ~1 f0 ]! ^7 `9 k3 p; d$ X
- * This file contains EDMA3 Test code.3 ~/ G/ r, p3 g z/ W% n, E# H
- * Z( n8 G4 z" V! [
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE, f' r7 W. U* D( J
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT6 `# i2 L4 S) b% D7 k$ Z3 c
- * TO CHANGE.
. s! g2 n! N- i1 _( |) j7 g - *
9 U9 |2 `' D( S. s: e8 P6 A4 w4 x - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 l% U+ [9 T3 N8 d, U5 m7 m1 | - *
: y8 H+ R/ b+ h* R3 f7 O - * This program is free software; you can redistribute it and/or% }! K8 V( g8 Q" U( Y( X
- * modify it under the terms of the GNU General Public License as# N' o( o( I% l0 P: t$ M, W
- * published by the Free Software Foundation version 2.
- ^* N5 w; V. ]) L0 i5 F. Y - *. F4 s% m% F: L( N4 i5 s2 t" M
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 p$ W) ?8 ~+ U! r w2 l- X8 j
- * kind, whether express or implied; without even the implied warranty
4 n$ M/ Q3 c+ o. o( d - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2 \! u4 P) W; r1 W! q - * GNU General Public License for more details.
7 f1 ~0 D( z5 \0 d d7 ? - */
h9 ~( V( b% k- {1 |. a
4 c4 Q' {2 U$ ^* v. I" e; U! J% ?- #include <linux/module.h>* O5 s' |6 d2 L. O7 r
- #include <linux/init.h>, z* c6 N/ P- R6 x% d
- #include <linux/errno.h>, Q$ X# o# v; a" [' J* g; Q
- #include <linux/types.h>
8 r7 T3 \" f! c! D7 h - #include <linux/interrupt.h>* L* M: F: T" f. \& h
- #include <asm/io.h>+ q8 q9 _! K$ P: Z4 e
- #include <linux/moduleparam.h>, j+ O$ f& l0 D- R5 ?1 a A) ]/ V4 N
- #include <linux/sysctl.h>
! i& U. j6 c$ C% `8 I - #include <linux/mm.h>
# Y8 M$ k1 C! y' [; c7 I. L1 R - #include <linux/dma-mapping.h>$ Y; b8 Q) F4 ?
- M6 a5 ]% z" o$ u- #include <mach/memory.h>1 J- X+ r9 h5 T3 t$ I
- #include <mach/hardware.h>
" c% w& l; R" _8 V7 P( t( M - #include <mach/irqs.h>* @$ d' v6 {! d+ k3 V- o% K! i
- #include <asm/hardware/edma.h>+ R0 O& Q7 g( C# K
- / [' g. V p+ U. _. {2 c
- #undef EDMA3_DEBUG1 e& t9 O4 a4 u; T3 C. a4 |! Q
- /*#define EDMA3_DEBUG*/
# ]' N$ ?4 F5 X8 m
( h% [) Q7 U( K" m4 e- #ifdef EDMA3_DEBUG
/ F6 n7 _0 x. b) `" B. a - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)) v3 N7 n- _0 e K( M
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
" x! z; x) T# `0 P ] J8 ] - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 |: t3 r* w, C( G4 w; H
- #else. f( k9 l( O! p3 D4 r
- #define DMA_PRINTK( x... )3 K8 L3 I0 n, u" Z2 ~# v
- #define DMA_FN_IN
3 l1 m$ C( ^" O - #define DMA_FN_OUT3 G1 \$ g [) x, I
- #endif0 D6 K6 V+ B2 K5 g1 Z; \- P. P6 L
- 3 v! E" F) m. @# Z Q! A2 a
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- t" i& t) Q5 o8 t7 k - #define STATIC_SHIFT 33 G6 T' x% v$ ]$ B! B
- #define TCINTEN_SHIFT 208 ]! \* d% S/ H2 k7 f/ O
- #define ITCINTEN_SHIFT 218 e' V5 X4 _; i3 n7 v* N) ~" q
- #define TCCHEN_SHIFT 22. X( D4 V3 g6 r) @0 ~, h+ J9 H
- #define ITCCHEN_SHIFT 23
: q* C, z" P8 z' M - + ?0 v1 P/ ~% [2 o
- static volatile int irqraised1 = 0;$ L( r/ I. u, \& Y; d; J7 Y. {
- static volatile int irqraised2 = 0;
& i3 \! z' l% F% x0 l1 e
8 ~, |5 O" G* O3 X, J/ P" r! e- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% G4 g9 l' ]1 l% V) T: w - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" @8 u y: h# U! a3 | - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- Q& Y$ f" x! u/ Q8 ] - # P& \) y$ i8 H& m; ~; i7 S
- dma_addr_t dmaphyssrc1 = 0;6 M6 x$ c& @/ u$ u2 W& y3 M
- dma_addr_t dmaphyssrc2 = 0;: h6 O1 x* a" f2 T6 W
- dma_addr_t dmaphysdest1 = 0;$ r/ M4 y* X. H# ?% V6 T
- dma_addr_t dmaphysdest2 = 0;7 g2 l2 v8 H3 C$ Q
- 9 y2 Q7 A5 v2 G9 z f$ w5 z
- char *dmabufsrc1 = NULL;
( {. h u$ H* R/ z2 D+ x# X( m - char *dmabufsrc2 = NULL;
* r3 _9 X% O. k& q* [ - char *dmabufdest1 = NULL;% ?! A6 w) M% s. G/ M, v$ ~
- char *dmabufdest2 = NULL;
/ o# G+ {- ?' O) y$ I) w - - { {5 z8 t# U, Z
- static int acnt = 512;. ^1 X: l( w4 W7 N& E+ i, `4 [
- static int bcnt = 8;) A$ G! }2 u3 F2 E2 r$ j/ K
- static int ccnt = 8;8 n' q' d* r; S3 r6 u k! q
- ) _) m7 P9 F! m, ^& \3 V
- module_param(acnt, int, S_IRUGO);4 R$ y9 ^9 t0 n7 n, H4 l
- module_param(bcnt, int, S_IRUGO);
/ g: }$ d6 g7 K0 W; k- k - module_param(ccnt, int, S_IRUGO);
复制代码 $ W. F" }+ {& U5 [5 G3 B% _) f
% _6 ~' N' Z/ \' e
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
+ F' B- M% t# Iarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
' {* F* J% B8 G* C 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
k3 F; H/ d1 h8 t& V I$ w
$ R( m3 n- v( m' \# g; b0 M3 l+ P- J' K7 F3 K) v
|
|