|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 h: J; s4 f `. Y- [code]EDMA sample test application
1 @6 z# R2 g! u7 ]1 d! t. M - /*9 H& I0 ~, O2 y
- * edma_test.c6 G: }7 `2 R: |3 h
- */ s$ {' P2 a# [2 q( S
- * brief EDMA3 Test Application
# Y e8 v( }" J$ v' G - *
/ C2 s* k* p; \8 V; f9 I9 D3 F, x - * This file contains EDMA3 Test code.
" n5 l8 \. o, A1 c9 P - *7 G0 N/ v" D4 T9 H- S6 h. M; L: l0 e- b
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
6 r3 }5 l6 ^ z" t* F - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
\8 ]% E0 `1 O; A5 R0 X - * TO CHANGE./ s' v2 d) A1 s5 E
- *% i* `7 G) u+ B4 [* y6 P
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- @* U4 Z3 f# h, D% G - *9 k* O% u# {; Q( y' Q
- * This program is free software; you can redistribute it and/or) ~% r8 F& d6 `# c
- * modify it under the terms of the GNU General Public License as; L* l, T' M" @8 u* }9 h0 w
- * published by the Free Software Foundation version 2./ ~" |7 Z& S# }6 G
- *
" v" ~8 A6 h6 ?( a2 V& r! P - * This program is distributed "as is" WITHOUT ANY WARRANTY of any% K) [* ?) T/ _5 T- u
- * kind, whether express or implied; without even the implied warranty
, o4 n. ]8 E! \$ q$ \6 u2 r4 S - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the D7 M" Y: S; P y4 b* Z
- * GNU General Public License for more details.( s& a q$ {* v0 |+ k
- */* N; j& D; c, Z/ L$ M0 n
( v: E& Y! O' Q* j" M- #include <linux/module.h>8 r& w( D3 V( K7 K
- #include <linux/init.h>
! q3 T& J! o. F; X - #include <linux/errno.h>
) D: Z- r1 w% Q" T- {# h - #include <linux/types.h>$ {' o2 Q2 s( Y, U2 m6 h0 G. ]% K2 P
- #include <linux/interrupt.h>
% v4 y8 z( w+ B* m, ~ - #include <asm/io.h>
# X; G6 i* p% } - #include <linux/moduleparam.h># w* ~$ R! U6 S
- #include <linux/sysctl.h>
( U* k1 ?" b8 w - #include <linux/mm.h>
) |8 Q9 @, r! G* }# B" K6 w - #include <linux/dma-mapping.h>
9 @* p" G4 p) r# I4 \$ F
X8 a* v& J3 _- #include <mach/memory.h>9 t+ e8 r& h3 c" d( D w
- #include <mach/hardware.h>
7 d o3 A4 Y0 o$ T6 j3 W/ Q - #include <mach/irqs.h>
* {5 q. i' P" {6 P3 N - #include <asm/hardware/edma.h>- J1 Y* C8 o9 v3 r
$ t+ K/ m: w2 v- a! ]! C; F- #undef EDMA3_DEBUG- ]8 _0 H2 C9 p0 Q8 A/ j$ ^
- /*#define EDMA3_DEBUG*/ I0 d; ?5 ~& h4 m
- 4 i; G- f' X% l' X: E
- #ifdef EDMA3_DEBUG
! i0 w( m' n, u9 ^5 r1 G8 l - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
' H) q; l2 Q" ^7 p$ y) ~$ C - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
: n& i( u4 H& ` - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
Q; V% G/ s4 ` - #else
7 \# H. a& l9 o- | - #define DMA_PRINTK( x... ): |! o: C+ b4 |2 q2 |
- #define DMA_FN_IN
3 T+ l# n$ s8 {5 T* O - #define DMA_FN_OUT
; E: h, ^8 V8 [. [+ Z7 [- g - #endif) H" x4 L+ q' J T+ e, y
- * g& _8 h5 A; b
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
5 h$ y$ F) W0 ?" G( p9 q - #define STATIC_SHIFT 37 m4 D H$ I( S7 P/ _( V6 D" m/ `
- #define TCINTEN_SHIFT 20
: i. d$ X2 S& U% l: U - #define ITCINTEN_SHIFT 21; z V3 G8 p) r& P. u6 a
- #define TCCHEN_SHIFT 22
2 M- J- q+ ?' S M% a - #define ITCCHEN_SHIFT 23& g; M5 c! Q4 ?- r6 D! Z% o
- 9 T: R- X+ A! ^
- static volatile int irqraised1 = 0;; a4 f9 Z+ [/ n& m2 U0 _
- static volatile int irqraised2 = 0;+ W. I3 G* a7 \6 f
! v6 S2 y4 H k- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; B m5 ^& F( E0 n
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, F* t/ k" S# \) n; i0 k4 J - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 M8 h- B% C3 c6 g2 Q - 1 z* n0 Y' S; k# ~8 S( H
- dma_addr_t dmaphyssrc1 = 0;6 ~( U7 ~5 N* S- B- K+ j
- dma_addr_t dmaphyssrc2 = 0;
2 X! v/ [ a7 t9 V/ b% m; |, |9 e7 J - dma_addr_t dmaphysdest1 = 0;
B7 \( q$ F* @% G) h7 T - dma_addr_t dmaphysdest2 = 0;
2 @# a6 w0 B3 t - 7 f1 c l4 b' N4 Y9 b
- char *dmabufsrc1 = NULL;3 q) t* k. i. p/ x: M7 o, o
- char *dmabufsrc2 = NULL;- c( g+ z0 N+ p2 y2 S. c
- char *dmabufdest1 = NULL;* z# P: d6 |: [- Y& e
- char *dmabufdest2 = NULL;
, `# u/ k+ J$ n3 n( u& M
! ^+ S% I: L& J, g/ p4 P/ }8 j1 E- static int acnt = 512;. l* {) w$ Y! |: L% j
- static int bcnt = 8;% Z9 V4 Z/ d6 ?# l% j
- static int ccnt = 8;. m1 @! g. Z& K2 I$ t" q
- ( o2 f. ^( ~, X* r) C& m
- module_param(acnt, int, S_IRUGO);1 n( {6 M! w; C
- module_param(bcnt, int, S_IRUGO);2 L6 I6 ? h6 g# {8 x
- module_param(ccnt, int, S_IRUGO);
复制代码 * m6 k \/ c4 l0 @8 \0 |. o
# i8 ^. C$ M7 F
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用( O: S% O; H, r, o) T
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
# E, X! E8 X/ z$ @* t 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ r) m0 V: c+ d5 u* G
# @% O R$ B' p, C7 D4 Q
0 g+ E Q. i( J5 Q |
|