|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 z9 k4 G, C; o b1 H- [code]EDMA sample test application
! ~" m8 J2 U5 c( G- D | - /*4 z5 D; g( G' g+ i- f
- * edma_test.c
% {9 x; n2 J! h# O - *5 N1 U4 Z* R+ |9 w
- * brief EDMA3 Test Application$ O+ F: f$ t" G# i# }
- *
- k: H" F! }9 e6 K! O - * This file contains EDMA3 Test code.6 ]5 e4 E g8 [$ D! |
- *
# Q7 L: I: d3 x; | - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
# z) }) {6 d1 y) _( p" C - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT, Z* B& ?9 ^: A( N* p
- * TO CHANGE.2 x$ t+ W! ?& S- J" V- T) @0 x
- */ d6 j3 U: F5 B0 W$ B
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
! y% B) n; j! w+ E" L - *! [9 `* a7 ~9 V0 g5 _6 t
- * This program is free software; you can redistribute it and/or
. k+ u" I4 Z$ c6 C w3 T - * modify it under the terms of the GNU General Public License as/ z9 [! M8 E3 W. l
- * published by the Free Software Foundation version 2.
) @* j. n; I4 L4 d - *7 j! ^7 X# q m& f- x+ k! M( r \
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& i3 W$ }9 F2 Y5 c1 r. A# ^+ [( } - * kind, whether express or implied; without even the implied warranty
@# l2 _4 S+ ^7 P/ {+ U) A1 } - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- M6 q1 [4 v2 R, ^ - * GNU General Public License for more details.7 {! P2 P! Q, \. u: `
- */
9 Y4 I( N+ x/ k/ E' u
. s' T8 A G8 Z4 w- t# K- #include <linux/module.h>
: N" P( f. D2 s' M - #include <linux/init.h>
% x1 A1 v. w8 i W5 C - #include <linux/errno.h>& E2 A: m, R& c% a" Q. ?5 Q
- #include <linux/types.h>( }+ {4 D6 q0 n) r; J
- #include <linux/interrupt.h>
( X7 R7 E8 F l: z - #include <asm/io.h>
( {1 t8 J8 r. u4 d; X% z$ R - #include <linux/moduleparam.h>0 C) h i4 s3 Q9 ]9 E) N' Q
- #include <linux/sysctl.h>
' A d8 a4 A* {6 x7 R4 N, N - #include <linux/mm.h>
* X2 d" u5 B3 L - #include <linux/dma-mapping.h>
5 _* ~. N/ m9 n1 b4 ~6 H# F0 j% C9 j
0 r) H3 I# G, s" a. O$ x- #include <mach/memory.h>
3 d6 _ J) w k9 D# y: ^ - #include <mach/hardware.h>
# x A/ v: T3 \ k$ ^ k1 \ - #include <mach/irqs.h>; L0 v0 D# k8 A8 \( B" b
- #include <asm/hardware/edma.h>
' v7 Q% v) G/ {7 n/ n - 5 U U" x# T Y8 r4 ]
- #undef EDMA3_DEBUG
" }# i7 L7 }( G: w* a; C0 p9 f - /*#define EDMA3_DEBUG*/
{$ ^8 D) C# j, d/ X% v n3 p6 \ - / D1 R$ O8 T' T1 J7 H
- #ifdef EDMA3_DEBUG
! [; d# h& O; I; x2 S; m - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)8 ^7 V0 \! D+ ]$ a
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
0 ?" q! \) J0 k$ u6 A; R - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)8 r4 K# `* j" i i
- #else
! G! G& V. Q+ a$ Z0 u7 y2 s0 N2 [ - #define DMA_PRINTK( x... )
6 ]) l, a' a$ x: U% Q - #define DMA_FN_IN. \+ \. F1 _! g* f7 d F" `1 u! I
- #define DMA_FN_OUT
: S3 T- ~% c: B. }) x - #endif* u. o# s R. D* t
- 1 L, D" t# {/ d+ e& e5 R
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
' t' [& F @3 h1 E% b* q2 c - #define STATIC_SHIFT 3
/ M) O7 Y! g4 `9 P - #define TCINTEN_SHIFT 20
$ f6 i* e( P l( y - #define ITCINTEN_SHIFT 21- j# n3 X) K# N
- #define TCCHEN_SHIFT 22
4 S& t, q* Z: ^5 K) T$ S - #define ITCCHEN_SHIFT 234 n4 o1 h ~, `
- ; b8 J. x' E9 b h( l. E$ z
- static volatile int irqraised1 = 0;
0 ~1 K, F: @7 w; v2 Q - static volatile int irqraised2 = 0;
. d) z! }$ L+ J4 Z" M9 u - 3 y1 B0 d( P9 O' z/ T
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* I% t- S( J1 a4 E8 [; Y! |
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); |7 p9 p0 |! d- h) s2 b: B
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 A: A5 z* l2 I7 h4 \
- 9 q1 d- p" |- a2 L3 h
- dma_addr_t dmaphyssrc1 = 0;
+ t& N# X: V! R0 C$ D3 K - dma_addr_t dmaphyssrc2 = 0;
& S) n: c7 D i5 j - dma_addr_t dmaphysdest1 = 0;
* C( y4 f8 \1 M b( K - dma_addr_t dmaphysdest2 = 0; K& J1 y, n3 \, |: J7 @
- 8 e& I' U# ^8 r$ w: U
- char *dmabufsrc1 = NULL;2 y* T/ i5 f) e6 u/ J
- char *dmabufsrc2 = NULL;( l$ i& a/ E3 W, ]
- char *dmabufdest1 = NULL;7 t1 i7 S+ l) p1 k- C I& m
- char *dmabufdest2 = NULL;
: [) B- P+ e& m - ! `# i% @6 a- n7 S8 A; [! Z% p
- static int acnt = 512;
3 ]' m. n: n3 Y* q% H( o' X6 @ - static int bcnt = 8;5 }5 E( L# g' t' w, r7 a
- static int ccnt = 8;
2 U' W6 g. T% G7 y" I - 6 J; ^/ g* [' M2 Y% d0 |
- module_param(acnt, int, S_IRUGO);
5 m3 K0 z. X" K6 N' ` - module_param(bcnt, int, S_IRUGO);
" F8 F; g, B+ B2 w S: y; i3 K) ^5 W - module_param(ccnt, int, S_IRUGO);
复制代码 9 a) S# V# z8 P" Y' v9 @' h- e+ b
1 Z" i% C! G! i: _ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
- Y% [( {% n% C4 D. d' h+ F" Z. _' [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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。$ P |' G" G o5 t5 o1 X2 {
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
: y Z4 V- n# w- C$ n5 q% e; V
! P* S. h1 r$ @( P' c
$ D9 @$ t1 e$ _2 \+ F& R) q8 ~. i |
|