|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 l8 Z* r& J2 {% k, v, w; s
- [code]EDMA sample test application
4 s8 s9 Z/ i5 A2 k - /** d( Z. v, u8 Q3 ~3 F; d" d
- * edma_test.c
- p Y @6 |( G4 N3 H - *
' L) \8 E1 h2 [2 X- Y% E: b - * brief EDMA3 Test Application
4 D. X8 `' r5 R+ \4 G5 @8 _ - *
& A& [% k* m. z" Y- B) Y/ [5 k - * This file contains EDMA3 Test code.& C1 A9 ]) d/ E1 z7 s' V
- *
& O- S) F4 [( M0 W: S5 x8 q* M" u - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( }! N7 Q( m0 H$ T* I
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
n8 u5 [' n5 J! E( t* z& i8 M2 J) Q - * TO CHANGE.
z: Q: u2 F% Y5 C0 s2 f1 p% e - *
. u# k; I5 v- T) V - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; |2 N% j6 t' Q - *
. Y: A1 J7 l8 L$ c4 |+ x0 Q - * This program is free software; you can redistribute it and/or
- n0 v% Q _& C# I - * modify it under the terms of the GNU General Public License as( h' x8 j" j1 ]) L4 j
- * published by the Free Software Foundation version 2.
6 Y' C" r% d3 }& X- }" N - *% a8 q4 P7 Z" q6 p7 Y
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& x+ c, V- q/ s' V: K( N6 B - * kind, whether express or implied; without even the implied warranty
! [1 o7 o! a$ F* E, W- i - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4 L2 d7 q% Q! F1 w u; h$ S - * GNU General Public License for more details.; E: l( w4 n5 H( _6 L9 g- r
- */# M5 o1 O" V, H" _! G3 G- d3 F! l
- 8 d j% Z# ^! ?6 Z- h' C- l
- #include <linux/module.h>
7 _6 E2 R/ R: R$ M- _! j - #include <linux/init.h>
( x0 q5 h R5 b1 A$ L: @: x - #include <linux/errno.h>
, Q5 c5 O, j: w) d" a - #include <linux/types.h>
* a- o7 S, q m" N - #include <linux/interrupt.h>) W. `% W) ~& t: s+ t/ |
- #include <asm/io.h>
. y0 W% ^' n( j3 ` - #include <linux/moduleparam.h>
6 O" b, j: w) P, D - #include <linux/sysctl.h>
& S! F3 s. T# M) V% N. ? - #include <linux/mm.h>
4 O: q3 u9 B) z! w# m0 p/ }( O! X - #include <linux/dma-mapping.h>
+ x/ f% `- ^% O$ U( F
) X8 l4 D1 g' v. o. x6 H3 S- #include <mach/memory.h>2 j2 i0 H7 I& {9 Z0 l. l/ F" H
- #include <mach/hardware.h>0 F" T1 z8 F! g, e
- #include <mach/irqs.h>/ ~$ d( G; `$ @3 R
- #include <asm/hardware/edma.h>2 ?5 Z" Q3 X) d# P
- ! m! d- V, b( G" X. g
- #undef EDMA3_DEBUG7 E9 Q0 A1 d4 {8 K" q' D6 O" S
- /*#define EDMA3_DEBUG*/
% R& H0 ^0 H7 ~1 Q, n5 O - . d+ w1 A- A `1 `
- #ifdef EDMA3_DEBUG$ G# [! o$ h$ o* s0 Q
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)! z0 Z) v T( s
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__) [9 q# W0 V1 v* m( G* ~7 q9 C. o
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
& v. c, p9 J0 s0 W" K1 C+ z - #else4 }. \5 P* }- U: j5 o( B
- #define DMA_PRINTK( x... )% ]! F# T' @ G1 N6 g6 Z6 m
- #define DMA_FN_IN2 C6 M( [! Z* s$ @7 k
- #define DMA_FN_OUT
& p+ x- X! Z& o/ ~: Q1 D# f) R - #endif( r6 o7 A( X8 Q7 `. f& y9 U2 h
- , R& C7 F* x3 [
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
# M% w" U, ]6 X7 M - #define STATIC_SHIFT 3
$ l& _' j; a5 Q! e: U. j - #define TCINTEN_SHIFT 206 W! L- C- S6 \- `; F) [1 d5 m
- #define ITCINTEN_SHIFT 215 Q7 B: L' J: l0 [" n3 ?
- #define TCCHEN_SHIFT 22) ]% Y4 E! J: S
- #define ITCCHEN_SHIFT 237 u0 p% |& J/ K1 t- ^
' i* J K7 |6 G- static volatile int irqraised1 = 0;
2 s, G; t F% ~9 v2 J - static volatile int irqraised2 = 0;# B; v* m2 u/ e6 h1 G+ A
. _5 }" i. P1 y- K- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 E; {1 G) P, B% S
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
c0 b, I. K* P! {" M' q, O' E - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. [9 h# Y- f3 T! Y7 }: I
" q$ g& l) ^8 Y5 d9 N8 r- dma_addr_t dmaphyssrc1 = 0;) D, `' r, d; E, ], y. d
- dma_addr_t dmaphyssrc2 = 0;
3 L2 z' ^ p5 { - dma_addr_t dmaphysdest1 = 0;
( t' i; `3 F) ^6 f9 P: n; z - dma_addr_t dmaphysdest2 = 0;
3 G5 c$ U0 D" E( g6 z - ! z0 B1 o8 f" U) M: }- [, A
- char *dmabufsrc1 = NULL;
7 i$ f. w+ u- }* } - char *dmabufsrc2 = NULL;
: O9 M4 _- E5 d' n. o& \ - char *dmabufdest1 = NULL;3 g& H1 `& B) }: F( ]# _! {
- char *dmabufdest2 = NULL;1 {- `; _/ s. m. c
- - K' Q/ R8 _. Y$ g/ L( I* G
- static int acnt = 512;) X9 C8 E* B6 I6 F$ L4 d- A
- static int bcnt = 8;4 u- R5 d0 F: ?; c; y+ ]3 a
- static int ccnt = 8;8 P. |7 o H& c" E$ ]+ c
: A2 ]$ v ^1 ?/ R$ j- module_param(acnt, int, S_IRUGO);! b2 T' L# L6 n8 S* b9 s
- module_param(bcnt, int, S_IRUGO);& S4 p9 ^ Z# g- y6 t7 n
- module_param(ccnt, int, S_IRUGO);
复制代码
& T* M! F/ {9 N6 h) P4 G2 a" q% }) J' N. r( p0 f, Z3 g
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
2 V: i) _9 l# g4 p) W4 darm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 r$ ?* d' S1 K
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。7 R0 p% c2 Q9 E }! X& o( N
0 u4 l+ o/ S- t% @& e7 p5 z
# u/ t" w# g( B$ D8 m" T6 q' E |
|