|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
: } f" ^$ L' u0 r: h( W# H& N# M- [code]EDMA sample test application0 d+ @: G. I9 C# u+ M. c
- /*
6 V4 e& h E! L/ u - * edma_test.c
# w" ^) C* J0 @* a, S# Z - *% q) y% M/ z- ?& ^+ C
- * brief EDMA3 Test Application
9 q. i4 _& }4 _- d6 ^ - *
& h0 a; a" ~) X# {! O7 Y - * This file contains EDMA3 Test code.
: r1 P# V$ t# G5 b# `0 z/ `5 @ - *: Z' ?- \1 D. H8 r, _& E
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
$ |' Z% v: E5 M% L4 D# a$ S" `0 k6 J - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT- s9 C9 r0 u5 u
- * TO CHANGE.) A2 W! ?! n# X1 E$ [ y) n7 J
- *
% l# C, h, I% f" F( V7 s - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/: }* w6 N# T7 B& e2 u
- *
/ q; P, a0 C& f5 E: w" { - * This program is free software; you can redistribute it and/or
4 T" ?5 u$ I9 Y0 C; `0 s( q - * modify it under the terms of the GNU General Public License as: U( I9 c" H+ ]5 C% d
- * published by the Free Software Foundation version 2.
# P! `- m' j O! a" P6 H/ g1 [: w( | - *
. s* H9 q) z7 a% Z: G9 G0 n - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
2 b& K" E+ W4 w. [ - * kind, whether express or implied; without even the implied warranty
1 \) z5 u, F {$ B - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- Y% s& j( [: t+ q- R3 A) R
- * GNU General Public License for more details.
7 a Q L) R& J4 u v - */
2 y5 w- E+ Q) ^. Z8 v1 u s
5 W$ [/ s7 T8 @1 q# _, E" y& g- #include <linux/module.h>
# S+ |; q4 Z/ z - #include <linux/init.h>0 | x b x' `; s
- #include <linux/errno.h># f! W# d+ p5 g4 w' t8 j* E
- #include <linux/types.h>9 u5 `0 k$ R6 d0 y2 H& E" _" E! H
- #include <linux/interrupt.h>
9 [4 B2 c) }$ z, E8 @ - #include <asm/io.h>( X" J" s& L. v' K1 C( T
- #include <linux/moduleparam.h>
& S0 A, E# v1 { e2 K+ g) c - #include <linux/sysctl.h>/ c5 _1 s: A6 _# J
- #include <linux/mm.h>& ^# U' N1 A1 @, o
- #include <linux/dma-mapping.h>, V" Q( ?9 |0 R
5 j6 U8 H8 W1 b3 R7 q$ M2 O- `- #include <mach/memory.h>6 B+ k6 d2 `" b+ I
- #include <mach/hardware.h>" W1 P) e5 O# b7 C8 \, A; X' _
- #include <mach/irqs.h>
8 s' H/ l' M4 _ - #include <asm/hardware/edma.h>0 m2 {+ A( U0 U
% G& W$ Y$ ], C z- M- #undef EDMA3_DEBUG
# I9 i, c& I" F4 y5 i1 h- U - /*#define EDMA3_DEBUG*/
f2 O6 S/ y% ^1 Q8 b
; v! O& j2 `, Y$ z- #ifdef EDMA3_DEBUG
9 ?! l! I! e$ q% p, y* i - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)% [6 v$ a" o" o1 g' k4 Q* W0 l1 c O
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
0 b1 M+ p, O& U9 ~5 }. Y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
0 B5 U0 D- ? C8 } - #else2 V2 j/ y+ b5 X* R$ ^
- #define DMA_PRINTK( x... )
9 H8 K4 s: m- z' W$ [, H; F" ? - #define DMA_FN_IN0 c! @3 v; x4 S1 h
- #define DMA_FN_OUT
8 A: o- Q8 F- M1 s- c - #endif
. }* U( ]' ?+ {$ g - 1 K$ j9 `: ?0 Y8 r# s
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)! [0 S. l, C/ b" P- G
- #define STATIC_SHIFT 3
- V: _! ?3 O2 w( S4 H( P4 [3 [ - #define TCINTEN_SHIFT 208 F+ O3 w* C% _# J% i0 a7 F
- #define ITCINTEN_SHIFT 21
* z' o) X" ]# B8 g - #define TCCHEN_SHIFT 226 V0 L+ M& I" o! n
- #define ITCCHEN_SHIFT 23
g* B6 N) x: b- W: Q - ( A1 y: b" D' o( ^
- static volatile int irqraised1 = 0;
) E7 z8 l b6 s. X - static volatile int irqraised2 = 0;( }+ Y$ t7 B3 D, V9 U
- 7 V3 z/ |% x G) A# I0 E+ ~
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 b* c0 l/ E. h+ z3 q* L
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! V1 X5 g/ L! X: X - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: L2 W& B! ]( `
: [- e9 v E9 A- dma_addr_t dmaphyssrc1 = 0;
9 b$ I+ d M: p5 R, x+ p0 N. N - dma_addr_t dmaphyssrc2 = 0;
# c% {1 _9 g2 w) C* q - dma_addr_t dmaphysdest1 = 0;; S' J! ~/ N$ C6 b
- dma_addr_t dmaphysdest2 = 0;
, w7 e3 D% K9 k6 f - 9 T* E5 f) ?) \, s% n+ i) I+ [6 q) ?; y+ ?
- char *dmabufsrc1 = NULL;# b7 y" i0 ]7 q" B3 t7 o
- char *dmabufsrc2 = NULL;- V5 s, J4 O- z
- char *dmabufdest1 = NULL;3 N2 }$ N* M( d. g" h
- char *dmabufdest2 = NULL;" @ d& n8 X% Q
" u6 L8 d5 l3 ~8 l" H- static int acnt = 512;
0 {* U0 _# i3 T3 C% c& t - static int bcnt = 8;- w6 `; J/ O! Q& G. E4 G
- static int ccnt = 8;- A5 `' W8 H6 ? z2 r
2 ]/ _6 |7 C2 |* t* K; h- module_param(acnt, int, S_IRUGO);
: A9 d; J2 ^4 D1 x$ P8 ^0 _ - module_param(bcnt, int, S_IRUGO);
% l; a$ x( }4 x( y# ?! A$ o- I - module_param(ccnt, int, S_IRUGO);
复制代码 , A1 G s6 K# T2 U/ a8 T7 b
6 Y1 Q' ~9 Z# L2 `, C F& {# O
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用, G9 G2 F @, |/ I; D# d$ 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
" {( C$ a$ D) w4 Z6 U 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
3 M: n, F% I' [; L4 w& S
2 \; g- t( A: R. B! L. W# K0 ?4 F& k2 [+ w: q( n8 y- {
|
|