|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ! U2 N' K+ f; x0 \4 z8 ^0 [& [
- [code]EDMA sample test application( z3 L0 `, Q" `; i5 C
- /*7 c. z: {9 c' @7 [$ a
- * edma_test.c+ I! i# K- P1 X. O7 W" V
- *
) t5 B. X* B/ Y; L( [0 u8 [ - * brief EDMA3 Test Application8 T- s8 C; [9 y, C4 J, {( t
- *; g! m! A/ g a6 P8 g4 L' X- Z, J# @
- * This file contains EDMA3 Test code.
|# n2 i* ^/ ]3 `! g9 @ - *- V& c) ?0 m. }% ~- t k1 k
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE) o0 {6 y2 a/ _; ]$ u; }6 ?/ P' O
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT$ L0 O1 S: T- {$ ` O, c
- * TO CHANGE.
! h+ {6 k4 W0 i- K( X - *5 i- u) Z9 t! E; n3 J
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
# x/ ^6 K5 F `* M& H - *. Y) Q+ G2 D+ l) c8 n) Z6 K7 ^) y
- * This program is free software; you can redistribute it and/or
6 C+ h3 { L; V - * modify it under the terms of the GNU General Public License as
; A( E/ i# g1 N2 T8 T% T - * published by the Free Software Foundation version 2.7 f* ]# I7 h% m8 j' N; n1 G
- *
; m4 i/ Q) z. h- s1 N( J - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
# w& E5 J( d8 d* M$ F, j# u- J - * kind, whether express or implied; without even the implied warranty8 d$ Q& \/ K! T( F* m E. U0 X
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% u0 j- n# h5 q2 L4 R; e7 B) V) o
- * GNU General Public License for more details.; i1 _/ f3 ]1 k8 R% r) o* D& i6 k
- */1 J" ?/ G) B: i
7 n/ f1 o+ j1 V. [+ q6 Z- #include <linux/module.h>4 R$ S. g3 S4 j- P
- #include <linux/init.h>
$ a/ I [& i6 F9 c* j - #include <linux/errno.h>
0 @; H5 j- p5 Q; [ - #include <linux/types.h>
# P% S0 s0 u5 r& H. h( _ f1 f - #include <linux/interrupt.h>' ]# b5 `( Y. w+ |9 b0 V8 E
- #include <asm/io.h>
# B" X9 l8 ?* j: Q- [' p% d8 S - #include <linux/moduleparam.h>9 A( L5 s* [7 G! o5 N
- #include <linux/sysctl.h>
5 h3 I+ k* \% W. `4 ^4 b7 r+ B; l - #include <linux/mm.h>0 d Q/ }$ S" ~# Z7 S4 J: c- c1 Q
- #include <linux/dma-mapping.h># ^6 G4 m( y& O- s7 u6 W; b# O! W
2 W8 D2 _- Q+ F/ n( R9 p4 G2 Y) k- #include <mach/memory.h>
8 G2 `, v. g% v5 h, A' g - #include <mach/hardware.h>
|* [! Z/ H* X; D, \/ f - #include <mach/irqs.h>
& B' Y7 o2 B. t6 ?3 g! V7 X - #include <asm/hardware/edma.h>9 b, A: r; `" }: j
; [* k" ^6 q" |$ d% B/ D, `- #undef EDMA3_DEBUG
; K: P/ T9 D9 P! i* G1 P - /*#define EDMA3_DEBUG*/0 s6 y* P0 a& x! G1 d! T" @% D% R/ J
: `! H4 U9 z( b+ E- #ifdef EDMA3_DEBUG: E+ {1 d, |7 D7 s
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- y) @1 N+ a5 ] ]
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
4 j# i6 F; c% J, L; M( { - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
8 U+ Y& p$ {( h* ]6 J, `$ o% y - #else* h d# u/ j! \/ S
- #define DMA_PRINTK( x... ). ~, b0 l# i3 c' R
- #define DMA_FN_IN
, j' M l Y8 k* o' H" d k - #define DMA_FN_OUT& `# s0 x8 I% i! c, P& ?/ D% [/ W2 G
- #endif
0 P5 W6 J! g9 Z# U
0 I! X0 V( J! z' e6 V" R- #define MAX_DMA_TRANSFER_IN_BYTES (32768)) i' m5 Q2 |4 O
- #define STATIC_SHIFT 3
+ N/ m7 q6 j6 G; n, T - #define TCINTEN_SHIFT 20
1 N. x' A6 S5 q9 @ - #define ITCINTEN_SHIFT 21# v; E' E% s2 t$ B* ]8 i; n
- #define TCCHEN_SHIFT 226 J$ I" G' U, d% A# V( a& r
- #define ITCCHEN_SHIFT 236 C; X3 ~3 ]. O, L2 F
- ! o/ Y9 P& a. {; B+ U) u
- static volatile int irqraised1 = 0;
) w$ K( J0 E, \0 H1 v- C! U - static volatile int irqraised2 = 0;) a: V: N- {: @* @' h
- " ]4 P% w! |" Z* j$ n; \4 J
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 }# @; U2 b: l8 p
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ X0 i+ U6 J. }4 h/ K& a/ g6 c
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ Z+ {, C+ Q1 ~/ _) l' X- G# E' E - - S! X' {% [! k- D: W. w
- dma_addr_t dmaphyssrc1 = 0;
& g" L$ G# p) S+ t - dma_addr_t dmaphyssrc2 = 0;% Y. p: g1 ]. k' C9 V: s% v
- dma_addr_t dmaphysdest1 = 0; @! v+ F( _7 p H( o
- dma_addr_t dmaphysdest2 = 0;
' B/ R+ a/ j. J0 k" m0 m4 x1 P
! l3 Z3 _- y0 z0 g5 q0 J- char *dmabufsrc1 = NULL;
7 r2 a) E" g4 u# s Z - char *dmabufsrc2 = NULL;
% h% y# _6 ?1 G. E - char *dmabufdest1 = NULL;: \5 K: y l3 g5 u7 Q
- char *dmabufdest2 = NULL;
) \3 {/ [( `. z6 x3 R2 T - 9 d2 O6 v- j3 G7 L
- static int acnt = 512;
0 d1 s% n) z5 R; Y! h" n - static int bcnt = 8;3 C [- J$ f) q. x$ h& o9 b ^
- static int ccnt = 8;" g/ F* W- [- }% W$ Z: g
" i; g* r% }9 }- x- module_param(acnt, int, S_IRUGO);; j7 X2 W9 i. U: }5 G
- module_param(bcnt, int, S_IRUGO);3 i+ }/ l( } R5 z$ t0 }- S4 w
- module_param(ccnt, int, S_IRUGO);
复制代码
0 l* D( F+ _. g( p) A: K4 g/ f) V! n1 E
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 c! p3 ^# O( u" Y: oarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
& p B4 T( X. f9 x 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ b ^1 u; U% o9 [( ?7 J- {
- d# R8 B0 d# y v3 C D3 O
8 M0 a# t0 ]- \& T" I" B- g) o7 z
|
|