|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : E: o8 z) @' \& u
- [code]EDMA sample test application
6 c. l0 h, r; v - /*
1 J+ O2 D' I- _& q4 K - * edma_test.c
* j( @5 f) u8 \ - *
@, Y; f' o7 \( N. Z - * brief EDMA3 Test Application
$ o" s" Q A+ T7 E8 o$ O - *% Q( u# \: ^5 |" x5 d
- * This file contains EDMA3 Test code.) D/ w6 }5 R* h0 _% i- V
- *, d3 l) @4 r& c }" Y* U% R
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( D7 Y$ _/ }& V& Y
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 y$ I0 @" T0 R: G P
- * TO CHANGE.
2 H- V" i. N9 M% m9 ?( E8 i. X - *
! c' B. G. k6 y5 u8 \8 M2 ~ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com// I- l+ l2 ?: Y4 ]( K! P, L# J! I
- *
, e' U' k; t1 @( D# S4 V2 M: ]) d - * This program is free software; you can redistribute it and/or
+ u! F `9 a! A! A* W! i - * modify it under the terms of the GNU General Public License as4 T% C& H+ q! R* V) C# E
- * published by the Free Software Foundation version 2.
0 x0 E& O. R9 }- ~6 j - * e/ r4 e' [, x" N6 G
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any- T, a- ~) f% @% c5 l* I# S! K
- * kind, whether express or implied; without even the implied warranty
7 j# F: V. W* g2 P5 H: p - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! q& B6 [" R7 Y+ u% | - * GNU General Public License for more details.
6 ^2 V& p- V, N* g( i - */1 l' ^. d. a/ K8 k
- * q8 \6 {+ ` S6 l4 j _. v
- #include <linux/module.h>- j: s0 S+ X, B$ L% f3 j
- #include <linux/init.h>
/ E/ B1 {# L( L; z; F2 a6 i - #include <linux/errno.h>8 |0 n# R% H$ H- t/ D+ T. l
- #include <linux/types.h>
" u9 J f0 s, N - #include <linux/interrupt.h>
0 w9 M) Q% U; \0 }5 E - #include <asm/io.h>
- z/ m# `: M1 y- s6 b8 C8 h5 h3 p - #include <linux/moduleparam.h>9 O4 w, k0 H$ U4 b' b1 m
- #include <linux/sysctl.h>' K a @- M* i. |1 N( K T
- #include <linux/mm.h>
4 g% W, ~ g3 h. R3 A - #include <linux/dma-mapping.h>5 d$ L( b' Y0 C" P# u6 e3 H
- \& I, u' {8 o; F6 R3 X- #include <mach/memory.h>
. n$ k" _. ?% ~ - #include <mach/hardware.h>7 z+ i; G4 h' X
- #include <mach/irqs.h>5 L5 s: A2 H6 @' j/ a" c
- #include <asm/hardware/edma.h>
5 h. ]2 t; n3 g6 E1 M# D0 V - 3 q( F }9 l2 c5 t1 @1 c
- #undef EDMA3_DEBUG
# C' m* R9 G }# R# K3 G - /*#define EDMA3_DEBUG*/
, }9 V, G. c- Q O- h }; G% k
. u p0 V4 t" I" \% P) U6 _- #ifdef EDMA3_DEBUG5 z' T2 A) {4 `0 ~3 F/ A8 V) j, m
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
, P2 H; S! g+ N# P( R$ X, r. E - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): C6 L( R) g, y2 f) f2 v& N
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): |: a1 d3 Q, v7 w3 y
- #else
! e2 v( j/ j' {7 e+ N - #define DMA_PRINTK( x... )7 z- u4 f, H' X
- #define DMA_FN_IN
1 m7 Q8 Y5 _* N, V M - #define DMA_FN_OUT
5 ?# d2 a( A: P- E0 L! `5 q1 N! h - #endif
8 i# O* a: U5 n* i% T1 I2 e% p - * z. u% ~% t# l+ W+ m1 r: h4 \
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
3 t6 Z. q9 t" S$ @0 H - #define STATIC_SHIFT 30 ?' A/ }6 o2 ?7 F5 [
- #define TCINTEN_SHIFT 20
" x! J1 z2 U/ B( y - #define ITCINTEN_SHIFT 21
; R* z/ `0 K6 \" m" F( ~ - #define TCCHEN_SHIFT 224 f- C! s, n9 \8 s$ Q# S) Z9 H
- #define ITCCHEN_SHIFT 23) A; B( w4 h, Q6 A' H; Z, j
- 7 M5 m6 K' z' M, X. {
- static volatile int irqraised1 = 0;" Y+ d# M% n& Q9 l4 E
- static volatile int irqraised2 = 0;
% W& J, P A) G9 G
- C% X2 m @: d8 ]- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) W& t9 s2 Z7 ]; L - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ n# K: [3 R9 E2 Z3 v. y* N A - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 V& |& R2 N# M$ ~2 i9 A
- 7 K% \! ~: w! F( h
- dma_addr_t dmaphyssrc1 = 0;2 i1 e1 V1 O$ S0 l& q7 O
- dma_addr_t dmaphyssrc2 = 0;- q. m% I8 p$ F4 @5 U/ {1 V# U7 e
- dma_addr_t dmaphysdest1 = 0;% x3 P/ S; M' T8 v% S3 V3 \% u. [
- dma_addr_t dmaphysdest2 = 0;
6 D1 q( ]2 A# N0 e- `" Q$ D7 K - x, p' Q+ J0 j6 [9 L
- char *dmabufsrc1 = NULL;* {" P# t4 s) Q# O. Y b1 X
- char *dmabufsrc2 = NULL;
$ @, j# x0 ]/ J! N3 e1 h) w - char *dmabufdest1 = NULL;; I9 M$ C, U w- H# R
- char *dmabufdest2 = NULL;
& a8 f2 @: K1 x" r- }* Q - " t. s! }8 }! E: Q1 j( n
- static int acnt = 512;
& U% ^- I$ K; D, S( W# \& _ - static int bcnt = 8;
5 @ e5 U4 B6 y/ L1 ^4 `, Y - static int ccnt = 8;
; Z1 ?' ~) ~+ w, b - ) `% ?+ `5 d5 i# ]- W+ B8 \
- module_param(acnt, int, S_IRUGO);
" t' r, [0 M) p6 l - module_param(bcnt, int, S_IRUGO);( O, J3 `5 f8 f" ]3 L" F8 G, L
- module_param(ccnt, int, S_IRUGO);
复制代码 ; Z5 |& Y( O6 J# F
$ F. y4 d& n- G7 V: n 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用; j2 W0 ~; j9 I; p- }: \
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
) C4 c" Y2 H3 Z8 n: g8 n h; K 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。# i- g% z4 x7 R7 N+ X g
, r3 M; C3 d$ C, S( X* z/ J }
' F( I) j0 n1 k3 s8 K9 E9 j |
|