|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; V0 t5 @' K7 E a- [code]EDMA sample test application. s. x; H- @# g) @- y# [& x: p
- /*
. b0 H2 N' w& H, i8 J" i; m - * edma_test.c
- Q$ t- E5 R E5 R# I, a - *+ U2 {5 A7 I9 d! V
- * brief EDMA3 Test Application
" c) m* ?5 v: b; ~5 ~) G+ E; D" { - *
4 m6 V! [8 E2 U# r. P0 P - * This file contains EDMA3 Test code.7 }3 [4 e \: ^' Q" K3 s: z( p; [
- *! y3 [* \7 |+ }- i/ ?% f
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE7 s' a! R s) O7 v
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 M5 s9 J5 x0 K- P4 b! g - * TO CHANGE.+ T2 r( a4 X! A8 H# E( L
- *
. m' d7 @, v+ C6 S+ V - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* Q5 E+ G' w& s* \5 l: O; K, U - *
n7 ^5 ^8 Q+ R$ j+ n9 P - * This program is free software; you can redistribute it and/or
+ M4 p! k7 d6 t7 Q% O" s7 q - * modify it under the terms of the GNU General Public License as
$ J. L9 y/ v6 y$ @' X, W) y - * published by the Free Software Foundation version 2.. u& i4 h* o" N4 p
- *% A- l* Q7 [* h3 V' H
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
! T, B8 l* l2 P+ v! v" g% c& g0 ? - * kind, whether express or implied; without even the implied warranty
: P. p! x0 d+ C - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1 F# ~' q+ W" |6 H' M - * GNU General Public License for more details.
& f, y% n" J9 } - */
& {/ ?3 E9 P$ z
4 V" h) p: B# Z9 r+ x" L- #include <linux/module.h>
* r. k% |4 g \/ V - #include <linux/init.h>
) x2 _- k/ H% D6 o: M/ O* z0 ]5 m - #include <linux/errno.h>
6 Z6 d2 V/ O0 u% v2 M - #include <linux/types.h>
% I+ u/ P+ h4 a3 I - #include <linux/interrupt.h>
8 n* _; j- G* l& s: r; m* b( p - #include <asm/io.h>
2 o) q, o# R8 e - #include <linux/moduleparam.h>
" V' Q1 k) n* n( k - #include <linux/sysctl.h>- J3 ?3 ]- ]: b; O% B4 n" t3 U
- #include <linux/mm.h>9 `) [9 h& { t7 @, W
- #include <linux/dma-mapping.h>* O* Y5 a. {! L" @2 z. i* Z5 z: M3 r
3 F: o7 C$ V! @. c" J, I+ x) {5 W. R- #include <mach/memory.h>
2 J- P# o# V2 D& ~/ j$ x: x - #include <mach/hardware.h>" L ~% m L4 X, u! e
- #include <mach/irqs.h>! f8 ]1 p( D" y: P) V2 c* x3 D
- #include <asm/hardware/edma.h>
2 g! O( V2 W7 z9 `. \
8 ?( {8 a8 H9 T* ~# Z& H8 a6 ~* G- #undef EDMA3_DEBUG4 X/ O. M' p& v( m& Y
- /*#define EDMA3_DEBUG*/
- w7 ~/ m) j3 ~5 l* I+ g8 r - ; M' g$ q# X1 h$ \( O- W
- #ifdef EDMA3_DEBUG
6 B( O3 j! c9 R: b* X/ g6 b' D - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)6 F2 F% t7 N- H; R! c
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
0 H$ y c$ A0 W - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)8 e( T& {/ ]' S1 I8 u2 h
- #else
, F3 [$ U9 e2 H) N h% F9 I4 _ - #define DMA_PRINTK( x... )* o* f A$ J' ^
- #define DMA_FN_IN7 f0 D3 ]8 Y( E1 Q$ b6 A
- #define DMA_FN_OUT
" x! ~' c, C h' y4 q - #endif
; ]: D1 c/ J. m4 D7 s0 K9 l - 1 I. y( t# z0 j5 k% X+ i
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
# a Z3 ~3 c: L } v - #define STATIC_SHIFT 3
& }# u% Y+ `! R7 Q, T6 _% U - #define TCINTEN_SHIFT 20
5 Q# e* H8 M* W/ m) a - #define ITCINTEN_SHIFT 21
& C) ^) I6 |+ B) i - #define TCCHEN_SHIFT 228 R# F6 m" K( S. W
- #define ITCCHEN_SHIFT 23
" s, r$ U1 t/ W9 Z/ B' g* {1 u7 h% D - 6 Q0 U3 Q# N" ^& J- e3 B+ A
- static volatile int irqraised1 = 0;
0 j# d# U) m' Z3 B - static volatile int irqraised2 = 0;
0 W4 _! S# ?, r- ^+ M
9 e% V/ t8 v7 d6 T- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- d x) @- N( }: g6 a
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 N; E; B2 V+ I8 `
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# l/ C7 L; \; ^2 s9 W9 q- t3 [2 W
- : D$ p3 O0 f8 i+ l; |3 m
- dma_addr_t dmaphyssrc1 = 0;. }5 g+ ? r. W) ~
- dma_addr_t dmaphyssrc2 = 0;
( `6 c. `& W4 D5 ^& h3 ` - dma_addr_t dmaphysdest1 = 0;3 h4 g& z$ E7 P3 o4 }2 o8 J
- dma_addr_t dmaphysdest2 = 0;: H9 L5 t+ c0 t5 N* v9 v/ W
/ x4 {* d; A( L- O0 A% O @ x3 s( z- char *dmabufsrc1 = NULL;
( B7 u' g' \( T! \( i6 n - char *dmabufsrc2 = NULL;+ ]( X$ {: Q' ?+ d; p
- char *dmabufdest1 = NULL;5 R; I" e6 }/ x3 I! E8 q
- char *dmabufdest2 = NULL;
g4 X" i: Q/ w" T& T - ; R" {2 |% r" ?! s5 ~: o
- static int acnt = 512;: I' {. f9 c% F$ c3 P- h7 V
- static int bcnt = 8;: ^2 m' I+ q" c- r
- static int ccnt = 8;
# l4 P, M9 p* V- J8 X* y7 X( L) L7 g - ( w. G4 o, c0 V2 A( y" e: ?
- module_param(acnt, int, S_IRUGO);4 w8 y& N! c3 \6 Z# ^; F, w
- module_param(bcnt, int, S_IRUGO);
% p8 X& n1 P0 j; w - module_param(ccnt, int, S_IRUGO);
复制代码
1 z% B7 Z1 H2 z6 c: R
' L Z9 C" V, E8 Z' W) t 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! i: W8 h1 E3 y) ^3 n7 ~) warm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
$ B3 c, L$ i6 q! x% O 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。! W0 h8 |, V4 x8 `
( r8 e, F7 N+ l) v7 L( @" ]' s( T, Y: O
|
|