|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( C9 x G( | o. a- Z- [code]EDMA sample test application
6 M4 y% p9 L& M/ M - /*
9 J2 Q* ^" }% L0 l! Y' G4 S - * edma_test.c5 {; C8 t3 G, B
- *
8 |' n' q6 w7 @6 S* a" r0 q8 ~ - * brief EDMA3 Test Application
- s! x- `$ ] Y% [5 p2 T - *
6 E* _4 ^: W( e1 P l1 J - * This file contains EDMA3 Test code.
: ^ o2 H* W. h( n3 _# g0 ^ - *. ]' ^- p2 m6 f, `' }- b
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE0 z* J! n; B: I% O; t; h/ T% H
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
1 w7 b0 o5 o/ v0 b2 o5 L( { - * TO CHANGE.
, t( a2 R; K, O, g, ~1 | - *
7 J5 w0 Q" _/ M1 v7 q; r - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/3 w L- |& N, D7 \
- *# S1 W# @6 {; a$ b
- * This program is free software; you can redistribute it and/or
+ }5 @# W# Z4 l. p0 X5 o+ @ - * modify it under the terms of the GNU General Public License as, e" v$ t# k! }& L& G4 _8 g
- * published by the Free Software Foundation version 2.
0 J, H5 ~) V' |. E$ _* P - *
, A ~$ P7 {/ X - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
0 |; V1 v9 b1 m - * kind, whether express or implied; without even the implied warranty7 G7 e8 U$ k% R, G/ S
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" `0 m- R, [0 I1 Z2 W3 A" g z, ^, i: z - * GNU General Public License for more details./ J* a% e- z) \6 i
- */
, R4 d6 h) \. C6 m0 j - 1 ^& K* @3 ~. I# u# y5 F
- #include <linux/module.h>
- q1 u. q# {3 E! r - #include <linux/init.h>/ G0 T3 u. s) k& S( ~
- #include <linux/errno.h>
$ |$ y; O0 J# r - #include <linux/types.h>
; E5 N; _! }5 }5 |$ o% ?' { - #include <linux/interrupt.h>+ U) Y2 H L' @$ T
- #include <asm/io.h>
1 @5 I# x+ `3 H# z1 ~! r3 ^ - #include <linux/moduleparam.h>7 o6 Z- r2 f' O- T
- #include <linux/sysctl.h>7 w# e9 W( U0 U) X8 `; x: l
- #include <linux/mm.h> l1 c; \3 p$ F
- #include <linux/dma-mapping.h>! ^6 i% I! W" N2 C
1 [% C# c$ _0 M. Z8 k" g6 R- #include <mach/memory.h>$ ?2 l8 F! W8 n6 g5 O1 C) d8 Z9 Y
- #include <mach/hardware.h>8 T d, S( F9 q6 R! U
- #include <mach/irqs.h>$ S1 z% O/ G) M- M1 E: D
- #include <asm/hardware/edma.h>4 m& [0 y2 N' ?4 b$ p
- : B7 n8 a1 ?) U4 y% G7 w* T
- #undef EDMA3_DEBUG4 K, M4 H$ H3 C: s7 W
- /*#define EDMA3_DEBUG*/, u. R/ g1 d1 N! P* {3 F+ `
- $ l- C# V d9 q( s
- #ifdef EDMA3_DEBUG1 x, V" W* X, U
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
0 Z3 x O! R/ |* k/ c1 y - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)4 d( r2 ?4 s( s i1 @
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
5 E8 l9 w+ f$ Z8 m. l& k - #else1 Y p4 p m# T/ L7 _
- #define DMA_PRINTK( x... )' C! O4 p: e- _# u
- #define DMA_FN_IN
( n! Q1 m4 n: m& G - #define DMA_FN_OUT
0 ~2 U( H7 Z" I- m: T' G, z - #endif# L0 ^% t# j+ Q" X
3 x" E( ^6 @; P; _3 E9 R/ p6 j' j' w- #define MAX_DMA_TRANSFER_IN_BYTES (32768)6 P' A3 g7 L) e7 \+ L
- #define STATIC_SHIFT 3
2 k3 f4 _( @1 g( b) G4 n9 X# i2 F% } - #define TCINTEN_SHIFT 20& x( e) @. ~7 |# B
- #define ITCINTEN_SHIFT 21* R3 y* U' l: ]" ^/ O; ~9 [ u
- #define TCCHEN_SHIFT 226 k2 K. R% L1 N4 F9 X+ b, z
- #define ITCCHEN_SHIFT 23$ e% F/ O& H. T' o. j1 H! @; c
- ' ^5 D! p: }8 Y" }5 H0 ?5 x
- static volatile int irqraised1 = 0;# P2 r% J! V3 E
- static volatile int irqraised2 = 0;! t6 ^+ T7 T1 g
- : y( k' F* E( W7 f. C5 P6 \
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( [% U- @8 [" r6 o
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. K d$ }4 D: U) }3 ]8 i
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 U, t* d6 Y! o9 d
0 ~$ T- s% C5 @8 }" Q$ n- dma_addr_t dmaphyssrc1 = 0;
R9 ^) m, Y9 S3 h7 R - dma_addr_t dmaphyssrc2 = 0;
' D* D- z" l; D: i8 y* _ - dma_addr_t dmaphysdest1 = 0;
0 Y! V$ w) `7 ^4 K, Q - dma_addr_t dmaphysdest2 = 0;
' l8 ?. z: ^* l2 P! t; R0 E1 L" ]3 j - ; E: p. A( G7 ?% x
- char *dmabufsrc1 = NULL;; i8 @( a6 ^" I- y0 K
- char *dmabufsrc2 = NULL;: q2 K1 K1 S5 d7 |
- char *dmabufdest1 = NULL; R" g9 U. ]+ r
- char *dmabufdest2 = NULL;
9 G. c J: {8 N - ( j8 r8 {7 W% w7 V
- static int acnt = 512;- `8 ~" \. n7 z
- static int bcnt = 8;
! L! x( {) b! E2 X1 G - static int ccnt = 8;4 e8 ]4 v5 B) F; }% s5 a: b
( ]0 ^3 Y3 X" B, ^ T* ~- module_param(acnt, int, S_IRUGO); P1 k* U0 d1 I. \. e* y5 f
- module_param(bcnt, int, S_IRUGO);
( w# H) e2 n. b2 n* P$ a" ? - module_param(ccnt, int, S_IRUGO);
复制代码 ! Z& e+ u9 E# i g. |! v! {
" P- P$ R4 m% M b 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& ?% d+ u l; U$ o0 N6 F/ I4 xarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
+ i* c5 ^, A- b6 O) Y# ~% U6 c 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
7 |4 N" w$ i4 r
7 R: B: C5 i) ~6 p# c
f( i% s6 _( U |
|