|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
* {: i0 V0 G9 w8 m4 {- [code]EDMA sample test application
& Q& |* K3 ^' Y" O - /*
* t7 ]2 ^2 p' T: S) E - * edma_test.c5 t- V5 r5 i, ?
- *
9 g9 L: O. x) O# v+ X - * brief EDMA3 Test Application
) g6 ^8 U3 p1 N# l9 p D - *
% a4 E/ R/ r. ?: Z/ I+ U3 a5 O( M3 s( E - * This file contains EDMA3 Test code.0 e5 W, p" C0 G; _" X! f
- *3 i; W* u% o4 |) A
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
b! [: V6 A, ^* l+ E - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT* P9 [9 G; ?+ Z$ S' ]6 ^
- * TO CHANGE.) G+ p# h% p# e$ S$ p7 B$ q
- *
5 e0 a9 C6 D" R& X1 }" B - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ S# A8 T$ c0 L8 J - *2 q) e g) e% i2 w6 f% T2 Y
- * This program is free software; you can redistribute it and/or6 ^4 z( r8 a' g
- * modify it under the terms of the GNU General Public License as
* u$ t# }/ G3 z. U1 i5 C5 I - * published by the Free Software Foundation version 2.$ q* X$ \' `2 F2 x3 G% \2 {
- *) l t ~% l) s# c7 [
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
1 \4 o- I' f9 V$ J - * kind, whether express or implied; without even the implied warranty
5 M& Q4 E2 R* S% r) R! \ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) u/ f1 m3 ]1 K9 ~6 d! f; h9 ]
- * GNU General Public License for more details.
9 ^: ?9 @! p6 c* Y& n9 o - */
% B7 `/ Y$ @# k/ _3 h$ m
- D y# R6 n- {$ g5 H* L5 H- #include <linux/module.h>8 \$ g, [0 W. v
- #include <linux/init.h>
+ M! |7 j9 H* N* y. Z - #include <linux/errno.h>3 H M3 d1 L# z/ H3 W9 r
- #include <linux/types.h>
( y$ Y4 d3 I# A9 c - #include <linux/interrupt.h>9 }( @' q& L% w" a
- #include <asm/io.h>
6 |4 [' i6 n/ }' E, X& }4 O- I - #include <linux/moduleparam.h>
+ h1 j4 E9 H. l$ ~0 i( A9 h - #include <linux/sysctl.h>0 }2 o8 Y5 ?, N9 t" Y. |
- #include <linux/mm.h>
( `6 M0 \; J4 n8 V; G9 Y* }1 B7 Q - #include <linux/dma-mapping.h> {) w! D& n- n* ]9 l2 j4 i( g
1 a( l7 F) A) I( n# g" B, M- #include <mach/memory.h>2 Y% Z" @3 ~9 ~# I
- #include <mach/hardware.h>
+ q1 m' x( V! x6 w+ U7 t c% O - #include <mach/irqs.h>
5 I! k+ K$ P2 ^# r* f - #include <asm/hardware/edma.h>
W' q8 `* i. [" n; A' a6 U - ! z! I& y7 }! c' S2 x: a! b! V% e
- #undef EDMA3_DEBUG; x3 Q- x% A8 P' N9 F! n
- /*#define EDMA3_DEBUG*/' Y/ [# A, C& a% H. O4 `, @% H! x
- + i, T* ^0 s: m' t
- #ifdef EDMA3_DEBUG
3 a0 s4 z1 I$ g6 E; p9 ^5 W' n - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
, x5 V: X( y7 B3 z3 I - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
% S! v5 R7 H' ~' _% a$ h - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)+ Z% ^) L u* K7 M+ P
- #else
6 h' x7 h f' J' `4 r t$ Z. P2 y - #define DMA_PRINTK( x... )
9 k& l' U8 Y1 ]5 F. K( ] - #define DMA_FN_IN
# I( N9 X: V% I% \/ v - #define DMA_FN_OUT
5 q7 T$ g: I4 j* w1 i - #endif8 n. G- ^8 I. b' N5 O
# J3 f/ a* I* w# B! x- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 \) y* g U/ |" p1 z( p, N - #define STATIC_SHIFT 3: v u, U. H! Z! m7 _9 R- `
- #define TCINTEN_SHIFT 20: ]- g0 V( e7 G- f; q
- #define ITCINTEN_SHIFT 219 j1 p3 j" n/ Z% }0 \- b/ V
- #define TCCHEN_SHIFT 22; k. x& z1 n3 N; @6 N
- #define ITCCHEN_SHIFT 23
, Y; Z; r ~' C$ L' e& m - ; a# T( m [# F- w) _- D
- static volatile int irqraised1 = 0;/ r. k! x4 L6 R& @
- static volatile int irqraised2 = 0;" J. I, ]7 P4 q
" ~$ y4 g0 u4 `; B0 e* k' g% x- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, a6 z5 M+ o7 }5 x; k
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- w1 W. Z& \3 O/ i4 j9 N- b: f - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. L* |' _4 N! g: Y9 L/ s7 E
- / b4 D6 I3 z7 ] Q, d8 ^
- dma_addr_t dmaphyssrc1 = 0;
( Z- Y7 K+ r- W% ~) e- V S: t - dma_addr_t dmaphyssrc2 = 0;
; `. m8 f& r# M. T! ^# w- T - dma_addr_t dmaphysdest1 = 0;; Y0 B% S, S' Y$ y; {. ]1 v
- dma_addr_t dmaphysdest2 = 0;
7 t* x/ h' u% |7 q" y5 u: b/ E - , I Q. u( F& \6 S) y
- char *dmabufsrc1 = NULL;% d& U& r* a( ~) f2 B7 g
- char *dmabufsrc2 = NULL;# b/ N& c+ ?" t& ?0 r3 Y- H
- char *dmabufdest1 = NULL;
( H: V+ N$ F/ D* m/ j# x$ ]% A, i: b - char *dmabufdest2 = NULL;
& F7 | W+ d7 I8 ^
3 U" U$ o: G: U/ m% I1 V- static int acnt = 512;
& L6 a" l! b0 ]0 g0 R3 d1 e - static int bcnt = 8;1 g' @4 V j% Q6 P# N/ E# _. A
- static int ccnt = 8;
- K6 Z; \7 l6 E
; _+ v1 H- }; ]& d" ?- module_param(acnt, int, S_IRUGO);
6 _: @; y/ v, f; i& m6 j( b% @6 } - module_param(bcnt, int, S_IRUGO);
9 a$ z- b, Z/ X% W. {8 w - module_param(ccnt, int, S_IRUGO);
复制代码
7 j1 ?% L4 e4 _/ d5 M/ \$ ?5 B+ H4 X* e! D2 s
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用$ U R5 g- i& d" L2 p6 y
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
3 B3 S# B4 p3 l5 b0 i 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: e" q& z! B9 ~4 O ]* ~5 w1 g
$ u. @ _2 }" W3 {4 q) x
; G# b3 [, r ]. g
|
|