|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ! |3 P* T- c- R
- [code]EDMA sample test application
) d& }' G3 }( F3 P+ G+ a$ z& F6 @ - /*
L) Q1 E: `8 v- X. ~9 I7 Z% [% c3 S% q - * edma_test.c
7 f+ E, y3 r0 ? - *: R( K, y# K4 T, h! ^1 `' S
- * brief EDMA3 Test Application
4 C8 J0 t; l7 b: c- K2 \: K - *6 J T$ x4 q0 }- J
- * This file contains EDMA3 Test code., Z, X' w7 \3 s
- *
' C$ p/ V" Z9 m% H7 X' C. v7 V - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE- K2 m5 z3 h% U/ g# ~
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT. v( ~/ _$ A8 s0 D8 r' r+ r
- * TO CHANGE.. P4 Z$ I! r- O: Z
- *
! |, F* t( f+ m2 L! t; A8 Q0 ? I - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 ~5 ^- `3 r. Q+ O+ O M5 B - *
$ i0 ^, M' d" t0 W4 @, o - * This program is free software; you can redistribute it and/or
& k: W/ k/ k3 r! v* `, W: L( g - * modify it under the terms of the GNU General Public License as
- ?' B4 Q& w* p' Z4 u, G& S) O& O - * published by the Free Software Foundation version 2.+ e* z9 O# X! L' N
- *9 q- N- K5 K: }2 v. `& g0 U
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any2 J0 V, e$ o' u7 F# A( m
- * kind, whether express or implied; without even the implied warranty! {. |! ~9 [" `: V4 O0 T$ U
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! j7 x$ u; i/ J2 R( M0 n - * GNU General Public License for more details.
( j) M1 N: J+ ~/ C5 v - */3 q% `/ E6 z5 n: M
- & l' n) b& w$ w) m0 O
- #include <linux/module.h>
: ~ g% K* ]" C - #include <linux/init.h>
$ ?1 v' g+ { T) T0 ~6 K - #include <linux/errno.h>& \$ m/ D: Y6 L$ i; t
- #include <linux/types.h>. j4 s @0 ?( I# g! f. X- I
- #include <linux/interrupt.h>. ^$ f1 [' ^: l/ q! y1 A
- #include <asm/io.h>0 E; y7 j+ L3 @5 Y/ [
- #include <linux/moduleparam.h>
( P$ X( j0 M, s, O# w4 m - #include <linux/sysctl.h>
1 K3 L, ]2 T# Q1 q9 h - #include <linux/mm.h>
# u; y: n' x1 A s - #include <linux/dma-mapping.h>
D; C; h* {5 U9 r. { - ) o5 l7 ]9 p0 l0 K+ e- b1 V
- #include <mach/memory.h>
) j4 O; \. Q! V2 |( N$ N: k - #include <mach/hardware.h> {8 [/ ~8 `: C
- #include <mach/irqs.h>6 l" d4 l6 m3 q% s
- #include <asm/hardware/edma.h>
" y; w( |" q9 r) W, H" y% ~' y
3 _! i* X4 t( b: g- f# }- #undef EDMA3_DEBUG, R% d: i: r$ _: K: {4 U/ l
- /*#define EDMA3_DEBUG*/1 O6 {4 j+ e8 T b2 c: n
! B/ i1 W# v! e' M0 R3 J- #ifdef EDMA3_DEBUG
5 e d' {: [. O& l$ B2 h/ n - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)3 p. Q: V8 J+ y5 Y2 f2 h
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 p1 B, q' f& ~, n( s3 w! { - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
3 J. L7 m# S3 p - #else3 z9 ~! B. U% `7 o0 M" U3 ]% [$ |
- #define DMA_PRINTK( x... )
6 x3 O ?1 V9 B5 _ - #define DMA_FN_IN1 H3 [. B! G5 [( V, F" `
- #define DMA_FN_OUT
% g6 s3 j! B# _& P' ^5 N% T# F - #endif: o# e! F( E& ?1 D# c; y
- ) }: z" E$ H& B) q% Z
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, U2 k" d( w/ d1 S; @5 I0 n6 u - #define STATIC_SHIFT 3
8 ?) ~5 s0 ^& J - #define TCINTEN_SHIFT 20# R) q9 y9 G/ j8 [+ s
- #define ITCINTEN_SHIFT 21- [' V3 n2 W$ D! U5 H
- #define TCCHEN_SHIFT 223 g! K. J1 o7 v- t
- #define ITCCHEN_SHIFT 23
0 z# b/ T! M3 B; U$ @+ D! c. W; f
. c0 l* Q* ?) [* U. D9 }" D( F- static volatile int irqraised1 = 0;' u/ B% q9 j0 N' b6 j% s
- static volatile int irqraised2 = 0;
+ {. h1 o' ?. e3 h" O6 y1 b9 z
5 s3 z, o! n6 Q' m) A- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 I: t9 i& s5 x' I+ `
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 R0 q2 C, k9 [: |
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ Y) g" ^' R ]4 B6 q9 {( B1 g - ' c% m, o2 P7 h5 D! k1 v
- dma_addr_t dmaphyssrc1 = 0;6 x; @7 G5 o( m/ D
- dma_addr_t dmaphyssrc2 = 0;
2 K. m: a& N' I! T: i - dma_addr_t dmaphysdest1 = 0;% U' X, ~6 e+ ^. i6 S
- dma_addr_t dmaphysdest2 = 0;2 I* r2 F# v. H/ o2 g4 g
- ( e/ U2 B H' x2 }0 Y/ ?8 B
- char *dmabufsrc1 = NULL;
L9 f; e) k& G0 c s - char *dmabufsrc2 = NULL;
2 u6 Y3 \ N% H- u - char *dmabufdest1 = NULL;6 G1 z9 U; ^" u6 B) m8 m, ?' i, C
- char *dmabufdest2 = NULL;
. _( c( C G" A# e( Y
5 a( h9 g5 b4 n; c/ i- static int acnt = 512;
) I0 L* P+ e( q+ ]# C+ t - static int bcnt = 8;" k/ l' [" ]5 n. C7 s/ g
- static int ccnt = 8;
! f0 c) r/ w; P: U% H9 y - 6 ]3 x! L6 U* ?1 x
- module_param(acnt, int, S_IRUGO);
+ L, k; v; W3 A$ u$ Y - module_param(bcnt, int, S_IRUGO);
' t0 l( A& E4 m0 y+ _- d% h' h5 o - module_param(ccnt, int, S_IRUGO);
复制代码
, X* l a/ F5 N- y0 z
g% K- r7 w9 m. R# h 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用) ]* }: [9 l m
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。% d2 u* R, D. m9 S& M) k
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。- t' p! Z8 K+ V
- W/ o6 g' W$ i3 z! C; ]: O
2 m( ^+ v% `% F5 e# J |
|