|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 , ]' B- ~3 o9 O- k. L
- [code]EDMA sample test application
7 i4 N( w6 M) a- O% Y7 f - /*
! B. z# W- \1 s. f) p' i - * edma_test.c' a% j3 m7 _6 ?! v
- *
- k0 j/ b5 E- T% B+ Z7 X1 i - * brief EDMA3 Test Application- K i& b3 N2 z7 L
- *
+ g$ O( y6 o# K2 @+ w - * This file contains EDMA3 Test code.
' ~5 P9 ~: f+ N7 ? - *; h3 z4 f4 k# I) z% G! b$ s
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* y7 V! s& w; V7 j# n - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
! q. V8 o/ N1 X- D& x+ I - * TO CHANGE.7 f. D& Z K; l/ ^. C0 W
- *
" t4 R3 m* A3 p, L( J3 ~+ I, H9 R - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/3 w/ L& X, B0 @$ e% d
- *2 N8 @/ ~+ s9 O p7 j
- * This program is free software; you can redistribute it and/or Z# D: V4 S3 @4 J8 F6 l. ]* D3 k) d
- * modify it under the terms of the GNU General Public License as
6 U& M8 ]0 j/ _2 O$ _' g5 J& U - * published by the Free Software Foundation version 2.2 E# K7 R/ y% d; g3 `& E
- *
; U* _. @6 h a, s - * This program is distributed "as is" WITHOUT ANY WARRANTY of any6 D! X; T* a. p+ y; n; G
- * kind, whether express or implied; without even the implied warranty( V1 ~! g* B W8 J/ t% }4 e
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' ^1 g. Q1 T7 d9 H. l% A - * GNU General Public License for more details.
4 w1 s! ~ V+ g - */
) ]+ |4 s: {" C, n) u
5 u4 \" P; ?% ?% a( t9 a: F; S- #include <linux/module.h>& s; E$ B. q$ G$ u
- #include <linux/init.h>/ |' G. @7 p& @$ w" G
- #include <linux/errno.h>$ c1 r C% o' |' @2 n
- #include <linux/types.h>; p0 c- h; o( \- [* ]* y/ z8 q8 g
- #include <linux/interrupt.h>4 N+ _8 }& l2 Z: W
- #include <asm/io.h>. s7 }8 D: p+ {4 y' z$ P, [
- #include <linux/moduleparam.h>
, m" j9 C7 G7 w. ~ - #include <linux/sysctl.h> X0 B/ T1 M$ q5 p3 P
- #include <linux/mm.h>
: s# ]2 X. {7 j. g+ x - #include <linux/dma-mapping.h>. B' X! G- Q! Q
- 5 n+ I: e% {$ F, Y
- #include <mach/memory.h>
0 F% T% @, H, ~1 q! ]! D7 a - #include <mach/hardware.h>/ m$ a9 \! `& _
- #include <mach/irqs.h>( X$ }1 B" g" @6 C6 ]
- #include <asm/hardware/edma.h>7 ?7 K8 V, M3 K: L; a3 Z: W
- / u& ]: Z/ b6 B" }5 v6 M# P- e
- #undef EDMA3_DEBUG
5 h- h/ q3 v$ R6 j: F! |7 ? - /*#define EDMA3_DEBUG*/+ F1 Z& A; P |. F Y+ L' n( c
- 9 b/ T/ d, c( V! M5 d; b' Q
- #ifdef EDMA3_DEBUG
5 U" K. S% T4 {! y, ^" @ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)! V( Q: p; w6 k2 k- s ]
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
/ S! m) y/ ~) l1 p t$ }' S1 \4 j, D - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# |% K( j; [; w" ` V0 @4 Q - #else
" ?* f& z, N; {6 m- [# W - #define DMA_PRINTK( x... )
5 h6 \% H1 d0 a7 X1 G - #define DMA_FN_IN0 J6 O6 T0 H3 C! `
- #define DMA_FN_OUT
* Q7 l( \ u6 k u. [" E - #endif( n, e+ I1 P% Z8 r
- 9 T# Q- F9 O9 X( \' ~7 V
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ x- m. e# U/ ]7 f: y
- #define STATIC_SHIFT 3
) f- Z7 T) S0 ^, ? - #define TCINTEN_SHIFT 20% @- ~# K! u# k+ Z
- #define ITCINTEN_SHIFT 21 b8 k7 d, A- _3 d+ u& @
- #define TCCHEN_SHIFT 22
9 Q' v* x! d1 x& l* @) s4 c0 b. v - #define ITCCHEN_SHIFT 23
# O; ~, q# x( G- t ]9 S! ~/ I: ~
& U4 C ^3 F1 c! `+ t2 l K- static volatile int irqraised1 = 0;
2 H" Q6 o# S K - static volatile int irqraised2 = 0;
, t% c+ O2 \8 M! r6 Q
$ f; h) u ^- g7 o7 J: N- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: \. d5 a# k0 ?+ V: b4 P: N3 l6 L0 E8 v
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% M. l4 |! H; g: q - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" Z4 I! i* P5 r5 R& w8 p
/ e( s' r% X4 g# u5 B- dma_addr_t dmaphyssrc1 = 0;3 C# @# j5 \+ h6 l5 ?
- dma_addr_t dmaphyssrc2 = 0;) j7 d& s4 Y2 x6 W* d
- dma_addr_t dmaphysdest1 = 0;
2 y N$ B; o$ [) `9 g3 M8 ^* } - dma_addr_t dmaphysdest2 = 0;3 R. s9 y0 \- `* c6 M! M2 \
! S; r+ J; Y! B! R' R/ W3 r- char *dmabufsrc1 = NULL;
) o0 t6 [% q9 y( j; K: ` - char *dmabufsrc2 = NULL;# g6 ~) A6 e# P& Y r# }, f0 \
- char *dmabufdest1 = NULL;
8 ^5 B* S, q, _- P; ?; @; Z - char *dmabufdest2 = NULL;$ r- M1 B) s* s& z4 a: V" s- C( l
) M) k5 g1 h( e1 O) o$ @- static int acnt = 512;" E# q. U8 h- e5 V% E
- static int bcnt = 8;
9 O) ~7 l, D- i2 e! e# Y8 Q* J - static int ccnt = 8;& _ |( i. }' P' y4 Q4 R
- ! x l& `* C5 l% j
- module_param(acnt, int, S_IRUGO);" O; ^) ^$ @' e0 w8 I! b# i. ?
- module_param(bcnt, int, S_IRUGO);$ [! s* C, L5 N+ k& Q
- module_param(ccnt, int, S_IRUGO);
复制代码 , Q* W' e- V! W8 n/ O/ [) D3 Q
7 \, ^/ a$ a9 c: _$ e
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用7 w4 w; {) P+ Y9 S1 S2 d/ ^% A5 L
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
$ d" Z+ ]: |- @/ ^' ^# k 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。% { N& f- {; t
; {* ]/ a) K! p M: D" w
# {, |& C& V. G/ U
|
|