|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 i7 R6 r/ d g. o& W- [code]EDMA sample test application. |: I5 B& b$ G$ {6 m2 U
- /*
' ~# I6 X3 g8 Z4 u# C - * edma_test.c
$ P; b& I. S( P( _' X# ^: R - *
" p: R3 [! c+ z' F& ^) P, S - * brief EDMA3 Test Application
# {# x9 C% V6 c0 d$ c+ b - *' K% {8 k! S, ^7 A- @4 v2 S
- * This file contains EDMA3 Test code.
: x+ {/ @) P: R( c0 N0 t - *
- x& D' o& `9 R4 Z0 j7 Y% t4 S; G - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
5 y1 {; M9 ?8 v, `2 f - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
1 R1 @( a! J' O# r - * TO CHANGE.
/ Y( H$ ]2 o' K - *
/ `& x( W) `5 I1 K/ v5 \ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 P) ~9 l; }! B" b+ D; z. p; M - */ S6 ~- e) n. F3 C# V D
- * This program is free software; you can redistribute it and/or
@7 M" F+ n( W! p: A8 d& A - * modify it under the terms of the GNU General Public License as( e; v3 z' f- V K m# O
- * published by the Free Software Foundation version 2.7 o9 r5 u5 H4 }8 L; x4 T
- *; N( s9 e( W. _2 P1 _( E
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any, S* A. p H" X+ C4 t4 A
- * kind, whether express or implied; without even the implied warranty6 M2 O0 W2 m3 E% F
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) m5 R- Y( m" r/ `2 Y4 [" U - * GNU General Public License for more details.2 k r4 p9 r4 w- e# u
- */
% B/ T' [; t# n+ j
! o9 V ?& P$ y4 u- #include <linux/module.h>
* a3 g3 ?+ Q9 t0 p0 E* W - #include <linux/init.h>
/ D" F, b) _; M) `, G - #include <linux/errno.h>3 s% v7 P( c M1 ]2 |9 {. Q+ W
- #include <linux/types.h>( w6 L( c4 v! I( ^
- #include <linux/interrupt.h>
! N3 |3 w/ f6 q3 |( D% \# q - #include <asm/io.h>/ }0 D$ T* i# l" d2 A6 s3 W
- #include <linux/moduleparam.h>
3 e7 E) v; B5 P8 W - #include <linux/sysctl.h>
3 K4 ?0 X% b% L! W! ~ - #include <linux/mm.h>
0 C, j1 R6 J: t: i7 T - #include <linux/dma-mapping.h>& ?5 L" ^: ]& p9 ~" V4 h3 T
5 R4 W3 l" N5 H4 j% D- #include <mach/memory.h>4 g# S8 K) [# A# K
- #include <mach/hardware.h>( Q( m; n8 A( N; D3 g5 K! i6 {
- #include <mach/irqs.h>- ]5 h) h9 o i* a4 k7 O1 i
- #include <asm/hardware/edma.h>0 B( u$ A( e, F/ e
2 a: }9 x n6 V, t+ e8 w- #undef EDMA3_DEBUG& F9 p" I* J6 z2 n# Z) M7 Z5 h2 u
- /*#define EDMA3_DEBUG*/
$ @) o! R3 E9 ?' |. H5 R# I# p - * n' c+ k2 c& \; P5 {( V7 {# Q
- #ifdef EDMA3_DEBUG6 T( f7 a3 d7 L0 ]5 ]+ q( K
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
) W; K+ Z1 U, p4 l( g, i! b5 O - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
" w/ C8 O7 @0 k9 {: Z- B# }' Y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)- u, k# [; X- m8 j _
- #else
+ D5 K7 p5 e! \. j$ S& y - #define DMA_PRINTK( x... )
5 p; b+ I7 e6 B1 I K7 Y6 D - #define DMA_FN_IN S8 }" U( J, J
- #define DMA_FN_OUT
0 R9 W: B6 i. H/ E7 W - #endif$ Q+ q0 b) g) M" r& N
- ' G' Y$ }' P+ i4 O: H
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ [; ?+ y6 ]& {4 ^ - #define STATIC_SHIFT 3
: }) a! H& U0 N" l - #define TCINTEN_SHIFT 20% Q! C7 k1 ^' B0 _9 M2 Q4 z
- #define ITCINTEN_SHIFT 215 y" Y3 R' \, O& b. V& f, z
- #define TCCHEN_SHIFT 229 E0 [3 I, f: m; a
- #define ITCCHEN_SHIFT 234 E, @2 m7 S D6 v/ D
- ) l8 P3 ?0 h+ t0 Q) m1 T' [" O
- static volatile int irqraised1 = 0;
5 `/ D J# ]5 ^/ n; r( B5 l - static volatile int irqraised2 = 0;% B* B2 w2 z7 r% N. v9 @
- ( U, x; b( R$ q/ B0 Y' g+ e
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 s! N! l8 T6 G0 A, H
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 ^! [$ A& g+ i2 u1 S - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% @3 v1 a" E( X4 n- ] `5 ]
- & E# M$ S. B4 i
- dma_addr_t dmaphyssrc1 = 0;
$ ^7 V4 |# k- C* m7 q( O8 e - dma_addr_t dmaphyssrc2 = 0;
# l: l+ Z# z) M2 s - dma_addr_t dmaphysdest1 = 0;
3 n5 g: D8 C6 c/ F) k) B% ] - dma_addr_t dmaphysdest2 = 0;
5 S$ ?4 A) I. e2 f; z1 c
: L) v6 }. Z; J8 s1 A, U' U- char *dmabufsrc1 = NULL;$ P# ]! [5 v- W4 j$ ]
- char *dmabufsrc2 = NULL;
: f% }- ~% ]$ ]: T& f: m& n' u& e2 K1 p - char *dmabufdest1 = NULL; m, V6 u/ R) U" W
- char *dmabufdest2 = NULL;
" p+ A3 f$ n- j- l9 s0 ^ - 2 r6 J4 W, P. A; J" J
- static int acnt = 512;, P; P: @# f9 Z, X: F/ n* U q
- static int bcnt = 8;
' |3 B" a9 a- s6 A0 r* f+ a - static int ccnt = 8;
8 w+ ^, V' {! F! a. K/ @1 q - ( d, ?8 O5 T0 d" {8 O! J
- module_param(acnt, int, S_IRUGO);
* r/ f3 @ A5 Q# k - module_param(bcnt, int, S_IRUGO);
3 J. m& R/ D! u9 Z L# e - module_param(ccnt, int, S_IRUGO);
复制代码
* W* ? i1 h9 T" @' ` u3 p, ~6 [) U+ B- ]* j/ O ^
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用+ e" D* Z# y. z' 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
6 C- S% \& B0 x3 W) C( U 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
( I8 z, X8 }; I/ y
& J+ I. e0 o+ L+ Y7 A; l
, b) e+ _6 m* X7 X |
|