|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 * b$ ?8 V0 A3 ]# a2 V. t
- [code]EDMA sample test application6 A9 E2 k) T+ D$ o: ?% G
- /*
4 f; S; G; @7 I% G4 ^$ Z - * edma_test.c$ T) N2 x- Y% p/ c/ N- s
- *5 H: r: s r) M
- * brief EDMA3 Test Application
$ k+ O% R, n1 T n - */ |/ R8 ^/ u l9 P& h
- * This file contains EDMA3 Test code.
! S A' x- M; {' P6 \* B, } - *7 y1 d3 }1 l/ q2 z
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 i2 \! s8 h" z. n
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% g* [6 f8 @# G- y) s
- * TO CHANGE.
8 g* S0 U9 R/ G+ n r6 a) m, f - *# q- ^0 S. ` X* V1 \+ I7 d
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
7 h* q" C( M6 L7 u: Y. N - *
$ I% X" _* N7 I& G; p* A - * This program is free software; you can redistribute it and/or
& g) C8 I) Q* W+ I% d - * modify it under the terms of the GNU General Public License as- m/ E) U( x9 P8 g* K0 r
- * published by the Free Software Foundation version 2.
3 d7 {: S: J8 Z2 S" ~/ y& E - *
6 p+ s* o. {# w+ _4 } - * This program is distributed "as is" WITHOUT ANY WARRANTY of any" X7 y/ Z( `. i) s, t
- * kind, whether express or implied; without even the implied warranty: L# K+ J- w2 P* @7 y
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" a( Y0 E& S" s( R- _ - * GNU General Public License for more details.
) O5 {( v' g8 H" ^ - */# Q1 i) g/ S1 R7 F( i( z' k& X4 `
- . Y+ ?. u9 Z$ p0 ^5 J/ |( r
- #include <linux/module.h>
! M9 X+ u; a; t# W1 b$ W% _3 W - #include <linux/init.h>
: j% @- L$ `+ y7 x6 k. l - #include <linux/errno.h>% I& G# e9 f* G' B$ j
- #include <linux/types.h>) t& \- ]4 g0 \& z
- #include <linux/interrupt.h>7 D$ [2 D) B7 i# |
- #include <asm/io.h>
7 B5 c: t: x( ^; [2 s9 j: j3 ^ - #include <linux/moduleparam.h>. o8 v5 K7 C( g( I' N k; Q
- #include <linux/sysctl.h>
9 r* o2 o* j0 \ o t1 n - #include <linux/mm.h>$ w4 l: ^* u7 D! H/ n2 D
- #include <linux/dma-mapping.h>- W- j t0 L/ l Y7 t1 C0 n
- ( N3 f/ C4 [3 L; `& Y8 L8 e, X
- #include <mach/memory.h>
3 J# H$ K1 u: ^) i - #include <mach/hardware.h>9 I- J+ n4 Q/ U k5 e5 t
- #include <mach/irqs.h>) {$ @- n$ z" l/ {* K
- #include <asm/hardware/edma.h>( A/ h3 z8 Q" [" g3 f
* \ f# I! e3 i# Z+ Q- #undef EDMA3_DEBUG
% k/ K' Z' ?/ L- x/ T - /*#define EDMA3_DEBUG*/
; N( P) L+ y [6 W3 X. @' @ - ! `- E+ @/ \" X* @& R5 S
- #ifdef EDMA3_DEBUG& Z/ N& M, P. J- C" H4 g
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
# h% q) | C: e2 Z8 j - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)1 _4 t# ?- L a
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)' [4 f1 q2 H# D, N; h/ r( a7 i
- #else
v0 y$ x) U/ E$ U' ^ - #define DMA_PRINTK( x... )9 Z) U; ^4 A- @" f
- #define DMA_FN_IN5 L$ F7 z6 f: b/ W) e
- #define DMA_FN_OUT
- ]/ ~) P- D. A8 u* L - #endif
1 d: M8 h! h( H7 a3 H0 z - , P) R" n1 D' U) L H. W
- #define MAX_DMA_TRANSFER_IN_BYTES (32768). h+ @4 I( a- o, B4 Q
- #define STATIC_SHIFT 37 `6 s, N2 y) L
- #define TCINTEN_SHIFT 20
: E% l; W( X0 X1 p; O - #define ITCINTEN_SHIFT 21
7 O% A5 |% L2 U9 ~' u* L6 | - #define TCCHEN_SHIFT 220 x, L+ p9 J7 Q. V
- #define ITCCHEN_SHIFT 23/ p% l! a7 A9 B3 ?! b$ c
- $ |, @2 `: G* q9 t4 U G
- static volatile int irqraised1 = 0;! j* J" o* N% ^* y# k. d
- static volatile int irqraised2 = 0;
H' F3 ?# J: ^* A9 T - - S; w2 ]5 V( K+ ?6 ~, g
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 l8 i+ J6 F' U6 q# n" U
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 l" m9 s) S8 }- G
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: {' b* n( o( E
* ^3 B; Y. U. S+ H& z- dma_addr_t dmaphyssrc1 = 0;
2 t# ?2 Y1 ^- P! |0 J/ e) Y: x9 L - dma_addr_t dmaphyssrc2 = 0;* w8 Q5 [6 {8 f0 G
- dma_addr_t dmaphysdest1 = 0;1 F5 H9 X: i, T
- dma_addr_t dmaphysdest2 = 0;2 e5 o7 M; @ `, N$ U
- ' x8 j# |! }0 k; d
- char *dmabufsrc1 = NULL;
F! v6 p0 m2 M3 B/ i7 u - char *dmabufsrc2 = NULL;
. O* U# q, f% d, U5 a" f' Q - char *dmabufdest1 = NULL;
" x. g* o3 f: Y' P# | - char *dmabufdest2 = NULL;
+ l7 W8 _( j( A9 ]% S2 ?2 Z
: X! L" h; I: J; H2 R- static int acnt = 512;
9 s1 y7 ]7 d1 Y( ]4 S - static int bcnt = 8;
5 W, c, A) |$ K) X$ e - static int ccnt = 8;, q+ {' T# c! k0 I! K+ _
- @3 i( x8 K' p+ t ^. o
- module_param(acnt, int, S_IRUGO);
6 ]1 h: N; y v" l3 ?3 g: f - module_param(bcnt, int, S_IRUGO);
+ |6 j* M$ C) j- Y. n) y - module_param(ccnt, int, S_IRUGO);
复制代码
B$ R# l2 I7 i$ S' r- q
' Y" y' i+ w6 R6 n3 p. V2 O 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
- R5 K# a3 b9 @, Narm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
% Z5 }) p. Y$ P7 m2 u 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
6 X N/ h% F0 ~( @! T' |
; t# c- C. Z" M2 b9 E1 {/ N: T0 Z) X
|
|