|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. h+ S- k0 U8 s8 y8 o- [code]EDMA sample test application
; K& e" V) g" t - /*
2 H% A% E* j( C+ { F' L - * edma_test.c( i4 X+ v/ P; g- {# M+ P+ R# M
- *
$ M* U& Y. E! z" a" e7 S. Q - * brief EDMA3 Test Application
: i0 R7 [& ]- K) E% y - *6 p; t) ^/ ^0 G0 p& I& g
- * This file contains EDMA3 Test code.
8 b4 I- q9 `) @5 j% h, c2 O - *: s2 j# r2 a4 w X$ G' a- w
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE$ k5 }$ E$ B* J4 z
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 A4 V7 d$ u( K, [
- * TO CHANGE.
0 ]8 T5 Z3 g" B; g - *) N1 n; S6 [- t: p# T% V
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- U. ^6 y3 {% N8 M7 ?" `% f
- *
* Q0 V; g: {9 E( P+ v - * This program is free software; you can redistribute it and/or1 c- s4 R) w% A0 w2 U! K
- * modify it under the terms of the GNU General Public License as% I( H. V6 r% a0 A2 w" Z4 y
- * published by the Free Software Foundation version 2.
, Q- m: V5 T$ g) d. h - *
5 f1 j6 y2 j' K p4 ?% r# |# _ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
: n6 `" ^ S& J+ S8 |+ a% P" _ - * kind, whether express or implied; without even the implied warranty4 G7 F: y# ~* K
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the4 h- j. T9 i f$ o/ C! G7 L7 [, Q
- * GNU General Public License for more details.% J& K7 g4 }4 P% e7 J
- *// B' d3 m& E9 L' m0 t* U
- - A- u. A9 ?1 g: s& K9 @
- #include <linux/module.h> W# ^( W4 {0 ?4 K5 i2 w! E& O
- #include <linux/init.h>0 ?) f- l I4 l' _9 S5 J
- #include <linux/errno.h>7 Z2 u1 M& V7 a! T4 M
- #include <linux/types.h>) s! U; o3 q" @) q. N
- #include <linux/interrupt.h>8 \/ Q1 N$ q0 B4 s2 p8 F
- #include <asm/io.h>
k, D/ ]8 l; C8 U1 W - #include <linux/moduleparam.h>/ v. [2 S% n% D4 J9 O7 g) R u* ^
- #include <linux/sysctl.h>
7 w8 w" M. m# D - #include <linux/mm.h>
. C6 i- f/ m5 N9 R0 s( f3 y - #include <linux/dma-mapping.h>
* z: }8 O4 N" k( {* K4 W - / W F# C$ f- R2 s$ ?- p( B& O) h" Q
- #include <mach/memory.h>
& ?% Q% P/ ?9 ]8 K% N( n8 | - #include <mach/hardware.h>! N9 U) ?* i! X" A
- #include <mach/irqs.h>5 r8 w3 {4 w3 c5 J! V6 x
- #include <asm/hardware/edma.h>, |( l- N4 n: O7 p
- . \2 a- T) H% `: I7 i% B
- #undef EDMA3_DEBUG
. n0 A! K. w3 L7 r - /*#define EDMA3_DEBUG*/
1 @ a; }9 T7 R7 l. G - [! I& E- @$ E) d, m+ \
- #ifdef EDMA3_DEBUG* `0 |9 G: ~( J8 R( t) f
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
# X2 b6 ~ U. m - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 y7 r9 Z# o- m( L# _$ L% H - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
1 K+ M P, C' P, q8 C% V - #else
& K! {0 k' S% A - #define DMA_PRINTK( x... )+ p. P, a, X7 v# o
- #define DMA_FN_IN
% |1 o) x0 P. Q( m+ u9 W - #define DMA_FN_OUT
9 \6 Z/ z0 t9 G& n# l - #endif
' b8 }0 d/ D0 k - 1 {! s9 `! J. R/ K2 i, i
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)) d# V/ B$ e, Y- ?
- #define STATIC_SHIFT 39 d7 G2 K. v) Q1 k6 W
- #define TCINTEN_SHIFT 20
0 q; i- ~4 B( @1 T - #define ITCINTEN_SHIFT 217 X9 y) d& W. f
- #define TCCHEN_SHIFT 22
8 Q( d7 k/ b9 M+ L/ g# X$ c - #define ITCCHEN_SHIFT 23
/ B r/ r% G% p' ] r
! h0 [7 D0 H/ u3 c+ M1 _% F- static volatile int irqraised1 = 0;
5 J- ?1 f0 J. B: o) w t - static volatile int irqraised2 = 0;: {7 M3 l1 F+ ~# ` _
$ b, n# i4 r: b9 {- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 @' n. m, F0 c* M
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ R/ _9 q# r0 l8 K# l
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' o# r5 r4 g7 ^$ v# j% S
/ q4 s5 W) a5 X- dma_addr_t dmaphyssrc1 = 0;! G0 G7 m( _ D. M3 `
- dma_addr_t dmaphyssrc2 = 0;7 R9 M( ^4 E6 A V; y {
- dma_addr_t dmaphysdest1 = 0;
6 `8 M4 D* l8 ~; M% A - dma_addr_t dmaphysdest2 = 0;" Z3 H& y, P; z. Z1 ?
) m6 a( a& R- ]( z; r# ?- char *dmabufsrc1 = NULL;
! k7 m. `* l( [! f5 I' K+ q - char *dmabufsrc2 = NULL;
- g9 P5 F9 p7 k) E - char *dmabufdest1 = NULL;" G4 M/ O" B- r: A
- char *dmabufdest2 = NULL;
7 y2 D+ R2 j0 f4 t
+ x( E0 k, X% b- static int acnt = 512;
/ S, H; s' `& F) U( o - static int bcnt = 8;
; @1 F& T, \, {, ~) o9 e1 |8 A - static int ccnt = 8;" I# Q7 u% v: ~, N
- 5 o* Y9 ~) e) i7 a( \7 F
- module_param(acnt, int, S_IRUGO);
# c0 C0 K5 o+ E u' C4 s0 B7 l- k! U - module_param(bcnt, int, S_IRUGO); K; o1 q& e/ B- [
- module_param(ccnt, int, S_IRUGO);
复制代码
/ {- m' A5 _! K% v; }2 Z3 r' a" S4 \- v3 Q9 d* R
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) K; T% H" p& b4 G1 Jarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。0 ?7 B: M) ^3 j3 @
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
! X5 O. L _! V- p1 C' n J9 k3 `! T3 z+ u- l
1 J- p4 ]+ N. N; ]- L/ w |
|