|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 * V+ o- D" n# c# B
- [code]EDMA sample test application
, j8 N2 ?. A, a$ o4 y7 {, | - /*
& L$ z+ s! \) M( M& y' ?+ y - * edma_test.c
7 [1 k9 w% ^1 ^9 |+ A - *
5 ^; q/ x0 X' v" ` - * brief EDMA3 Test Application# Y- D2 X8 `' _$ o. b$ [$ r
- *
: [+ K) m( x1 K7 @, c% ]9 J - * This file contains EDMA3 Test code.2 j' ^* F& u' d# q' z
- *
+ Q& N+ P/ s$ Y% T - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 \% o8 U, f2 j- a7 P* D - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT# p! t' W: O( N& |" E
- * TO CHANGE.
1 F4 ?4 t0 R1 s1 \% i! h - *
4 W1 e+ O6 k' _' m5 p, D! o - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/: I$ t0 Y T6 u; {3 O, ^
- *' k* K8 @* P! o* @( D+ h! D
- * This program is free software; you can redistribute it and/or: b# [ m2 @8 z2 \
- * modify it under the terms of the GNU General Public License as6 x* f$ A+ K. C$ z5 b& D' j; }
- * published by the Free Software Foundation version 2.4 M/ w; x! W( f# G5 W1 _
- *
' m, T" {8 P2 s& y+ \8 V - * This program is distributed "as is" WITHOUT ANY WARRANTY of any1 U" v2 m2 y& @( h9 }
- * kind, whether express or implied; without even the implied warranty
: s$ \, r7 B/ m, @3 r; b- w; n6 @- A - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
. o, _# ]( C: `& G+ d- N - * GNU General Public License for more details.
) U0 f% R4 J. A6 [/ B0 R - */; n; e2 q* x, q, q: g2 e4 H2 m7 R0 h
- ! l" ^/ {' ~. m7 Z/ l1 Y
- #include <linux/module.h>
; N3 i( s. f" _) Y3 X' N - #include <linux/init.h>8 W" \6 U; C$ I" F' t
- #include <linux/errno.h>. T/ G2 `$ x1 w3 b
- #include <linux/types.h>
% {2 G) ?$ r8 ~: ~$ d* f8 Q - #include <linux/interrupt.h>
( b) }* y; T0 h+ w; h }9 Z - #include <asm/io.h>7 U4 K8 [5 e$ _9 E# p5 K, W
- #include <linux/moduleparam.h>. G7 b9 F. i5 o9 Q# |1 o# h# S
- #include <linux/sysctl.h>) D5 U4 j* |1 Y, H8 A8 |
- #include <linux/mm.h>
6 F% y' O: X! Y% X" N7 @4 L4 m - #include <linux/dma-mapping.h># T- ]" b' g- `$ x" p7 M( m7 l
- $ T, I. i! m+ x6 b, Z! c) v- s
- #include <mach/memory.h>) Q3 |0 t& N8 Z2 ]+ Y. Y
- #include <mach/hardware.h>: Q |4 ^) R& I) ^) c
- #include <mach/irqs.h>
% B& H9 P, w2 m; F7 Q% K. u% ` - #include <asm/hardware/edma.h>9 V [2 z: q2 y; z5 ]! F' S! W
4 }% k. I( H. P2 z/ J$ B% ~) P+ O4 ^- #undef EDMA3_DEBUG
8 p3 }1 Q7 C5 `) t) Z3 w# y - /*#define EDMA3_DEBUG*/
& U; q/ L' H/ m& M7 b- \7 P - + N1 r/ ^, j" ^. v8 M; `
- #ifdef EDMA3_DEBUG
. y3 z+ m- f: B( l) }! E - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)# O' Q/ A% p0 @* v. x5 z( X
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
% _% D: U( d3 u+ b( u; T+ W - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)2 G( ?% _6 Y4 X. e6 j" X
- #else
+ {/ T! v+ u3 ?8 o - #define DMA_PRINTK( x... )" n/ C, u; Z. S8 \0 v
- #define DMA_FN_IN: {" y! }3 s# S y/ E* q; _0 c
- #define DMA_FN_OUT
, p1 R4 c: u% |9 j6 M - #endif( ?. t& R. ^/ `. h, w
6 U4 Z' j7 [; ~" P, B, q% G, j- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
( l2 A! X1 ^! d - #define STATIC_SHIFT 3: Z, K3 D7 `/ l' f' {/ M
- #define TCINTEN_SHIFT 209 X4 |$ l9 |2 _& v
- #define ITCINTEN_SHIFT 21( P) i l; C5 z5 d
- #define TCCHEN_SHIFT 22
' e2 Q7 G& o7 I; p - #define ITCCHEN_SHIFT 23
: E. P w# q& c2 @% u& K - / M0 \' Q( @0 ?
- static volatile int irqraised1 = 0;0 w8 U5 E @# D! I
- static volatile int irqraised2 = 0;
4 O9 b" {. d3 o7 N" k4 w8 l
4 {- v' G1 @. l# t) {# n5 Y: L9 z: M- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# s, r# k' J! J# S+ ]# p
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, F/ L" m7 L4 Q! C - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ K' Y6 K# n4 v" ~
- + e n& X4 P5 D' z! O/ f1 `/ `+ O
- dma_addr_t dmaphyssrc1 = 0;2 p4 m, T* q6 }" F4 V% @) H
- dma_addr_t dmaphyssrc2 = 0;" Y1 P% v o; M/ Q
- dma_addr_t dmaphysdest1 = 0;1 }( ]9 N" B6 y9 W- B3 S; Y" e" j
- dma_addr_t dmaphysdest2 = 0;
' n+ `2 i( _8 _ v7 o2 F - 5 h+ k# h; a$ t
- char *dmabufsrc1 = NULL;' [; f2 q7 m: o7 Z3 p
- char *dmabufsrc2 = NULL;
7 R* f" D. `7 C6 q' n) e- r/ @ - char *dmabufdest1 = NULL;
- Q* E' A! G9 a) y. F$ F! D$ {; N" @* n - char *dmabufdest2 = NULL;
' u: J/ z0 K2 u4 M7 t
5 L. f2 Z/ s+ a1 L; @2 V- static int acnt = 512;3 e; ^0 C; ]4 T/ f. `$ s6 }" I" r5 _
- static int bcnt = 8;( j8 B% E) R$ B9 Z, v; M. \
- static int ccnt = 8;
3 ]& U! b4 R# m4 f- g8 ~' _
$ D, |) h% h _- module_param(acnt, int, S_IRUGO);! ~3 f9 h$ h' _& P5 w0 e6 N+ i
- module_param(bcnt, int, S_IRUGO);
8 z, J, C; l8 _ - module_param(ccnt, int, S_IRUGO);
复制代码 , J0 z& ^7 B1 D2 e$ d# s |% d5 p7 _
9 ]9 C7 c* O- {
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
; [1 f5 a" X* ~& ^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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
; N( S9 `/ J5 d5 | 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 Y7 t& s6 g% o8 s1 ~
' v' ^- O4 r% F- n R: s
" ?) b ~- r, e |
|