|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
* l6 i( d+ l, |$ h! `- [code]EDMA sample test application
8 E9 V- a+ g% F - /*9 q8 C7 X+ \5 h7 W G: T8 t
- * edma_test.c
" O* e9 }' H1 d0 C7 g$ K - *
! ]3 n3 L+ V: B# o - * brief EDMA3 Test Application
" Q, S# N7 W& j% I, |0 r( ] - *
7 z; D7 W' d d7 |, Q- g* y - * This file contains EDMA3 Test code./ B* t5 p. V0 k' a! @. O
- *; \" Y) l1 d( l! ?$ d
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 `7 L3 w- y, o2 O7 c: [1 s
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; `: ^0 G1 x2 Q6 @1 e) A$ |
- * TO CHANGE.: Q0 Y4 U7 l, L% d0 c( a% _7 u
- *, L F3 e' ?/ s
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/) J! U4 q# y( L- N T d3 l7 L
- *
. t' |1 R e& d- w7 B% {: g - * This program is free software; you can redistribute it and/or' K3 c) d ~& t! [9 n3 p: y
- * modify it under the terms of the GNU General Public License as2 F# s% J* N# S
- * published by the Free Software Foundation version 2.* l6 E1 j$ k4 Z' s$ S1 v
- *
M# V2 a" U5 Z' [* E. F - * This program is distributed "as is" WITHOUT ANY WARRANTY of any$ A1 b* K( `. u; {1 O) S6 d, g- |0 k7 ?
- * kind, whether express or implied; without even the implied warranty
, ^7 Q1 r: h+ W/ Y4 b - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 T. R' @5 o8 C( h
- * GNU General Public License for more details.
8 S: ]' M6 x9 X' b" x* ^7 X$ H3 F3 F - */( u" b7 r a% Y2 `6 c+ a) T
- 5 g% S5 Y( G5 \! Y5 e1 [; T
- #include <linux/module.h>
5 J4 S3 m* x7 W - #include <linux/init.h>+ a+ y; S1 G: J
- #include <linux/errno.h>( o6 P# y5 _' Y
- #include <linux/types.h>
0 T2 a) C& }4 Y; w' l - #include <linux/interrupt.h>
( x& w/ l: J5 d- Y) ^1 Y - #include <asm/io.h>; I! z" B& L& {: J- r# y, I
- #include <linux/moduleparam.h>/ e# g ]9 [' m. U" W
- #include <linux/sysctl.h>3 [1 ]5 v3 _. H2 X$ p
- #include <linux/mm.h>
; Y0 N( D9 `7 r' F; O$ O U - #include <linux/dma-mapping.h>
- a7 k& z- V/ p6 U* U- w - ! ?5 r% k& ]0 k* k8 F
- #include <mach/memory.h>6 G; \. G7 {! H( N. ~ e- O
- #include <mach/hardware.h>
' m0 E! o- }+ b5 n9 X1 k* b - #include <mach/irqs.h>: b1 L, K6 P- e8 B3 z; l
- #include <asm/hardware/edma.h>
, X5 b) a1 B. { - ! s! Y) O0 D6 I: ?" @" h7 s
- #undef EDMA3_DEBUG9 H, T1 ?/ P- q# z7 H6 K
- /*#define EDMA3_DEBUG*/
% k% i! q/ U3 [% S. ? - # Y" ^5 `2 l9 U4 M1 f& ^
- #ifdef EDMA3_DEBUG
( X- R* {; i" x4 H' b3 f - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
2 W5 K: i1 g5 M9 b2 ]. Z. c - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__) k& i' z& d% Z: F- D! ?4 l
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
3 v" a0 B$ b# L' c7 c - #else
8 `; o; L: n f2 j% m; S6 n( N - #define DMA_PRINTK( x... )" |5 Q: r+ T% L7 c% X( F
- #define DMA_FN_IN/ V! `+ o; x- T! m* c$ G/ G
- #define DMA_FN_OUT
8 a9 \. a5 F D - #endif
O6 z* k1 y# t7 S6 r" S, ~) z - 3 u- Z l3 R" b1 l6 `/ p# _2 T
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
& A/ q( L: N, s! d8 C; J - #define STATIC_SHIFT 3/ V, T9 d$ K! i. o
- #define TCINTEN_SHIFT 200 c, r9 ^* u8 p: w8 h
- #define ITCINTEN_SHIFT 21
t8 J& ]7 x* _3 E' K7 _ - #define TCCHEN_SHIFT 22+ S9 R/ f7 o$ a% W. C- N
- #define ITCCHEN_SHIFT 23( z9 P' y8 z) c* g2 ?
- ! x# E5 E, k1 E v
- static volatile int irqraised1 = 0;
% l) \, I: V# C; s) L, R - static volatile int irqraised2 = 0;3 }2 g3 _6 W% g
3 w; F' I, e* o2 W2 E2 f/ Y- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ f: ]/ H% n9 u# Y
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* ?0 C$ [! N( V2 |/ d - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
m6 g! r* T$ q6 o - 0 i" R* z# U2 v: ]
- dma_addr_t dmaphyssrc1 = 0;
3 ?- b, y# ^6 }6 @8 X4 m3 C - dma_addr_t dmaphyssrc2 = 0;
* f/ M6 a0 t* B% R2 n- u! a; Z - dma_addr_t dmaphysdest1 = 0;+ [4 V( |8 |, H
- dma_addr_t dmaphysdest2 = 0;
: x2 x& Y6 P5 {3 s - ) U! ~9 ^9 \" V- B& k
- char *dmabufsrc1 = NULL;
' z! @/ X& D& W5 E6 H1 Q S - char *dmabufsrc2 = NULL;
' g! L5 U& T. h# s9 t# M - char *dmabufdest1 = NULL;
9 J" w5 ]1 `' e% {/ K' ? - char *dmabufdest2 = NULL;) `/ I9 n- O8 [6 E
0 n3 N1 }* X3 q- static int acnt = 512;' O" n) l% t4 k a" }" E/ k; A! c9 D
- static int bcnt = 8;
; o4 Q) R* o$ o9 \ - static int ccnt = 8;
5 z, x$ \; Z7 ^
6 `/ Z; p: H9 ?- module_param(acnt, int, S_IRUGO);
! J `# B/ j" J8 [- U' j - module_param(bcnt, int, S_IRUGO);. E2 A% t' W% G* z2 c6 ?/ v, Y
- module_param(ccnt, int, S_IRUGO);
复制代码
1 a6 k& L, N3 U% X) Y. t' W! C& {: j2 O% t r/ N
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
* d, U" Z7 Q. {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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
, W/ O3 x9 h: D. a. ?$ b9 o; v! B 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
& a+ C( O4 L4 z* J; v1 m$ ~
( D& |9 M3 m8 D+ \' N: @3 R7 @) R+ i+ y. m9 _3 r" n( z0 N
|
|