|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; k2 F. s0 k% G8 o- [code]EDMA sample test application
5 r! w0 l Y0 F) h0 y - /*/ c% l4 S+ } Z, ?) T- R
- * edma_test.c
5 Y" v# d: u" j$ y$ L6 |6 b. E - *+ J7 ]0 i( i8 S1 j2 m( G; b1 V
- * brief EDMA3 Test Application
6 i7 `. g+ A' A; w6 e1 R7 k - *
$ [& `+ M" }+ C W' [6 ]' [( C - * This file contains EDMA3 Test code.
' |& l4 f s3 c* j1 E) G! p* ] - *
: T3 ]4 F5 g& N - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
' \+ d. Z0 X, ~4 |! I - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT0 X; Q2 G/ k& V
- * TO CHANGE.* V/ w! n9 f) o$ V+ w! ?2 Y8 w+ m
- *, b5 ^2 S8 u. E* ?9 `2 ?
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' p% V$ |- Y# L# `8 b; R/ J: |# C - *! Q& w% k" Q# n
- * This program is free software; you can redistribute it and/or0 L* p2 ?% m, a# v, x" i
- * modify it under the terms of the GNU General Public License as( ^% G1 M; O( I3 E W8 e9 g: u
- * published by the Free Software Foundation version 2.. i* L7 d8 v2 G7 B7 ^: w) p
- *
$ p* ]+ j9 K& X& P: v - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
! M4 w* u! A0 Y( Z/ f - * kind, whether express or implied; without even the implied warranty
* z6 ^8 V: [% _+ v. ]& J' f - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
, ]* q& C) z% Z! m. u - * GNU General Public License for more details.- O/ v9 Z, Y& k+ W' w: Q
- */$ ^8 @ D9 v9 V U) e0 f' Z4 i
- C% L$ ]2 o9 m9 m9 M, j) V/ {7 B- #include <linux/module.h>
7 M7 x& v5 S" o& T8 O: V0 ] - #include <linux/init.h>
4 t- ]5 g8 `& D' p+ H1 ~ - #include <linux/errno.h>
- K* _' U+ @; X3 p - #include <linux/types.h>. v" Y# X! v1 \( v
- #include <linux/interrupt.h>
1 K* t4 n' o7 O/ J4 v7 k - #include <asm/io.h>
8 L( L3 f; @' t - #include <linux/moduleparam.h>% V' m$ ?: l& X! A& C/ x
- #include <linux/sysctl.h>; f$ W$ m) g$ H( b
- #include <linux/mm.h>
( Y: i* P0 c8 g/ Z - #include <linux/dma-mapping.h>/ C$ h$ w5 Y5 B3 w2 u$ M
7 j# d# O% s# H7 q0 q- #include <mach/memory.h>
; O4 C3 u( g" Q1 C; ] I- ` - #include <mach/hardware.h>2 u7 e1 {% M" Q% G+ T% G
- #include <mach/irqs.h>
& M/ u5 T6 P+ g0 S3 s4 W' c) t M - #include <asm/hardware/edma.h>! o% \ P8 f' r3 g" i* B
( e. N! T0 q c- #undef EDMA3_DEBUG
( u1 `* |4 @) Z" ~ h. E - /*#define EDMA3_DEBUG*/; K7 _# a1 x& z4 {& Y5 u3 H
- N* |+ t) o1 K3 C' f, f" [+ R- #ifdef EDMA3_DEBUG# r! T$ {: q6 e: }6 N
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)$ U* Y8 ^8 v5 Y* i1 u0 B% ?: ?* n0 f
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)8 g9 b& ^9 S0 P5 R
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): R( ?; ?& ]7 J
- #else
6 w' @6 _0 g, C* n# o - #define DMA_PRINTK( x... )3 }! u) [3 ?3 d: r) z! P9 W7 @
- #define DMA_FN_IN
S/ j9 l+ g" \ - #define DMA_FN_OUT! ^ {7 [7 w) u) j) q) S
- #endif
4 B7 X- f: a8 |) r9 r - " O9 }% {; ?/ ~6 }/ V' F8 @8 o
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
! m4 E/ V: t0 F& t0 i0 c - #define STATIC_SHIFT 3
: P1 u$ ~ V( H5 U" R1 U - #define TCINTEN_SHIFT 20
3 J" J9 b2 |. ?9 ~* ` - #define ITCINTEN_SHIFT 21
& O' P4 I; z9 k4 S) H6 t - #define TCCHEN_SHIFT 22$ T( k, a# f( p4 w3 T/ b* Y$ s
- #define ITCCHEN_SHIFT 23
1 S0 h {. |( v - , S* a3 C- M' D8 }
- static volatile int irqraised1 = 0;" f- J3 ?& N! q* S% x7 G
- static volatile int irqraised2 = 0;& G3 s3 D( Y, K# |3 N5 w
- 4 {) `' l" I' x; X8 j9 h
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) N& y- c" H8 P* ~* z1 @
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' S2 y2 \/ W) i: Q4 l
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 T$ W J, v) {0 P8 s
; q& S" q9 e3 j! ^5 u8 R/ P9 e) H- dma_addr_t dmaphyssrc1 = 0;
6 Y# m. o, g' p* }7 h( w' ]4 i% o/ s - dma_addr_t dmaphyssrc2 = 0;0 [$ @& a# |/ N) c0 O& J3 o
- dma_addr_t dmaphysdest1 = 0;
: B& F1 F- O/ R! a) n/ s% W' } - dma_addr_t dmaphysdest2 = 0;7 B. ~" n% m2 g7 N# G v+ V; @
# z3 Z* U! t' Z; \- char *dmabufsrc1 = NULL;0 G8 C" Z# ]8 ]7 L2 C- i
- char *dmabufsrc2 = NULL;4 b3 w; l/ w- ~" i
- char *dmabufdest1 = NULL;
7 b4 [' e: R8 H - char *dmabufdest2 = NULL; I& k8 d2 d, S" i j
2 x6 ^# _* y- z1 e# A- static int acnt = 512;
% T2 r& s6 |2 b# G$ X - static int bcnt = 8;+ y K& j0 t; u1 F5 ~8 ]
- static int ccnt = 8;
) M8 D# u4 E7 f5 i& `$ | - : v1 E& |3 E% Q f( |2 e3 E
- module_param(acnt, int, S_IRUGO);
0 H4 ?, q t$ [+ W5 k+ W - module_param(bcnt, int, S_IRUGO);
" J* T9 q' g a - module_param(ccnt, int, S_IRUGO);
复制代码
- k( n/ I9 k3 _5 A: T
- w; F( u1 r' R1 ]% _7 U 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用 i0 i; F+ n' z. Q( E' 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。- J0 B/ Y9 K) S4 U9 `+ A F4 }; a
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% F" M# ]% F5 V- @) Z s# I% j- f- }+ F- y% t' {
/ Q, i/ c! _2 Q" d! B. d |
|