|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 i# X, a! }* N6 u9 S- [code]EDMA sample test application, B. `1 O$ R5 A9 \2 l; D
- /*
& h6 o" C0 o: E" z( H - * edma_test.c J. W( f6 r8 \! j# d, z, A
- *7 p' R1 y$ ?) z9 t: L, ^
- * brief EDMA3 Test Application% ?; ^, Q ]2 L: y9 i. l1 o
- *
- P5 D4 C1 [( G9 [ p" Y! U - * This file contains EDMA3 Test code.
2 ~# ~. G. f6 Y8 a - *
( i+ r4 k) D# @4 S) u+ h% A - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE2 p. j( U& _0 W+ Y
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 y4 R. h9 \ N/ o1 L+ M - * TO CHANGE.% _ d- M/ z9 o) H- u4 g- Z% s
- * q& K: K( C, C; B
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ a# b7 |/ D* w% Q - *
% R9 }$ H1 N6 d: {! w - * This program is free software; you can redistribute it and/or
" ~: _( B) Y- }+ U% n% O# A - * modify it under the terms of the GNU General Public License as
9 ]4 z# n3 y) W$ ] - * published by the Free Software Foundation version 2.2 ?& k) X; _2 l3 P: f2 @ n7 f4 D% H
- *
+ B7 S; Y |. S& ~- U5 L/ Q! a - * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 M0 C. v' o6 u$ g( ]
- * kind, whether express or implied; without even the implied warranty
3 n3 ?1 j! b/ [7 G - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4 _* f. q, H3 c P - * GNU General Public License for more details.
+ d% {( Q/ A, g - */
2 m# c }- Q& ^: U - j! }2 a7 U& `; N
- #include <linux/module.h>7 N0 I* V; _, `9 R, n
- #include <linux/init.h>
6 {7 H+ B) |0 o. R* h! C. ~( D - #include <linux/errno.h>+ e$ m3 ^' F9 s$ s) @$ b0 m
- #include <linux/types.h>; Q. c+ \7 L2 K! c- y
- #include <linux/interrupt.h>7 i8 L% C) }: U8 b! b% I
- #include <asm/io.h>
& _# |1 e+ S# j0 r$ L# P) k - #include <linux/moduleparam.h>+ f* D' F5 E: Z: e& l- ~9 x9 K
- #include <linux/sysctl.h>) g9 F/ ^8 H7 x/ B# M
- #include <linux/mm.h>
$ F! j3 [, `; u) c - #include <linux/dma-mapping.h>
6 `; J2 W. f3 Q+ t, \0 p
1 k4 A. F7 F& T) U6 J# O- #include <mach/memory.h>. Q$ c, y. ~2 G3 ]# E! ]
- #include <mach/hardware.h>7 I! c' }- R% m4 m$ Q. q' A
- #include <mach/irqs.h>
) {6 Z" U$ U' `6 _/ ] - #include <asm/hardware/edma.h>! p. k% `6 Q4 w& Y% e
7 ?/ F% }) e) U- #undef EDMA3_DEBUG
% l7 i$ e7 D! z6 \ }& ]0 Q4 k0 z - /*#define EDMA3_DEBUG*/$ @6 h! L1 m6 E0 T' p' Z* k: N, q
- ( k* f5 a7 c- d! u( K
- #ifdef EDMA3_DEBUG
1 A$ f/ ?) r* d- G. B4 J - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- n7 c6 C' g5 \9 d2 E
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__) m. i/ F, |, g) i7 |
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__) |1 F- y0 z4 t# u% w
- #else
5 ^" Q2 s" M( L w- u- Z6 U - #define DMA_PRINTK( x... )
' b+ X$ o& X4 M: N - #define DMA_FN_IN7 d. z* M) ]* U7 I
- #define DMA_FN_OUT. Y, n. L$ @% i% l) X* ]
- #endif
9 K$ h* N& e! v - " I% l- w; l" o d
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)( y& a" T w* C, h' [+ h
- #define STATIC_SHIFT 3% p& ^, a; y* b# K, ^4 F
- #define TCINTEN_SHIFT 20) N! z2 t n# k3 _9 r& A
- #define ITCINTEN_SHIFT 21
5 z* O4 _0 O6 V- N% N' ]% e" }5 Q - #define TCCHEN_SHIFT 22
8 b- j) F8 M2 Y! D! x - #define ITCCHEN_SHIFT 23
) e9 A: F/ x9 p1 p7 \
3 k# ?/ ?% h L/ z5 i2 _. s- static volatile int irqraised1 = 0;
4 X4 a" l4 r8 u) r+ E( R3 F - static volatile int irqraised2 = 0;
$ C( N* o: X7 S' X0 S' B - 2 U4 P* X: ~% g8 P% o9 {
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! x+ W0 E3 a& \ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 R% Z( C* w) a2 f1 K
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
O$ p8 b6 r0 S, A- {+ A" Y - - l* | I X$ W( N! `. B
- dma_addr_t dmaphyssrc1 = 0;7 k0 O- R* ~7 N9 s4 X
- dma_addr_t dmaphyssrc2 = 0;
7 c& \4 r4 l# _0 _5 ?* | - dma_addr_t dmaphysdest1 = 0;
# a* s' v( J( v: I* Q - dma_addr_t dmaphysdest2 = 0;' F7 t9 p, L3 L6 X
- ! U! k' p7 N2 C, X/ X- Y
- char *dmabufsrc1 = NULL;' l0 T: M+ Y4 m% T4 y" H9 X
- char *dmabufsrc2 = NULL;
1 @5 @" |+ r+ D( F5 N, |( ? - char *dmabufdest1 = NULL;
3 A' C$ x' K6 W - char *dmabufdest2 = NULL;
5 Y7 }, x4 B) g: ~, \6 c& T - ) {+ m% y2 H/ d7 k0 M6 T& E9 m6 K
- static int acnt = 512;
g, }$ R, l, E( K) w - static int bcnt = 8;. U1 ?$ @# ^) W* ^
- static int ccnt = 8;- Y6 Q6 ~$ K/ u
: X& \5 t1 I4 ]9 S! T- module_param(acnt, int, S_IRUGO);
+ \ c" w# T' c. G3 I - module_param(bcnt, int, S_IRUGO);6 a6 T- A/ s! k5 d
- module_param(ccnt, int, S_IRUGO);
复制代码 + E; L9 k" [" c4 q' M9 ]
- X$ f( S% t4 o7 |6 Z; r. A- H1 a
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
- X/ r1 `5 V$ } v) V$ Barm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
0 Y: s9 v/ }* `: y 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。; N: b" o) {6 C% ?" f6 Q
7 L8 ]2 h4 b& \4 u
% e L3 z+ H5 V; g6 J* Y7 b |
|