|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 1 f* K2 C2 M$ ]' x, _7 X
- [code]EDMA sample test application
# _. ~) v* h; Y; @5 ~( |8 X) T - /*
& Y8 t3 H, u( t4 Z - * edma_test.c5 A3 o( } L+ j( p* o. h
- *3 D+ Q2 }4 [, d, [2 A7 m
- * brief EDMA3 Test Application8 m& U- Y* A! T% B
- *- n: Q1 U* T9 a. b5 Q. V
- * This file contains EDMA3 Test code.! c L1 d6 P4 q3 D* _$ ~
- *# m( H2 q$ Z7 G$ G+ h, j' c
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE+ F( I8 [# }1 J6 T. k* U- e8 Z
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
! \ C5 n. \, t; D6 M - * TO CHANGE.
- O& Y% ^5 R$ ^, R3 t x1 |( S - *$ M" s5 a" H+ E9 ?
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/% g( ]3 C5 L5 X# v1 U4 C
- *; L1 f R! u! M! J T2 I
- * This program is free software; you can redistribute it and/or" \0 {3 d! N$ o# }% F
- * modify it under the terms of the GNU General Public License as+ M4 e( K; ]0 O
- * published by the Free Software Foundation version 2.
5 n. d' j* @" n5 [; B! R4 Y$ [1 Q3 S - *
6 y" d) _, e& n! @6 g - * This program is distributed "as is" WITHOUT ANY WARRANTY of any" t% z1 R! m- ^6 [
- * kind, whether express or implied; without even the implied warranty
9 V8 H6 d$ L; C: S, j: H - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
: u$ c) z7 i+ m; D- j, \* ] - * GNU General Public License for more details.
4 I5 e& r7 v) j0 ? - */
% ]# [2 U7 `, E) e, b
2 }. h( x. ~5 b, W# B8 v/ L% P8 t- #include <linux/module.h>, X1 [0 w/ U0 {
- #include <linux/init.h>+ M4 f) ?( x8 h3 F/ v
- #include <linux/errno.h># H! e8 y# T0 M$ U0 t
- #include <linux/types.h>/ W9 }* k8 i# w N4 O
- #include <linux/interrupt.h># X0 h0 a+ K: U5 @( ?" T/ L
- #include <asm/io.h>! E# Y4 d l' Q5 t
- #include <linux/moduleparam.h>3 L$ l* a7 B8 @, b
- #include <linux/sysctl.h>/ n q" J' W$ K+ Y7 C. U
- #include <linux/mm.h>$ ]! G* w2 B. _0 {! L& v
- #include <linux/dma-mapping.h>
/ B/ U D$ R" u: E z! a/ M - " l# y9 e) s' n" ^. |, w9 H! A
- #include <mach/memory.h>3 S k+ k! f: j
- #include <mach/hardware.h>2 i( G! k$ Z& t# b/ ~" j( i+ E
- #include <mach/irqs.h>- {& j6 ]& y5 Q& c- k3 L
- #include <asm/hardware/edma.h>
% v1 ]: T9 t, e/ V, j, t$ I1 h
/ _& ] W8 G2 \' P- #undef EDMA3_DEBUG
" Q: Y" K" o; y4 p) i+ E- H - /*#define EDMA3_DEBUG*/
6 V" z% w) ^, ~7 F4 b, l
9 K% m" P( D' C$ A; z1 V- #ifdef EDMA3_DEBUG' r4 d: H' ^- x% |
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)% b6 \ `% k- h2 Y3 Z& z7 G( U
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
" n" F% V3 D6 T3 E - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)# ^1 m R: z+ o' z( J0 K- p2 S7 X, {
- #else- O; k3 }, o3 B+ E1 U. O) O
- #define DMA_PRINTK( x... )* F: v! x. p+ Q! Y
- #define DMA_FN_IN Q. o% h: w" b8 P! U8 I
- #define DMA_FN_OUT! c- l) C3 t X& S8 O, f* h0 K
- #endif5 b) k5 z) d" I# _
- 7 B/ R7 g* T- B* }( P
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)) c9 o% h! H0 Q5 q5 \& g
- #define STATIC_SHIFT 3
# x6 f- g3 q- ~# R- w0 ], v - #define TCINTEN_SHIFT 20
- Z/ ^/ R% z1 _, E% X' q N4 I - #define ITCINTEN_SHIFT 21: _, N1 Y# z: }) A9 a8 m4 K
- #define TCCHEN_SHIFT 22* j. v4 l1 o+ D0 N% G% t# Y$ W
- #define ITCCHEN_SHIFT 23
+ [! j. D2 g* D1 ?4 R) ]7 T - s( n* c* N, L2 S1 S! n
- static volatile int irqraised1 = 0;7 G: h6 T4 t$ J! n% ?
- static volatile int irqraised2 = 0;! r# c9 w5 B; g
- . `; n( o, ?) c$ C. X- O3 b
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 J* ^9 c3 f; _' \+ ^ \
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" v+ e, z/ ^) z/ @# l& K- `/ l
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( R! }( u \1 Q8 o
?1 V- ]9 I. F+ X" b8 V6 E- dma_addr_t dmaphyssrc1 = 0;* }) k! O* Y6 a; r
- dma_addr_t dmaphyssrc2 = 0;3 m" p9 m' ?. L" F
- dma_addr_t dmaphysdest1 = 0;: B6 ^" e. i T
- dma_addr_t dmaphysdest2 = 0;
: o, b& ^. q) a$ v, _: }3 D1 Z
. ^4 k; u1 l" H. \- char *dmabufsrc1 = NULL; s- E. X) `5 W! O6 G
- char *dmabufsrc2 = NULL;
7 ^/ ?% w7 f3 v - char *dmabufdest1 = NULL;
# [6 z' ?9 Z" Z! W3 f) c' \' h& i - char *dmabufdest2 = NULL;* u) S) Q7 {! [, D" y( _
: e, g6 U7 c: k# ~8 X6 I( X- U- n- static int acnt = 512;
: H; F J i+ ?8 x& @% O' m2 J5 h - static int bcnt = 8;
* R2 q- y* x4 K* ]! J( v4 g - static int ccnt = 8;6 P' g5 Z0 Z3 t' ^5 F" L
4 v. n' Q% M2 L e' _! z @- module_param(acnt, int, S_IRUGO);
5 t/ O. }* ?% ]3 O) ` - module_param(bcnt, int, S_IRUGO);: j( E* Y. k( f, l
- module_param(ccnt, int, S_IRUGO);
复制代码
8 F8 B& N- C7 ^1 }8 p
# m1 z, W7 s1 a x' u1 V# L5 @1 ^ C 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& X6 I j5 e( a# Q
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
/ Q+ O' y9 ^5 \( Z 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
* S8 ^0 i! ^$ f7 m# a; G& B0 a$ O3 `" `
2 c3 e; n. e# K7 z( |
|
|