|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 3 V$ c# P- k* u9 `' k1 Z, f* r- q
- [code]EDMA sample test application
' Z; b7 I/ ~& u3 b( H - /*
# s7 f7 { \& V$ r8 p - * edma_test.c
6 Y- U- b% z6 Q ^4 A) } - *
' U7 I6 w, I9 {& `2 F" ^3 {& e" D Y, \ - * brief EDMA3 Test Application
& Q- j: q2 D+ ~ - *3 t `. ?' {% l: V0 l
- * This file contains EDMA3 Test code.
% y8 b6 R& a3 P - *6 C" g( }8 l' m3 x
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE& N: [) }3 C1 v% h1 n/ S% T3 o5 n/ F
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
1 U( |+ I5 V( O - * TO CHANGE.) k7 x! Y6 g8 u) k2 x
- *
) h+ O! v0 D) N: E0 L - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 h; v/ b! u! T/ ^& W. i
- *
; J& G# k! D1 W - * This program is free software; you can redistribute it and/or! m7 i; F8 D% Y
- * modify it under the terms of the GNU General Public License as
/ n; ?- I- ]2 H - * published by the Free Software Foundation version 2.
1 `* Q1 t! b, E - *. B4 O/ H% r; A+ H5 w/ [2 V
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 `. f; q0 A; O" K8 n
- * kind, whether express or implied; without even the implied warranty
# n' D1 y/ t% Y- F$ R - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 t& p# k6 S# j( `
- * GNU General Public License for more details.8 i$ U6 g$ W+ _. |; ~, S
- */3 q' N" U: w: y8 \! d' b
- ' _- f4 H3 W; M/ p
- #include <linux/module.h>3 C h8 W6 m2 O7 h6 t" O S
- #include <linux/init.h>) @2 |: y( `* f0 V( J( L
- #include <linux/errno.h>* I$ q. Q3 F& c- S/ S1 H! z
- #include <linux/types.h>0 P4 h7 B* u8 g& w( O
- #include <linux/interrupt.h>, z. ?0 ~) x# {3 o: {; o) J
- #include <asm/io.h>9 s) f4 C" Z% t$ A4 K" {* f- p# f2 s! D
- #include <linux/moduleparam.h>
3 E9 y: ~6 K! N5 B/ z9 K; Y - #include <linux/sysctl.h>: B) P; b: i4 q. w2 a
- #include <linux/mm.h>
% x& _1 T/ B# X - #include <linux/dma-mapping.h>
& l8 }- y- C; `/ T" Q/ g8 d% D/ V& y6 K - 7 o4 l' z' H2 q. ~9 @. ^
- #include <mach/memory.h>
) J+ K9 j; k5 L- ?2 ] - #include <mach/hardware.h>
8 M) @' H( A- j+ b. k - #include <mach/irqs.h>
- U3 A; J& r, u' k9 h/ a - #include <asm/hardware/edma.h>
8 ?# g* ^3 K4 P- N# u& m
8 a+ E) r$ l& ^) H3 T- #undef EDMA3_DEBUG
+ v5 J6 E i1 R6 Q" P( `. j - /*#define EDMA3_DEBUG*/
; C$ o# H7 U- X, `) q5 @2 J0 q - 7 O5 ~/ @3 x" U& R: f" V, |" o; p
- #ifdef EDMA3_DEBUG
& C) e" ~. k0 x+ m# q9 R - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)+ j3 y, b7 r6 e" G; H4 c& l
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). q# c% d4 h2 e6 q
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
7 Q$ J; t! D2 \$ E1 _ - #else1 |0 D- m4 Y: N: M& ?- D
- #define DMA_PRINTK( x... )
2 l. Z5 s0 y0 q - #define DMA_FN_IN" w5 C" a8 w# y$ k) U( S
- #define DMA_FN_OUT! R( O- H$ N# J. O; z# C# U" s8 N
- #endif
/ w9 X- S, L+ b( k9 V* Z - & x. \ _5 U$ h
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)# F: j5 B5 R8 O% j2 D
- #define STATIC_SHIFT 3
9 [' O" y, y' \2 h9 A: M8 p# } - #define TCINTEN_SHIFT 20* }$ A% q; A8 Y& y- Q2 [& y
- #define ITCINTEN_SHIFT 21
$ {. D+ t. E4 {' E, v - #define TCCHEN_SHIFT 22
2 P& @/ ^7 Q& o0 a4 o, c: ] - #define ITCCHEN_SHIFT 23
; _' |9 O3 T4 F9 |) P3 U
; L9 n" D; u' _. q- static volatile int irqraised1 = 0;
' J- t. b. v, W+ \! T- d) W; U4 e - static volatile int irqraised2 = 0; }- d8 \- y6 b- ~ W% e
- + e: ^, R0 _& N
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
C! v" K6 Z) H - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 G( [4 p( M5 r6 T2 k$ B% e$ U
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: x' D" Z6 o7 g7 I
- ; t7 F2 e- Z# E1 h5 B
- dma_addr_t dmaphyssrc1 = 0;6 L8 ~4 h- d" J h% r6 ~0 o
- dma_addr_t dmaphyssrc2 = 0;3 v: S1 w" | U0 p7 I' f
- dma_addr_t dmaphysdest1 = 0;4 N9 p o" q* Q3 p# _
- dma_addr_t dmaphysdest2 = 0;% V) Y- e; y! v
2 E5 X) T9 }1 O8 [- char *dmabufsrc1 = NULL;! g- a, _, `; M0 x5 v- P7 _+ q1 k
- char *dmabufsrc2 = NULL;& e2 }$ N# G/ p+ |% o
- char *dmabufdest1 = NULL;
! x3 D- b) H: {3 X7 T& ^ - char *dmabufdest2 = NULL;; O& s' }( k5 v6 P% P2 D" E
- 4 U3 a) j7 w# y4 A0 r
- static int acnt = 512;
2 M% \& e! ?7 H4 x - static int bcnt = 8;
6 P( Y ^/ @4 E6 m - static int ccnt = 8;
& t& ]# Y- M( k3 {* F - 9 j) D$ a/ n% p7 ~
- module_param(acnt, int, S_IRUGO);
, \1 z Z+ ~8 w# j6 u, p - module_param(bcnt, int, S_IRUGO);1 K$ }0 M$ V$ b* ?& F7 }( a+ k
- module_param(ccnt, int, S_IRUGO);
复制代码 3 E& k3 S9 ?) V7 _
( G" l9 m# @9 B
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用/ q$ U5 n( H+ x+ j: 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* E( H2 R y! ~. R ]4 K4 b
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。7 H2 _& `. @/ H% K J- G& W
! ]( ?; g' ~. F( u7 c5 w" o @9 R
- O, `+ W8 R' ~: w |
|