|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
" Y9 b# G* i( M- [code]EDMA sample test application
* |6 @& x7 ^: y) n$ y8 S3 j - /*
$ N0 w- s) o5 B1 s# s0 l - * edma_test.c1 v$ V+ \$ m( X* K s0 z& g4 C b
- *
% _ X2 ?8 m( l, k# a& Z, c& \( e: T - * brief EDMA3 Test Application
* W) [! C5 B9 X4 Q. R, S( j8 z - *
3 F6 q! R R) l8 \, B2 ^2 A$ K - * This file contains EDMA3 Test code.
) T+ S( C2 W6 i, _# U - *
/ l! m" l2 w& p; B - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
5 W8 ~" u" m: L, v/ n9 A0 w - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
$ ?4 ^ x: o/ t) O - * TO CHANGE.
: K# f7 U2 i8 r3 p5 @! u) Z$ n - *
) i4 P3 p/ v0 `* ^4 f! r - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ @5 |8 `- x# E5 A3 U, ~5 j9 [5 L - *
- M% N& v& J T+ w$ q- K - * This program is free software; you can redistribute it and/or% m3 O" H/ T+ C$ I4 m
- * modify it under the terms of the GNU General Public License as* n; b' A4 _+ a3 O
- * published by the Free Software Foundation version 2.
' c6 d! Y7 m- D" ~7 M' n2 l) t0 ^# g - *
& @& @7 N$ {0 q- f - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
6 g6 |; \; b' |7 H - * kind, whether express or implied; without even the implied warranty
: \! U! r0 N% |$ T. U7 d3 C [, x - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ _) x+ t( g# F. `9 M$ _ - * GNU General Public License for more details./ _4 E" a7 s, v$ I8 k+ b: R
- */
) r# c# D" r4 ^, A' |7 p - 5 P! y. l- N. k' ?3 C) s2 l( Z
- #include <linux/module.h>4 y- A9 |" R! V9 x6 K
- #include <linux/init.h>
% J7 K+ U) U7 J - #include <linux/errno.h>6 {$ ~& {) \! Y- A0 a' N
- #include <linux/types.h>! d4 m' H6 z. s4 L6 z
- #include <linux/interrupt.h>
/ n3 K9 `- Y, V& @: x" s - #include <asm/io.h>
9 U t4 r% W C5 q& Y - #include <linux/moduleparam.h>7 `* \: L2 R1 R9 U1 x& O
- #include <linux/sysctl.h>& n6 r+ z4 v& f3 c/ I
- #include <linux/mm.h>. s* {$ m. b: y1 }0 _8 F8 S
- #include <linux/dma-mapping.h>
- P. X! V! D1 y# o# f1 z, i6 r - 3 f- F1 O( ]& r
- #include <mach/memory.h># b% D+ o; L# ?: l' @5 d7 f
- #include <mach/hardware.h>
0 q. U2 R) g/ ^- A& x6 m - #include <mach/irqs.h>/ p1 n) {4 B% w/ Q) V& |+ Q) l' o
- #include <asm/hardware/edma.h>
) v9 x9 ?* C& T' p. q( K
0 R8 N- Y5 I# d+ b$ r4 K% b- #undef EDMA3_DEBUG4 r; k0 I) \) j: R! S; {
- /*#define EDMA3_DEBUG*/, j+ V/ B( v+ p8 A# t
- 7 w' L4 X; L# Y% T o. }
- #ifdef EDMA3_DEBUG$ p; D7 S. K) g/ @
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)) s! a. u8 l# @5 j5 M% ]% z0 T
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 ~3 U) {4 A" R - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)- D6 M# [, H3 U8 c8 e% j3 B1 w
- #else$ X! J6 _3 e# A# g1 a; x' g6 G
- #define DMA_PRINTK( x... )
" L: `. D; F5 d [ - #define DMA_FN_IN
* | l0 e9 Q3 M6 f* D& k; W - #define DMA_FN_OUT
7 O8 A; q. z7 N2 u; [; J4 y - #endif( V6 `8 H) U5 U* @
- G3 E/ ^3 \5 a- #define MAX_DMA_TRANSFER_IN_BYTES (32768)' d: X! g9 i" r
- #define STATIC_SHIFT 3
& F R7 A: ]9 O5 F3 H - #define TCINTEN_SHIFT 20
0 M, F: s& M& \. e' V - #define ITCINTEN_SHIFT 21
+ v5 z# j1 M5 f: e8 T$ ^ - #define TCCHEN_SHIFT 221 \$ F: j3 i, |
- #define ITCCHEN_SHIFT 23! ?& d2 Z1 E, X5 w& V
9 G, r# z+ `7 k- I' v2 n) O# Y: M' E; o$ U- static volatile int irqraised1 = 0;% `% g3 a5 q9 b5 C# }. [
- static volatile int irqraised2 = 0;$ \: c4 i9 X+ I* H" `1 x
) v7 n$ d3 y1 y- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% Q; ?3 z* j s1 f# y2 m5 s - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: t7 P5 R% |2 p( F) i0 e' W! r
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 D8 _* N$ X3 U; P - / N- o3 J2 F. r0 R: P
- dma_addr_t dmaphyssrc1 = 0;/ E7 a/ r2 C/ Z5 d
- dma_addr_t dmaphyssrc2 = 0;
( i9 S1 |, r4 f# Z8 e - dma_addr_t dmaphysdest1 = 0;
+ @1 a- V1 d# Q$ A$ ~. C2 y - dma_addr_t dmaphysdest2 = 0;
+ [1 N0 M w) @/ V! t! w* U - 9 ~" T2 w' {% v$ {
- char *dmabufsrc1 = NULL;) Q8 Q6 s4 D g/ c3 O7 v' S0 T% U- @4 ]
- char *dmabufsrc2 = NULL;
( g+ ^, S- }/ U! f3 B3 a - char *dmabufdest1 = NULL;
2 f" ]) E3 E# H w1 l# U - char *dmabufdest2 = NULL;; u& R. j/ a/ }
- + C4 E1 M7 B' ?
- static int acnt = 512;
" i, s$ }- n3 X. x: f. ^- L - static int bcnt = 8;
$ ^' u3 l- x& \$ ~- m - static int ccnt = 8;
) w( T" R0 |8 z, D. y( | - / \6 B! f2 B- Z4 E2 s# i+ |1 H
- module_param(acnt, int, S_IRUGO);5 T& o; U' I6 H7 u
- module_param(bcnt, int, S_IRUGO);
G, B" U9 {6 W/ n N B- d - module_param(ccnt, int, S_IRUGO);
复制代码
4 ~6 y6 O0 U/ A* \; j) |! q a, I$ t- ^1 B3 a
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用* v4 ]3 _- j4 e& Z6 `9 N
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 i/ Y( {- P+ Y: e3 \1 ^- Q3 A
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。# j4 k% Q3 u6 |! M, l
, u& R. t. N1 N# C
+ V1 A$ T# G0 n3 k$ x q+ E |
|