|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 p; ], e0 E6 z" f8 P- [code]EDMA sample test application
$ F5 w8 E% a# O8 z( P - /*
! t# u: W3 Y" R - * edma_test.c
7 S( G' G, Y& L! R: A1 G& Y - *
& a% a1 P5 h Y - * brief EDMA3 Test Application
( ]3 s' l( I3 c& N - *
+ n9 U) `, k% y& w- I - * This file contains EDMA3 Test code., M W/ o: I; T) A* W/ }" n( N
- *
- W" T& e* z: s7 r, l - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
: y+ |. D- D$ F: g - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
1 _) Z4 `2 I) F' u5 @. L2 j" ]# Q - * TO CHANGE.
: A" l g9 z) c3 l - *2 V9 l4 l, q& G' e; u
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/) U5 e% d/ e3 h1 J
- *7 U0 K1 |9 J$ N, z: @' O
- * This program is free software; you can redistribute it and/or( ]& Z0 ]. h- i- K/ E& s
- * modify it under the terms of the GNU General Public License as
3 w+ j B( d) {5 \# C - * published by the Free Software Foundation version 2.
) L% F7 E; }2 i - *# i; B$ X' u: V' |; y
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any% k3 W) ]# m5 z, |- V, g
- * kind, whether express or implied; without even the implied warranty
% u# n6 f8 l# ] S1 S# W1 p - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1 O# s% q; K$ L4 H0 f# n - * GNU General Public License for more details.1 e& y' X0 Q, |6 x) u" X5 C" g
- */
+ l" P5 L1 f$ b - 3 T- {: o# Y+ C2 |$ P9 @& m$ b6 g
- #include <linux/module.h>0 i: v7 r% S7 Q8 G ]8 k0 k
- #include <linux/init.h>
; W+ X% K8 R! X; F6 L - #include <linux/errno.h>
2 l( ^. L4 t4 V/ r/ R' h" @ - #include <linux/types.h>
( B3 g' q7 X/ z; V+ i8 L - #include <linux/interrupt.h>
, x8 [& B* f! h8 s - #include <asm/io.h>0 ?+ ]$ T/ _' Z; q3 m: L7 o
- #include <linux/moduleparam.h>3 R5 Y( o2 O* T4 l
- #include <linux/sysctl.h>! ?6 F6 Y3 k7 _# u$ a5 X
- #include <linux/mm.h>
- Z+ @: Z. [+ Y& Z3 T - #include <linux/dma-mapping.h>& ]& p+ Z1 u# h& {5 {
8 A }5 X1 Z5 v- #include <mach/memory.h>& f* Q c5 X+ g1 i% [/ `9 `1 X
- #include <mach/hardware.h>8 [/ [0 l% G/ [0 M* `
- #include <mach/irqs.h>1 f7 `" b5 v4 j5 j
- #include <asm/hardware/edma.h>
; D: _2 _6 v1 d1 ] w: n! l* E S
4 ]. J4 q5 [6 N) h. z- #undef EDMA3_DEBUG
3 T0 l" I; H9 F' {1 Z% W3 J - /*#define EDMA3_DEBUG*/
1 z' V$ Y" ~; z - - Q/ |) c/ i- f- Y7 p" q
- #ifdef EDMA3_DEBUG. ^1 E+ ?5 E1 `% M! a* m1 Q% \3 t7 ]! L
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)' r* b! |3 V8 D# B+ }8 }9 w' c
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)+ D# T1 y, z, `5 i' B& ^" k9 ?- }$ a; t
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
]7 @0 [+ B5 @: A/ q- U8 L* B - #else
; s7 ^0 [& n- h2 u, g - #define DMA_PRINTK( x... ); V7 m* ?( K, d5 L# B
- #define DMA_FN_IN
2 o; E6 B- M! Q- k0 V - #define DMA_FN_OUT9 c q# K7 w- j
- #endif8 T! H+ V% H9 N$ z
+ z9 S' e \; \: `$ @( _ W- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
* C; s, \$ l0 B8 A' x - #define STATIC_SHIFT 3
0 @$ G' s' V( n. W6 z% o) z' J - #define TCINTEN_SHIFT 206 f5 r3 y( L: h1 Z2 @7 m; |
- #define ITCINTEN_SHIFT 21
( U7 ?/ G$ w" l9 d6 i5 O& J) V - #define TCCHEN_SHIFT 22
5 e$ z1 F) f& m6 V, f' O4 F - #define ITCCHEN_SHIFT 23
4 d! W# q1 D" h - J; D" e( ~" n7 \0 s; G) {
- static volatile int irqraised1 = 0;
: I a$ R& Y# d4 Z- a3 C. @* S - static volatile int irqraised2 = 0;" F0 r* |; z6 X4 X. f" i
( `" ^8 m6 i1 u) ~3 U- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# F$ g2 A" }7 _' t( F4 j1 S9 m - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ k/ ?' y! {+ P- Q$ H) i
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& u9 A+ @5 [( Y/ s - * S9 I$ o, G& M9 ^1 h
- dma_addr_t dmaphyssrc1 = 0;& x: e! g& S; [1 ^/ U% y4 ~! D* S
- dma_addr_t dmaphyssrc2 = 0;
6 Y; P7 {" ^0 m) r - dma_addr_t dmaphysdest1 = 0;
. `% U0 z, p( B% d* B - dma_addr_t dmaphysdest2 = 0;( _+ x3 ?! b, _) F, l0 N8 }/ X
3 {: p9 M8 P- n& ~: Y- char *dmabufsrc1 = NULL;2 _, \6 c' s! J7 w0 s0 u
- char *dmabufsrc2 = NULL;
; Z+ d: |% f7 l! }: y7 m; q% y7 e - char *dmabufdest1 = NULL;
: A9 q3 G/ h% A; I4 S1 y1 `' Z$ M - char *dmabufdest2 = NULL; G% y; n& C9 \; y4 ?
- ) j3 ~1 o& p4 x2 ~ d% C
- static int acnt = 512;
% c. _7 c0 A' ]: d; W/ w v4 P( c - static int bcnt = 8;6 _+ g! y0 s% t/ L
- static int ccnt = 8;
) ~5 H. D* _/ R3 Y7 G
; J; y! n& W5 O& Q- u- module_param(acnt, int, S_IRUGO);0 E# D/ Q; t( a
- module_param(bcnt, int, S_IRUGO);6 Y# U, H1 ?! K) R( Q
- module_param(ccnt, int, S_IRUGO);
复制代码 ( a( c) ?7 x) y" h5 F
) t: `2 E/ \- s2 O% h 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
( U* X( ?$ F8 K" Earm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。 g2 d# G$ } ^- i, l4 G
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。9 f2 P% @* Y8 k; S( X
1 m/ Q1 J6 E' w0 p4 P! J
$ G9 C; ?7 b2 R9 |& m4 H |
|