|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, h, H Y2 @! h- o% `- [code]EDMA sample test application
* B' G% p3 d' C2 k+ @* ], c/ a - /*1 s, ~: D7 Q5 s- v/ ]
- * edma_test.c2 }- x* J5 s- N% X
- *
6 g$ F$ m! I) S6 ]+ P - * brief EDMA3 Test Application. q* f0 V2 _2 M" Z0 d6 c3 ` R ~$ G
- *
Y0 [8 [5 f+ M* a5 M - * This file contains EDMA3 Test code.
J# q5 h! v ^ - *% x+ e+ O* z. ]" k3 ]: z9 b7 y1 |
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE+ g' P' S+ J$ `8 l+ P+ C
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 T* w" b; L* E O! N7 C
- * TO CHANGE.
6 {# o* q# b. y6 q& I2 N - *
9 h6 s7 z' C y' O. ]7 b) Z/ f - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ _' C7 B6 R6 J, ~! m+ s. p
- *
. t U" c9 S! J - * This program is free software; you can redistribute it and/or
; _8 V. P, A$ {7 ]7 C* E - * modify it under the terms of the GNU General Public License as' b) u# r% D, r, i! b9 T; n
- * published by the Free Software Foundation version 2.% n! L* i; M! G4 J! w
- *
$ O5 W8 O5 ?* n' b - * This program is distributed "as is" WITHOUT ANY WARRANTY of any T& `+ [0 ^6 i ?0 w. ^2 H, q
- * kind, whether express or implied; without even the implied warranty" D5 z: z6 Z- N+ U
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the z$ G/ k1 [! u7 N
- * GNU General Public License for more details.
B5 h8 d! X1 Q& A' s - */% _+ ?: h" r% q2 y& u4 R7 I
% L& ?" T+ I$ S8 E% `- #include <linux/module.h>
$ A9 b& N) I; a3 f6 E) ` - #include <linux/init.h>& K* M+ J) P! n; T5 p
- #include <linux/errno.h>! h. s; {* H3 b* C
- #include <linux/types.h>
4 k2 y# H0 ?" X5 R" x1 n8 P& X6 N - #include <linux/interrupt.h>
/ Z) n4 J$ S! P3 [* G9 N - #include <asm/io.h>& N# w5 h R( m( F
- #include <linux/moduleparam.h>" ^8 r! J' E& j$ {1 b
- #include <linux/sysctl.h>* R" |- h9 o; V4 v
- #include <linux/mm.h>
" ~" d) O8 W9 Q - #include <linux/dma-mapping.h>( E) q- ^% p3 R# j# U
9 D# C) q$ B0 L i5 b+ x! a, y- #include <mach/memory.h>0 R1 D8 J5 U2 S0 N" _! x7 v; v
- #include <mach/hardware.h>+ F0 m4 t+ A' n7 R9 R' F; W
- #include <mach/irqs.h>7 {" t8 n! @/ o z) F1 z4 i
- #include <asm/hardware/edma.h>
3 y! z) b- |9 Z4 K
, e# t7 A3 o! d7 ?6 J- #undef EDMA3_DEBUG
% m7 ~ q: ?1 }3 C6 s( n& B - /*#define EDMA3_DEBUG*/! N" X x/ X5 Q3 [
! P* V. m5 h* e) ~- #ifdef EDMA3_DEBUG
- Z! x1 X2 x" S3 W2 `! g+ } - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
9 I* N* h8 G2 D9 N5 h q" ?8 z6 ~; c - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)' e& v( t) D& j* G. H( b8 T
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
( d& r Y5 }* h. A - #else$ c! Q+ C- c& ^$ _+ M
- #define DMA_PRINTK( x... )$ f _- l6 k# U5 J: C
- #define DMA_FN_IN
5 w& [* C6 d$ c - #define DMA_FN_OUT
/ T) u( Q; s6 Z$ \ - #endif6 E8 l( ]6 ~2 d1 r
( A4 c; ]3 f% |5 V7 J: S) H- #define MAX_DMA_TRANSFER_IN_BYTES (32768)7 C( m- |2 w% ^1 w
- #define STATIC_SHIFT 3# v4 s0 T% `8 n. D+ W) K* R
- #define TCINTEN_SHIFT 20: G8 g8 X5 y8 |! r3 I0 H* I3 H
- #define ITCINTEN_SHIFT 21# p4 G. R) D: n U: X
- #define TCCHEN_SHIFT 227 z' n% l. Q7 O& L2 A% u* M
- #define ITCCHEN_SHIFT 23
# l- h( g5 G" t* `$ Z9 I - 0 {, N6 X3 @% W& ?( o
- static volatile int irqraised1 = 0;2 o# F' n m! M: p$ o
- static volatile int irqraised2 = 0;' h8 V7 g7 ]! o
! N6 I; i/ W* ^) y# o) o8 }- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ A g* j4 v0 L2 v/ V - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! j2 H1 @3 E1 ]' f! G. g
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) @9 e8 X0 q+ W
- 7 H5 h ~3 _, l
- dma_addr_t dmaphyssrc1 = 0;) f0 ^# ]. n8 i' U
- dma_addr_t dmaphyssrc2 = 0;1 @) b; @# ~# t& k
- dma_addr_t dmaphysdest1 = 0;# J1 S; i; T/ U8 h
- dma_addr_t dmaphysdest2 = 0;5 V" v+ S" }3 G' u# P! x2 R
- / P3 s7 ~' V5 P/ O
- char *dmabufsrc1 = NULL;1 j0 q }8 i$ n# m8 U3 \
- char *dmabufsrc2 = NULL;
- u9 ]2 [2 \- E( z s/ i - char *dmabufdest1 = NULL;! h4 {- F: O- L. L
- char *dmabufdest2 = NULL;
" ^8 n' F# [) U1 o/ n) m - : T- f' e. X6 n! A9 H: F" e
- static int acnt = 512; Z8 m1 L s: j- t
- static int bcnt = 8;. b9 _2 E! `6 L( c$ Z+ z5 \6 E
- static int ccnt = 8;; o) O6 m5 ]3 _& E5 m6 X# e1 A
X N# d6 W: D) ~. P! J- module_param(acnt, int, S_IRUGO);. ?' D$ I& f5 m" m8 A. c2 D9 T3 t# w
- module_param(bcnt, int, S_IRUGO);
6 M, b" R. n& r8 _" M- j8 ? - module_param(ccnt, int, S_IRUGO);
复制代码 . F$ b5 {7 z9 K
; r+ S; p$ D! Z/ r, L; Y
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用* W: o" D' f5 C2 }9 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; _, X# k3 x) u$ z) p: N
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
- r8 l& f* F+ T* M9 m: ? R. ?. r9 n- H4 y7 K
$ z$ }0 ^) e4 @$ k( ]! a |
|