|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 " w- t5 G6 Z9 r7 `6 j% O, \
- [code]EDMA sample test application% y/ r% v$ ?3 l( T4 V1 {
- /*
) _6 F: w) Q- I4 I - * edma_test.c( F! X3 [2 k' X
- *, B* W3 f* D9 |. |+ A O. c
- * brief EDMA3 Test Application
7 A/ P# }% o' k- @% }9 { - *5 s( J' D/ L, e a, I2 [0 h
- * This file contains EDMA3 Test code.- a) m+ ^# s! V3 T# b( r8 X# H' a
- ** K$ T; R8 S& U* _
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( O/ ^0 F4 V) [7 \5 E% Z
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 B( C7 ^) [( p% b$ A6 O u
- * TO CHANGE.1 \7 S& L3 p$ E/ Q8 R! Z: r
- *
1 c# I+ t! B2 E U; O - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/4 o; X) y2 F: t$ e' U# [
- *2 y+ F3 q6 G+ [/ p
- * This program is free software; you can redistribute it and/or0 S+ E6 ~2 J/ }1 R
- * modify it under the terms of the GNU General Public License as
* M7 R5 b. E) `4 [; ?, N - * published by the Free Software Foundation version 2.
3 J7 S8 I" j4 ?5 G: F5 X& | - *
0 ^5 ]% t% _& d; l - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
' \ J3 R6 A* u, z3 W4 h - * kind, whether express or implied; without even the implied warranty( k% L3 N. A; f) w! A' S
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
z6 H5 u9 W1 s - * GNU General Public License for more details. A6 p- @& w, [' A
- */ s) f" E S. ~$ x O1 u
( _0 ~' r! z, F0 s5 \0 ^- #include <linux/module.h>
( O( m) p; u) [ - #include <linux/init.h>9 B) k& N" a! V- m& s9 A# r! g
- #include <linux/errno.h>
~0 e7 I, v. O' m6 _ - #include <linux/types.h>+ x% I% {) O. {5 s' W
- #include <linux/interrupt.h>
6 s! q9 ]+ s7 n/ ?) P+ k2 e - #include <asm/io.h>
; O. O4 d* e3 M! ] - #include <linux/moduleparam.h>
$ l8 |) W2 }1 T( T - #include <linux/sysctl.h>
) x( ]7 ~- [. h i6 C - #include <linux/mm.h>
, s+ `. L5 ]9 o8 o" O - #include <linux/dma-mapping.h>% V* g5 N2 x) S4 M8 o( m
& o% w1 O. }5 T- #include <mach/memory.h>
7 h# }. d& z8 o. k* L" y: @ - #include <mach/hardware.h># t: Q3 n( y$ t1 `
- #include <mach/irqs.h> D+ }5 Y+ N( O5 O ?
- #include <asm/hardware/edma.h>
& k; P& h o9 O" \. L: z# { k4 t9 [ - & s# y% ^, |0 `
- #undef EDMA3_DEBUG, Z) @% A% {/ } M, A' E
- /*#define EDMA3_DEBUG*/
$ t9 \0 L& C) f d/ R - % D. f) P" D4 i6 K
- #ifdef EDMA3_DEBUG% L4 f* V) R9 b( R- a. l7 N' z# u6 E
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS). G. \2 V0 Z5 V- g: _
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
( P! S( ?. f4 K7 ~! i1 s W - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)/ [+ s; N9 I3 z0 [6 u
- #else
+ G2 @* n9 E q$ S1 a1 k - #define DMA_PRINTK( x... )3 L% s# {$ Z- h C
- #define DMA_FN_IN; |5 f: N m a* c
- #define DMA_FN_OUT) m% b( T9 r7 ?3 @! g# I* C9 U
- #endif, j( r# g* f- y4 t8 L2 W" B. q
- 7 r- ^' W4 `" n8 B' |' J. [
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
) C& g- N2 l& Z( o7 D* \& }7 I - #define STATIC_SHIFT 3
! M) O; ^/ b( Y a - #define TCINTEN_SHIFT 20
# n: e" N. F3 O8 L; j - #define ITCINTEN_SHIFT 21 d1 P: H+ V7 i8 w
- #define TCCHEN_SHIFT 22
8 n4 b# ^( \% o* o1 [) P7 _7 l U - #define ITCCHEN_SHIFT 23
+ p. e- Q- I' `+ {$ v. p, \
$ t- [3 h& [: ]& v3 V: z/ s5 C- static volatile int irqraised1 = 0;
% E4 O2 O, I5 D% V, I+ f3 k2 B( D - static volatile int irqraised2 = 0;
( J# k( K4 N6 E! e/ [( L - 7 E- @5 c6 [" a4 A, Q* ~
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ n) F9 |- Z1 ?; a1 o - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ l3 ~2 Z' z9 ] - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- T' R0 d, U" C0 H7 i- j0 n
- 6 Z* ^7 n: Q* w: W7 U
- dma_addr_t dmaphyssrc1 = 0;
3 [! l' ]4 _) @2 n9 r0 ~ - dma_addr_t dmaphyssrc2 = 0;6 |9 Q3 X* ^3 c- u6 i+ j( j
- dma_addr_t dmaphysdest1 = 0;
7 N- W5 Z. X/ u, O6 g: B6 { - dma_addr_t dmaphysdest2 = 0;+ k' r. |: R7 [2 q9 [( C
- * c8 u. e1 z: I! [% y
- char *dmabufsrc1 = NULL;! H2 [+ P" U/ I) \0 X4 k
- char *dmabufsrc2 = NULL;
. h+ ~# U) R \! K7 W - char *dmabufdest1 = NULL;9 w& [4 V# n |3 c) `) Y
- char *dmabufdest2 = NULL;! T; Y9 }& { k: l
- " K4 N; p: V! U; s
- static int acnt = 512;9 E( `$ t' |1 B6 r2 h# N
- static int bcnt = 8;! m7 X8 }8 c( p0 P: S1 n# p
- static int ccnt = 8;
) f% {# @; |, k
9 o; H. {+ [) T8 p% G0 d# Q- module_param(acnt, int, S_IRUGO);
4 }( w3 S5 x) ? S6 F - module_param(bcnt, int, S_IRUGO);5 B1 z2 }- e; @
- module_param(ccnt, int, S_IRUGO);
复制代码
: w/ o1 ]) ?4 J" S" p) \$ [
* [! R; g1 ^# e/ v7 D& Y 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用% u6 I+ e* H$ n% k9 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
7 R' b$ A: ~" G 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。3 u2 G1 R* ?% K4 N0 ?8 `: Q
$ l! L+ h' T: d$ Z2 R1 C+ q
- P; B* [/ Q7 b$ j* [9 r+ q$ P o |
|