|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. H( e4 ?" W- L: b9 Z; m3 u- [code]EDMA sample test application
! n& F+ x4 [; J, i) F; Y2 _ - /*
/ r# P4 h& R7 B: d; n! T/ X3 l - * edma_test.c) K1 y/ J9 P+ M5 m+ h
- *# P( X) R. c# N/ J1 ^: O x
- * brief EDMA3 Test Application
' d# `1 H) `( { - *; O0 C2 K$ q5 N
- * This file contains EDMA3 Test code.
+ S, U7 A6 X, Y2 @ - *" V) o( V+ Q8 B6 ]( D; j. H
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE# t# A2 P1 N# s$ ?# V
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
; r: h( K7 n1 C) h: t - * TO CHANGE.& T$ U5 ^3 c- v U0 c, J
- *
# Y0 O( C: W8 `& m" n4 {8 _8 Z6 D6 A - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/* k& n8 S, ?/ u/ r* N: r' g- g
- *
* ]- V, k$ }* U+ x - * This program is free software; you can redistribute it and/or& M7 {+ Q5 Z: c* j+ V
- * modify it under the terms of the GNU General Public License as" ?5 b: Y& V7 ^' P7 ~" Q. P) E2 d% ]" ~
- * published by the Free Software Foundation version 2.
1 ]. U) y v% M. R2 S' _ - *
; g, g/ b {. [- c+ @ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, V# m, G( @, n+ ^- D( h. [ - * kind, whether express or implied; without even the implied warranty$ k7 y5 W8 G) n; C
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" m7 }" `) o4 S3 ~$ n - * GNU General Public License for more details.5 [+ f6 ^0 t' B# F
- */( G9 g) j. F* K1 b1 ?
3 A6 n* @( G. f0 k D, i+ Y5 b- #include <linux/module.h>$ ~% u) I* [; X
- #include <linux/init.h>; h0 i+ n! n2 T, P) ^0 P
- #include <linux/errno.h>7 @7 I9 z8 }0 R7 h# c( J* ]
- #include <linux/types.h>
+ v# \2 f2 a5 f7 a" P' x) C - #include <linux/interrupt.h>
/ C A5 X0 A0 y& t - #include <asm/io.h>
* y: F. t" Q- ^& v j! c - #include <linux/moduleparam.h>
# y7 \3 p7 X8 b5 w& `* P: i - #include <linux/sysctl.h>3 t7 {9 S2 \& L* B
- #include <linux/mm.h>
9 j) `' T/ \' ^* P8 `1 v. ? - #include <linux/dma-mapping.h>
G. t4 F9 s% N: X8 \
5 a* \# v7 H6 P7 X- #include <mach/memory.h>
7 S; h4 d3 t5 m* V, c0 ^ - #include <mach/hardware.h>! a/ z+ ?' \& ~+ {. a- w
- #include <mach/irqs.h>: [4 L' y, m6 C8 r) \( \
- #include <asm/hardware/edma.h>' x" n1 t' ]* l' Y$ o; P$ P
( ~' `+ f+ c" \4 h- #undef EDMA3_DEBUG" |; L. I' j; s
- /*#define EDMA3_DEBUG*/
6 L* T) m# o: N/ J - $ u+ w C0 E7 T( | O0 ^1 v
- #ifdef EDMA3_DEBUG
- L6 s. q' v" W- }. i - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
* Y7 P( S2 t1 d; Y. x r - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)# O! c+ g9 E0 W) V$ ?
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
% E* K* i- y2 z; G- _' R - #else+ a, t& e5 l: ^
- #define DMA_PRINTK( x... )$ Q- p) C% o' k( K+ t
- #define DMA_FN_IN
! y# [1 n* C) h5 E0 e - #define DMA_FN_OUT
( d6 w, v: i2 {: Y! ` - #endif# ]! m: R. O$ u0 u( O& ]- l
/ T1 ]0 o# S. b9 p6 P _( P u- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
0 U @7 ~; ]8 l, B! z# M" ? - #define STATIC_SHIFT 3
6 o. @/ f9 ~ |' @" w- S: l" z/ f - #define TCINTEN_SHIFT 20: b* [# L& o+ G* y
- #define ITCINTEN_SHIFT 21
" s1 J, c# s8 g3 N# U0 }, U - #define TCCHEN_SHIFT 22
# A8 c2 D( h |4 a, ] - #define ITCCHEN_SHIFT 23
6 ], A8 O3 ~4 r - ; a5 w$ ]) a) X1 Y: H* M
- static volatile int irqraised1 = 0;! J( s8 P# L. k8 a8 s
- static volatile int irqraised2 = 0;
5 q1 h' O6 q: }' j$ S( p - - e# e' R! M* N2 |% X& p3 V4 {
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 H% y, v# D' j- Y# p
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 f: w9 ?3 L8 D! z9 o+ e - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' C/ S8 @) R/ ?6 w/ [ - 0 Z4 x/ _' G7 P+ R4 G
- dma_addr_t dmaphyssrc1 = 0;
- w9 p8 t- q/ n; X) ^$ S - dma_addr_t dmaphyssrc2 = 0;
2 m( u+ `; h# L5 s( j/ m - dma_addr_t dmaphysdest1 = 0;( G0 g/ X) @* X& Q6 g/ ? v
- dma_addr_t dmaphysdest2 = 0;
4 e! K" U" \+ u3 x+ d
/ \: R. Q6 q+ n/ T# \& i- char *dmabufsrc1 = NULL;
9 I/ U9 i4 L. [: s5 N& K - char *dmabufsrc2 = NULL;
7 a2 \2 K2 M/ X- ]7 O. ] - char *dmabufdest1 = NULL;# h* D% g# a7 v, F
- char *dmabufdest2 = NULL;
) q$ p0 C1 g0 S8 \0 b5 ?
9 x; B, C" c9 u( f- static int acnt = 512;/ H$ o: x+ x7 }
- static int bcnt = 8;
8 T3 @# e; m9 {. k0 u3 L - static int ccnt = 8;
5 f1 ~5 f' |5 ]5 o" u - ; Y: Z' t4 F7 ^
- module_param(acnt, int, S_IRUGO);$ o6 `" q. h$ l2 t& U$ N, t( }
- module_param(bcnt, int, S_IRUGO);$ X! l! u% p$ Q) M" d
- module_param(ccnt, int, S_IRUGO);
复制代码
* l0 }$ O* y2 |/ z. o# U* M; W9 r- G6 G! D9 T- r2 c
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用9 k! V/ ?" ]! \% I3 B! ?
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" @" m/ |/ e {, G5 g3 Y
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
$ P5 s" D& U2 B; ^
* n# l; Z( n! R
" [" t! e2 z/ o O9 j% c; e& j |
|