|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 3 R1 d ^. [# v5 ]& b. e2 a
- [code]EDMA sample test application
5 J0 _4 G, ]+ `" \$ L - /*% @+ {! g- z8 f/ D" H; n
- * edma_test.c$ A7 d3 h9 ?- `: @
- *
! q' L6 }1 V4 c! `7 h - * brief EDMA3 Test Application/ p: Y Z; P: k- D( s- {2 T
- *' t* _ ], z3 M3 R0 l3 H
- * This file contains EDMA3 Test code.
5 ?. a2 D2 |8 [' _. { T - *
9 V3 D; k6 \7 J - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
' t" A8 u# x+ K/ O0 H - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 |4 h& n: J8 a" o& V
- * TO CHANGE.
# w0 e b/ u5 J( M6 | - *# u) [# X- m, a1 L" d
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/( v& k$ y" {0 i- G
- *" l: |: ` c* C: N! `3 E T( m
- * This program is free software; you can redistribute it and/or* d. g- B3 H9 x$ ] o
- * modify it under the terms of the GNU General Public License as, A. I3 O! B" i* Z8 X; ~
- * published by the Free Software Foundation version 2.
- R9 r- H8 u: [ - *, f2 v* g3 u r1 @3 F" ^. }& z
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any" }) ]/ k% r6 F; Z6 I
- * kind, whether express or implied; without even the implied warranty5 ~+ o, r3 X9 m
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ B9 W$ F: P4 d9 k: }3 U( u# u - * GNU General Public License for more details./ H0 e$ Q/ G* g( d; @. p
- */
Z/ L( b! w5 z - 9 k- F& ?. l# B4 T3 I0 ]
- #include <linux/module.h># v4 ]* F& D) ?/ g d
- #include <linux/init.h>
4 c# n8 a$ y" w2 ? - #include <linux/errno.h>) e+ ]! a. u3 V3 a
- #include <linux/types.h>' `( W! j- E, X0 O
- #include <linux/interrupt.h>
0 N9 B* w+ n% S( s2 E - #include <asm/io.h>
/ v1 q% z8 b- z+ a - #include <linux/moduleparam.h>
/ b. w# G. E+ T* {6 r - #include <linux/sysctl.h>
( G5 ?0 x% ]) r6 J1 w+ O% B - #include <linux/mm.h>
3 S, O: _1 V5 z' x$ I - #include <linux/dma-mapping.h>( k* |, l( a. `6 i
- 1 z$ K! P6 `: j4 d4 X* e
- #include <mach/memory.h>2 N( F5 z1 O, [. d. i! b
- #include <mach/hardware.h>2 c6 m8 Z. o; N/ g9 h" C5 K
- #include <mach/irqs.h>7 L7 M% e: U+ j- k" {2 R' B1 k
- #include <asm/hardware/edma.h>1 u; t' d& G |" R$ z. r/ X/ T
7 k3 K3 m+ @. e3 V7 L; V ?- #undef EDMA3_DEBUG
6 D# E# S, J( y6 w) L/ ~ - /*#define EDMA3_DEBUG*/
; D. ?; I% S# Y4 S$ M - ; F. b4 q6 Y' O, h0 n1 s
- #ifdef EDMA3_DEBUG
) P! z) |, h* w7 r5 |0 k" q - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
0 i1 x" c% `% |$ j - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)# s- w. Q J- V- Q2 T' L
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
4 u I( f( u1 t. P% z - #else. B* @5 u8 j* M- J2 k* a
- #define DMA_PRINTK( x... )7 V0 F" Y+ m2 Q" |) e* K% n( i
- #define DMA_FN_IN8 j' y# ^8 Z3 m
- #define DMA_FN_OUT' s: c7 x; ~% N) Y: ^
- #endif
8 q1 R O4 ?& _, n& R( k9 z
# f* Q9 X. Y7 ?: X8 X- #define MAX_DMA_TRANSFER_IN_BYTES (32768)2 d; A4 r: V. O4 m% k; I# o
- #define STATIC_SHIFT 34 N( `; T0 {9 [' ?+ o5 V
- #define TCINTEN_SHIFT 20 m# K! n& w3 Q
- #define ITCINTEN_SHIFT 21
( I( G8 g7 { C8 l, s' g - #define TCCHEN_SHIFT 22
: J$ H& b- x* ~: o& m- Q - #define ITCCHEN_SHIFT 238 Q; t L t! Q' n% Y; K
3 Z; a' } W' o3 s: E- static volatile int irqraised1 = 0;
; @4 l8 F% p% S' a" u; i X+ J - static volatile int irqraised2 = 0;
& ~1 T, f2 {2 l( ?6 n - , i- y0 G# E O( o) I I5 A
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( h7 i, i2 ]+ w - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 \3 w3 N5 P; b' Q: [/ l6 f
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 U% X7 J- }' J+ D& H" B
2 T) b" _3 M: v6 u! x6 o- dma_addr_t dmaphyssrc1 = 0;
% o( A& I# T# t/ a2 y( f - dma_addr_t dmaphyssrc2 = 0;7 j* S P% C6 Y2 u Z; I* Y
- dma_addr_t dmaphysdest1 = 0;. j: v3 w6 G" K& O+ a
- dma_addr_t dmaphysdest2 = 0;, M2 k' E4 y2 P
2 }4 D c* @: M; x, m% a" Z# p- char *dmabufsrc1 = NULL;
/ ]9 N3 `2 @5 x! @) Y - char *dmabufsrc2 = NULL;* V7 K7 `- Q. j1 p
- char *dmabufdest1 = NULL;' O( U4 H# r+ E+ X: g
- char *dmabufdest2 = NULL;, O8 k5 D" l& z2 c
- % B8 N, n8 E- e7 y5 H7 j: F% b
- static int acnt = 512;2 i3 B w* n- L! k# X
- static int bcnt = 8;
* K5 a& h" m% x2 V" j0 M - static int ccnt = 8; X( c3 X+ N1 ] o! y3 ^
) o" n/ C! B% W1 I7 [- module_param(acnt, int, S_IRUGO);
+ ~9 w( g' f2 V; } - module_param(bcnt, int, S_IRUGO);/ Y% N) o7 ?) e2 S1 f0 [
- module_param(ccnt, int, S_IRUGO);
复制代码 , z9 T8 K! y# x4 y
$ x3 H3 H# ^4 z6 d6 ^
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用8 I7 E$ t, J6 A0 s
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。' l5 x n% N4 k/ s$ u t
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。 l1 ?" T: F; s4 C4 u; ?; M* n
9 e. P7 T% L& ?1 m3 t- G7 |- m) c2 R F! e( b: x
|
|