|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
$ ?* y4 E& f! |* l" \1 E7 S- [code]EDMA sample test application
6 V/ t0 [5 C) E7 o |6 I - /*
9 U, I8 B" u1 i - * edma_test.c
5 w" C+ o) n1 }( E% | - *9 w, g0 z0 I* j, D4 \
- * brief EDMA3 Test Application9 Z! c5 c! F& P: g! q) s
- *
! \# a6 x& D( Q2 Q% K - * This file contains EDMA3 Test code.8 G3 K. i O2 G# h2 V+ s7 X% G
- *2 B0 _' ^2 r! _3 `# Q
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE E* j% a$ S3 Y+ L6 S
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% |, A0 @, N0 J - * TO CHANGE.3 O) v: N# i& s9 y E3 r
- *
8 c: z; \# I& R+ d4 n; l5 ?1 \ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/) {* y6 W; {( ~/ a! t) C
- *
! j" u- @ D/ @; B9 ~2 S - * This program is free software; you can redistribute it and/or
% ?, ~' l9 ?: u- X - * modify it under the terms of the GNU General Public License as
, }7 k' u; r3 Y- n8 I - * published by the Free Software Foundation version 2.
7 k( w0 s, |# i - *
, L- c! m5 H+ G - * This program is distributed "as is" WITHOUT ANY WARRANTY of any7 R) E# G; D8 W" g/ w
- * kind, whether express or implied; without even the implied warranty: x9 _1 H% n1 g, Y' A+ D# X9 |+ C0 i
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 n5 F2 a/ \9 a- H! W! X5 a
- * GNU General Public License for more details.! J2 n! Q6 @; e7 T+ O. T" g2 q
- */- D6 \7 h4 [ J
- ' l1 p: X* F+ P0 W8 E
- #include <linux/module.h>
$ `1 T2 }2 c4 Q2 a: Q - #include <linux/init.h>
* C: _7 @) d, K, j7 ` - #include <linux/errno.h>
1 `, \7 E2 H8 W; g9 ^" s; ^ - #include <linux/types.h>0 i- O, P; a) L- O) ^; o5 M+ X- V6 M
- #include <linux/interrupt.h>% r4 ]: c* ]9 t& Y( }
- #include <asm/io.h>0 d) \+ Y& P9 z" E9 U7 j7 e
- #include <linux/moduleparam.h>0 b1 g. Y( m- Z; q( ]; q& g' I
- #include <linux/sysctl.h>
" H" f$ s ]& L4 e( b, Z - #include <linux/mm.h>
9 n6 J/ T, s' k: w! K; Q' [ - #include <linux/dma-mapping.h>6 X. q1 D2 `- Z/ X7 x
! t4 g7 m: T. W- Q- #include <mach/memory.h>- y2 |3 R2 q! N! p/ z' P& k, R9 N
- #include <mach/hardware.h>
7 j |7 B W( `$ ~) s1 [: b - #include <mach/irqs.h>
1 \$ {: V* U0 R+ X3 v- ~ - #include <asm/hardware/edma.h>
" f: T. P2 |4 | - 2 W+ P& W3 }9 B8 \, [% R% b
- #undef EDMA3_DEBUG! z+ z3 W" m' P! x7 a
- /*#define EDMA3_DEBUG*/
6 o: v+ M; e1 ~5 f8 [! q
' @- G* }6 u" Q# T- #ifdef EDMA3_DEBUG
4 u0 P( n. ]1 n0 v% S3 k4 V$ S6 k - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS); M1 V. b; c0 b6 E4 V I
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)' C5 M4 W8 Z9 b0 F& T2 N
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__); s0 H3 i8 U& e9 x+ J% ^ K$ }: r- i
- #else
( U6 t, p5 @1 Q5 D1 m/ | - #define DMA_PRINTK( x... )$ D. I+ B4 ?# q6 o& h
- #define DMA_FN_IN; c( `1 u& v. C9 K: t2 n( y
- #define DMA_FN_OUT; `) k( g$ q1 D% n1 \- s3 P
- #endif+ l, Q7 R: D2 ~: n5 R1 w$ `
5 k" S! Z/ m0 C2 U- #define MAX_DMA_TRANSFER_IN_BYTES (32768)$ G0 Z4 B- T8 K; H
- #define STATIC_SHIFT 3: ?9 m+ }& k8 V7 n$ n
- #define TCINTEN_SHIFT 20
' _ F: s1 y+ t' `8 N( M; F - #define ITCINTEN_SHIFT 21# Q" q1 l0 h& h1 u( [
- #define TCCHEN_SHIFT 22
! B) i0 u9 v4 i$ x8 g' q - #define ITCCHEN_SHIFT 23
7 I2 V9 i+ E( ^" V
+ k# h( Q3 R- j9 e9 x- static volatile int irqraised1 = 0;
. j1 n; z4 ~% v5 n+ f - static volatile int irqraised2 = 0;* Y' J/ t0 t& D+ U# o# C( R! J
- x" T% j2 P4 i) D8 T- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! {* E; W6 @3 U/ L1 q
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( R; R3 L2 B# r0 O
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, l1 ^- {8 E& P6 m6 h, F- p
: F5 [, n X; m2 {: n8 j4 T- dma_addr_t dmaphyssrc1 = 0;9 [# v X- L6 W! G1 Y
- dma_addr_t dmaphyssrc2 = 0;
1 e. x# s/ m3 ~& ~% j1 Y - dma_addr_t dmaphysdest1 = 0;* @+ G w* X( N3 I
- dma_addr_t dmaphysdest2 = 0;: a+ t1 m, d3 \; _# s# W6 }& c- b
- g* }/ R, e& o( t" y- char *dmabufsrc1 = NULL;% a- N$ H/ w8 H9 l# `
- char *dmabufsrc2 = NULL;
- l4 K, V( P/ ]2 Y/ \6 ?' ^ - char *dmabufdest1 = NULL;; D6 v$ V& W& q) \) O2 m
- char *dmabufdest2 = NULL;' D6 j; O8 ` ?6 J- Y9 T! C7 O) O8 G
- V: h+ J* x, H2 Q& a# O! \
- static int acnt = 512;
4 r( Y: X1 E/ [' _ - static int bcnt = 8;
; B7 b5 p8 b% }7 ^( Y! W, p1 c - static int ccnt = 8;! j, `: g5 k4 h
- ) U: Z' P. u+ q+ Z- W
- module_param(acnt, int, S_IRUGO);
3 h. d4 D0 D( ~2 u4 O( Y2 J F1 ~: F- T - module_param(bcnt, int, S_IRUGO);; i, v5 \$ Z9 \" q, j8 A2 t5 j
- module_param(ccnt, int, S_IRUGO);
复制代码 ' c* }( I/ f; G# _) r
8 K* T/ o$ a$ i, I, s8 \8 t 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
% h; ?, j# C$ a$ A9 J) t5 e2 Karm-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) T0 Z+ v* r$ m$ l* d% C( v8 n
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。- N5 x$ e5 j5 X4 A
1 H0 P& Q, _8 \0 G! |# d
7 L0 t+ Q' ^- D7 `. q: K |
|