|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
/ _' t6 h2 D! O- [code]EDMA sample test application
4 s. s, S1 J1 ?" j; C" g - /*
& R7 x* s9 _1 @6 @0 P+ k9 V - * edma_test.c
! k3 D9 V% z, F3 f) U8 d7 L - *+ h- u3 R k/ p+ M7 x
- * brief EDMA3 Test Application
! p: v. O: S/ X2 `; e' [5 ] - *
$ I5 e5 X$ P$ v7 _ - * This file contains EDMA3 Test code.+ X4 O0 Z% J4 O: ~, J" \
- *
4 S6 ^+ c' b3 U" Q9 L- B5 G1 a# c - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
' p9 A b! w& e& } - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
: C* m: V* m3 Z - * TO CHANGE.: e7 v4 I3 B: g2 n C: K
- *4 h9 ^6 i( e9 j" w$ i/ P
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/' l C" H# N! J1 V% y$ d
- *
4 p: |7 t9 g8 e; L0 X$ a2 k - * This program is free software; you can redistribute it and/or+ b% K6 d& B5 |7 y/ ?0 W& V
- * modify it under the terms of the GNU General Public License as
+ `% `0 ?& Q+ A* ? - * published by the Free Software Foundation version 2.
, W4 ] Q0 ]# o \# v - *0 s3 R' L* m) \
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any. o' I( a+ }+ a
- * kind, whether express or implied; without even the implied warranty
0 L! |/ K, r5 t - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the6 D) }7 L% [ r ?3 G
- * GNU General Public License for more details.2 h* \+ a" M2 c* O5 r
- */" }! n' |2 n( r" g
# o3 L- U% G! L: ~& _- #include <linux/module.h>
! k# a% e$ I6 W2 G# D5 L - #include <linux/init.h>
( F5 ^! E ?3 x' N& g* s& R [ - #include <linux/errno.h>3 Q, i! j I3 w2 L, J
- #include <linux/types.h>
9 J9 ?. {5 L: d% d - #include <linux/interrupt.h>/ I2 K3 V4 B/ A* f. `# @+ j
- #include <asm/io.h>
0 |4 n4 n' D f) R - #include <linux/moduleparam.h>
( O' e2 w0 v) h) b# k0 Z7 {) [% N - #include <linux/sysctl.h>; P' C; Q) ^! `* U
- #include <linux/mm.h>
, ?+ k! Y7 G X u' @/ p7 c( H0 M - #include <linux/dma-mapping.h>
) ^6 Q; |8 y4 i- I
+ ?& X8 }6 K( K9 _- #include <mach/memory.h>
6 q+ A& Y" d; p$ e& d) P; f - #include <mach/hardware.h>
' i5 s) L* [8 W" S - #include <mach/irqs.h>! k) v6 F+ Z1 F1 m- ~ g7 B
- #include <asm/hardware/edma.h>
' ?3 }1 u# k8 S* W: ^- ^
0 z5 v. k) I4 D% v) k) j3 ]* `8 N, ^- #undef EDMA3_DEBUG2 E P [; s: d
- /*#define EDMA3_DEBUG*/
# W9 K& p7 P' J4 \ j' c2 z1 A - ) X5 \ _ m# X w: ?
- #ifdef EDMA3_DEBUG
1 Q7 Y, k" ] o' f0 w - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
7 Z: a8 f2 @9 E+ M2 `/ h7 s* E+ w - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
% k3 A1 l% _$ Y: [8 w- l - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__); M* H. T& S6 v% X5 F/ \
- #else
1 C7 t l3 [5 v! W8 e - #define DMA_PRINTK( x... )
# R0 Z5 }! p$ Y9 V) u) T4 N1 E1 _ - #define DMA_FN_IN
! E% V+ |; v0 H - #define DMA_FN_OUT
7 r3 N0 H( b' S; K) e - #endif) G' z7 ]& X/ k: D. x) |& ~' r
: M$ l6 I& \( |& U- #define MAX_DMA_TRANSFER_IN_BYTES (32768)3 ^, u$ t, l& Y1 J3 H6 P, w0 E
- #define STATIC_SHIFT 3. U6 u5 ]. F. Q
- #define TCINTEN_SHIFT 20% T+ r% `8 @3 q2 _) |+ C
- #define ITCINTEN_SHIFT 21
. Z: N/ z) }! D# V - #define TCCHEN_SHIFT 22. |; i+ q6 B# R& M+ T
- #define ITCCHEN_SHIFT 239 w# z+ ^; U; i [
- 5 Q3 ^3 d5 L- R. ~& Z2 `# R3 m
- static volatile int irqraised1 = 0;
]* Y. ]% w. p+ o2 o - static volatile int irqraised2 = 0;9 ^5 {, V: v/ X/ D& t5 P
* u7 n p# p& Y. {1 y1 T0 x, @9 ]; |5 }- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" j8 N; v; U' Z( {! S6 h
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ N+ i3 M5 f: W* B9 M4 V2 \$ s - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 `7 ?: m# z K$ e
* S% L+ C# `3 ~3 {$ y9 [6 C1 g8 V. @- dma_addr_t dmaphyssrc1 = 0;$ Y O0 w; u0 T( N9 s% n
- dma_addr_t dmaphyssrc2 = 0;
/ N1 O K8 H; v% b5 t7 F, ? - dma_addr_t dmaphysdest1 = 0;
) q2 [3 ~( `) ~. M% D - dma_addr_t dmaphysdest2 = 0;
4 {1 v/ Y% m% f9 q3 V
% m; H3 F9 @) u8 S- char *dmabufsrc1 = NULL;
2 A# I" W/ u+ a6 { - char *dmabufsrc2 = NULL;2 F8 `2 a d$ g# G- P7 M/ e
- char *dmabufdest1 = NULL; h9 O) x) T% ^0 J: d6 {, ^' L" P( c5 u
- char *dmabufdest2 = NULL;
3 A0 B( v9 I' c
+ F1 t* m$ Q6 F4 H- static int acnt = 512;/ W! U h R# M, G$ H
- static int bcnt = 8;
) G) p: g: G3 M, P, w - static int ccnt = 8; r3 Y5 u4 G8 m3 o5 b H
/ n) }6 d7 O5 W$ a1 N+ L2 ^/ Q- module_param(acnt, int, S_IRUGO);3 I' q5 n- j ^" t
- module_param(bcnt, int, S_IRUGO);0 c- H8 C, r+ g: [1 u
- module_param(ccnt, int, S_IRUGO);
复制代码 4 m% e+ l, n# p( G; {% c) p
" t( i4 c0 |$ X( ]
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
+ Q( k8 Z; m8 G- u" J4 ?/ b2 zarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
% I" s0 I0 _8 A: b! [ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
5 e# u ^! q: @# `& E& [) g) k: x( {4 F `& J" I* T4 C& L- z
0 z( t7 ~# ?" Y1 u/ c" I7 B
|
|