|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
+ N9 N% L, w: Z" I- [code]EDMA sample test application
0 w, F3 W1 T- f - /*
$ L, R$ k" J& Y7 M a" c - * edma_test.c
! l0 m# x/ i# g# }# o( C+ g% A - *3 F4 n' j- r( ]0 r
- * brief EDMA3 Test Application
( v% G) J0 ?8 K$ b$ y - *4 A% `% P% J+ z) z7 R X& S m
- * This file contains EDMA3 Test code.
! x. d3 j) o4 B; l% A - *
! ]- r3 g$ h. I3 t& f2 r2 x - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE$ d4 R- K/ h3 n8 M3 o0 w
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
+ b( C P6 X3 l# H/ y% S3 c - * TO CHANGE.
/ q/ G3 T! R! v; a0 c - *( i$ e6 I; ^, W9 W% ^* D
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
6 I- g& k0 ^0 O1 u7 d( Y) F - *
! t/ P& k4 P4 e V- O6 T - * This program is free software; you can redistribute it and/or
! U$ m6 l k6 s5 Q. l/ e+ [ - * modify it under the terms of the GNU General Public License as7 ?) U0 c% A) a4 j( h) Y- D# j
- * published by the Free Software Foundation version 2.* Y- A: s$ d' C. H
- *
3 o! B' O9 j6 s- l- h9 J - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
/ G& H+ w4 F- X7 G* I5 w - * kind, whether express or implied; without even the implied warranty9 [/ m! _" W: i* E' j, r
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% E* a5 i; B* H) c6 U9 ]! c& R - * GNU General Public License for more details.$ ^, I8 ]' d# x/ Z; X. W
- */9 P" D8 P+ r/ G; @- m
% a' R) ^0 O3 c) ]. a- #include <linux/module.h>2 }6 Q4 O7 ]# d2 r! c
- #include <linux/init.h>0 r, T H- l6 X& }" Y
- #include <linux/errno.h>0 M9 \& a# W4 E1 o" P* \& M/ n
- #include <linux/types.h>8 s& C) `; G* U% r; W
- #include <linux/interrupt.h>3 k9 h- f2 P3 j: ]6 T% T8 N2 y/ P
- #include <asm/io.h>$ g1 G- R. L; D) L. W1 q1 z" A
- #include <linux/moduleparam.h>
% k, n) V. k$ L# \ - #include <linux/sysctl.h>! U+ T/ E L5 D) b; _. Q, |* Q2 ?; b
- #include <linux/mm.h>
7 Z' D5 k; L1 b" L; {; { - #include <linux/dma-mapping.h>! k% a' X* E3 b0 ?" ~4 I8 a" ?# b/ h
2 ^+ H, E! b6 ?% u# m- #include <mach/memory.h>
9 u1 q. B, j6 d! w9 {5 Y, w; A - #include <mach/hardware.h>
D* `% r$ H/ A) W7 e - #include <mach/irqs.h>
' o. U f/ _" r8 | - #include <asm/hardware/edma.h>
; M- a8 w1 d, x0 K# ^- |- z: Z - 0 |5 Q2 i5 D* A) L
- #undef EDMA3_DEBUG
- U$ i8 @- c9 n; l - /*#define EDMA3_DEBUG*/
3 T' A" N4 S" W% D/ n4 _
+ t( \1 E& r; ~( [- #ifdef EDMA3_DEBUG9 C% E' `5 y: y
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)$ m! A3 t' S% {7 j# ?: B
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
4 @- t1 a8 n+ [' x- e C3 F - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)) W) W2 Q( b% [% t- L0 \. K
- #else# ^ ] G6 v. w, a) [
- #define DMA_PRINTK( x... )
, K$ I* h5 ~4 F0 l# h q/ i1 Z - #define DMA_FN_IN/ H1 b7 H' n4 n. k% N4 q0 Z! k5 I) u
- #define DMA_FN_OUT# Q1 u, J, X/ J N: ?
- #endif
1 ~4 w# ]9 w- V* ]( P! N - 3 z/ H1 T4 A% o' b
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)2 X) p+ Q: X3 p# e
- #define STATIC_SHIFT 37 ]: B4 q5 T3 w+ t F! ]3 Y
- #define TCINTEN_SHIFT 20 x' ]8 G+ X! C; s
- #define ITCINTEN_SHIFT 21! d& {7 f I& |) j" V1 N6 u
- #define TCCHEN_SHIFT 22
. s0 J6 J) Q3 a* w# b - #define ITCCHEN_SHIFT 23
- K8 m2 Y3 k7 h, R3 R+ J/ t - % f# e2 N& L' i2 P& z5 i" p9 s/ ?& ]4 p" z
- static volatile int irqraised1 = 0;
7 \6 H B1 e+ s - static volatile int irqraised2 = 0;
3 ^! x$ w! I$ l - 2 L, n) L( z( y3 ]8 M" S8 W
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; A7 y6 l6 b) p# {9 z3 B
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 U! G5 a* ]* ?7 ` - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 z4 [9 R4 L9 ? Q
; B2 H6 V) W( G% Z' o- dma_addr_t dmaphyssrc1 = 0;
* j0 I2 Y8 U1 }2 ?# B U) c - dma_addr_t dmaphyssrc2 = 0;
: o$ r* d o8 [/ j6 C - dma_addr_t dmaphysdest1 = 0;
7 @9 q, g& f" G" w0 g- ~# F8 `2 t - dma_addr_t dmaphysdest2 = 0;
- y; @6 d2 y! S% F - 0 d2 c! p& ~1 p7 O, M/ L1 j# d
- char *dmabufsrc1 = NULL;: |5 J( \1 |; X; ~5 W
- char *dmabufsrc2 = NULL; s( D7 X: r* _4 k
- char *dmabufdest1 = NULL;8 R2 F z; n$ w z
- char *dmabufdest2 = NULL;
, Z" v0 H4 {- s ~ H2 y9 X - 9 F1 U$ l- {+ y
- static int acnt = 512;
) r0 o* |6 p2 O8 q - static int bcnt = 8;
6 u6 t) [3 v. P$ p- t - static int ccnt = 8;0 ?5 w1 y6 p' V! @& R0 P Y
7 S1 M$ D5 A: l* y' ?- module_param(acnt, int, S_IRUGO);
6 z2 y+ U# d7 H$ V1 e. Z! c# h - module_param(bcnt, int, S_IRUGO);9 F* ~% Y2 @! l5 w7 e
- module_param(ccnt, int, S_IRUGO);
复制代码
4 {: {: q) ^8 ^! O( v" m& y9 ]3 H
% K' U% H9 n+ b1 W/ r) _( I/ G 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
8 a8 @' y2 @$ Q% Carm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
2 {* d3 d) H% H) K1 ^- c, D 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 I& z% J) U4 t* l! Z
) `! N+ K# w! F5 h" [! M" ^1 @5 K( b
[0 ]( Y. Z/ D2 ?0 k |
|