|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 Z2 m1 f! u4 n( z$ g6 P- [code]EDMA sample test application) h% e' v! U5 z5 }. k: ?
- /*
) Y8 u3 j) t' K% D$ J7 e4 L. O! l- e - * edma_test.c
& I1 {1 j; x% q% A% n A. H - *! I6 d- z% g( B6 X# X5 G$ g, z
- * brief EDMA3 Test Application6 ^& ]& z+ U; ]7 q+ V5 T& B
- *
$ e- P/ H$ j: d# J - * This file contains EDMA3 Test code.
& R& E) P5 \* @8 t( ?$ d - *( a' J# r" C3 e: g( L7 J* ?9 T
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( U- h i+ _, d3 H$ G8 o1 A: m
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
9 n, t* f; X$ L4 J& t - * TO CHANGE.- y1 M* _5 X9 y% D! F0 J6 \2 f+ s
- *( _) Q; ?) l+ y
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/( u1 B$ T' P7 b2 u# K8 m
- *
e. g6 _+ h# E4 X, u9 d6 L, M/ i [ - * This program is free software; you can redistribute it and/or
8 ?% c! t' D/ Y" _4 L - * modify it under the terms of the GNU General Public License as
% f$ E5 p- v; ^4 a& V - * published by the Free Software Foundation version 2.6 n3 w. v$ O- k9 ?1 i0 c8 a0 i
- *2 b1 u' W: r. X' _2 j
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any$ g* I" w' @4 o" F! F( S$ i! u
- * kind, whether express or implied; without even the implied warranty! ~$ L7 q& `/ V; |, S2 x. _
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1 t; z, e' x8 I* S" V9 v5 w7 k
- * GNU General Public License for more details.
* x( N7 V, n: Z# @3 d$ h - */; |. } _) a5 f, m% b& I
: y9 h9 o4 @, P* z; R- #include <linux/module.h>
' d5 v( t4 n O9 w, ] - #include <linux/init.h>
; F" q F8 X2 G - #include <linux/errno.h>4 Q* x+ k' ^ j
- #include <linux/types.h>
. T. j4 R0 j; p P7 g* `; C - #include <linux/interrupt.h>7 X O7 r {! a5 y! N( n- [1 Z
- #include <asm/io.h>
+ H1 H4 W% [' U, D7 A; j! z - #include <linux/moduleparam.h>/ c0 L2 C- n8 t1 j2 @/ J/ X
- #include <linux/sysctl.h>
& i1 K- K3 M* r7 E$ B% n - #include <linux/mm.h>3 \$ @+ z" c3 |, I- l1 k: D) _% A2 p
- #include <linux/dma-mapping.h>4 O" L& \- b( x2 Q+ `
, b& K( R X0 v* e+ |2 {- #include <mach/memory.h>
% g V; u' v% z7 Z& e: I( s! U9 u - #include <mach/hardware.h>2 q6 f7 b0 C# D$ i- Q
- #include <mach/irqs.h>: E; Z* X9 u- d
- #include <asm/hardware/edma.h>/ R6 h6 `) K7 G- `: o
- ; N, b. V7 |9 \7 M
- #undef EDMA3_DEBUG( j% j. g4 x6 G" e: G1 y+ o
- /*#define EDMA3_DEBUG*/
0 q+ l9 n* q" e! ?/ X - 0 R$ S" C6 o( G+ }
- #ifdef EDMA3_DEBUG& V* g, u8 T# x9 x; O/ ]
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" }( b$ w. x" O( o; P& k- y Y P8 z
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
: A' g% {$ f9 n! T z c+ ~' j - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) A8 X9 c$ C* I* G$ b1 J" W( v8 p - #else
- a+ Z* k' Y* Q/ m: g - #define DMA_PRINTK( x... )- ?9 I( e& E6 s% r
- #define DMA_FN_IN6 K+ B% x. p$ o$ ]* t/ Y
- #define DMA_FN_OUT
7 Y; s0 u$ D* O8 Z0 L# v9 u - #endif
$ ?) d% Z; `; ~% q- F3 A
6 S1 |3 w( k: M$ `# l4 I- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. l5 H6 S- R- t: ]8 t# J0 ]/ Y; q - #define STATIC_SHIFT 3
/ L# i. F0 C8 X* A - #define TCINTEN_SHIFT 20# h5 R$ Y* Z5 e
- #define ITCINTEN_SHIFT 211 K: z; `4 g/ F9 K n' r; Z
- #define TCCHEN_SHIFT 22
3 K$ ^* |) m* s/ x# D8 V, X) \ ^ - #define ITCCHEN_SHIFT 233 K6 L6 I- T6 `( ]% \
& a. d9 `: [' S. |! ^% ?- static volatile int irqraised1 = 0;
. E# K6 J% Q/ ?* R, _' Q - static volatile int irqraised2 = 0;
9 _) Y0 j1 I* u( ~5 f - * N' S8 {" A+ S# H; y. Y" y
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 E- x& R. A+ {/ ?+ s |: H
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ F* I1 f9 j; @8 ?/ _4 l; ?2 l - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! R/ D( l' t" Y& m O n
7 K4 R I& E, ?; F# m$ @! k8 B- dma_addr_t dmaphyssrc1 = 0;6 U& k9 N: v, L: N/ J. z" f
- dma_addr_t dmaphyssrc2 = 0;9 _8 ^, a2 R6 {3 q( b
- dma_addr_t dmaphysdest1 = 0;) y+ x h/ O6 R8 K
- dma_addr_t dmaphysdest2 = 0;
- g. {; W, \. f6 _: i2 h - 1 y1 {- q# @, o+ g9 T* B1 N6 u! f
- char *dmabufsrc1 = NULL;
, u9 [5 l; b+ \ @4 W' H6 J - char *dmabufsrc2 = NULL;
# P" Q' w" k5 ] - char *dmabufdest1 = NULL;9 `7 l; a9 B. F7 ~2 c9 h) z# M
- char *dmabufdest2 = NULL;/ c9 j2 o2 o9 y9 n: L/ z
4 ]! U a3 r/ h+ ?- static int acnt = 512;
; `; }- E8 T' Y* m& o R0 L - static int bcnt = 8; L$ t9 E! Z% R1 u1 P
- static int ccnt = 8;$ [! k2 l/ y6 A d) V
& l# V# [* s; e% s/ e- module_param(acnt, int, S_IRUGO);
* ~! ?. `9 o2 L - module_param(bcnt, int, S_IRUGO);5 A. Y7 J7 Z* u2 ?0 S
- module_param(ccnt, int, S_IRUGO);
复制代码
! B5 K! v& I* m- w# q3 I \
" G6 a: [' |2 r6 Q# {6 b9 u 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
# B. @: O; z: K, W. {# v) tarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。! { g( m1 g# C" v" o+ l
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。7 @) e W" \2 k
; y" K5 b- U3 b. _! `
6 d4 J+ X6 ~% z! w+ n# x |
|