|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
1 X- I) w- ]5 q$ r6 C- [code]EDMA sample test application% h7 r" w5 O3 c+ d+ ]' u/ W
- /*0 v) Z9 x) _ e/ o
- * edma_test.c
$ {6 N! u( G. u V - *2 t2 I* f& Y, u! S
- * brief EDMA3 Test Application* X) I6 k9 g8 }! j* \2 G
- *
8 `! k$ F5 J7 g3 p6 t& ] - * This file contains EDMA3 Test code.
7 k& P* a0 o' V! J5 X - *+ `2 m9 @! n, N! W3 E
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
9 B. q0 ^, j5 f1 M - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
6 T. F m$ b% D m' B# s# `+ M - * TO CHANGE.
5 H5 r1 N& O5 M1 P) Y6 s - */ y) ?; C" U1 w6 J
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/$ q6 _4 I0 i K* l$ S0 t
- *
2 v: I5 d' {: c6 }* ^ - * This program is free software; you can redistribute it and/or
# T6 q5 T% w6 p5 k- w - * modify it under the terms of the GNU General Public License as5 f. H8 T9 H$ \5 m4 H' W2 ^+ {) p0 \# ]
- * published by the Free Software Foundation version 2.* z: i$ c% x/ t/ O [" U! N; `( E
- *
7 ]& s# P2 ]# S9 L _ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
. K4 c& w% M5 ]3 k3 L ]) J$ |' [/ \2 W - * kind, whether express or implied; without even the implied warranty# L' ]3 o- B8 Z9 j' B% Y- I
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
J; L' _% n+ i - * GNU General Public License for more details.
* o2 n1 G4 j8 f/ Q+ D. A - */ C" w K; y. T' t6 E! X
1 ?1 d- Z' J) [; [- #include <linux/module.h>- k/ p, E9 i6 d
- #include <linux/init.h>! M% R( F' q1 E0 g& P. q; l
- #include <linux/errno.h>5 H j# C) q: b
- #include <linux/types.h>- T4 v! c* k4 q* B
- #include <linux/interrupt.h>
( a& ^! ]! V; w! q6 P* A - #include <asm/io.h>: A: m7 T9 A0 A4 U
- #include <linux/moduleparam.h>. B0 Y1 J4 L+ p2 s
- #include <linux/sysctl.h>
* @ M* i8 M a - #include <linux/mm.h>" i. a- @" p6 X8 R
- #include <linux/dma-mapping.h>) [" P: `, X" @8 ~
- 8 A( X6 E+ }! ~. ~* t% |
- #include <mach/memory.h>) {/ ?4 s& l8 x3 t9 G- h3 t
- #include <mach/hardware.h>& v7 m$ g# T W. f' p* n
- #include <mach/irqs.h>5 v7 X+ P& [; L I) {1 [' _$ P
- #include <asm/hardware/edma.h>
2 o; K: D. `1 Y$ Q6 x% [0 O: Z
$ E g+ n8 ~2 x8 {5 L- #undef EDMA3_DEBUG7 {# H3 k4 h# N/ O9 R' t" J" [
- /*#define EDMA3_DEBUG*/
, ?. O5 S0 y: Z C7 {: Z# y - / q0 ]+ \1 A7 k# H. u6 F8 m+ _8 H
- #ifdef EDMA3_DEBUG
" b" o3 K7 m8 Y6 q - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
8 [! W" [% x* a. C/ Z3 t8 B+ ]3 j - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
' J1 s8 `3 F+ o5 \ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 L& |3 U2 u1 o7 l6 k# B9 R - #else
7 w$ C- `7 X! ^! @* ]; X, a - #define DMA_PRINTK( x... )! Z1 n$ o9 X0 U- ^( g
- #define DMA_FN_IN
$ j* \) G4 \& j& x* ]0 @ - #define DMA_FN_OUT
4 a5 n4 R) \6 O0 S; D( ? b - #endif
+ R7 G6 u: v% K! J; n* | - % y. |; `- W2 [, c
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)( G7 X0 r- [" W; b _& Q
- #define STATIC_SHIFT 3
5 w8 I, {) E0 h: W0 B - #define TCINTEN_SHIFT 20 m5 o+ L; Q; T1 v. G/ ~" Z
- #define ITCINTEN_SHIFT 21# |) ~1 X" {: i& J7 p# J* p
- #define TCCHEN_SHIFT 22
7 [& z/ J! _; w5 r6 w - #define ITCCHEN_SHIFT 230 C2 k. R }% j7 q$ p4 O3 X" |
; o$ x, s4 M( o5 ^3 d- static volatile int irqraised1 = 0;& ~* y' |$ u8 M5 f
- static volatile int irqraised2 = 0;. O; J9 e) `# [" o3 z U- n0 ~
- - p' s5 F: Y- j- { b% |
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# [ P+ F3 U4 p$ y
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 L5 z2 B1 B. z" e1 I4 K - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# h2 R+ P) `$ B6 u: R, x7 L
2 l, ^$ Z4 D3 \0 O( f2 i- dma_addr_t dmaphyssrc1 = 0;
. x F" n D$ \9 |7 k* h - dma_addr_t dmaphyssrc2 = 0;
* I: \! U& d; a5 E3 `" ]+ p, V - dma_addr_t dmaphysdest1 = 0;
* u6 m( S' d4 j+ G4 @& @5 H, E - dma_addr_t dmaphysdest2 = 0;$ R: u* y9 |3 x5 {: G8 S7 I0 @
' l& O3 a& C y- char *dmabufsrc1 = NULL;3 \. S6 a" y5 ]9 Z
- char *dmabufsrc2 = NULL;. I- A- d- k4 K6 _/ M$ D
- char *dmabufdest1 = NULL;
# f; m! ^1 j3 {$ D0 f/ K) U - char *dmabufdest2 = NULL;3 m' x J! X4 J4 M
- . d& d, J! F8 s( e8 o& b, Z0 Q
- static int acnt = 512;7 o: o/ ]- z" w% h
- static int bcnt = 8;3 z# y0 ^; n5 e" K
- static int ccnt = 8;
* K' o( `4 i+ i2 Z) Y9 u7 ~ - ) A4 N& Y$ b# C |+ T
- module_param(acnt, int, S_IRUGO);
* ], Z8 A& L7 _ - module_param(bcnt, int, S_IRUGO);
, H/ `6 E. l Q; a9 \9 O8 x - module_param(ccnt, int, S_IRUGO);
复制代码 : S6 \- ^, [& w( c, t1 U! K
$ V' X+ ?6 w+ j0 R; a4 ~
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用6 ~. X1 l1 f" y9 {4 Y" P/ z
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
( L) A2 T6 V2 h: F, ~3 {2 j2 a 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。0 z6 w2 O- W m# X
' i9 a, l0 k6 P7 V. o
' i: S1 X2 y P |
|