|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, W5 n O4 ?7 p+ `. P- [code]EDMA sample test application" _9 l. _7 |& F
- /*+ K+ y! y5 m. c* w8 ?# M
- * edma_test.c
, H: f% `+ e4 M" Z, W- K2 Q6 _/ \ - *$ H& ^4 ^8 J: B: Z8 {3 _
- * brief EDMA3 Test Application I) J+ G$ }) \" S0 @# l% u
- *
* c8 X& ?" I. F- N8 A - * This file contains EDMA3 Test code.
B/ J1 M( w3 e) l) s0 L+ B - *
# _9 n" o9 e- _4 w; J; M - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE1 G) y8 T7 i& O
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT: Y' X6 I9 \! X
- * TO CHANGE., `$ P& o$ P8 N+ s( F9 |" f
- *1 V2 r6 }( e+ v9 O3 S5 q |# n& {( r
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/& W& i$ i8 U" B" M3 f
- *
' @( K2 u7 C" [2 N/ `0 u { - * This program is free software; you can redistribute it and/or
1 I& W/ Q$ {5 B) i: R: {- m - * modify it under the terms of the GNU General Public License as
0 b' L' H5 i" Z# y - * published by the Free Software Foundation version 2.
8 ]+ \. [5 {3 P$ X - *
5 c2 D* U- z6 O p - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
8 A) o& n8 E' ^( B9 L' H - * kind, whether express or implied; without even the implied warranty
) h) K: X( _' `0 @6 m - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6 U# @: p( K/ }7 D4 v - * GNU General Public License for more details.
0 [% n! Z" x6 F% l) A - */
2 Z! X7 d% l, E, C @
# g N# g- v2 ?& M+ e5 k6 c' n- #include <linux/module.h>
7 }2 R' d4 j/ C) \9 V8 e1 _( K+ j - #include <linux/init.h>
, [( ? C# Q/ m0 t! g% K: ^' N7 n) z. @ - #include <linux/errno.h>
r+ E, Y% U# m U& f - #include <linux/types.h>3 L: w4 \& A# k5 {7 V! @5 z
- #include <linux/interrupt.h>
2 o0 a% ^- k; c7 [ - #include <asm/io.h>- b) _; Y; q" y8 D/ N- G# B
- #include <linux/moduleparam.h>) k- O1 _% d' X1 Z
- #include <linux/sysctl.h>
( A# ~ K( b4 M$ v# O G - #include <linux/mm.h>
: v' r3 t% Y0 e1 q1 E( l - #include <linux/dma-mapping.h>1 @# N- S0 V5 Z1 g
- 6 D8 A c/ Y4 Q9 i5 ?, T' ?
- #include <mach/memory.h>
; I3 Q& t) ]) _7 ~" P& m* b - #include <mach/hardware.h>
9 c9 [! q. h$ v/ i2 N2 |$ W/ q* j# F - #include <mach/irqs.h>
; p3 w5 G3 t+ {. g \8 r" R0 w - #include <asm/hardware/edma.h>- j& |3 U3 a9 B+ \% M# ]+ }" e
- : ~( x6 s" l1 y/ O1 H
- #undef EDMA3_DEBUG' g* ?3 f# e' \" U, e
- /*#define EDMA3_DEBUG*/
( G& W5 O0 _7 W; a' ^4 j1 ^
9 ^/ @& g5 C% C0 v. K: ` o- #ifdef EDMA3_DEBUG/ z& |: Q# y1 ?1 ~
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS), O+ B. O: c, V4 F/ o' G
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
/ q4 ]7 l/ R, F2 V" O& P3 J - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)6 G4 w% ~9 ]& j" d6 J
- #else
n, o: A2 q* w5 e5 j2 A - #define DMA_PRINTK( x... )) p4 v0 W* T0 ]( ^9 k [
- #define DMA_FN_IN5 e) y: T, G) `4 c/ L' `
- #define DMA_FN_OUT2 r- n9 |1 d3 l1 T
- #endif2 m% ?0 {* s- u2 Q0 c
4 }8 K6 x) S6 |, O- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 R" G- @/ s& t b; N* h& p/ B - #define STATIC_SHIFT 3& Q1 ~. }/ \1 z8 e
- #define TCINTEN_SHIFT 20
' J L3 a) L* F9 P; ^7 ?' y - #define ITCINTEN_SHIFT 21% w6 N1 J* K- i- l6 w
- #define TCCHEN_SHIFT 22
. j! \: ]" L, q4 I, | - #define ITCCHEN_SHIFT 23" M# I& ]5 L) h
- : R0 l9 I8 b% ]" G" t8 F
- static volatile int irqraised1 = 0;
h2 {' Y. }$ k2 }% o7 G - static volatile int irqraised2 = 0;# R8 [& T8 ^8 N6 Q$ r7 }
- * M4 ]3 Z" a& r' X8 C+ X
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 l# Y8 D! S+ w
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 W7 s- x- x5 Y# X( j% N$ ^) e
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- C* q6 ~ N6 C: m6 @* W
- 2 ]# E3 x) Y, C* h3 @4 w
- dma_addr_t dmaphyssrc1 = 0;0 j. K. n5 W w5 ^. e) y
- dma_addr_t dmaphyssrc2 = 0;
8 V3 q# _2 A1 A - dma_addr_t dmaphysdest1 = 0;
: y+ V5 N8 H+ l5 D5 P6 `* {+ u2 ~ - dma_addr_t dmaphysdest2 = 0;2 _% d, C: t( k. P) _+ ^
b1 e% R d! _7 g$ i: N- char *dmabufsrc1 = NULL;5 D6 ~, S9 I7 I; J S3 A
- char *dmabufsrc2 = NULL;
! `' R# K. b$ s. W: _) }6 u - char *dmabufdest1 = NULL;
4 C0 g* c% B8 K+ q. { - char *dmabufdest2 = NULL;
7 }2 w: Y+ Y: x1 _ B% o
! _- }; H& k) X% I- static int acnt = 512;
% v+ T6 E' M* z2 i6 P- \- } - static int bcnt = 8;% L- H9 f+ z& c3 \
- static int ccnt = 8;5 K- K; R5 Y3 P
- + m' g7 O, [ {" e7 S% j6 s
- module_param(acnt, int, S_IRUGO);
7 g& H4 M) V: s7 a* v0 k* C - module_param(bcnt, int, S_IRUGO);
! _; g% Y; ~4 D" c$ a. p# p* ^ - module_param(ccnt, int, S_IRUGO);
复制代码
1 d/ r- f9 M9 h2 f$ z7 X' x0 X8 C1 v# Z) K# t
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! L( N% j( ?, Marm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
% d1 g; }# m5 u) [5 X 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。% b+ C) f" r% ^) `
4 Z5 U: r# e8 F$ T) N
: M+ r7 j; {: [3 U+ O
|
|