|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) O6 X- G$ \; r% L E' {* c3 G' D- [code]EDMA sample test application
* Z' ]- H& G! e0 d - /*
+ X. T# H8 S4 r! F - * edma_test.c
8 D0 e; Z6 e: S# H0 c1 n, V - *$ Y' u( z# y2 t' f' y
- * brief EDMA3 Test Application
( d2 r- z8 l# u: F3 c - *
' Y3 j. b7 q, W; V8 }6 ] - * This file contains EDMA3 Test code.
( E% E- F/ u& _1 `2 X1 e6 Y - *
0 L w8 s) q. N1 {7 T2 g$ [7 x - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
9 }1 C7 o5 @& L4 p6 P - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
/ r3 g0 m) i6 e1 N7 O* c% b. c - * TO CHANGE.
% @: \# h9 J0 S+ w2 E% I - *
0 F; q9 t* O0 f' c - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* d; S7 h* H* j4 c - *% O) E6 a# ?9 t; V/ G, p8 W
- * This program is free software; you can redistribute it and/or
6 h% W* D9 r! a8 W' A. a - * modify it under the terms of the GNU General Public License as
5 U4 A3 z! c1 g4 G1 U - * published by the Free Software Foundation version 2.3 x' x" Z/ Y9 b. O% l- ]7 T
- *, b% ^$ J5 x) J1 Y( g2 U1 }5 a
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any1 ]1 o2 e$ |0 a+ G; M
- * kind, whether express or implied; without even the implied warranty
& b) s0 _: C+ ~9 f; V - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the7 v3 f- w+ @. C6 m1 D
- * GNU General Public License for more details.) C7 R2 J. m. Z- P# ]2 J
- */
5 G- \5 s5 H. l7 ? - 0 x' G9 R! a- ^1 @; d6 _/ q
- #include <linux/module.h>
8 z" k5 O" y- X4 J - #include <linux/init.h>
$ g& Z$ x& U' V7 Z- d; u, W - #include <linux/errno.h>/ y1 P0 w% {+ n" {
- #include <linux/types.h>$ |5 t; v# t- j7 Q, \- ^
- #include <linux/interrupt.h>/ t! T% j3 K& v% G4 |* h
- #include <asm/io.h>- g; H3 z5 B5 g. v& [9 h
- #include <linux/moduleparam.h>
2 _3 D& p+ s3 l. y" O' g P9 X3 e - #include <linux/sysctl.h>+ q2 {! G. W5 ?
- #include <linux/mm.h>
C2 a# V5 l y; W - #include <linux/dma-mapping.h>
: C b. Q! y( |# D
1 s1 O, L# }6 d( @3 C0 V" V- #include <mach/memory.h>( a& ^8 R4 {2 {) b, v6 k
- #include <mach/hardware.h>
8 N- A8 Z0 \5 b) \4 ^# q - #include <mach/irqs.h>
5 S& {1 }. B& n5 V+ m O. l+ n4 p9 I' [, Z - #include <asm/hardware/edma.h>
! a4 i, Q H! `+ z7 |
; ?1 i6 _$ V; n% _+ r4 J- #undef EDMA3_DEBUG
; h5 C! z: t, V f' H- X! o - /*#define EDMA3_DEBUG*/1 y) b: X! w+ V& `$ }8 k
% J6 h& m3 C; S( y/ ^- #ifdef EDMA3_DEBUG* W6 y, {: r- e7 x4 I! |
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)% c3 g$ h/ g6 o6 \% c+ U4 h1 V
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)3 }- `9 A4 a8 T5 }4 o% r
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
5 P. Z, ^9 @7 M' r& R - #else
% E; B( V/ z! n5 n" p/ ~ - #define DMA_PRINTK( x... )
/ W& D7 ? f! p X) M! ]0 } - #define DMA_FN_IN3 E+ ` K# E0 @# V- J0 u2 }; o
- #define DMA_FN_OUT
+ j8 |7 K, G3 Z9 a r; q - #endif
/ |! R8 a9 _2 P% W/ l
9 \4 Y# |+ m0 \: f+ T& \" _3 \- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ D0 B0 X' |4 `8 z8 X1 v
- #define STATIC_SHIFT 3
) c9 W+ ^' C4 U P( d! l' h, J, _ - #define TCINTEN_SHIFT 20
8 Y5 b: f S2 w - #define ITCINTEN_SHIFT 21/ u( [5 t J1 j8 N
- #define TCCHEN_SHIFT 22
" {4 W0 n0 D, J1 g& S U/ P4 a - #define ITCCHEN_SHIFT 23, E, G) I, u: \3 J4 t
3 e Q& ~2 K/ T- static volatile int irqraised1 = 0;. Z4 r" W3 s6 R' H5 d w
- static volatile int irqraised2 = 0;
4 _- B5 N* n1 _; m9 \( K% L" c) x - , V6 k! X2 N- |6 m
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 F# k" }- c/ e" W$ Z - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ Z' n( p( u- @) h- y
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ a, d. K* u- o1 f! E
- 5 f) R4 k. r$ D) M, |7 T' \
- dma_addr_t dmaphyssrc1 = 0;- C2 E5 _; J* {1 v$ |' S- j
- dma_addr_t dmaphyssrc2 = 0;
2 n- L8 P) R' R9 L X2 p Q- A/ b - dma_addr_t dmaphysdest1 = 0;6 s6 Q" X- l8 q) K: w
- dma_addr_t dmaphysdest2 = 0;
; ~! I) A8 R0 k$ J# P+ s3 \
8 P- d! m' G' M# ]) z$ m- char *dmabufsrc1 = NULL;
# C8 _3 o4 \% H' \ - char *dmabufsrc2 = NULL;
3 B, Q- X- }, [8 Q, e - char *dmabufdest1 = NULL;
- ~ f3 j0 F. p4 H4 N; d - char *dmabufdest2 = NULL;; a" |* h. F6 w3 G" G
- ) T) D6 x7 Y" E, V& u; R7 p$ ~
- static int acnt = 512;/ Z) _8 p$ T. g6 [# i+ ]* `! g% r2 Q
- static int bcnt = 8;
$ t/ \! V6 K' Y; t" a% B - static int ccnt = 8;
# s: |8 k* o% j$ m8 n" x
/ B) h! X/ N. p- module_param(acnt, int, S_IRUGO);3 u. n- o0 o* W+ Y; E
- module_param(bcnt, int, S_IRUGO);8 I7 k: i* S* g+ H% p. e
- module_param(ccnt, int, S_IRUGO);
复制代码 4 R% ~- i; [& j! f2 n! `
& y5 \. t" R/ g8 ^" f2 O8 t# ?9 F
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 z* l1 ~/ P) Z4 A6 i) U' N$ iarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
2 `! J: A# D7 C; H6 t( }& V v8 t4 G 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' W% B+ f* F$ H+ m
/ d& g2 F1 S, z" `9 h( D5 Z& s5 C3 `# m
|
|