|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
' G0 }5 ~2 z0 B% \- r7 T; d- [code]EDMA sample test application
( k' a2 q/ M9 n* e& t - /*/ ~5 ], B' I' ^& I& j' r& o
- * edma_test.c. l% F, J0 a- Y, g( E1 L
- *
8 u I! g, [0 `3 ?) e% B# s* _$ i - * brief EDMA3 Test Application
" G- B9 B* s8 Y: D - *' U: Q6 }, m" I' v: o
- * This file contains EDMA3 Test code.
M% R1 e5 D- s5 f$ {. u - *
8 q( E+ N+ u( V. c% U5 H - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
1 b, Y- y9 f" R7 O - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
# P* ~4 a! G5 D1 ]" y - * TO CHANGE.' S) _; b, a0 O( d
- *; G9 O/ W9 \! G7 K
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; f- E, x, R- M. P - *
% w9 x4 p" k: e2 H8 C3 x - * This program is free software; you can redistribute it and/or
- f$ m3 B+ ?0 v) T - * modify it under the terms of the GNU General Public License as# P/ h; A/ N' `5 L! b
- * published by the Free Software Foundation version 2.
6 G* A" J, P& c+ @ - *
. }, D; n! P" N m% G$ ?" \, _ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any6 v! I, T- p) b; p$ R5 B2 w0 g" }( m
- * kind, whether express or implied; without even the implied warranty
- g/ r0 ~- v' V2 u - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% h ^! a0 k' o - * GNU General Public License for more details.
8 ]+ ^+ N+ `8 U- p" c - */
p" J H1 ^6 S5 y2 s5 E3 Z
8 N" |' l+ o3 Y5 j( B( o5 {' C* P- #include <linux/module.h>
' p% o. {3 L9 t% ]' j% W$ d. Q, ^ - #include <linux/init.h>
: k6 z u [% L& s - #include <linux/errno.h>
4 A8 t \- {1 l. Z5 l) X6 U - #include <linux/types.h>2 b! X+ C/ b, g, ^
- #include <linux/interrupt.h>
% I9 P! W3 c4 P- j5 k2 O - #include <asm/io.h>
& k) n, G3 n E9 L1 ^ - #include <linux/moduleparam.h>
( G5 t: ^& m! i3 C3 e - #include <linux/sysctl.h>
& M0 D. n6 q' y# I! H a% t - #include <linux/mm.h>6 D5 m+ o/ {/ a4 d a
- #include <linux/dma-mapping.h>3 L" N1 m) \+ o! p8 o! i
0 n+ ~+ D9 [: b6 I, [/ l6 C- #include <mach/memory.h>- B) i: e" ~3 d! H& L
- #include <mach/hardware.h>! f( S7 g; g, |1 }- Q: z3 Y2 G! c
- #include <mach/irqs.h>: A, S N6 |8 w5 ~9 s
- #include <asm/hardware/edma.h>
% b" d! z9 v, k
3 o4 V6 e) g6 t) B, n- #undef EDMA3_DEBUG( N' W, [# |5 d% j
- /*#define EDMA3_DEBUG*/
- N# h! F; B( D4 t0 h0 X8 R& } - ( O2 m- c7 g9 |" [2 B! Z& t
- #ifdef EDMA3_DEBUG( P6 c4 K7 g$ u3 N
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)& x' K* E' A! Z
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)/ B) S4 Q A2 {" \9 n
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
5 v% z% W4 R& |$ T, O( J* p! } - #else
0 m; e4 g* a- `( y' {" R7 m) X. P, H - #define DMA_PRINTK( x... )
( g" G" M4 c9 c2 X - #define DMA_FN_IN
$ W9 A0 ?" {6 L9 F) h, Q - #define DMA_FN_OUT8 z$ @2 E, ~, I
- #endif
: ~3 M M* k3 z% K9 v& e# f. j' c( |
: G% z* N+ _/ I' ]+ v% n& R+ V- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; ?" H8 {" R3 o) e1 `0 h- r - #define STATIC_SHIFT 3; i" ?' m! Q' _) I6 |8 X
- #define TCINTEN_SHIFT 20# l \! P6 ~- ]' z: D* _
- #define ITCINTEN_SHIFT 21! `1 w+ y1 Z5 }3 a- V
- #define TCCHEN_SHIFT 225 o% R: I' f5 V
- #define ITCCHEN_SHIFT 23
3 V( s9 d* ]* _( i4 d! ~ - , ~) N! V0 ^1 p3 w: ?
- static volatile int irqraised1 = 0;1 x% Z, W6 Q* A
- static volatile int irqraised2 = 0;7 \- W+ q6 }4 `, g2 L
- # X) q. R7 C& Z4 x/ ^+ ?' B
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ `0 g) t. i K$ i! H' ^7 Z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ S ?- q( R$ F1 z8 P - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ z6 i0 O( P" o# ~1 B: d5 J# S5 l - 5 d+ Q3 o* y1 e$ j- L
- dma_addr_t dmaphyssrc1 = 0;! a& R( E* R" ]9 V7 [% H% y5 s( |
- dma_addr_t dmaphyssrc2 = 0;7 m6 l# @8 _8 r$ V( h: {2 N
- dma_addr_t dmaphysdest1 = 0;
: b/ E. ^2 m5 Z( i: ]) i. f3 a - dma_addr_t dmaphysdest2 = 0;
P9 ~7 b* X' f$ W9 r4 q
2 n( F8 |! i, d$ Z- char *dmabufsrc1 = NULL;
& _/ l" J4 {# R9 m& D) D$ E - char *dmabufsrc2 = NULL;: J( t. V' g2 h) Q4 j# U8 I
- char *dmabufdest1 = NULL;
/ P1 y& s# }- v# M1 q - char *dmabufdest2 = NULL;
8 |( Q5 T k1 E - & X F% g. p* r
- static int acnt = 512;
/ W5 z% V2 N! \8 Q) `( y$ t9 e5 Z3 A - static int bcnt = 8;
% Z7 `. C! F$ a, I6 m" F+ P. t: G/ p - static int ccnt = 8;
" a* L4 s7 T4 j8 I4 e( J
# x0 @1 X# s2 r- module_param(acnt, int, S_IRUGO);1 @6 o1 ?; {& T
- module_param(bcnt, int, S_IRUGO);
7 D9 h7 ]1 a6 S - module_param(ccnt, int, S_IRUGO);
复制代码
0 a1 Y) Z9 D! y$ K) L6 [! o* Y0 M, o/ v
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
( w* l5 I" @6 }, z; Sarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
7 ]( ~8 U. P* Q. l o. H* n 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
) v, m7 y$ ]% g& t: ?! F2 |
6 [5 X/ l5 i( j. s
\8 X7 ^9 v$ h8 y) { |
|