|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
& v, |3 \' {5 n/ k' {9 i2 M- [code]EDMA sample test application
! M6 u1 U# t4 v' D; n - /*
0 B" m# N# H2 d% d9 W; G - * edma_test.c
. O$ X0 e1 _; F4 I' g - *
# x7 I2 Y* B# A+ h* I( l - * brief EDMA3 Test Application( D( G. u2 j9 i+ D$ e- d8 g
- *1 N" L( \, l; R& p6 U
- * This file contains EDMA3 Test code.
& I2 v4 u4 A1 ~9 w# K% N% V - *3 y R) v+ O& C! V5 j
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
3 l9 b0 i; d/ }& t9 U - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT! a5 ~0 p* Q! Y
- * TO CHANGE.
# I+ `1 N( Q1 r# \; O2 @ - *. T i% m* P6 i& f
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
6 U: Z' H6 r5 |+ _! c" c' k# S - * A- a: ~0 B. b" g5 O$ G" \
- * This program is free software; you can redistribute it and/or; A4 x( z! J+ Y' Z0 z
- * modify it under the terms of the GNU General Public License as" ~( A+ A' |# @3 X! \
- * published by the Free Software Foundation version 2.* {/ \' L' h2 e7 M
- ** Z. r+ { I% p6 Q) B. B
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 B# r( y( f# i, B - * kind, whether express or implied; without even the implied warranty
8 O$ ?, S8 E' G, H! _" x - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# E7 Z* ?. C c/ b- {
- * GNU General Public License for more details.2 ]: m( e0 P/ \- ~' k* x% h
- */$ A0 N1 ~# {6 ~& m' }1 X4 C
- f" Z1 X9 {( K* b$ F% F2 t
- #include <linux/module.h>7 ]2 q: g2 i* `; U) k! d
- #include <linux/init.h>
- F$ q( D5 |0 G$ U* u - #include <linux/errno.h>, i$ ` C# d1 V
- #include <linux/types.h>4 y4 Q h0 K2 c2 E7 N& I' [" }- {/ \
- #include <linux/interrupt.h>; i( W2 Z9 e" P* U4 T
- #include <asm/io.h>* o. F/ J+ V. m1 `% k- C
- #include <linux/moduleparam.h>' r! U. |/ O ^: m
- #include <linux/sysctl.h>4 W5 e) q& g0 m F' Q% H) I
- #include <linux/mm.h>
1 f, p4 j! B& p+ ^9 \ - #include <linux/dma-mapping.h>, W8 _- ?. |. v; n
- 4 x) {* a" I7 h. M
- #include <mach/memory.h>, g9 N, {9 b3 f) E V7 b5 F# s+ I
- #include <mach/hardware.h>
0 v% `% E8 ~% A g* ~- q - #include <mach/irqs.h>
/ ~+ g8 N7 q* P) ]" C - #include <asm/hardware/edma.h>3 G0 N) u# `+ Z9 N! y ^$ M5 A/ d/ q6 S
$ t- `! Y7 D" q9 V2 `$ O0 c- #undef EDMA3_DEBUG
; q* ^5 u( {7 k- O4 B - /*#define EDMA3_DEBUG*/7 b0 E7 q ^# D$ q4 o
. r% p) _1 C+ O. ]2 U, A- #ifdef EDMA3_DEBUG
+ [' _: i& O# ?3 o! o D - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
D9 i) r( S& C1 T6 P; n. a- I - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
, K3 b2 H" ]& F7 N6 W. A, N( e - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)3 p9 s6 L: h$ m5 x5 \2 J
- #else
. p( Z5 V/ N% D3 G$ w/ z3 L - #define DMA_PRINTK( x... )6 B; ^& Q4 P- N/ v
- #define DMA_FN_IN
/ O2 y; y) V! @. w; P# a - #define DMA_FN_OUT; Y& o; A5 U5 m/ h( Q9 j) _1 V: m4 q9 `
- #endif: W X& _) C0 n6 f3 W1 E$ H
& R+ G6 c) [ ]2 _4 s! Z- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- o/ H. S. B- K8 ^ - #define STATIC_SHIFT 3
# ~" f- X4 R0 s- t+ v - #define TCINTEN_SHIFT 20
- J3 G6 i/ K( {9 \) U% H3 { - #define ITCINTEN_SHIFT 21
0 M7 S& m7 n* f6 V$ _8 V# q - #define TCCHEN_SHIFT 22& J: {9 h5 j/ f) y: A; u
- #define ITCCHEN_SHIFT 23* o/ Q1 [( |' d
- 6 U: r: O" j$ z
- static volatile int irqraised1 = 0;
" |- G& x- O2 s7 g) R0 l, p6 q - static volatile int irqraised2 = 0;- z6 ^/ m3 x1 V: g+ r
- b* l% Y% E/ K: j) t- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! ]/ |6 W% h, c e' z% H
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 H, Q D- ^5 M3 [4 W& v% @1 K3 _
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 b. p% z/ b! b+ e: Y; U
" l9 h# d: |# E- ?- D- dma_addr_t dmaphyssrc1 = 0;) m. F3 B+ T6 K4 ]3 I% y
- dma_addr_t dmaphyssrc2 = 0;6 C% F1 {+ U+ g# J# Q/ [
- dma_addr_t dmaphysdest1 = 0;
+ D5 C4 o: g% [* Z% f( T - dma_addr_t dmaphysdest2 = 0;, Y: c/ U0 B) t* u% n
$ Y2 {6 }- }# u- char *dmabufsrc1 = NULL;# |0 w* h8 J4 j$ {7 `2 `
- char *dmabufsrc2 = NULL;" R% i5 n1 B3 L" `; D# D: E" K# [8 u
- char *dmabufdest1 = NULL;
& F( {' P) M: t, v - char *dmabufdest2 = NULL;
+ F L' ]9 |; q( h - 7 U0 ^1 x% |4 g5 B
- static int acnt = 512;8 ^) {7 u& U* E. C* l7 X
- static int bcnt = 8;- Y; V5 S3 {+ G. D) s7 |) R8 d
- static int ccnt = 8;7 l* P$ K/ w$ H
- 9 z( I: Y/ [5 @* G
- module_param(acnt, int, S_IRUGO);* z: C! S8 A) Q, D+ s# g
- module_param(bcnt, int, S_IRUGO);. W) h* l: i. {
- module_param(ccnt, int, S_IRUGO);
复制代码
- j& ^5 V" g7 F- s. E6 d
0 f7 b' o/ ~* @' R' o- H 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用1 R6 m5 g; j+ ~8 z( T
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。& i1 N2 Q8 q p* t2 @& m
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
: T7 z) [* U* P& c- B# D% y5 T3 _+ x) X) n
* S4 p' y# V$ u, U: o: ` |
|