|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 t3 q! u Z9 `
- [code]EDMA sample test application9 X C. @$ Q+ v, i* U
- /*7 l7 w/ _; w# e5 }4 W$ @8 I
- * edma_test.c
# C% X3 \+ U/ X" L/ n/ J - *
( G* r0 d; k) q) ]( [ - * brief EDMA3 Test Application
' L3 J9 T# R) _9 W7 ~3 i1 V9 L - *
% L( H2 a3 B1 r9 h - * This file contains EDMA3 Test code.8 p7 ]5 ]: L- q
- *
( d0 ~+ J3 i! \1 a: { - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE9 f8 n, W4 M& ~1 q
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 P8 ~) v3 V+ M2 \& @# d( `; x8 i# [ - * TO CHANGE.
% m& C) S! q; }1 O8 _ - *: x+ l9 X- k3 }9 W7 \0 J
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
. p4 A( q9 V8 D9 I! t - *8 @/ d5 M- a& @# p- [& s0 g
- * This program is free software; you can redistribute it and/or6 V& K, `, S+ a M9 }; ~ G7 f
- * modify it under the terms of the GNU General Public License as
" D8 u- s5 e' C# d% Z# S - * published by the Free Software Foundation version 2.
( Z/ ?9 ^5 K7 t3 _* O9 o9 _2 Q - *
8 J& D! |6 v1 G7 ]+ t" |) A L - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
2 a" V0 v- ]7 j! { - * kind, whether express or implied; without even the implied warranty
R. M: e: W& J6 Q5 M - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* {3 p2 n' P/ `& F) z" D% r
- * GNU General Public License for more details.
) U* v$ c: [5 H& I* U8 ^2 o. [ - */; n- t a: k5 O* e9 \
. W0 ?6 p+ g# P' U# U: z% b8 [- #include <linux/module.h>. S4 V. w% k( Z, O Y& a
- #include <linux/init.h>
& w) T1 B1 b; H* [ - #include <linux/errno.h>1 k. O4 B+ \8 V, l# p
- #include <linux/types.h>& Q0 m: b4 s8 R, L! s4 s
- #include <linux/interrupt.h>
9 V* |5 ?3 }9 \8 L4 z* l - #include <asm/io.h>
0 |! q ^2 b8 X/ N' y - #include <linux/moduleparam.h>8 R i. b5 j9 x3 ?- Q5 k- c
- #include <linux/sysctl.h>
* m; ]9 B R& V - #include <linux/mm.h>
% \2 t# v7 |: A6 M2 i - #include <linux/dma-mapping.h>6 i; d6 F/ U6 {
- % k- E% T" X1 O# q* a
- #include <mach/memory.h>* D. J. L/ k6 D. {- c& S5 I
- #include <mach/hardware.h>! |/ t. n( y( S4 r
- #include <mach/irqs.h>* C) z1 r4 \/ b7 C6 x# B( G
- #include <asm/hardware/edma.h>% U2 d* e% |, o% p: B- q* h4 e
" z( Z4 L# s Q! K, Q2 G5 S- #undef EDMA3_DEBUG
L, a* e Z3 O0 p. k' v8 |! b3 f1 Z - /*#define EDMA3_DEBUG*/1 u* u8 D K; x: \# p. d: B
( z1 L. F9 H! @( ^# o" _& K# E- #ifdef EDMA3_DEBUG
! u* f& j, s. r! f2 r - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" s" I4 Y8 x' Q
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 t! q" P! Q7 K- h - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
. X( M* u+ I/ C0 j% v9 n' [) n: k - #else, u4 g; t/ \2 E) N
- #define DMA_PRINTK( x... )2 R( S/ [+ F6 h7 F6 N
- #define DMA_FN_IN" g+ T5 I: s6 d& W
- #define DMA_FN_OUT! ]6 |: A. q* P5 G" W' @
- #endif
; V' E5 U- ~+ T8 R- h; W - 4 D) K2 g' k; [0 d
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
9 x: M q1 N; j/ C - #define STATIC_SHIFT 3
; |' \4 Q k6 u7 z( E$ U - #define TCINTEN_SHIFT 20- F3 f5 y2 Q5 |
- #define ITCINTEN_SHIFT 219 Q) [6 w- r( U
- #define TCCHEN_SHIFT 22
+ @- S! J% i+ F9 M - #define ITCCHEN_SHIFT 23
n3 ]6 _2 ~: e3 a$ ? - ; Z1 k2 R: v# {8 z. N
- static volatile int irqraised1 = 0;
) u& | r! B9 U# m# M9 @ - static volatile int irqraised2 = 0;! j: V I5 ^' K ~% b/ w4 t
0 s: Y% F3 n3 n0 Z; z- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ p7 L2 Y5 Q! C/ c: i$ U4 b - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' q3 _3 n* `+ Y" o# S3 h - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); F/ t: Y: l# a3 M) a
- * Q" p% g0 Q }7 ~! @! g* F6 }
- dma_addr_t dmaphyssrc1 = 0;+ `( y3 s. c; R; ~% E- F" a$ O
- dma_addr_t dmaphyssrc2 = 0;
7 L7 g: l) }/ v( t1 q L - dma_addr_t dmaphysdest1 = 0;# z- x4 _ l8 a
- dma_addr_t dmaphysdest2 = 0;
/ k/ s4 H! M" E+ q
* k$ N4 f ^( k6 c+ k+ p/ C; Q- char *dmabufsrc1 = NULL;' }0 L" z2 N8 D& l4 M/ _: j
- char *dmabufsrc2 = NULL;9 b5 n2 D3 P6 g0 k* P
- char *dmabufdest1 = NULL;
0 u! |: Q( m9 m5 L. @ - char *dmabufdest2 = NULL;
# V. n2 k) I8 @* d
. Q# p$ E# O# c" j" E& U: V4 p- static int acnt = 512;* Y8 ]. f& Z V+ J8 }7 k" q
- static int bcnt = 8;
6 _# j4 ]* ^% n! W - static int ccnt = 8;
8 l& y' I& S4 n! y ]
" f+ C/ r6 l$ ~3 d! q- module_param(acnt, int, S_IRUGO); V. s8 j: f4 C# E, y- ^
- module_param(bcnt, int, S_IRUGO);5 c$ f( \7 u+ a# D
- module_param(ccnt, int, S_IRUGO);
复制代码
( [1 L. j1 H R1 m/ ?) ]0 d4 x$ T5 Q' ], ^. e$ m( Y6 h
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用0 N4 R* P( k& w6 Z2 _& d2 R0 O5 l9 {
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。1 k9 H! M! y) L5 v" k( u# Q
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
+ b, o" P' [: b2 O8 I. Z& K5 e0 J; b' d% C1 n
) o& g2 o+ b, _$ h3 [6 F
|
|