|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 X) E x m8 A- [code]EDMA sample test application
$ d0 V9 u6 N T8 |; Q8 P - /*
: b, e( a, g$ S6 p - * edma_test.c
8 \) I4 V M& \* H' y! c% U0 c - *
: `; n8 j1 N0 q* B+ ] - * brief EDMA3 Test Application3 t+ e4 c t. v; ?$ T+ h
- *5 @2 j+ L" Y0 @1 [* Y- `+ u- Y
- * This file contains EDMA3 Test code.
! A# F: M/ H4 f* ^/ v, L: B - *
9 _) d5 z) l z9 G- {+ Z - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE% P( j9 z7 x7 M+ h, x+ ^3 k
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% i7 t& r7 D9 H; [) z b( I$ R- U
- * TO CHANGE.* N5 W0 g7 C( R* o7 \
- *
! j5 u1 C* p4 L; ?. X* T' E* r - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
3 g/ `1 X7 p* ~! k, w( R9 n6 g - *
* F( Z; N1 j- ] - * This program is free software; you can redistribute it and/or- F O7 k1 _- l* @) n6 D' D4 G& \
- * modify it under the terms of the GNU General Public License as' M9 p7 `9 ^0 }5 Z) X' f0 z
- * published by the Free Software Foundation version 2.
: U- K- X" p z: u( E - *
2 a F5 l4 M$ I; `: p: e; o9 j - * This program is distributed "as is" WITHOUT ANY WARRANTY of any0 ^/ ~* B: W" N
- * kind, whether express or implied; without even the implied warranty
4 C! U% {) W- l( y- k& z# V - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the4 h7 @$ K; p1 @5 D
- * GNU General Public License for more details.
% R5 u: B# z3 t, ]9 W( Q - */
: y5 ^- s6 |7 S+ ]. G! x" v - / {3 ?/ E7 G+ n& p5 o
- #include <linux/module.h>9 G) T0 n. }6 [7 m/ {. }. [( @
- #include <linux/init.h>
( X- F* y9 {& G2 Z$ d: O) v - #include <linux/errno.h># @7 ?; [3 |8 m9 L
- #include <linux/types.h>/ [$ y* u7 U8 i3 [- t- T
- #include <linux/interrupt.h>5 o, p% B# S4 `/ S( H
- #include <asm/io.h>2 d# B# [- A$ W5 m; E8 _
- #include <linux/moduleparam.h>
' {+ n9 c/ b6 l% D4 c - #include <linux/sysctl.h>2 ]- L7 n( Q/ G6 z' {' [
- #include <linux/mm.h>
; S m9 j* l/ K; J: z$ H - #include <linux/dma-mapping.h>6 ^; a. l& x K, E3 e8 O/ E9 V
, \" F2 u- |8 b. N3 g. F8 Y2 Y: ~; ]- #include <mach/memory.h>- i5 p& t* P; f* _
- #include <mach/hardware.h>8 s/ I% {0 y4 k) ^5 j& w9 s* B; {
- #include <mach/irqs.h>
p6 |5 i! O+ n - #include <asm/hardware/edma.h>8 }! }6 U r4 s9 h2 Y3 E/ V6 Y
: ~; C, c/ C6 t- #undef EDMA3_DEBUG
5 G2 | K0 l/ t# { - /*#define EDMA3_DEBUG*/0 p/ V8 e0 Y% a! X7 R5 M# |7 a
- % l/ W# ? b& y2 B u& H# I* g2 \
- #ifdef EDMA3_DEBUG1 B$ |, F' p5 j: W
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)9 z9 ?2 d7 z4 A, u, m
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
! s( `* h* G/ ]# ?" y; K$ N' R - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) ^6 W& P9 Q! A! z' b4 u% H - #else
3 U% p! j0 `4 w4 }! S - #define DMA_PRINTK( x... )
! O) X h( ?$ M - #define DMA_FN_IN
; \, B: X) z% l6 o% i- K - #define DMA_FN_OUT8 p+ E w* B- Z+ R8 h' r C
- #endif
! K2 q3 U9 k$ w# K
1 J; }1 T' R9 `- w- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: o9 w, b( y/ Z g9 V | - #define STATIC_SHIFT 3
- q- f% y& E+ P# y) _ - #define TCINTEN_SHIFT 20
$ z1 k- S4 ^+ q- s - #define ITCINTEN_SHIFT 21& v; P$ v, c0 ?1 |2 e/ Y4 B1 z) V
- #define TCCHEN_SHIFT 22
0 }$ F! ~5 }5 q# ^ - #define ITCCHEN_SHIFT 23
. n$ T5 ^3 ^9 O; _ - 7 |& w& X9 X1 ^3 j/ Y
- static volatile int irqraised1 = 0;
) e! r6 G* [0 q& J' u! U - static volatile int irqraised2 = 0;
]% l7 `- M* P+ P9 }( q* K- |5 M+ m - 3 Q5 v$ L3 g. H" s( U
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ k- T1 ?$ C. l( D* w! Z+ {8 N - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( L, A" h9 u r
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 Z9 a' D! I, M
- ) B/ F+ [! o/ N
- dma_addr_t dmaphyssrc1 = 0;
; x; f7 e0 M; ~4 Q3 u - dma_addr_t dmaphyssrc2 = 0;
" Q8 N9 y7 q( A' ` - dma_addr_t dmaphysdest1 = 0;0 \& q* R5 m. n w) ~. i
- dma_addr_t dmaphysdest2 = 0;. a& `2 H3 J, b8 X. ?
- ( Y% K7 _8 h- }5 D( z( S- v. D% H* [
- char *dmabufsrc1 = NULL;
3 x; x( k3 a# F7 E+ C0 s8 X7 m - char *dmabufsrc2 = NULL;4 T9 `8 O% e* @0 v2 v
- char *dmabufdest1 = NULL;
_1 M7 B! y4 O/ U: B( N3 t# e* | - char *dmabufdest2 = NULL;
5 y* Y3 R5 i; |6 o
( [! n& l, f/ C% ]0 k5 ?$ N- static int acnt = 512;9 Z+ o2 P2 _( Z, m: i% o6 x
- static int bcnt = 8;
8 H& F8 o6 f. e/ E. h8 \ - static int ccnt = 8;
; `# A9 o+ q ]! x3 V3 Q; B
; |, L5 \* c! |- ~) c3 W4 l- module_param(acnt, int, S_IRUGO);
, g7 S3 f9 [0 L: E - module_param(bcnt, int, S_IRUGO);
) {6 M; U( W0 }# F - module_param(ccnt, int, S_IRUGO);
复制代码 6 |# A b) i) \2 ?" K4 ? r
- ]2 f0 V9 Q/ T2 M
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 ]- _# [/ F( d! 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
0 d3 F0 Z, P0 P, X; S 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。0 x! c3 c C3 s
' R6 m/ E/ H5 e2 H. V
- Q# ` d: k$ I8 n8 Z$ n |
|