|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
' E3 j( H" ?: k% B2 `' V6 h& p" h- [code]EDMA sample test application
) X" A8 ~3 J# X1 g7 z8 \7 Y - /*) K+ v s: r) f8 c5 o4 }
- * edma_test.c
/ a- Q/ I, G2 Z( r @' t - *- i! u! S8 F$ w+ I
- * brief EDMA3 Test Application
! f2 Q1 u4 x9 v, I' F - ** g5 k! x; W3 S2 B
- * This file contains EDMA3 Test code.
1 a& |9 x/ r4 l' j - *
4 \: v* h+ ^/ d - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
; c7 B0 N9 @- N0 A7 S+ i - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT/ D* Q! N1 S; p' \5 b
- * TO CHANGE.
) U6 @6 }6 R+ O3 R; x - */ K I4 x( C, ^" U9 M" |' g
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* x/ |6 a; u/ _ - * x/ V4 K1 D' p3 j
- * This program is free software; you can redistribute it and/or8 q3 N2 r2 b9 _: x1 n& X
- * modify it under the terms of the GNU General Public License as6 _6 i) |$ H& K7 ] M' a
- * published by the Free Software Foundation version 2.
% s$ E9 P1 y" j# @ - *
2 h3 O% g6 I5 q, G - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
! ~# B' v" S& o7 ^1 ~ - * kind, whether express or implied; without even the implied warranty a" c0 {9 Y7 E) s7 ]
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 g1 \: ^* P, D/ y - * GNU General Public License for more details." [. j5 D. f' o. u$ Z
- */# ?; S6 T4 U0 \( x0 ?. D
- 1 I* D2 r, Y7 x" l- [9 @: u
- #include <linux/module.h>
- m( [0 x1 U% T - #include <linux/init.h>5 t- P& f, s1 p& v- U
- #include <linux/errno.h> c% X, Q9 ?3 S+ x. A
- #include <linux/types.h>/ ~0 p" G) |6 n: c
- #include <linux/interrupt.h>, k, _$ o& }# J
- #include <asm/io.h>0 K4 [0 ]1 ]3 M. N' U, [. ^, g
- #include <linux/moduleparam.h># M- t; R8 }, f: L8 M
- #include <linux/sysctl.h>
/ q4 X' N3 r5 _5 x9 C" r* O - #include <linux/mm.h>+ w- T8 K' H7 q: U: V
- #include <linux/dma-mapping.h>5 r1 g* x3 x: r; r$ i1 u8 ?* a
- ( w4 K1 L! ~0 {- S% h
- #include <mach/memory.h>, s3 P9 i ]8 n9 \" m
- #include <mach/hardware.h>4 M9 Z# A) Q' y4 c# H J8 B
- #include <mach/irqs.h>
% K% _7 Q; \8 X* F4 K$ N - #include <asm/hardware/edma.h>4 s) e9 Q7 \& U
* Q: d |6 D2 o5 U7 j8 z- #undef EDMA3_DEBUG
" ?( I C0 j8 P7 ?. j3 C - /*#define EDMA3_DEBUG*/- i% L* t/ U9 s: y' P
9 z1 V3 `0 `- L- Q1 E; _- #ifdef EDMA3_DEBUG
2 P% A3 q' W- |6 E: h9 m - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
( [$ l5 k, V& ]/ e" | - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 t# R7 e" ]) U2 P+ n! D - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__) P5 o' B5 |8 j) B
- #else
- c2 k. h) S0 ~9 i" a6 p# f7 R - #define DMA_PRINTK( x... ): M' e. F1 h) Q9 ^2 ~
- #define DMA_FN_IN
5 h0 p; k$ u2 x - #define DMA_FN_OUT
1 ]6 t, Z& T3 z2 J6 O( ? - #endif) W5 b" P* [) p1 W. ^6 e
- ; p6 F! v+ t- u
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 O2 }# S! W1 @; ]# w* j2 \8 }: n - #define STATIC_SHIFT 3
4 A! e1 ?9 B/ L% D0 y5 ^( R - #define TCINTEN_SHIFT 20) a3 g0 J$ P9 {8 j& J/ c
- #define ITCINTEN_SHIFT 21
( J$ T+ b I3 F l - #define TCCHEN_SHIFT 229 Y0 \3 w1 |% h$ Q; d: G
- #define ITCCHEN_SHIFT 23/ A3 }1 J! K a" b. a7 u6 q
/ H0 e4 e, R7 L4 k0 m* U# }: U- static volatile int irqraised1 = 0;" X: x5 f' D( x
- static volatile int irqraised2 = 0;
4 z6 C: c& V4 l. r$ T9 [
4 w1 l: i$ I% r5 ~0 G1 A- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' V/ E+ i! D, ]) H# ]
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ j% E3 O2 j. f d2 k+ f% l" c - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% W9 V3 j5 N& ^
( w! V9 Z! g- o1 ?- dma_addr_t dmaphyssrc1 = 0; H+ J9 W. m% k! ?8 l. k9 K/ _7 p
- dma_addr_t dmaphyssrc2 = 0;0 g8 H$ |3 z) d9 Z( S8 g
- dma_addr_t dmaphysdest1 = 0;
: ^+ C- L0 |* [% M$ Q+ m - dma_addr_t dmaphysdest2 = 0;
, O* }. f: V/ j4 ^# u
/ B5 ]. q3 E- v) U$ w/ h7 }' ?6 G- char *dmabufsrc1 = NULL;# r9 b, y' m7 b' i3 o4 z0 z# `* \
- char *dmabufsrc2 = NULL;
. J" |/ A+ G6 I - char *dmabufdest1 = NULL;% j9 O2 R- x# J
- char *dmabufdest2 = NULL;4 u. [- K v# Q1 x8 |1 y
- " d, o g% J: B- H3 [3 k* n
- static int acnt = 512;1 @7 ^1 d1 T9 B- j: i; R
- static int bcnt = 8;
0 i& e! l6 v( @. m5 H5 u+ T+ I - static int ccnt = 8;
# \. o- v; g$ P7 F
% t/ D! m- b0 d$ j, ^+ K$ K) L- module_param(acnt, int, S_IRUGO);0 p) c( U/ I* `. M% b$ N
- module_param(bcnt, int, S_IRUGO);
* z/ K' F) X% N4 b \) i - module_param(ccnt, int, S_IRUGO);
复制代码 " |" N! w: a+ w$ v1 h
; D1 h0 }2 f: X" Y# f 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& O4 J, M/ }( g. h; ?: B. P2 E& `7 Warm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。6 Q" `7 X0 x q( x; D
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。& C$ F7 u, t0 L3 q5 q7 L; `
. @1 h' j5 F# R, Y: |
$ i4 U6 C' @8 B, M8 ^1 k
|
|