|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . A% ?/ {+ L! z# G
- [code]EDMA sample test application
4 E8 X4 a' I1 }. y& c# N0 `( s - /*) T7 [: Y/ w) u1 f; y
- * edma_test.c, X: c$ ?" ?4 ?1 u) O
- *7 S; M0 J5 P* O5 b/ ]
- * brief EDMA3 Test Application
5 R- s# s/ z `; o* M - *
$ D1 {% |, ^6 \8 W - * This file contains EDMA3 Test code.$ \1 a: J* H ^( z' V, U( K8 n
- *
$ a9 U* ^. N [5 l9 I4 F. ] - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE* L1 {2 u y- A5 j
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
0 R: x/ n- x8 j9 o1 y9 \ - * TO CHANGE.4 U M3 r [ D! |6 q
- *
9 R: J" E& b0 O- ]" T4 ~+ F- M - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/* I% x9 {1 K! D! t1 @# X0 S
- *. ^$ B4 i7 K! f' s1 k* T
- * This program is free software; you can redistribute it and/or Y5 I" o3 A/ ?2 G& {# m' d
- * modify it under the terms of the GNU General Public License as
# o( Y& h) i9 V2 X+ A, @ - * published by the Free Software Foundation version 2.& ?5 b4 ]0 A) H% z# g
- */ m+ o, e5 Q9 l% J5 m8 \/ i
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any/ d; g H3 c% O; I8 E
- * kind, whether express or implied; without even the implied warranty
5 J& s( f9 d& \1 \5 a0 A# O7 b9 w - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& i$ @9 l" I, u2 m7 U% P. i - * GNU General Public License for more details.
1 P5 F, D& D; o. `& o - */) M$ t1 I$ s; s+ I& m& N3 K
- # }' n) t/ n ]
- #include <linux/module.h>( X d2 \2 `- m5 |+ K
- #include <linux/init.h>
4 {8 I$ v- ~! O4 x } - #include <linux/errno.h>
; X" U1 i7 W' m4 R) o8 s! Y' Y2 I - #include <linux/types.h>
, `3 U4 Z! F6 ? - #include <linux/interrupt.h>
9 C5 M6 f$ q; ?' t( \ - #include <asm/io.h>) m0 W1 B9 h+ C- X4 `3 p! A
- #include <linux/moduleparam.h>
$ _* U' ]8 x! L - #include <linux/sysctl.h>
4 a4 L: n, i5 D+ A. T0 }) P) v, P - #include <linux/mm.h>
8 n' X X& m; } e2 W5 h; o - #include <linux/dma-mapping.h>
# n+ ?6 }. j2 d; V8 N) j# w- i - 7 ?8 l9 i( D+ r N" q( R
- #include <mach/memory.h>( T# V7 \; V Y- O1 \! X/ \
- #include <mach/hardware.h>! \$ b% G. C/ [, t+ A; y- z
- #include <mach/irqs.h>
M C$ h0 M! J9 [% |( r T4 B" o; O+ } - #include <asm/hardware/edma.h>) G3 o; u/ g$ t+ l6 i
* R( n- f9 @- Q+ ~* X- #undef EDMA3_DEBUG6 K, B" ^/ h* r
- /*#define EDMA3_DEBUG*/
8 N2 [) H! m& g) J& P1 R% U$ Q
! x- |" @0 P* P/ K- #ifdef EDMA3_DEBUG, Q" o2 T2 E0 |/ `
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 E9 n3 I/ ^: i, j5 ^: t0 v0 c7 k - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). p& P9 I( R, L# f
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)) I3 z1 \. D6 D; W) {2 f5 Z
- #else0 g, `- C7 G/ X; N7 @# g
- #define DMA_PRINTK( x... )
; @! P# |) I' f7 t9 l( ]# H0 r, ? - #define DMA_FN_IN
2 ~! o$ t) N7 p, f! z) e$ M - #define DMA_FN_OUT6 q, m# _; `3 I& d s* \$ V; Y
- #endif
4 N& r$ l; o3 s' m- j
- C0 w0 ~4 A0 M9 \9 B H- #define MAX_DMA_TRANSFER_IN_BYTES (32768)% E$ N o* F: J3 H5 L! B. c9 W* x
- #define STATIC_SHIFT 3
# b( a U5 `7 `( M- r - #define TCINTEN_SHIFT 20
9 p$ g) @) }/ b- O - #define ITCINTEN_SHIFT 21
" C0 ]" w2 r- L) U8 [5 |8 t( [ - #define TCCHEN_SHIFT 22
: N$ e2 `: }1 s( P/ z - #define ITCCHEN_SHIFT 23
- M& g- V, J0 R8 E9 F: W# n
3 M. G& `, b% B- static volatile int irqraised1 = 0;
' K. z' t) ~. L# S - static volatile int irqraised2 = 0;
, R7 p( o9 h/ h8 Y4 Q% p+ u
) k0 q: F( p4 @- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: w+ V3 U- `' G( d. v - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) e _0 [& h# g' {/ k+ j
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 |$ Z3 M A i
' K, ]: p9 H5 Z/ d- G5 Q- dma_addr_t dmaphyssrc1 = 0;
1 m' N) ]+ E0 N3 t - dma_addr_t dmaphyssrc2 = 0;9 B# }6 B/ K B* \( d( S6 \+ C
- dma_addr_t dmaphysdest1 = 0;
) d8 e% D! @. @- I; n$ |5 X - dma_addr_t dmaphysdest2 = 0;
2 g+ }: n9 r$ n" n$ \ - + ]1 c- o j; U f- H
- char *dmabufsrc1 = NULL;
' _* }" D+ ?% ?9 M3 F( C7 ^! ^ - char *dmabufsrc2 = NULL;! n2 L. Z, V1 J P( S
- char *dmabufdest1 = NULL;; T* q0 Q: Q! f, ]' \9 F) i
- char *dmabufdest2 = NULL;
% y- U4 [8 {' d' k$ K2 t* q" L - 7 M, G5 i O" I# N \( i. X, _
- static int acnt = 512;
1 Z5 J3 E: A7 l2 P4 D - static int bcnt = 8;
2 @* N6 F; W1 t8 x8 ? - static int ccnt = 8;
0 a" H6 A$ D, q7 i
, L/ f" U- q1 _! A# H- module_param(acnt, int, S_IRUGO);6 E, _; F5 l$ I7 ^1 ~1 n
- module_param(bcnt, int, S_IRUGO);
$ f2 f( }5 q6 d: F9 L" _ - module_param(ccnt, int, S_IRUGO);
复制代码 - H# P, o! V- X" A9 d3 W" B2 ^3 V2 s
) N; E( ^, T, u) ^
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 b2 F8 `. N, u3 c& U6 B; s5 y6 r: Carm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
6 q3 W! D9 ?- c; @: e% F4 i% | 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
; |& S* t: D; b4 u8 r6 [7 L9 |5 q
" G/ f' n. P5 L% |5 {, O5 P0 n' h, \$ U' T1 [+ |
|
|