|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
# v @- `- N. t% l# k- [code]EDMA sample test application
% g) z# I5 r1 p% }; M. T - /*" u; K8 D+ K# ]5 V8 ?6 m
- * edma_test.c
\) X( d6 k2 O/ t1 @: j; C - *" C+ ~) t) X9 B" ]4 E1 \( ]/ `
- * brief EDMA3 Test Application
1 h9 u- c9 U4 N4 q& R - *6 r# B$ a6 f; ] i6 p
- * This file contains EDMA3 Test code.8 `5 u# m6 ]% J$ g. T
- *
i0 L6 X) _# r) M5 p: U( g - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
/ |" k1 P& g+ t - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 A3 V7 e, R/ K+ L- n
- * TO CHANGE.
% {' ^" R: g% d' F. g% p# W - *
" W3 u* ^6 E9 E( f5 u6 C8 ~ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/) C6 l( C" I8 J! H9 a
- *& G" e3 q0 f' W5 ?% |) r# i4 T. H, ]
- * This program is free software; you can redistribute it and/or4 \* q: M' n- {3 _& S
- * modify it under the terms of the GNU General Public License as
6 w8 F2 W' z( M: ]! c3 ^ - * published by the Free Software Foundation version 2., C' R7 {4 ?$ {
- *
: p0 D' \9 J& m( T) [# M/ e7 v( { - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
# ?2 r+ @' |4 K3 Q _ - * kind, whether express or implied; without even the implied warranty0 p+ H4 A6 `- q; ~1 N
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! ^9 K' \9 H3 B, l) ] - * GNU General Public License for more details.. D z. Z8 X4 B1 e0 |
- */" K5 v" I. N' W
) r) H3 p: i8 T d4 F2 v7 N- #include <linux/module.h>
) n0 b4 y6 E7 X) C1 `- ]6 |" g - #include <linux/init.h>
; k$ B5 Q' q5 [: c1 y/ E - #include <linux/errno.h>
6 Q# u; p& c) F! @3 j - #include <linux/types.h>
4 D2 r' D' n' _8 ]. | - #include <linux/interrupt.h>" Q8 n+ p: P! D; v
- #include <asm/io.h>- | Q2 g+ D1 m o X. y
- #include <linux/moduleparam.h>$ X4 k$ z! N3 f8 _. N
- #include <linux/sysctl.h>6 v/ l; T; d1 d* Q/ S7 [, C
- #include <linux/mm.h>2 ?3 F6 e4 a. N; [* \' t R1 y
- #include <linux/dma-mapping.h>7 |1 b. t/ q8 g7 W, E* _
0 |6 a$ M/ ~8 R- T1 c1 {- #include <mach/memory.h>
1 Z+ C! Y) C/ r. k1 v' x. g( {. o: s - #include <mach/hardware.h>
( t' |& I$ }3 I& c: L - #include <mach/irqs.h>
; u% I0 ?8 c" B* p: r- J - #include <asm/hardware/edma.h>! x5 P9 o7 |" p
- 7 s: M0 S5 `6 q& W8 M3 Z0 |
- #undef EDMA3_DEBUG
3 T1 O! M( O) w- ? - /*#define EDMA3_DEBUG*/+ P% g* }/ {. w; [
- q; g7 z S/ ^0 O' X' l
- #ifdef EDMA3_DEBUG2 g: }- A8 `9 l) I
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
4 B; I8 ?7 S* q2 ?5 I2 g- D0 W! m& P - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" b0 a* L( J+ ?7 l6 `* a! z( F
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
" k$ ~. i" ]3 P9 R - #else
7 m/ y3 h# F9 z" U5 q5 z* ?6 N& A - #define DMA_PRINTK( x... )
2 Z$ z* n& x8 P' N/ e0 I - #define DMA_FN_IN4 Q1 x3 I+ w5 ^- ?; ]& U
- #define DMA_FN_OUT
" |' m' A' K3 x, T# L! w - #endif! w; h6 r4 A& I& s2 }0 V! L' d8 \
; g, b- x: \) J, k7 b- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: y' `; q5 K9 _( v7 \2 B - #define STATIC_SHIFT 3
- {# m3 b' M, ?4 ?4 U2 e8 B - #define TCINTEN_SHIFT 20' t3 K& w. f0 U. |' h' M! e; O
- #define ITCINTEN_SHIFT 21
/ z# G4 Z: M3 b: W5 l - #define TCCHEN_SHIFT 22, w6 t: W0 m& w) b) Y) B; x% P7 D
- #define ITCCHEN_SHIFT 23
: Y( M8 I3 B3 k% d* S) {- X6 i/ @ - " ?( o! K) C: ~6 K0 |; ]
- static volatile int irqraised1 = 0;
( `. q* |! X8 G5 w( Q0 @) ]0 f- i - static volatile int irqraised2 = 0;, @1 q$ D1 J7 e4 U1 m. ]% J
- ) J; I6 K( [: Q- h) |- b$ t/ \. H6 ]
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# Z8 p; ~4 i0 M/ i4 F0 n5 ^
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' m+ q$ K# _' H2 b' `- Q; w
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
?9 E( w1 l# U# m$ G5 U# z5 w - 5 D5 |% G9 s% @6 _' A
- dma_addr_t dmaphyssrc1 = 0;
2 W+ [* f( \" Y! l# T8 O- k - dma_addr_t dmaphyssrc2 = 0;' V4 S, A( }# b$ @1 | z4 o
- dma_addr_t dmaphysdest1 = 0;
0 n0 E4 i# H! L0 r' y1 H0 I - dma_addr_t dmaphysdest2 = 0;; [/ Y _9 G4 Y A
! C9 G- }' H! T- char *dmabufsrc1 = NULL;
+ o V# @3 Z! u# X7 W - char *dmabufsrc2 = NULL;
1 x9 {1 } ~+ | - char *dmabufdest1 = NULL;; l# ^4 A8 C8 C P' k
- char *dmabufdest2 = NULL;6 f+ n& E+ c" ]$ s7 }- n+ b, z3 Y: W2 d
- 9 c9 m7 A' ~1 k% } W7 a
- static int acnt = 512;
9 V* O( S7 f3 c- g0 Y- c - static int bcnt = 8;" v- `2 E# I+ y
- static int ccnt = 8;
& H, L! ^7 q( O7 |
8 r# }7 ]9 K: Q+ o$ v- module_param(acnt, int, S_IRUGO);
. M6 r5 t0 A; o& q - module_param(bcnt, int, S_IRUGO);+ G% O6 B9 O* z" i4 h ?# `
- module_param(ccnt, int, S_IRUGO);
复制代码 0 w3 p. i; B3 p8 g
3 B7 o/ K$ p; a) n: \. w+ W. L
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用5 A* w; M2 p+ P8 O R" [
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; e4 S/ S, z. P$ E; T$ [# e
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。& r" _* p4 B [& [
: ]1 B8 l3 x( t u' Z9 z
% o, |: e$ X) Q( @ |
|