|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 8 D' i; A6 }0 z. B. u
- [code]EDMA sample test application
4 e* P) S* Z% L8 K - /*
/ L* o9 Z b/ V5 b: N - * edma_test.c
8 g& ^ `, Z1 x% E - *
$ C3 I6 a6 r) c5 V' Q - * brief EDMA3 Test Application
* a7 u) u" {8 o. a- X1 B - *
2 x7 v1 v" o' g) P7 Q2 I - * This file contains EDMA3 Test code.
) o9 Z( ?* f9 ]- q) G - *
$ ^0 l w' r( ~0 s3 M/ Q - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE- L$ e# F& h4 [. h+ f$ c
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
0 Q; g; e' V. C# q# A - * TO CHANGE.9 N1 A2 k3 x" J- Q- j7 `( d
- *. K, N4 j7 e6 d6 ?
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/" v2 E" L$ T0 X6 [
- *; t, O9 ^4 W+ s0 P" v5 z
- * This program is free software; you can redistribute it and/or
& ^- s0 U* K, [ - * modify it under the terms of the GNU General Public License as
/ @1 D% E5 \. m9 M7 X! N# Z+ N. m5 C - * published by the Free Software Foundation version 2.0 n8 V0 o3 h+ x) M
- *
2 N- P; u2 Y. M$ ^( E - * This program is distributed "as is" WITHOUT ANY WARRANTY of any" x: w7 |1 B% B \+ a: @
- * kind, whether express or implied; without even the implied warranty1 @; ?/ W6 p5 r2 s
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- T: J. _( ~! j c! o- e' k - * GNU General Public License for more details.
7 R; O# Q1 F+ D& n6 E6 a( X$ U4 H - */+ w3 U" L3 f; |; p6 O# r
- 4 }7 V( `5 O h0 f4 i, _0 T. l( i2 U
- #include <linux/module.h>
- \% B! f% d+ A& J0 Z) Z - #include <linux/init.h>) a/ R) R0 h; r6 I
- #include <linux/errno.h>; }. c0 _* j: R; A" \! D, l, x$ D
- #include <linux/types.h>
, c0 I5 D# A. u# ]- @; g/ B4 F - #include <linux/interrupt.h>+ T- ~! U0 G' Z. y$ G8 U
- #include <asm/io.h>
( s9 I; r0 Q1 h5 z - #include <linux/moduleparam.h>
9 ]1 D; y1 ?& y& o- w, G7 c - #include <linux/sysctl.h>0 \) r( J/ }& ^- G
- #include <linux/mm.h>5 o Z& T$ X, B& G
- #include <linux/dma-mapping.h>
( E1 @% m- r, k5 P6 D$ r
+ C5 I7 d) c" i# v q3 h0 @) s. n- #include <mach/memory.h>. {1 z) a; ?4 ?! H$ Q9 ~
- #include <mach/hardware.h>; p- C; K8 R& G% g. o( p% t! \
- #include <mach/irqs.h>6 v6 z1 e$ \ q; m
- #include <asm/hardware/edma.h>1 X; ?4 o1 t! T, H: {! T. B
^, B5 h) q5 t( k% z, W- #undef EDMA3_DEBUG, N! y4 U& n3 i( C2 B
- /*#define EDMA3_DEBUG*/
7 S+ Z( A, k" m- t! ]0 j; R
2 C, U' [( T v& ^8 \7 F- #ifdef EDMA3_DEBUG
9 j' {/ q: S8 L. D6 y8 C/ \; } - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS): u( H* H0 z% p+ q, N# O
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
6 G3 ^9 |5 E2 ^; D8 f3 p v6 _ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
! a4 u4 f! X) b7 G0 H: c0 u - #else3 J/ K4 a& u4 L6 h9 p- H) ?
- #define DMA_PRINTK( x... )
6 J. a4 v7 x% R3 h* R& K7 R - #define DMA_FN_IN
2 q- `( j. i+ U - #define DMA_FN_OUT4 y# P0 U+ |9 \
- #endif
/ s5 y( }# B8 q3 f) ~2 Y. G
: R) K9 |+ H% b# N- #define MAX_DMA_TRANSFER_IN_BYTES (32768)- h' h: t* v* \, P
- #define STATIC_SHIFT 3
, z( e+ N2 }$ y9 _ - #define TCINTEN_SHIFT 20
% X% Y% q; m7 a8 {" j/ K1 w - #define ITCINTEN_SHIFT 21
" ?% d! X, F* a( S8 M - #define TCCHEN_SHIFT 227 _- s: @, t2 ]0 } \
- #define ITCCHEN_SHIFT 231 n- G: p$ K; f2 d2 X
1 |- C5 d- J! F$ L- static volatile int irqraised1 = 0;1 q0 Z. s8 a9 s$ q1 f* P8 i: O
- static volatile int irqraised2 = 0;
0 G+ P0 w9 I( ^! x6 j. g - 6 p. X: O: }- h, l8 S9 L, m" A0 o
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 l! i) G4 s2 w( t2 W1 e" u* w( ~ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 {! A! l: ^1 X, K0 P! o. \( ?, A, a - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
M$ I$ g( @6 I$ l4 t7 ^
; k$ } k0 A& E4 {7 l- dma_addr_t dmaphyssrc1 = 0;
+ C4 O3 N+ |) t* M - dma_addr_t dmaphyssrc2 = 0;
8 t" G+ h# s5 Q - dma_addr_t dmaphysdest1 = 0;9 }1 W2 P4 O0 M) T/ e
- dma_addr_t dmaphysdest2 = 0;
+ q4 w+ d7 P# j5 g' g - $ R* b4 S6 w9 z6 N4 ?
- char *dmabufsrc1 = NULL;7 | v! x: ^1 K
- char *dmabufsrc2 = NULL;
8 l6 R4 M4 g( l- [5 i$ R7 l - char *dmabufdest1 = NULL;
6 R8 N. \7 ?2 ~ - char *dmabufdest2 = NULL;
) M) M4 H) s$ U3 \3 d' N
; U) T4 I+ T# n$ N- N7 E4 y7 @8 K1 c- static int acnt = 512;/ z4 `; G" E P4 j, P Z
- static int bcnt = 8;+ V! O3 G9 M- A+ w6 D) K
- static int ccnt = 8;
% f% H& T Z* \9 Q. `
; Y2 w) T: z! r' d- module_param(acnt, int, S_IRUGO);2 p& Q/ d: ]0 m" p
- module_param(bcnt, int, S_IRUGO);% c; H# y8 h& R/ b
- module_param(ccnt, int, S_IRUGO);
复制代码
|. V0 ?/ }4 ?! `3 @+ i2 o! z8 U* {. W5 B
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用7 _9 B0 }) O2 {
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
4 r4 Q5 P3 S h. Z7 g 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: ]9 p4 f- K9 d
5 N* a+ E6 O/ \' u
) {" U5 M* |- l# f( | |
|