|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 7 |" u: B, c- G# s, i( S
- [code]EDMA sample test application
- C+ u2 `! D2 q9 {* o - /*/ r8 `( |0 u; T% G& O2 n
- * edma_test.c
! J- u) K8 ~7 v- ?! `+ F6 v3 Y! w. v - *& ], S2 t `) V9 R k
- * brief EDMA3 Test Application
% }! d5 D* z2 U - *( [* _1 Q' v% T! q! h. C
- * This file contains EDMA3 Test code.
7 k, ]! w6 i: V# I" y - *: {5 N6 b8 y# f9 S& c/ F2 |
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
( X% X4 c/ C2 N5 I$ ^; _, T* D - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
, ^; Q9 f6 j0 G( X# w - * TO CHANGE.
" S9 p% b" \, J+ _, ^ - *! n; B% v1 o) y( R
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; D1 C+ G! q: k+ J4 [" L
- *1 y; @/ ~3 i- E# k K3 r& w
- * This program is free software; you can redistribute it and/or/ Q2 E% w) T& g$ G
- * modify it under the terms of the GNU General Public License as
, j1 _$ d3 Z) S' f8 B$ H9 K$ g% Y" @4 a - * published by the Free Software Foundation version 2.
+ C4 }- p% X, p/ C' B e2 z - *
2 I+ z4 }5 |' z9 P4 v. U& ]# x - * This program is distributed "as is" WITHOUT ANY WARRANTY of any. s. Z# c& N4 A; W3 X
- * kind, whether express or implied; without even the implied warranty4 M1 t+ f* i& x; n) S5 v |8 J
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1 ^; G2 n9 d v2 q7 |8 J; ^ - * GNU General Public License for more details.: W1 y0 M& e, O
- */7 Y- a3 N5 i# @/ o" z7 a
# Q0 C& } l, c8 I4 |* a- _- #include <linux/module.h>
# u. q( J$ ?% J& b8 K - #include <linux/init.h>7 b# M' t4 v5 b; Z" g: L! O+ Q; O
- #include <linux/errno.h>7 n2 i, J0 W# |- V m' X L" F; S
- #include <linux/types.h>6 z1 z+ ~: p% v- y
- #include <linux/interrupt.h> P6 E& x( H' N* d( l# f0 B
- #include <asm/io.h>% W2 [; \4 _# d6 n9 T# z
- #include <linux/moduleparam.h>8 R1 ]5 R( N- D, Q$ }4 a i
- #include <linux/sysctl.h>
R" k2 T5 \# b& Y/ ~( V% W - #include <linux/mm.h> |9 ?9 D. X7 D7 l: H# P7 c
- #include <linux/dma-mapping.h>8 _5 n3 J) z% l- i
- 5 k4 z- N' |1 V9 w* v+ W8 K
- #include <mach/memory.h>& ]/ |2 a9 p( ?( o+ |/ O/ K
- #include <mach/hardware.h>
( B: u" j, ?3 j9 l4 { - #include <mach/irqs.h>; D' y( ?, t' }$ j
- #include <asm/hardware/edma.h>8 E6 }0 A1 ?6 i( {4 e8 h1 V0 M
- $ l9 ^1 T' S* S
- #undef EDMA3_DEBUG1 D: @2 Y9 B5 A- y- i6 W
- /*#define EDMA3_DEBUG*/
' `7 g3 t3 e5 H( R& E% p - % m/ V1 k* k# g% ?3 u/ t
- #ifdef EDMA3_DEBUG
3 K3 o# ?% Z4 R$ m1 C! t - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
0 B' Z( {4 l* U. b - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)! U1 O; V" W! r9 z$ U" h2 W
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
- J6 q* |% `1 T, }/ | B0 z - #else5 p, A" m2 D- m0 a/ N4 P( O
- #define DMA_PRINTK( x... )# W7 L5 j# e) Y* l! ^+ A8 U, P( d
- #define DMA_FN_IN6 U: U2 Y) {( F) }- P; _
- #define DMA_FN_OUT
' i7 r/ _/ W) m* I5 G8 w M - #endif2 x% v3 x# X2 I. s1 R
- 2 W0 H: s4 Y8 Y/ R5 W
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
9 p w( I. K: O0 e( B* `" q+ D2 m - #define STATIC_SHIFT 35 ~/ r. B% h# {7 _% o+ ?9 T
- #define TCINTEN_SHIFT 20
, j ~: o% |- n% N+ U0 x' ] - #define ITCINTEN_SHIFT 216 j* ^9 q& }# p7 m
- #define TCCHEN_SHIFT 22
: W, k3 }7 r$ H( j - #define ITCCHEN_SHIFT 23
! u$ L& i k& [' B6 O. \ - 7 X$ g. M8 p, C- U
- static volatile int irqraised1 = 0;1 p! |$ d% |( [7 d2 C$ K9 N
- static volatile int irqraised2 = 0;
7 ]: N" u0 V# j/ c; v' T6 @0 ?
) I' |2 {+ ?+ ]! U% J9 S- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, O W, L# K! u8 f# y R$ X k - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: P) V" v! @ [6 S( Z9 @4 _
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 \4 M8 m& W! q" Q+ o, Y6 P/ W! X - 0 K% s( V9 e) t$ g4 d: Y# w! N! \
- dma_addr_t dmaphyssrc1 = 0;
4 H: C$ Q5 ~' d# D8 F. w - dma_addr_t dmaphyssrc2 = 0;- e3 L0 L+ T/ M/ [
- dma_addr_t dmaphysdest1 = 0;' T7 ?- G$ y- Z- f+ k0 d
- dma_addr_t dmaphysdest2 = 0;
! K8 q2 K; w0 P% c* B5 P/ I
6 M! ?' v, Q! L3 `% K+ U- char *dmabufsrc1 = NULL;
# `' \+ j+ N V% p - char *dmabufsrc2 = NULL;' O: d# j* f% H
- char *dmabufdest1 = NULL;' i. @( L a6 g4 M O3 O& r
- char *dmabufdest2 = NULL;+ o0 G p9 k9 i$ g2 Z
- r! R( m$ T5 T8 n0 n- static int acnt = 512;
' y2 c" J/ r ?8 v' | - static int bcnt = 8;$ `3 Q* A$ t; A% p
- static int ccnt = 8;
* C2 r, d, u5 |
5 _- B3 w: ]& P0 o( P, T- module_param(acnt, int, S_IRUGO);: @! H7 T) v( @; u2 O
- module_param(bcnt, int, S_IRUGO);# w5 y+ s/ _) n% m5 Y" T4 s
- module_param(ccnt, int, S_IRUGO);
复制代码 1 F" F# F3 W q& j
8 E# N W* Q6 ?
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用1 f6 x$ w& |. }$ W
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
! f- U6 ?5 n G 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 M/ K1 W0 ?" I' J+ C
" F/ v9 m8 `; l$ }; H% A
0 A3 E7 j4 N! P' K/ v9 B- g |
|