|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ; x" u; `7 G6 ~, O4 H3 k! ?
- [code]EDMA sample test application
, I' Y2 v8 d( c( e% e+ Y8 t# S - /*9 X! `+ N1 z+ B" Z# `- g
- * edma_test.c0 @0 j+ W: {+ p
- *3 K- a: p7 J L% L8 R' ]" [; E2 K) P
- * brief EDMA3 Test Application
0 d$ C3 E! U$ Q1 Z( Q4 a - *
" ]: s5 O; j, m! V+ M - * This file contains EDMA3 Test code., K* G3 D. x) D& X- g& W4 T& V1 ?
- *
5 w* k o5 l+ F d3 X# a - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE* u/ b) {2 y2 p4 v$ r( ]
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" V1 Q7 z& b. z - * TO CHANGE.
% o$ D" d. D/ d2 ] - *
- p: d# I/ u% S7 h6 o" K: f - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/2 F) D+ L- T; b7 ]4 a& n5 ?7 `0 x7 |
- *2 p' |& w( w. A0 X2 h) L5 L: \
- * This program is free software; you can redistribute it and/or
% i3 _8 C3 `# ?9 {* E# N6 h3 C - * modify it under the terms of the GNU General Public License as
6 _; `1 ~/ X9 k. D: r - * published by the Free Software Foundation version 2.
6 ^; B) q+ r% n - *! \$ b9 g, j' |; h6 {
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ g: E$ z! {( t) J - * kind, whether express or implied; without even the implied warranty" S/ v9 C) {7 O7 k7 l% @# J' F
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~# g* \8 [1 b c9 C1 | - * GNU General Public License for more details.
# B! j' R2 L+ C - */$ x7 O* z4 q4 n" P% j
" |6 D# s. A& K- #include <linux/module.h>4 @8 B( F. k- i
- #include <linux/init.h>( Z' a( e- {; V# o( f* D" g
- #include <linux/errno.h>
; I7 g! `8 f% C7 U S% C - #include <linux/types.h>6 W: E, H* N! N$ P2 G: F: q# p {7 e
- #include <linux/interrupt.h>
& w" i7 ?$ O; j8 a" N! r - #include <asm/io.h>, f2 X3 J8 w9 @; M
- #include <linux/moduleparam.h>& K2 n- D0 f+ Q/ ] c/ m
- #include <linux/sysctl.h>
/ Q. T$ p2 _( R6 r - #include <linux/mm.h>
+ U X# r C$ M! N( Q0 ?& Z% v - #include <linux/dma-mapping.h>9 o% L& W4 ~% Z2 O: N# V- y" l. j
- - d$ n+ ~3 n ^7 ~ s
- #include <mach/memory.h>
# f. a n6 S9 }: E+ z0 Q9 a+ E( }7 _ - #include <mach/hardware.h>
3 C' N7 g% _7 r+ h k - #include <mach/irqs.h>
# s& a: Y. ?6 H) I - #include <asm/hardware/edma.h>
6 t7 E" I+ w2 O
8 A% d% ?; H9 v2 h4 W( l1 _- #undef EDMA3_DEBUG. i. S' N( M1 j; l
- /*#define EDMA3_DEBUG*/0 d! ?0 K7 @8 P9 G1 N- g W/ g, H( g
- # Q2 N' u$ h0 x+ ^$ U& e
- #ifdef EDMA3_DEBUG
& C' T& q) x- R0 [ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)0 _* V+ K5 J% B' m4 d
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
$ t5 @6 W1 H! R7 J - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 x$ ^% V- c0 y) J7 U
- #else
?. ]# g) R& v" h8 O7 d; D - #define DMA_PRINTK( x... )) e* ~) E/ c' M
- #define DMA_FN_IN
: s+ l# e0 z. g% F# q3 \) o) ~5 T& u - #define DMA_FN_OUT
! i$ ~4 U! X0 \8 K- p - #endif
+ M2 |# I, a' j3 j; @
+ [7 b1 Y) W: l( y- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, {% r7 @6 U/ d; M6 z- {3 \ - #define STATIC_SHIFT 35 N" Q& f, C. q; o- m# z+ W& `
- #define TCINTEN_SHIFT 20
2 V, V6 i, v4 {7 n3 c% G P/ J - #define ITCINTEN_SHIFT 21
8 \; E5 a. _. N. Z& r - #define TCCHEN_SHIFT 22
" P5 \4 a1 R% H2 c3 H, b - #define ITCCHEN_SHIFT 23
! a9 Z) R% Z/ G: K" Z - . ~( ~* S% F6 F+ `8 |: t4 t! t9 f
- static volatile int irqraised1 = 0;
; l$ Q: @8 T' D - static volatile int irqraised2 = 0;
4 h5 R) E' @9 o - : U y. s% e; I
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' j0 R1 O, L! K0 U - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 Z* C2 H3 h7 Q# P" f2 L' ]6 k$ S8 I - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! C, U+ A' _8 w
8 _, b) N. ^: ?4 V2 [$ M3 v# \- dma_addr_t dmaphyssrc1 = 0;
; d$ E* U3 W; l7 q: Y7 J - dma_addr_t dmaphyssrc2 = 0;2 ^4 W* b5 Y, z" {8 k" H* p# I
- dma_addr_t dmaphysdest1 = 0;
. G" }, p) ~% o3 _6 } - dma_addr_t dmaphysdest2 = 0;; i6 X( l$ U# `) b, ?" Z( E
- 0 X7 X! K @, y( }* O) @; \
- char *dmabufsrc1 = NULL;3 u8 T- T+ o) }# \* S6 V
- char *dmabufsrc2 = NULL;
9 M3 y3 E$ H- w2 N8 w% c. P" d - char *dmabufdest1 = NULL;/ @( M* r, e( v; G- J3 u2 ~
- char *dmabufdest2 = NULL;
Q( e+ H' J5 |& v - ( Y3 e5 i/ A, r% p4 t0 {7 i" F0 Q
- static int acnt = 512;
J9 Y$ @ R9 l - static int bcnt = 8;: V. `% G1 u5 q
- static int ccnt = 8;% `, u/ R3 v8 k/ J
- a& p1 ~# b2 M! i
- module_param(acnt, int, S_IRUGO);* H' j! W. l4 z9 s
- module_param(bcnt, int, S_IRUGO);" M7 `- f9 R3 [* `: n O
- module_param(ccnt, int, S_IRUGO);
复制代码 2 c0 {- f; f9 N
. ?4 V2 ~! w: |
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 g* J" F/ B! N* o( farm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
8 L" c2 i, S7 o8 P# K; ]0 W5 j 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 m1 ]7 ?. _9 o. W
* w/ \- O0 c: r, L
3 r' z8 F) b$ G8 ^: G, m# ?
|
|