|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 * Q9 e) }# _; {% F! Y# ]8 V$ s. _
- [code]EDMA sample test application
- w! G$ H' W1 G0 { - /*
; C9 [* j2 H) s - * edma_test.c
) {+ e d8 _+ c8 `7 t9 b6 ` - *
1 G/ N+ \% k) h' M - * brief EDMA3 Test Application
- h3 _+ n# d$ n1 n) s4 I - *( Q- \8 Y4 h) K
- * This file contains EDMA3 Test code.
# V; E3 }) c2 |( d - *4 ?1 R) ^# b1 O3 i# E1 Y$ D- J
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE4 f! {: @5 w# I" |/ o; v
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT# s* h) y. o F+ ]; N" z; X4 C# O( U5 x
- * TO CHANGE. b- w2 a7 T4 x5 m0 U$ h0 \
- *
9 R2 h; p7 w' Z; }& U8 m7 o' x - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 g0 @$ D# w( q9 o5 O; ^
- *- P# t: e2 ^5 k2 c/ H8 f
- * This program is free software; you can redistribute it and/or1 X$ b/ C. H7 \: H
- * modify it under the terms of the GNU General Public License as
) g4 E, D1 `& @: B3 }% l - * published by the Free Software Foundation version 2.2 J) V: l% n' e9 m" C3 C5 b
- *2 e' F; x) m; i& D- G+ H
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any' y' n1 i1 f, X6 T
- * kind, whether express or implied; without even the implied warranty
6 X1 G. w, v- M - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# D* C, H8 `4 y; q9 @
- * GNU General Public License for more details.' N- Q4 L6 p- N+ v$ ?6 E- Y
- */! n+ Q) @: R* d. \# O4 B v2 k( T
Z+ \/ r6 A2 w* T1 }; G7 D o# L* X3 }- #include <linux/module.h>
( @7 Q' D* l9 ?+ W5 X - #include <linux/init.h>2 k( p9 \: A' b( ^) S
- #include <linux/errno.h>
6 ] k) v1 p0 j/ J! u - #include <linux/types.h>) U0 R# g7 a+ ]) L, n5 @
- #include <linux/interrupt.h>
/ x9 {- [; N7 d8 x7 j0 n! m - #include <asm/io.h>
8 x/ t9 V M+ f% F8 `, L - #include <linux/moduleparam.h> A# X0 U/ E2 I: Z! W
- #include <linux/sysctl.h>
# L2 r6 w0 J! Y9 ~' p/ i - #include <linux/mm.h>
1 {( D& @8 e# |0 M6 m7 D0 n - #include <linux/dma-mapping.h>
7 [, b9 z a r& x F! E7 B - , i% H! _' q0 O5 Y4 O
- #include <mach/memory.h>6 d. ?7 d1 O6 x9 R( `% M& Z% I; j
- #include <mach/hardware.h>3 }. E, \) n" I7 B/ B Z
- #include <mach/irqs.h>
: D$ F v7 M8 f& i - #include <asm/hardware/edma.h>1 i, l4 c% v5 Z5 X5 a( U# }
- J; R8 p* l7 v) s) x- #undef EDMA3_DEBUG# Y) @% @, w7 L! L- I. Q% N
- /*#define EDMA3_DEBUG*/
9 k/ K' r( c& ]/ N - ' d- |% h) {3 t Z; m
- #ifdef EDMA3_DEBUG
, K0 C. ?% M0 F( } - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- q- e% x9 N" Y; y% f/ |
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
5 A9 M8 r- \6 n, { - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
2 H! y+ d* s6 u! ~# A! T/ M - #else
8 ~7 l% k1 w8 B& q - #define DMA_PRINTK( x... )- g2 j$ m p8 U
- #define DMA_FN_IN% q' P" G8 D- J2 I: M
- #define DMA_FN_OUT
9 g& M7 N4 N% _' K- z3 m - #endif9 R m" Q: g# F' `
- . o" q5 S( W+ B
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)) i/ E& H: w8 ~$ [% j! h- ~
- #define STATIC_SHIFT 3" F7 Y6 ~/ _3 ?$ o, [
- #define TCINTEN_SHIFT 204 f6 _" t7 _" e
- #define ITCINTEN_SHIFT 21
/ m: |7 V) a ^! }% | - #define TCCHEN_SHIFT 22
& A; E9 s4 ^# q; h# W8 P - #define ITCCHEN_SHIFT 23( r4 V; g0 |/ y
- 7 R# F4 H& g: V( o) l
- static volatile int irqraised1 = 0;
. G- \; T; i. B( `; l- q1 E4 Z: l1 c - static volatile int irqraised2 = 0;
1 G' \5 i* d) p: _ - 2 l) E2 ^5 z, u8 g/ [
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# w" q9 T$ S4 ?3 w* g
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 S3 _+ ?, w6 r; l. W9 F
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 K+ F9 X: G' L" P, D
- : `' Y" Z& [$ N% k5 U
- dma_addr_t dmaphyssrc1 = 0;
; R9 z9 w% n( d7 M - dma_addr_t dmaphyssrc2 = 0; O$ B% M% ~! g$ w' U2 \9 m# F
- dma_addr_t dmaphysdest1 = 0;
! e# _; ]" U2 w) ~5 u, M - dma_addr_t dmaphysdest2 = 0;" g9 n6 @5 U$ d
- 4 \+ K/ J, d- j" q. o; w
- char *dmabufsrc1 = NULL;
4 s# m! y. w8 k! x! B7 @ - char *dmabufsrc2 = NULL;, G" L+ w) D7 X* O8 q
- char *dmabufdest1 = NULL;/ a! N5 E2 N3 D* f, j
- char *dmabufdest2 = NULL;' l+ I. E: Z+ l& n
- : e- { r2 Y U4 H c
- static int acnt = 512;) d* H7 @ i' P4 A
- static int bcnt = 8;
1 V- i4 C: I2 X' l' j0 \7 n! H, _0 w - static int ccnt = 8;4 N3 |/ ?/ D, V
* L, i0 G4 h, F1 f: q- module_param(acnt, int, S_IRUGO);
% W3 I6 ?# s. }4 L7 O - module_param(bcnt, int, S_IRUGO);
& i& |. O- t' N, h! Y - module_param(ccnt, int, S_IRUGO);
复制代码
q7 h1 z- w% l4 c9 v% D5 V" v
1 ], ?: _( N1 ^, }# j( m; K8 ` 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& G1 z7 w* L- \9 S4 @& W& f8 _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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。0 S, O' |2 ^/ }( }! ]
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。* P/ Q% S, p8 l: f& H0 _7 D* ?. M m
" ?: }8 c1 H9 u: ~& t3 R k
x0 L9 ?. |6 @% \3 C, i F, H5 c |
|