|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 8 E& m8 {/ q: i3 H, w2 G) j) ?
- [code]EDMA sample test application- y+ U! Y0 S: V
- /*" @/ ^9 e% `# T t0 s- {
- * edma_test.c
( z# t5 q' y7 d" w8 x z" V - *
: i( c) T: T1 z5 d - * brief EDMA3 Test Application( d/ b1 M8 | m$ r9 H9 k g; C
- *
- D1 K/ D- W: z6 B - * This file contains EDMA3 Test code.5 D7 S) C4 L5 ~1 ^" K
- *
0 z$ F# {; U& P( N; D _ _% W - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
7 B7 q4 j2 x: r8 h9 a' i& p3 H - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT$ t+ X5 c. K$ W) k
- * TO CHANGE.
0 `2 ?. c& Y7 m1 c. X) J - *' U% [/ S6 I0 @* J8 t
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
) D5 B$ O' V% ] - *
9 W1 }' k! G" h8 P: G& T - * This program is free software; you can redistribute it and/or
0 T- u# R( t- `# A. ] - * modify it under the terms of the GNU General Public License as
6 V% \ S1 p0 B! R/ |* Q6 f - * published by the Free Software Foundation version 2.
# K. d6 A4 X# n6 N+ j- O" B - *
% C* [+ l$ M6 i - * This program is distributed "as is" WITHOUT ANY WARRANTY of any& I1 o$ K4 M( |2 v
- * kind, whether express or implied; without even the implied warranty6 h1 B! B j k# f
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" T& p2 e; L" a8 I- j& m/ l - * GNU General Public License for more details.
- z- ?( C6 {3 O - */( j" N; X9 h! K
K. h; {" h2 [0 a- #include <linux/module.h>
7 p% u7 a* q- Y8 m t% }, E7 J - #include <linux/init.h>- M/ t @8 C0 C
- #include <linux/errno.h>; h/ E+ F& D4 p+ A" A. W
- #include <linux/types.h>1 ~1 P, _) J$ R% O! ?# F
- #include <linux/interrupt.h>
$ J; ^! z7 n5 ~ - #include <asm/io.h>2 o4 C0 t6 M+ E* {8 L
- #include <linux/moduleparam.h>* W' O8 P, a. h3 |+ _2 Z
- #include <linux/sysctl.h>! C' }( D2 \2 ?) `; l4 g, U; s% b
- #include <linux/mm.h>
# ~" d5 j$ Z) Z; w4 ^8 d - #include <linux/dma-mapping.h>4 c6 Y4 {( _+ B: @+ J
0 y( C4 A4 |( A; H+ B- Q- #include <mach/memory.h>6 Z, D! O: t# T2 u- }) y7 k
- #include <mach/hardware.h>
' u$ {4 [( D7 V: s5 c0 x$ H - #include <mach/irqs.h>
" T1 n; p0 i- N" F: f" p! S- q - #include <asm/hardware/edma.h>- v) ^ K9 }% s" [7 I; P% F/ @& h
2 p9 V( X9 V4 m- #undef EDMA3_DEBUG
3 ~; `5 W5 K0 u. T6 `; ^1 w! C - /*#define EDMA3_DEBUG*/% i$ [3 |. f' ]; A* Z, Z0 N6 w+ `
- " H: I" d+ V! n6 A
- #ifdef EDMA3_DEBUG
- v, V& c; _. n - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
4 R R7 J, `: M - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)- D, y; ~4 N1 f: O# k: |- u! T$ J' P
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)9 @3 F$ d$ L% Y5 S! K* j
- #else5 o6 |$ _& h' `6 o2 O
- #define DMA_PRINTK( x... ); Y' i$ f- V& e& D7 j5 d
- #define DMA_FN_IN9 c1 z, z5 q2 l$ o! R
- #define DMA_FN_OUT
- t( Y# r4 e0 i5 M3 r8 G7 A - #endif2 C# A2 h- F% H8 j2 ?
- $ v% l- K; A( E: x
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- D+ R7 ]* s3 H$ h. D - #define STATIC_SHIFT 3
7 Y0 x# N; a2 | w - #define TCINTEN_SHIFT 20" K' U6 D4 p1 b. d( ]" u
- #define ITCINTEN_SHIFT 216 L* c" z# ~8 r; z3 @
- #define TCCHEN_SHIFT 22' J' Z+ Y! b6 L3 Y: Y1 V
- #define ITCCHEN_SHIFT 23
6 L+ B/ ^, U4 C! A
2 r) L' H- o* a7 e# O+ [- static volatile int irqraised1 = 0;
1 M" Q+ |* a9 h( T Q9 n - static volatile int irqraised2 = 0;2 @% L' t, ?/ J; t7 z( U
7 R& W) k- ~8 o+ B- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 k2 m* [1 P* ^0 ^ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 @5 d$ j& h& ]# H, t- M) \+ S+ v
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 w/ z8 M) w4 d
1 J0 f/ e/ S6 I! z+ P- dma_addr_t dmaphyssrc1 = 0;2 h; |; L h' `6 Q: _- q( \6 ?
- dma_addr_t dmaphyssrc2 = 0;' Y2 o3 A! b+ P7 |
- dma_addr_t dmaphysdest1 = 0;
0 W& Q, P. K$ h - dma_addr_t dmaphysdest2 = 0;
6 F, M& P2 f4 E( M+ z - e: a, u, _* m0 D$ U7 m& c" Z# C
- char *dmabufsrc1 = NULL;: h$ w) `1 T+ q& N/ \
- char *dmabufsrc2 = NULL;( Z* E. C) \6 O+ p X. r/ [
- char *dmabufdest1 = NULL;
) B, }; K) @' o9 h - char *dmabufdest2 = NULL;
; n7 j- ]* z$ f; f: i% {2 m8 t - m3 u2 ? E4 m2 V3 p
- static int acnt = 512;
0 V/ d, b, f2 o( Q4 I2 V - static int bcnt = 8;
3 x5 R- w" c/ E6 A- ^ - static int ccnt = 8;
) _1 \% a; |: ~' B* ?0 A - / L7 |1 k1 v/ Z4 v5 T( }
- module_param(acnt, int, S_IRUGO);
5 B& B% O( t! y7 z d2 I( R - module_param(bcnt, int, S_IRUGO);
" S0 g7 i0 l* B - module_param(ccnt, int, S_IRUGO);
复制代码
- N6 H* g- V9 `% q" `) u3 A$ g
E; B0 S0 ], W/ b. V4 j2 k; U 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
2 [) E" h% r) B( xarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
, Z& j( [5 N% d6 R m. P, m A 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
& l, H6 ?+ D- x; d/ `6 b) h- F
6 f. o3 p6 l( d( J* L3 G0 t" q- J7 Q) c l
|
|