|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 N, l! |2 y3 g2 H
- [code]EDMA sample test application
' B/ K$ t9 z- b: w1 R# K: t3 s - /*8 E" b& Z9 v1 Y1 f. t) F
- * edma_test.c4 h) W p! X# L2 O( }8 X
- *$ ~1 M* O' W/ F! J! T$ ]; r
- * brief EDMA3 Test Application
+ L8 W, K8 m, |, Q6 K) c - *$ T( r' t. p. R# s, q2 H) K2 I
- * This file contains EDMA3 Test code.
" i1 z" e0 C& q- q$ Q2 h) o* V4 o - *( N" b* B# z# p" A+ v
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" `% \* a# c ^
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT! Q4 |+ ?! C" S- J1 G( t3 d
- * TO CHANGE.
1 ?- s7 y& n2 O2 Y. s; d" a1 u - *6 B. m* L3 D( R I _ R( j- N, i
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
2 T2 L6 m3 h8 ^& ? - *
# l- N5 g+ q1 A - * This program is free software; you can redistribute it and/or1 Y4 [4 U( G% j; h
- * modify it under the terms of the GNU General Public License as7 I5 Y- A; k" X
- * published by the Free Software Foundation version 2.5 ]4 M* a+ Z, I4 D" e" o
- *3 L2 V8 z* i2 A& ]8 F+ N4 V# R! @
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, C# c @1 w1 E. J - * kind, whether express or implied; without even the implied warranty
2 T( K9 U a2 S! J* W7 ]$ a- c% H5 k - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ P) j. ` I: Z9 x$ _; D5 u' z - * GNU General Public License for more details.: F( w6 U u/ t' X$ `: c
- */! @" X" E( A; [& l3 k
- W& f9 M5 m6 e, r
- #include <linux/module.h>
- c; s6 e' ?6 y+ c9 t# r* C - #include <linux/init.h>
* J/ Q9 S, q+ H* R, {% v# [+ S - #include <linux/errno.h>
, Q" |4 r4 ]4 d) i4 @* D; @5 E+ s# E - #include <linux/types.h>
/ V$ }& C2 @$ O5 T: F' A - #include <linux/interrupt.h>
4 M7 V/ V7 q6 r: @ @ - #include <asm/io.h>* g4 T1 J e$ [& x1 Q6 c" U+ l6 k
- #include <linux/moduleparam.h>
" F8 b; f) D" v n8 C8 K - #include <linux/sysctl.h>
* S6 u; e; m- _9 W, z. |* Q% Z, j$ Z - #include <linux/mm.h>6 Z: G$ T6 H. I+ p2 b$ I" {
- #include <linux/dma-mapping.h>+ z6 [, |& _, q; C: A9 B7 o/ b
- 1 @8 K& s7 s% F- |) L
- #include <mach/memory.h>' j% Q0 L, L! d
- #include <mach/hardware.h>
* ]/ j7 Z2 L( B9 ]5 E2 E% i. s* i - #include <mach/irqs.h>" {$ r6 x$ N! |! a
- #include <asm/hardware/edma.h>
1 n3 @* Y1 Y; b Y# Z' S - , L3 T1 |( N, B M# o) n8 |1 q
- #undef EDMA3_DEBUG
( C: [. g* m3 \ T$ [ - /*#define EDMA3_DEBUG*/
e3 F: F% A) x
9 Y+ `( W1 ~& H( z! T, ]- #ifdef EDMA3_DEBUG- R- k& N: }: n/ u+ ?9 H
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
' a9 g! f" {* j; g - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 b5 |2 m9 R8 I3 O3 M4 ?3 B* p - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__), Y& v, E2 O1 o$ A+ x0 U
- #else+ I& D& e" n, }/ K, Y
- #define DMA_PRINTK( x... )
: x0 Q$ |1 L* t/ J( s: m - #define DMA_FN_IN; _/ `% |, f3 t# {
- #define DMA_FN_OUT4 i( G9 ]+ k0 H: N+ o* y. x
- #endif
6 y, s# D5 q: z) W* f% ~
' d5 e# J( a4 ?9 V- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ W+ {2 X+ q! w A5 g R
- #define STATIC_SHIFT 34 Z7 d, j& A4 m& x1 j6 I: U' o1 C
- #define TCINTEN_SHIFT 20$ A7 K! {, J8 I, \2 `! E+ D7 U
- #define ITCINTEN_SHIFT 21
6 n) b8 w; G3 y - #define TCCHEN_SHIFT 22
; r! l' ^5 D4 N' }1 R0 M2 t - #define ITCCHEN_SHIFT 23
# H$ P( z4 ]; c Y" G
( j* L! e+ W& j% m7 F/ @. N- static volatile int irqraised1 = 0;, m+ C7 H* t/ c. k9 X
- static volatile int irqraised2 = 0;" c9 b' N3 Z7 {1 w7 H- P- a
, y; {5 Z2 H6 I% M( O- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% \( @5 K2 E: c# Z1 a* O9 [" H. E - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 P( o2 {& s1 `
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; S. k& X1 }1 f& U/ r0 F - 3 [' ^8 }$ R8 n0 U
- dma_addr_t dmaphyssrc1 = 0;
, i9 a$ m! v5 B3 @ - dma_addr_t dmaphyssrc2 = 0;
; u' f8 S2 W7 H* a; j+ t8 Q - dma_addr_t dmaphysdest1 = 0;
8 N6 s& T& G; R# g o) L x& I# V - dma_addr_t dmaphysdest2 = 0;
( }( `3 N$ q" Z, ~/ e4 S - " D# C- _- }; Y! N5 y
- char *dmabufsrc1 = NULL;
* P, L8 [2 ?) ?: G6 } `* x - char *dmabufsrc2 = NULL;
9 y( j$ m1 c5 Q+ ]8 y- e- T - char *dmabufdest1 = NULL;
& a5 j7 k5 @- C9 A) `$ A - char *dmabufdest2 = NULL;& E1 @7 R/ f, v9 M8 o* w0 s3 d" `
) R/ b+ [# @2 p1 ]! ~$ \- static int acnt = 512;4 @ s+ w9 |' I2 w8 p3 y
- static int bcnt = 8;9 ?4 U r/ P; n; }: o4 V% o
- static int ccnt = 8;; V: F# e+ g" o! h$ T9 O
" z4 ~0 C; l' ?4 c$ ~- module_param(acnt, int, S_IRUGO);
+ j- @6 m, ?! v+ Y ~ s% e - module_param(bcnt, int, S_IRUGO);
* X, m3 I4 q0 u; Y! q9 W# t1 `! a - module_param(ccnt, int, S_IRUGO);
复制代码 ' N0 a1 j3 |- @% U8 `
* e" k0 B, M7 y: M
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
8 H( P9 L+ `' o/ s0 M1 [3 e6 o8 Rarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。8 g P! N& O$ u
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。# l# W+ A" S H. x" I* c2 i
+ F4 i4 I8 a2 ?, m
2 O2 [% N4 a" E: F2 d3 B |
|