|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( o: F6 N2 q8 W( B- [code]EDMA sample test application) ?8 Z8 W8 Y' {3 ]8 F6 l
- /*
* s* ^, Q! }+ ]& N; \% U - * edma_test.c
4 z: i) ^% a; K% J# \3 R - *
1 n/ G% N) z8 _' n, G - * brief EDMA3 Test Application# B% q* j8 f9 Y
- *
5 L+ N2 Y7 {' g( F# `7 T - * This file contains EDMA3 Test code.4 y$ u& f2 s% s1 }( H4 l( y
- *
1 Y0 E3 ^4 K# r+ o5 C - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE0 \, d! N7 h; u' ^1 X+ p; h4 {" |
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT( e" o9 A- n, R! x" I$ B
- * TO CHANGE.) t0 E2 E" Z8 @! ]
- * K Z% h+ X5 V0 n$ ^
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/5 x+ v- b& ^- n
- *
5 W. ^8 u, W* N. ^5 `4 E - * This program is free software; you can redistribute it and/or; [; X0 o1 t. e8 o/ R) ^7 d
- * modify it under the terms of the GNU General Public License as2 f7 W0 s/ m% \7 I5 }# ^
- * published by the Free Software Foundation version 2.
0 T3 D9 p5 {, c. G - *, `" Q( ` T) G
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any1 L1 W6 i' |% d
- * kind, whether express or implied; without even the implied warranty# C+ d! o& R0 P8 Q$ S' _
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; D) q$ P( w# ~7 e! g, X - * GNU General Public License for more details.
4 Z+ Q( F- M# a/ \ - */
, A: l9 d3 l4 \' g/ K0 N2 b- f+ B" | - / R4 C1 t5 X, |1 u$ o
- #include <linux/module.h>
0 s8 M: l! \ r - #include <linux/init.h>
n8 ?4 |4 n) {- R, b0 l - #include <linux/errno.h>
' s8 ?# J, @# a* _4 h1 V9 p$ W - #include <linux/types.h>
" r+ ^4 n! n: C7 i. j. \ - #include <linux/interrupt.h>/ e9 ]. n# E+ ~
- #include <asm/io.h>
% Y6 C# `5 p1 _. T - #include <linux/moduleparam.h>& H) d( ~. ?1 v$ H
- #include <linux/sysctl.h>
* E# A6 `+ I: u1 n0 t! D - #include <linux/mm.h>6 T0 t- @0 i% _* x( R( V* R
- #include <linux/dma-mapping.h>
$ b, s9 \* g7 q) X$ H, l9 `2 B( |4 L; n - # b& m: g) } ]4 W; L2 o) K
- #include <mach/memory.h>
. `8 T1 Z8 t; X8 b ^" U& } - #include <mach/hardware.h>! g/ }8 T0 v& P; Q
- #include <mach/irqs.h> t9 Q) B: W! L
- #include <asm/hardware/edma.h>5 C, a* j: N& `/ ]) }
! b; e0 y% X" U5 v/ ^- #undef EDMA3_DEBUG% P& f" o" ^, H+ D8 A
- /*#define EDMA3_DEBUG*/
6 ]+ U5 n; U9 Z" `& @
! |* T( B \. P) O" O2 I; u- #ifdef EDMA3_DEBUG9 i. C: z _/ n: w+ G' o9 n% Z
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)& N( T9 N. c- I$ `2 ?* ~
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
$ @# M6 h: W) ?! }& K# I - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
- M6 H& J7 d5 q& }) G( W - #else
( g3 @6 W, g% \& k0 g5 Z8 s - #define DMA_PRINTK( x... )
( Y/ ~) y: q/ M& e - #define DMA_FN_IN
0 X- s: p u/ s4 z3 D - #define DMA_FN_OUT. P8 e% c$ t( Z; s- k
- #endif
7 l6 R( `( R8 F- D" U5 d - * t. h x/ \8 b# R! b' g+ s: y1 C
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
) j1 f' _4 k) C' Q3 X. T8 ? - #define STATIC_SHIFT 3
- h+ _/ u: }/ n3 w1 A - #define TCINTEN_SHIFT 202 t3 c# n! H$ _" ~! j
- #define ITCINTEN_SHIFT 213 x( \0 ~2 v' [% |$ x, W! ^
- #define TCCHEN_SHIFT 22
% i( B- M$ o9 F: \) @ - #define ITCCHEN_SHIFT 23/ x3 A( s' {+ \% p
- 6 O! z/ j, l1 ~0 m
- static volatile int irqraised1 = 0;5 b" F# t+ H% y. G5 I
- static volatile int irqraised2 = 0;
% y4 p# P% }: H9 M3 b& g" Q
. b/ O7 L+ X" x8 v& V- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 g5 w" b# G# ^; y
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 b) P& W9 T- l: s! s - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. k# q/ R/ `$ O1 Q B, t! q
) y! p$ ?* @% c3 v' T- f# n- dma_addr_t dmaphyssrc1 = 0;
7 H" w$ G7 \( \% @ Q% g - dma_addr_t dmaphyssrc2 = 0;
' I* e9 T4 O# J ^5 Q - dma_addr_t dmaphysdest1 = 0;
% T# e+ A+ h1 Z/ A4 K - dma_addr_t dmaphysdest2 = 0;
5 p/ K6 p4 n2 h0 k
( L$ V$ N s+ n6 P1 W* E- char *dmabufsrc1 = NULL;
1 L! Z' [1 N3 C- y+ g: T. S - char *dmabufsrc2 = NULL;" |) P* H# a9 }8 S# q
- char *dmabufdest1 = NULL;: {& r5 s& O% P0 J, m
- char *dmabufdest2 = NULL;- l0 ^$ {) K" O6 D2 K
* y; L- r k& I' N7 I$ u- static int acnt = 512;
. P: _& w6 n4 Q% C' K; @) v - static int bcnt = 8;; Y' T d! ~3 h9 W1 E" s
- static int ccnt = 8;0 s7 p. q( F; t8 r) l) w. Z6 e
- $ x8 I& I. d3 |) F* y
- module_param(acnt, int, S_IRUGO);
1 k$ M9 \6 ?$ J6 o' W8 Z - module_param(bcnt, int, S_IRUGO);
( ]6 T, D; B# ^. u" g& _5 _ - module_param(ccnt, int, S_IRUGO);
复制代码 9 B% |6 b8 e9 Y
; @8 u, b _3 h3 | 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用 J7 x7 n N4 J
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。8 {$ S: c) v* x
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
2 ?2 x9 k) `) A9 j' ]. k+ H' l9 i( b- K8 t2 I
& O% M) \3 A9 J1 l
|
|