|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
- G' z, \0 e9 m m$ y$ I; H/ q- [code]EDMA sample test application8 R! s0 l. Z: F; y/ q
- /*
7 I! B N5 B( [4 f, w - * edma_test.c
% u" h9 {7 ^1 V1 }" t - *
, Q, \% G. ~4 b - * brief EDMA3 Test Application4 i7 T: k5 h8 E# s8 \
- ** t0 [3 J$ m$ q% n2 ?
- * This file contains EDMA3 Test code.4 g% B; v/ g; B$ H) X: N& Z
- *
4 l6 {& J7 W0 I- c. }+ C6 I8 W8 a - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
& [0 i; C" @5 {0 W. E8 B - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
5 G# m( ^; e0 }+ x# T/ Y - * TO CHANGE.
: q5 i, ?4 Q, C1 y6 {' U+ ~ - *. v1 @6 e( E( m5 ^
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 x6 @% a$ e$ x4 u v
- *5 b' t+ {+ d% |1 t' u; u" p
- * This program is free software; you can redistribute it and/or
' C7 S7 a4 S8 V - * modify it under the terms of the GNU General Public License as
* y% t( U# v2 x - * published by the Free Software Foundation version 2.
8 W7 e0 E9 @5 R$ H6 k/ j1 @9 { - *
. g) t" K. K* b7 `: Z. F2 ?3 h5 |9 _/ w - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
! @% a5 k0 u% J) n/ { - * kind, whether express or implied; without even the implied warranty
- E& t# @# m% c# C9 ^ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the6 ]! C- B G }5 j
- * GNU General Public License for more details.
- Z4 Z2 N9 {* P - */
1 [. f5 `% O/ |8 Q( ^ - 0 E/ P4 Y% i1 c( L
- #include <linux/module.h>
: d% D8 r. t, N: }- ^ - #include <linux/init.h>7 y& H; V9 N/ y! H9 s* t$ {/ @2 w- d+ e
- #include <linux/errno.h>
6 S$ f" ^. u$ V4 h; b5 k3 W, ?) I - #include <linux/types.h>* k0 p9 w" t! g1 X% h
- #include <linux/interrupt.h>
! P5 y6 u$ n: ?# ^- F: y - #include <asm/io.h>& o/ X$ R2 Y* T6 C! e7 Y
- #include <linux/moduleparam.h>1 p( Q% Q# |* Q) k
- #include <linux/sysctl.h>
M0 u1 ]% Z& n9 m+ _% d - #include <linux/mm.h>
+ Z. q5 s: Q3 A5 w& r% C! O - #include <linux/dma-mapping.h>
1 H5 A" P; W9 q0 O" z: F1 A
* f% Z2 Y/ [* ~- X7 g2 P) @- #include <mach/memory.h># c" m6 r$ Z* n. ^
- #include <mach/hardware.h>+ b7 Q: _) o) F; N* E1 o
- #include <mach/irqs.h>- X/ Y3 M0 i3 d5 q4 `8 e$ r1 W& j% H
- #include <asm/hardware/edma.h>
* c/ a* z U1 y5 B) s) \/ O O# b - 9 M/ V* T. W( R# t
- #undef EDMA3_DEBUG
- |6 c) |$ S5 s; i k; _! n - /*#define EDMA3_DEBUG*/8 X m w/ r" R) ~) X7 X( S. P2 Q
- , A" p. b+ u Q) Z: L
- #ifdef EDMA3_DEBUG
. g) p4 d( z! w0 t! i# v7 _ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)( f8 f" B7 s, l& p7 i4 q
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)8 a5 L% n+ z9 P7 b
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)$ x$ d) c/ s7 j0 ^( P4 M' O" }( ^
- #else5 M1 x5 k. f! o* ?
- #define DMA_PRINTK( x... )2 ^# m0 M# J4 d0 E! F. J& m* W
- #define DMA_FN_IN" Q \% u! |' \# L, P$ Q7 ?
- #define DMA_FN_OUT$ e' }( P: a2 i" f" H
- #endif
5 ]! u6 M! q4 g z: I3 D
6 q3 o6 \8 j9 E1 G) o- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
5 R! u' r& \, k - #define STATIC_SHIFT 3' ~0 }/ L+ c6 W% l1 P4 Y% _
- #define TCINTEN_SHIFT 207 p: @' Z) z, |! h: s
- #define ITCINTEN_SHIFT 21
" E: c C# a$ R) R* }5 R - #define TCCHEN_SHIFT 22
. c: E7 f" Q: Z. |; J3 \9 U - #define ITCCHEN_SHIFT 23
' f( e, ?% Y7 l - 6 ]* H8 I7 p5 ?! } T ? @
- static volatile int irqraised1 = 0;' e1 F% H4 o+ Z. s
- static volatile int irqraised2 = 0;
! F- R: `2 ^: Y' V4 ]
) M# o* I! b; ~) H% @- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ r0 m7 V7 c2 l: B6 } G
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% \) o% ~2 ^# b) F( p, p
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 w6 U: r; J, S* x - * u& X1 J" k5 B
- dma_addr_t dmaphyssrc1 = 0;+ Q$ w: Y( s+ v# F- q' B) k
- dma_addr_t dmaphyssrc2 = 0;$ a( V# o! ? r5 {
- dma_addr_t dmaphysdest1 = 0;
2 P4 `1 u% y' l: @' f( Z* M$ Z& r - dma_addr_t dmaphysdest2 = 0;
" Y Y' Y2 `* \0 f/ J8 p
, S2 V( y; t2 ]* Q' `. ~( ]! G- P' n- char *dmabufsrc1 = NULL;$ u% @6 V, z6 q9 q7 G8 j, B
- char *dmabufsrc2 = NULL;$ n5 l$ ?2 w# y8 x( b0 o
- char *dmabufdest1 = NULL;
2 R; s6 N, p3 O }' I - char *dmabufdest2 = NULL;' D' \; [2 K8 \9 c- z/ e
- 6 ]7 W* G6 x t% B$ l9 g3 W
- static int acnt = 512;" N6 r/ r- t9 Q& N& G/ T8 E& t
- static int bcnt = 8;, K9 I; v' I/ j9 Z
- static int ccnt = 8;" ^4 i7 p) W! A+ O% i
- # D0 R' c2 V! e! j
- module_param(acnt, int, S_IRUGO);
9 o2 N! h" o5 V2 f8 U1 B9 y, N6 O - module_param(bcnt, int, S_IRUGO);
1 A) l( D2 l! a: | - module_param(ccnt, int, S_IRUGO);
复制代码
6 t9 ^+ R' w- ^# v ^
- H# m$ C. y: | 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用5 A, {1 I$ _. Y! j% X1 h1 i
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 t! O, ^* q$ e0 f+ U& j
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
0 ~; Z K+ L( G
6 O; ^7 O3 K% W& q$ C
+ [' n+ L& u) D% O6 V! i |
|