|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 I7 ]. _, |' ~8 _' ]9 T, A9 F
- [code]EDMA sample test application
5 a& a6 I( u( c' P' G4 z% L1 N - /*( S1 ~% B8 W8 N2 v0 g4 g% x. h
- * edma_test.c
0 h, r& X; L/ D, e# K4 u8 [) P# P/ h - *
! i' K4 s3 x4 d( T* C( c - * brief EDMA3 Test Application( V: d% A' x; ?7 k. Z
- *
( i9 e- N: A& U u4 U - * This file contains EDMA3 Test code.$ Q- C) \7 Z" j t
- ** [. {8 O8 b+ q
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% H4 i3 [4 M( f& x - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; M! z; g; n3 m5 h$ m: B
- * TO CHANGE.- @5 Y. w* T6 z7 c( |: X7 ?. e- L
- *
9 H$ ^! i2 c7 {" r% g - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
7 G U! ~3 v$ ]( ~ - *
1 b$ q$ f. f. B" n5 o4 j7 E+ v' m - * This program is free software; you can redistribute it and/or
$ z. @4 h$ w; l2 ^6 z) h: e - * modify it under the terms of the GNU General Public License as
. V T4 P1 q" a4 R6 k - * published by the Free Software Foundation version 2.
9 K9 P7 H% ~ L! `. g& ~ - *! ?4 O* M- J1 T
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- J0 ^' V A: |0 \2 C0 o# b3 i - * kind, whether express or implied; without even the implied warranty
! |' H+ P( X2 @! f: ^ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- t1 T5 D4 K+ k% |7 r
- * GNU General Public License for more details.
+ P% _: ?" |8 Y: v4 w+ E - */7 q' s3 L [4 I; I
- ( l1 t$ c; i1 i# e% E
- #include <linux/module.h>2 o* ~; d7 Y* {; T9 r) |
- #include <linux/init.h>
, K4 g: g( b$ c) l, j( R - #include <linux/errno.h>
( D8 J7 D1 n: |( y - #include <linux/types.h>$ N4 K; ^6 W) v' W- g0 w
- #include <linux/interrupt.h>; J* O( f- y& t* Y9 w' ^$ w. {0 R
- #include <asm/io.h> O5 d+ g% |+ V4 {
- #include <linux/moduleparam.h>
( t( p1 `2 u( Q. C4 L9 q - #include <linux/sysctl.h>
4 Y$ f, ]: W, V( C- N - #include <linux/mm.h>
2 j9 P' B* @" C: { - #include <linux/dma-mapping.h>
% S" {2 S) {8 D% s z# r4 P/ \9 m
- Z6 b+ n C& O- #include <mach/memory.h>& q. k8 g/ i* p/ q8 K: D
- #include <mach/hardware.h>* v1 d4 ^, N2 C1 E( \5 e9 h
- #include <mach/irqs.h>/ O& ^: z' s. }) j' ~
- #include <asm/hardware/edma.h>
: c$ R7 [/ ?4 }6 v
0 l( w2 e9 R8 {* W' Y) K4 o- #undef EDMA3_DEBUG
8 W4 Y4 V( b3 z/ A+ S5 { - /*#define EDMA3_DEBUG*/
: T ]/ x- S8 j4 H
- G c- F* e9 _- #ifdef EDMA3_DEBUG
" { E% Z4 p; }' l; I - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
% G1 [+ q3 F |3 D/ ]! S - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 G* Z. G% o( L, b$ X6 l/ J - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)5 b: |; `$ U0 x2 J% T0 C8 x
- #else
5 O0 `* L0 Z9 G; z$ i# p - #define DMA_PRINTK( x... )
% m/ e, m" s% w* Y; @, I Q, W - #define DMA_FN_IN
8 Z8 s( ^5 ?8 Y+ C& \4 K0 |6 A - #define DMA_FN_OUT3 Y n, J2 [+ Z% V% m4 K/ U
- #endif" K$ Q" w, G1 I( Y m
- 9 G: q& x/ E$ v$ K2 p
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ P8 n6 Z$ \7 k( T
- #define STATIC_SHIFT 3/ W6 k( k8 P4 C: }8 U- w+ y% h
- #define TCINTEN_SHIFT 20
$ a7 {1 E( F& c! m% i. R - #define ITCINTEN_SHIFT 21# ~8 x1 R2 C) [3 O2 f6 h5 ?( n) P
- #define TCCHEN_SHIFT 22
# D! {4 u* p( \% e9 U" o+ m - #define ITCCHEN_SHIFT 23
, o/ ]* `, L I8 m2 y; Y: G' h - 6 d! Y0 Q9 x) q+ P% S, [2 F
- static volatile int irqraised1 = 0;
3 b b+ `5 k4 b; C - static volatile int irqraised2 = 0;
& X. q% _( W: g% @( |; w - / c5 T( C% P7 f8 D2 x! `7 m
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& G, l) E% X! i* {" q - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! O: K+ U7 j" T$ d3 s# B/ D5 ^' p7 Z - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ |- A6 z) @& G `5 O
- 9 ~* o) G% o3 }; ?. K; L9 y
- dma_addr_t dmaphyssrc1 = 0;
1 d: t3 A! o3 A. d3 H - dma_addr_t dmaphyssrc2 = 0;
3 _- Q8 F% \6 A' z0 J! W - dma_addr_t dmaphysdest1 = 0;
- ?: W1 j% ^# U" I0 ~ - dma_addr_t dmaphysdest2 = 0;
( w& g5 P' \: y1 \8 V' E - ; I2 G1 W8 g$ o* T8 A% k
- char *dmabufsrc1 = NULL;
4 Q( T$ p8 v& }8 L R - char *dmabufsrc2 = NULL;* [1 C" A3 f1 h# u8 t3 h" Y
- char *dmabufdest1 = NULL;
4 Z0 P% S* }0 `, ?% C6 q4 a; P- w - char *dmabufdest2 = NULL;
; a! H) K% W" S m/ y' Q, Y0 Z
! o& o% d7 J! A- N5 R- static int acnt = 512;
; @" q, B- C) l2 E. A - static int bcnt = 8;" y# z1 n$ Q7 g+ p
- static int ccnt = 8;
; s9 p+ C# W) A, c3 X* E g6 E - 9 Q' \( Q \- \. Y
- module_param(acnt, int, S_IRUGO);* \! j' D9 j3 w% c: F
- module_param(bcnt, int, S_IRUGO);
% M4 m* X6 e- F- e) S) m1 l - module_param(ccnt, int, S_IRUGO);
复制代码 ) x" f6 @/ {' a' u
9 C( l6 S# |0 t" U) ^* A/ G
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) |1 k+ L. i, ]. T8 @) E% [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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
5 s9 S8 E2 F& P# J8 H5 ], n9 O 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。; M% E* r4 [, l9 o/ \) T
: u9 g+ e. X8 ~, F; v7 a. j% V& t6 v; ` a0 n' n2 H, p
|
|