|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 {. _, U8 b; V5 N- [code]EDMA sample test application
, w* |% ]8 J! k3 t5 E! r" w - /*
$ B2 L J4 }* b% [3 J7 d - * edma_test.c
/ [: G3 E9 @4 H8 |/ V! e - *& {0 w% }2 N$ T( r2 y V- s# q
- * brief EDMA3 Test Application8 i2 f2 r* t4 ~& `& s
- *" T) P9 H2 Q8 s/ n8 e( B; q9 w9 W
- * This file contains EDMA3 Test code.
* q/ I5 }, {! A* [0 y( w - *
! b' K. v, ?% f% y - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
a) O/ j9 U) f - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT9 V9 g& l2 t; B: `
- * TO CHANGE.
, u0 Q* @1 M# I) ?! b- |" M* | - *' ~/ p1 e' V7 L" Y g$ ^
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/, y# e- \: U) Z5 ?5 b# ~$ L
- *- w5 A: m. d2 U: c) \6 E4 N* z
- * This program is free software; you can redistribute it and/or
, a/ I+ B# N& O! x - * modify it under the terms of the GNU General Public License as5 ]5 K2 ^/ t8 F- s: B5 {: K4 b
- * published by the Free Software Foundation version 2.# @. F( K% j9 r+ F8 L5 u
- *4 K. @4 v/ \% A, A1 Z
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
( [$ w u. D4 u7 i - * kind, whether express or implied; without even the implied warranty* O& L5 l' y. W
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! s5 j9 g; {: v0 R7 P. k - * GNU General Public License for more details.
4 ]) c: _! I) J; `' I4 D2 O2 Q( o - *// u" O, y2 c; ~& N9 Q# T& k6 W
- 8 }6 R" `# c. p( V$ d* W; e
- #include <linux/module.h>$ V4 F7 C' e& G+ d
- #include <linux/init.h>% c5 X- X* A' W" m8 x2 t. T
- #include <linux/errno.h>
% g. d# ^( j0 j% U9 Z4 ^( G - #include <linux/types.h>2 g% ]7 g3 X" I; o
- #include <linux/interrupt.h>3 w! t5 p9 Q1 o$ r* Q a( r% a6 C
- #include <asm/io.h>
' u/ C% _& C: W9 f' N - #include <linux/moduleparam.h>/ |3 W2 t6 I8 i
- #include <linux/sysctl.h>
( S: x2 I3 R. ^2 s$ `2 R" ? - #include <linux/mm.h>
- A- r l! V5 R5 O9 I- w h# e - #include <linux/dma-mapping.h>
( ~% X% D/ O- q* b% I# J
8 D: {2 e" ~5 }4 M) h) L7 w- #include <mach/memory.h>
' h7 c- A9 F! Y9 b c& g2 Y - #include <mach/hardware.h>
, T+ U" W: ?- g5 q/ ?+ W - #include <mach/irqs.h>
4 `' r1 x7 `( }+ k$ t) m - #include <asm/hardware/edma.h>! n) ^, ?, |* A0 f8 M
! C6 r( [) x0 D6 z" ]- #undef EDMA3_DEBUG2 U% T0 e$ }% `0 Y+ ~
- /*#define EDMA3_DEBUG*/0 M9 c) f# ], B1 i3 v( A3 ^
- * C$ @6 u& E, J" Q! j& s3 f
- #ifdef EDMA3_DEBUG
! j2 e0 o( |% K - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)( C/ {/ S! ~: J }1 x' N; p- |: {
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. I; O8 Y6 w4 @" {1 m3 P+ D, J - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)5 A, X* r9 P) {5 K
- #else
+ z+ n" U- l5 X4 z: s - #define DMA_PRINTK( x... )) `/ }8 O7 q( ]4 Y1 W! K6 B
- #define DMA_FN_IN( o1 I3 U' T4 e6 T3 [
- #define DMA_FN_OUT
' ?3 o- f: O0 U8 \; g: K8 e - #endif6 P f& r# c7 T0 u! b
- / N( L/ b2 L, g2 D2 C- j5 e9 a3 _
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
4 ?& Y% f3 D6 U2 d1 k4 @ - #define STATIC_SHIFT 3
B6 o* d G9 m8 y0 H - #define TCINTEN_SHIFT 20
: f. H. T& T: m9 ] - #define ITCINTEN_SHIFT 21
; p4 k( { \$ l0 X. H8 w* C# R% p2 Y - #define TCCHEN_SHIFT 22
5 {6 v% s: [2 D1 t1 n, R4 l - #define ITCCHEN_SHIFT 23
+ O$ f V( Y4 t
% [0 P" [ u: @; ~# v( w# Z4 y, T- static volatile int irqraised1 = 0;# @; o2 R) Y+ Q. y, p; e: f
- static volatile int irqraised2 = 0;
! d* V$ P9 r9 f A7 w) X% Z' z
3 g# E% Z8 r# u7 V: H2 @- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" H$ @/ _* y2 C6 d4 w- b# @ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 b1 E, B; N. M& }
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ f6 m9 g3 J' U$ e. E
- 6 s5 @0 v4 d" ~. H
- dma_addr_t dmaphyssrc1 = 0;4 P* X' N, G4 ^, s, j9 [
- dma_addr_t dmaphyssrc2 = 0;
9 t- `( T. K2 c! R- N, \+ P3 B - dma_addr_t dmaphysdest1 = 0;
I. a: B; i% \ - dma_addr_t dmaphysdest2 = 0;
# C. N$ m4 G3 C, [# Y/ g% K - $ E: Q( m1 M# N( X* @6 r3 Y
- char *dmabufsrc1 = NULL;/ A" @2 T4 R4 m% c$ u- g2 C
- char *dmabufsrc2 = NULL;7 B1 P( F7 s- d) p& o4 _
- char *dmabufdest1 = NULL;& j! c4 }4 o W/ t9 l& j) h
- char *dmabufdest2 = NULL;. j& D) }# Q- X
! S9 a: s) S9 p6 |- static int acnt = 512;: p# d2 C' U* @, _
- static int bcnt = 8;6 j, P+ o2 Q4 o" u7 M
- static int ccnt = 8;
; X) ~6 `2 b4 z% X# V& H
* n2 A9 u& Y7 [. x- module_param(acnt, int, S_IRUGO);
7 W! j/ ^' _' h, ^) J' b/ t - module_param(bcnt, int, S_IRUGO);( X! N5 j& x2 I) h: r* _1 P+ c
- module_param(ccnt, int, S_IRUGO);
复制代码 ; S# f% d. L5 l1 z0 ?: I- l7 x, W# E
/ B" G8 v' T8 G 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用# u3 I9 d# ]% F0 X
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
9 L, I/ \( f9 i: y7 y4 P1 e4 b 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' v. W' h: o; J
H% _5 {& P% \4 g0 c8 |- r. @ t. P9 v+ ?2 z6 Y9 B* W" D
|
|