|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
8 Z- B6 }- Z- h- [code]EDMA sample test application
8 ]+ l( L% L7 c& ~( U$ H1 f( H) x - /*
; |6 t: }7 y0 H - * edma_test.c
; m9 }( C! ^/ k! _; S2 C - *
5 p$ C7 `# Z! _/ c; M5 |, X - * brief EDMA3 Test Application8 ^$ t4 V9 ?3 a; ?
- *: M9 [; l O0 Y! D' K3 s% y
- * This file contains EDMA3 Test code.
8 o. U, v0 \8 ~# q, w1 c4 I2 A! C - *
8 p) x% [, t" T3 ]/ {9 _# Z - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- G! } F: {1 M - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
* b# r6 {# l/ I9 t. m& P7 i - * TO CHANGE.7 ?6 R, h% |& ~$ H9 i: o0 f
- *
# f8 v' O( M5 i/ |( | - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/. h6 ~( `4 z* i' i! W5 _. L
- *- A+ J! I7 s' f
- * This program is free software; you can redistribute it and/or/ ~- o4 ~0 N( v# R
- * modify it under the terms of the GNU General Public License as+ e' r- D/ [2 z& J% o4 n
- * published by the Free Software Foundation version 2.; I( u) ]" {. [/ q5 M7 J
- *' g; U- d8 J8 k6 }6 m
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
! ?' J0 W" d3 Z) D - * kind, whether express or implied; without even the implied warranty% d. O/ v0 Q3 ^/ \( U8 w
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the; G3 d( J0 p. G6 z- y) Y4 q
- * GNU General Public License for more details.* E* N. i1 c! M5 U# ]
- */
0 n) J3 j& F' _
8 {# O1 K6 Y/ B2 ^- #include <linux/module.h>4 `3 _1 [5 z6 e" M" X) ^5 O- U' ?
- #include <linux/init.h>( L# O" G; k4 X) A. I( p7 v5 l# [
- #include <linux/errno.h>6 e) V2 ]6 n) I; q+ [4 v* Q$ c
- #include <linux/types.h>3 \1 N/ `% u# d( `; Q
- #include <linux/interrupt.h>
/ _6 m5 _7 {& t' Y$ I7 M - #include <asm/io.h>" S4 j8 T% h: U; I6 B+ }
- #include <linux/moduleparam.h>2 ^% x2 ^5 m! n5 _1 }; u; {
- #include <linux/sysctl.h>
; ?3 C1 U! x. f - #include <linux/mm.h>
: \; P9 k n( z/ {% V - #include <linux/dma-mapping.h>$ ^( r* H- \( V: I
, j2 I/ C3 w: Y, W6 j; M- #include <mach/memory.h>$ f* _7 x$ N" [1 }) j
- #include <mach/hardware.h>) X" S. P8 o* {) j& f3 Y, u
- #include <mach/irqs.h>& |9 R5 K0 T$ y' [* O! B) E* s
- #include <asm/hardware/edma.h>
: b, t3 z4 @$ P9 V
Z- ^0 S- `1 z' z7 q) h- #undef EDMA3_DEBUG
+ Z4 Q2 S; {2 l$ n+ z/ O2 c1 X+ s( Y - /*#define EDMA3_DEBUG*/) p @ B! r* k5 { j1 j
: N# d2 B$ a" U& e- a; v1 K8 u- #ifdef EDMA3_DEBUG
% ?2 i% D. y/ T" m" e' X ] - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 Q/ L$ p9 G4 C$ L( r5 h) r - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)% P( n. [1 J- E' K- T6 x! s
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)3 R' J& u: s. k9 t# D+ h k
- #else
2 H" G+ b. k w/ B7 g - #define DMA_PRINTK( x... )7 A8 K. ]5 c0 C+ M
- #define DMA_FN_IN- G6 v- P8 k3 w! M: A% K
- #define DMA_FN_OUT- y5 a! D7 _& f* F2 W
- #endif4 O, y' j) R$ e$ l
- % Q9 ^% @: f7 A/ U% U8 S
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
0 v2 |, A7 |$ Q5 p4 D. ` - #define STATIC_SHIFT 3
8 P# |/ a/ I( m - #define TCINTEN_SHIFT 20
$ u. ]8 D. K6 A/ a - #define ITCINTEN_SHIFT 21
6 U) Y) Z( X: l, {) U" i0 q - #define TCCHEN_SHIFT 228 h# Q" L/ o' C
- #define ITCCHEN_SHIFT 23
9 i8 V9 {- U. y - / M4 J1 V# u# x- z1 T+ x
- static volatile int irqraised1 = 0;
# B1 B4 e8 I9 Z. [ - static volatile int irqraised2 = 0;
$ U7 J0 j T4 h1 E
' t/ L1 H+ `3 X, S/ ^( K; I- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- j" v- @" ]# y9 z# T; |+ k
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
p; o# v; p; ?+ r( g - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 L7 I& d/ o/ x+ x: H% X
! y& f/ `- h6 Z+ b- dma_addr_t dmaphyssrc1 = 0;" I* L# i- S% [0 }6 P3 I% @
- dma_addr_t dmaphyssrc2 = 0;
6 V" G+ o4 k F( ~: i7 p2 _ - dma_addr_t dmaphysdest1 = 0;/ R# t. b" _7 Y D* s1 L. U
- dma_addr_t dmaphysdest2 = 0;
) G1 q: [! p2 B# h) c3 W0 |
( ]6 J; m" I K+ ]+ J r' y9 N- char *dmabufsrc1 = NULL;
9 ]; t2 a% T8 P8 k) T7 n - char *dmabufsrc2 = NULL;
( ?; m* l; f1 [& k+ K! a; k( b9 L, T - char *dmabufdest1 = NULL;6 p q" d* K& d0 R
- char *dmabufdest2 = NULL;
9 m6 d8 s" k Q3 x - 7 f! E* e$ \ e/ H. C
- static int acnt = 512;
* G2 D! g: ?1 ?) t/ v9 X3 w - static int bcnt = 8;
0 R% l: K" G, Z' t: J# ]: i - static int ccnt = 8;
+ I9 z4 R8 z7 i" N$ W5 W- b6 w - & `9 P- p& M- h2 y6 O' W) d) K
- module_param(acnt, int, S_IRUGO);
e( K1 j1 d: L6 `: Y - module_param(bcnt, int, S_IRUGO);# I" j1 C% {9 j4 i
- module_param(ccnt, int, S_IRUGO);
复制代码
' l6 M7 S2 v+ E5 P2 l) V; D5 W
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
* h/ \# ]! b: Marm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。- h3 _; k5 [) l$ X: j7 [' u/ j6 p* O
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。, X3 n% i/ C a; P: s w
9 Y1 o. Q' Y# m/ Y+ n8 C+ r) J. W5 H
1 b$ F) U6 S# w+ i |
|