|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% X5 z9 {* j: g/ s4 f- [code]EDMA sample test application
7 G( l7 s, U) p - /*3 `- o0 R! n6 g/ ?# e# n
- * edma_test.c3 R( V' `! b4 e8 k4 |0 e: M( i
- *- u t: M% i# v& a* e+ {0 l/ E6 [
- * brief EDMA3 Test Application! I6 C6 R0 ~9 t- D5 m+ _: i1 m4 E/ {9 p
- *6 L) Z% Y5 q* L
- * This file contains EDMA3 Test code.
4 c7 v( L/ c) ] - *
, {/ `* E- F% |( L8 s - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
. v% m* j4 i p5 { - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
- B1 q4 l) f I* l! e, g - * TO CHANGE.
1 T9 k0 X* `7 S( _, [ - *
$ h! c: y$ y9 }- a) g - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 T1 B6 k( N# g/ `3 C/ ] - *. V4 Z8 O$ U6 C
- * This program is free software; you can redistribute it and/or
1 r1 D! b" k/ O, I g - * modify it under the terms of the GNU General Public License as P, g4 {* S7 J+ a5 v" `
- * published by the Free Software Foundation version 2.
* Y/ K+ C/ `5 K% d6 v5 {. c8 z4 k - *9 |9 _4 f- D4 m2 L. b7 b- J6 y
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any: u! w" p) S; R
- * kind, whether express or implied; without even the implied warranty5 d* @8 o: W+ ^( c
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' e* v, q7 [4 X y4 z9 g - * GNU General Public License for more details.- S4 o! y% e: j4 S* X
- */
( X ], z; X4 J9 Q. m2 x( K - ) `. B c: E3 G/ g1 v6 d# d# W
- #include <linux/module.h>
+ V7 a- {' S: ] - #include <linux/init.h>
m9 r: D# p9 T - #include <linux/errno.h>
4 n6 D5 G+ q( B; f6 o, m - #include <linux/types.h> j& v1 p! ~. c9 V4 m5 E4 X
- #include <linux/interrupt.h>9 _% P4 ~' h5 G: I: T# s
- #include <asm/io.h>
$ H8 |/ D7 _" W8 i1 u& B) N - #include <linux/moduleparam.h>
1 X1 A) W8 d; V" ? - #include <linux/sysctl.h>7 d. r, ?+ V! ~: R0 p0 ^
- #include <linux/mm.h>
0 d& ~' p6 M( [ - #include <linux/dma-mapping.h>
% x+ _) _* n' ]% I$ Q0 h
8 j1 T- C* n4 ^ B- #include <mach/memory.h>
4 ^% a: N5 J, l - #include <mach/hardware.h>
) t0 I% F( g8 l& {' ~1 X - #include <mach/irqs.h>7 f% _7 g; h) j# S7 K
- #include <asm/hardware/edma.h>
' a# Q" x3 c. @" l0 F
x% E, i# ?5 T! u1 M- #undef EDMA3_DEBUG, W. t& C6 X5 d* i3 u
- /*#define EDMA3_DEBUG*/; a' i$ j0 M! O9 n- X
- % V/ b/ W8 o) g- Q
- #ifdef EDMA3_DEBUG
+ I+ g/ ?: O7 e- U+ M9 i2 V - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)/ _6 l. s7 L% c$ J
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
5 P r! s& a6 @; U - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ B- A: W" o. R* e$ |% Y3 z - #else
$ E" O3 G+ c( o' P9 [1 x - #define DMA_PRINTK( x... )/ E+ `! |5 ]4 J! Z' [' G/ [5 K
- #define DMA_FN_IN3 b7 V3 x$ d4 F) q, P! I
- #define DMA_FN_OUT
; t- \; }1 a6 z( \* D - #endif
% V: w5 V: W3 J1 G$ B7 R% Y1 ? - ! t% p, p- u7 _1 q6 U- W' O
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. j2 @0 n* y N - #define STATIC_SHIFT 3
0 q0 x9 Y h' d$ E - #define TCINTEN_SHIFT 20
4 m2 c: t s/ V: U8 R) A - #define ITCINTEN_SHIFT 21# E- G" K) i0 l" d
- #define TCCHEN_SHIFT 220 D9 o% F5 y8 A7 O
- #define ITCCHEN_SHIFT 23( g% s+ ~' J% x5 n+ x" r( H
- 1 n) X, Q" [7 q; u) q& D/ w4 v
- static volatile int irqraised1 = 0;) a! L5 _. C2 ?- i
- static volatile int irqraised2 = 0;
2 ^8 K! b k; s! h9 J( t - ; Q1 \0 {* k! Q5 G
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 r0 B; o. k n8 {; @ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 q0 t% t; q! f A, g
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% X. b) e- G; _$ r L" m0 t0 W - ; ~2 e2 T. g# |8 a
- dma_addr_t dmaphyssrc1 = 0;
) w) U$ ~; s0 `* S4 i, @8 A - dma_addr_t dmaphyssrc2 = 0;& n* Y* z! U2 M: |2 m" Q# u" L
- dma_addr_t dmaphysdest1 = 0;
( d- h! r5 E% G' c( {/ P - dma_addr_t dmaphysdest2 = 0;
6 S4 L9 Z8 b( C R& g' z5 q: B& D - + C: m% t( K: t5 a9 s w
- char *dmabufsrc1 = NULL;" ]$ q* T* g/ y( y
- char *dmabufsrc2 = NULL;
( m: V( w' Q. b" N - char *dmabufdest1 = NULL;
1 j' f! A: [% m$ J - char *dmabufdest2 = NULL;
' O" i# z" d+ w5 n$ u
# Y& n: P l# ]& n h5 L- g- static int acnt = 512;, O u+ J& u. b: r$ q9 d; K
- static int bcnt = 8;
& ^% r7 m/ q+ n; y2 G - static int ccnt = 8;
6 p. i+ J. t6 v( p E - # v8 x4 `1 l7 ]3 C; w& U
- module_param(acnt, int, S_IRUGO);% R# a# R" X6 K& w
- module_param(bcnt, int, S_IRUGO);
+ w2 [1 S3 y% l. i - module_param(ccnt, int, S_IRUGO);
复制代码 ' r' _; \6 b5 `7 u4 Q
4 q5 |3 B9 ?2 X 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用* e' p8 F+ B0 U& u) `
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。' J4 j/ O! ~7 f7 s a8 g: f
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。/ f( l# s' E3 E0 o
5 o, t) c# G. J# }
; S& n! d5 m ?' V9 t |
|