|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ; x, V$ O+ v# O) B: a! ]$ i5 m
- [code]EDMA sample test application
- C/ |9 v+ E6 ^7 F+ ~9 @ - /*3 `$ K, d; M8 p- T; _+ s* k& C b; `
- * edma_test.c
0 M- m9 H( K! N8 d r( J - *3 g; w- |3 F& |# G6 i2 w3 t
- * brief EDMA3 Test Application
. q' f4 ]3 P* }2 Z5 a - * r0 M2 U' {/ U# ?% N }
- * This file contains EDMA3 Test code.
& Y2 I$ g; @* _/ i( Q7 W - *8 F0 C3 Q. q$ @; y. C0 \. s4 ~+ z
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* q5 _5 X; b; m6 A0 c4 X - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
- }% N( Z& `7 R9 i: P4 a- w9 ? - * TO CHANGE.
( P& G8 K2 _! R' V/ @' {' O/ \ - *% z0 Y# m% @' d$ e% y, k7 {! ` P
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/) }" i/ C3 Q+ j$ p9 k+ j
- *4 _5 }" o, b9 E8 o( }2 S" ]# Z
- * This program is free software; you can redistribute it and/or F! D, n, h6 K
- * modify it under the terms of the GNU General Public License as: V! w8 e1 M* G- t
- * published by the Free Software Foundation version 2.% c, B4 e/ b! e6 c5 a
- *
. Z' H$ b$ S4 u - * This program is distributed "as is" WITHOUT ANY WARRANTY of any( X7 q, W4 w1 N" P, Q3 x0 o
- * kind, whether express or implied; without even the implied warranty! R+ } U' |2 N- O
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ K* X( e+ ~, t) F. `4 M4 q7 u+ F - * GNU General Public License for more details.: ?4 X& A6 ^5 {8 k l
- */9 m. h- O& _6 z2 q
- . `. R- Z4 U- A6 l/ ]& H- k
- #include <linux/module.h>
% S. A* w# A, d/ R' F - #include <linux/init.h>
+ S. P1 ]0 Q3 m$ `; | - #include <linux/errno.h>
" i* ?/ I9 t9 h - #include <linux/types.h>! h. X2 B& L' A
- #include <linux/interrupt.h>4 D) G1 R' x7 W A6 H2 @7 G7 [1 }
- #include <asm/io.h>
" U1 `( t0 p) v - #include <linux/moduleparam.h>* P" n& C5 r0 E2 v, T- j# k
- #include <linux/sysctl.h>
/ a( Q& f0 _6 n- L: l3 L; e& p2 r - #include <linux/mm.h>
`( L/ E9 W0 i& R3 e" L - #include <linux/dma-mapping.h>6 U7 a/ ? O ~+ e: S# H5 v
- " q+ M8 F1 ?+ H0 F% n
- #include <mach/memory.h>7 M' a8 D! |- w
- #include <mach/hardware.h>& u. G4 o. T/ A ?
- #include <mach/irqs.h>
% V4 x2 @# _& t, W3 q5 J6 G5 @ - #include <asm/hardware/edma.h>- T0 z" C0 _& V
! V; y7 V2 D# p8 z* Q- #undef EDMA3_DEBUG. H( Z0 B% t$ z$ ^9 ^+ c4 E1 |1 K* D
- /*#define EDMA3_DEBUG*/
* M) Q- n' M# T4 z9 \ - ) P- b, s# F- ~1 _& j/ S' N
- #ifdef EDMA3_DEBUG
d! Z5 d$ J9 g - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 ]% w/ I0 K3 y. h/ Q8 P' V. N - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 f9 `( u& v0 z# F9 g9 G E: Y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
+ I' k- O8 a; h3 {! i. R& E4 h# E - #else/ m% m8 f3 @6 w' _3 y; u
- #define DMA_PRINTK( x... )
; |, f& X. \0 q; h2 N' D - #define DMA_FN_IN
2 {; Q3 I' h' U2 ` - #define DMA_FN_OUT
# K" ]5 G# O2 t - #endif
& d ^0 k1 V+ t+ Y - ' [, L! a. v1 s/ |2 g( H5 ~
- #define MAX_DMA_TRANSFER_IN_BYTES (32768): q9 N" z: t4 j6 Z$ ?, y* v
- #define STATIC_SHIFT 3, m8 U( {% V* i# k% N
- #define TCINTEN_SHIFT 20& f" K- u' `8 Q. c7 T/ K$ I
- #define ITCINTEN_SHIFT 21
# r, T6 x$ U# k0 ~1 E% [ - #define TCCHEN_SHIFT 223 X! i5 [" N( S9 _7 m* O
- #define ITCCHEN_SHIFT 23# k% ~* V( o& l) x$ Z
- : v ^" C' N' Z4 t4 Z
- static volatile int irqraised1 = 0;5 H% h8 _& T4 o
- static volatile int irqraised2 = 0;$ z7 b" v# j1 d! O( W4 ?' { ]
- 1 Y4 x6 v+ q0 m) g# @
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- P( z. P$ ]0 \- @3 z* d
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 F$ |) H) G# R. t - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 X# f0 e' p, A! H5 L& c
6 k3 b/ T+ k$ p \0 D- dma_addr_t dmaphyssrc1 = 0;
: S' v ~% U/ j5 U - dma_addr_t dmaphyssrc2 = 0;8 K, L" {5 M* ]
- dma_addr_t dmaphysdest1 = 0;
2 c# S8 Y0 J: f; u - dma_addr_t dmaphysdest2 = 0;# `" J. w$ |1 E; |, Q' i, H" d9 T
- 6 A8 R8 d1 q; M; g8 l
- char *dmabufsrc1 = NULL;- o* v! x& \+ h0 Y5 n
- char *dmabufsrc2 = NULL;
. L5 }9 C5 a% c1 |* G - char *dmabufdest1 = NULL;3 C1 {0 i- S6 ?8 W
- char *dmabufdest2 = NULL;3 p; p' F* G+ {
- 8 ?; y9 F7 {5 L1 J9 H& W+ v
- static int acnt = 512;8 \* t6 p! B1 g4 Y/ Y4 P
- static int bcnt = 8;
* B( _; M" \8 x2 ^ r& _ - static int ccnt = 8;
' z: N9 M E# y% M! P, S+ t& Q
' ?7 S$ u- N7 q- module_param(acnt, int, S_IRUGO);
$ ^6 H9 W4 Z$ s' T' Z! Q - module_param(bcnt, int, S_IRUGO);
0 I! c7 N X2 K - module_param(ccnt, int, S_IRUGO);
复制代码
4 l. i/ L0 p8 p# h8 i5 Z2 o# R" X5 ]; I# U
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 @ a% b7 G4 u% v' O1 W1 l4 larm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。$ q5 N4 D% U9 p P
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
2 H3 D* T0 b" r4 f0 l
$ N, j R! t" C9 L9 z- L( D0 S$ E) T: V% H# G5 V
|
|