|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. ^* A5 `! V5 k' o, b! \- [code]EDMA sample test application
3 l3 o; U. [3 [2 [ - /*' p) J! h3 E. z& ^
- * edma_test.c
: t3 g( H7 D; D, i- n% b - *
! b5 \/ P, D* `" ]# f2 e% w - * brief EDMA3 Test Application
! F5 F# t5 I9 T% Z+ q5 U% I2 q2 k8 p - *
) t3 Z. |0 A+ b! g/ T+ X3 r- P - * This file contains EDMA3 Test code.
9 d3 O4 E. g$ O s - */ x( `1 V: ?) |+ c) h- n4 p
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
3 G# w7 v4 W: `4 \: f - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT2 z% @) ]. W0 b5 e4 A5 P9 R9 b
- * TO CHANGE.3 K! U$ ^! L) y7 Z1 q+ J, F
- *8 f0 e& C) {% o: ^* v+ D" a
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/( @' D2 G6 g6 |' X
- *
9 q0 k8 V4 i4 S* j' l( U& z6 N - * This program is free software; you can redistribute it and/or: k, w% {7 {7 U- Q
- * modify it under the terms of the GNU General Public License as
( j# s" K: }+ o% k - * published by the Free Software Foundation version 2.
. p% l: E* ?" Z - *
& n+ _" I1 \2 p. m' w$ B - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
! S% \$ f$ ~3 @% V$ G3 Z - * kind, whether express or implied; without even the implied warranty6 s' K4 n+ M4 S* e! r1 C
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the2 T' `3 o/ _ `. o
- * GNU General Public License for more details.
5 P2 [2 N% T7 a& d: H - */& E5 j2 c1 v! D: K
6 o8 S* ^5 m& J5 L1 d+ o- #include <linux/module.h>
2 ^) ]1 L! Y/ A - #include <linux/init.h>
: N: v8 D; j& _) u! Y1 w" |" N - #include <linux/errno.h>
' Z- W; v6 L& I( D* t - #include <linux/types.h>
. `( ]' `' ?) q+ Y - #include <linux/interrupt.h># m3 N+ d' t& U
- #include <asm/io.h>8 m( f% _& G5 s6 |. i# @$ d7 C
- #include <linux/moduleparam.h>
4 T |$ v8 g2 N; g - #include <linux/sysctl.h>
$ D# w+ _/ A: E* ]# P - #include <linux/mm.h>
7 L, u9 N4 k* n: }( C - #include <linux/dma-mapping.h>! O @: F, M+ Z4 c+ y* r
% h; ~' |5 |# v* L. U$ ?8 z. S- #include <mach/memory.h>
+ P6 s) C, M+ ? - #include <mach/hardware.h>- s- d& h. X4 C( T9 ^2 ~6 @
- #include <mach/irqs.h>) d$ J9 Z+ d& d+ |9 w
- #include <asm/hardware/edma.h>, V+ F6 J8 G% h, y- c1 P
- 8 J ?& r9 K! O, D2 H; S/ |
- #undef EDMA3_DEBUG& T! W0 ?) e$ A, E! | Y" L7 u
- /*#define EDMA3_DEBUG*/- B3 l8 z, L+ [7 T6 N$ h
- 0 \5 h3 O* \8 u* p E/ T* {
- #ifdef EDMA3_DEBUG
8 m \8 Z3 o' q! w2 N* w1 q3 \4 ` - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS) |% t( r' j) r' K$ w `% u
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
' y6 Q. [$ k& v( r9 L4 i ]+ B; Y6 I - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
2 P3 z7 j- H" G, ]! K9 I/ b - #else0 F$ M0 ]; T. X, d* J* K8 ?( c
- #define DMA_PRINTK( x... )5 ]0 a& U) _# ]# e% y: W
- #define DMA_FN_IN
6 P5 C2 _( [$ h. t0 s! f - #define DMA_FN_OUT
- k: i- h! \* D' \; J4 _ - #endif1 k1 V5 _5 a5 K8 F7 ^& ?
0 m/ Z# `" Q: c. w. _- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; @7 X- S `, x' y$ E1 I! t/ D4 e - #define STATIC_SHIFT 3
) [2 X# r1 q: [2 k% z* ^ - #define TCINTEN_SHIFT 20/ B# x, {" S; `* }8 }
- #define ITCINTEN_SHIFT 21 Z& N; o& o' O% L
- #define TCCHEN_SHIFT 22
6 f$ W/ O2 m$ J/ J* V5 }3 V6 u5 Y - #define ITCCHEN_SHIFT 23
. {7 n$ U1 A. K9 O - ; q) }! H3 V' p, t- k# z5 k
- static volatile int irqraised1 = 0;
0 [ ?! O% |- f+ r& z6 i - static volatile int irqraised2 = 0;9 c, G2 c1 s% U( [, `' J% M
- 2 p" l; ]/ Q, y4 j; M
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. ?, U( g Z9 h! B8 C1 X
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- N! M# Z( R! ]: K: Y r- G
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# W g; f3 g0 u* P4 O$ P
3 B. B) W q o0 s! n2 v7 u- dma_addr_t dmaphyssrc1 = 0;
/ F7 G' U. O# E' J - dma_addr_t dmaphyssrc2 = 0;0 D p B0 [1 ^& N' j( k3 V
- dma_addr_t dmaphysdest1 = 0;
% g/ R0 M; ]; X u - dma_addr_t dmaphysdest2 = 0;
% r, |: x) | {. C
$ v1 f8 F' F0 U1 m- char *dmabufsrc1 = NULL;
" ^8 p) N( Y" i - char *dmabufsrc2 = NULL;
( D8 Z% g" v. s6 O1 q5 C2 o6 _ - char *dmabufdest1 = NULL;' |5 u, v: r- x/ Q4 b7 T- j2 V. y) F
- char *dmabufdest2 = NULL;' K D7 u/ ^5 V7 Z6 L
6 {. l) |+ N5 n- U- static int acnt = 512;. c& f o @8 [* c* ^& Y
- static int bcnt = 8;
- T" J: R2 U, c4 D - static int ccnt = 8;+ B; T/ x- S# b b0 ~# B0 {' }" g
- $ E g2 c* z0 ^9 g. Q2 ^. N. [
- module_param(acnt, int, S_IRUGO);
+ G2 v1 I+ R T! K9 ^ - module_param(bcnt, int, S_IRUGO);% f9 Z2 [2 \* n( [! R$ D
- module_param(ccnt, int, S_IRUGO);
复制代码 2 h, x! Q9 A: d1 t B( a
* ]4 T9 b9 ?8 }$ M3 a' `
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
2 ?# ?0 \: J' i% A, Y$ |$ T- farm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。( D6 @! S1 h( T i7 P
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。" g# C) R- y4 [9 o! R" d* `2 Z9 D
( i& Z& ]: J7 [! x: G( Q+ W; l
; j# N& ?" K/ ]1 l p& I: \$ C |
|