|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 " h) F O& z6 [
- [code]EDMA sample test application
) \' i% y4 E# h- @/ x; F - /*
% S5 R% |4 o' m' O - * edma_test.c
3 p9 b M% d- G3 ?4 U - *' X6 @( J/ Q) @5 D" x
- * brief EDMA3 Test Application5 ^4 T3 F- o N5 d O5 B
- *4 o4 j' m+ e) O5 j; u! \; a* p
- * This file contains EDMA3 Test code.$ _" l9 ?' ~5 y
- *
3 ?( k2 G' [# s) b. l - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE# b+ \0 R L$ b s' K2 L9 w6 u- B
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
, n" A3 { w" [7 S5 s" H2 I7 Q - * TO CHANGE.) t& u5 q, Y6 S: _8 j5 M U
- *3 R; \8 _0 Z1 K/ r4 [
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/3 a8 q' n Q+ v) x( G
- *2 n( L" e7 J# Y9 {
- * This program is free software; you can redistribute it and/or
( g1 b3 | g+ v7 q# d - * modify it under the terms of the GNU General Public License as' g/ Z7 W4 w4 y# a% o& _0 h
- * published by the Free Software Foundation version 2.
$ O# P- Z; @# ^8 p' I& ^$ U' [ - * n) Q- M" i+ R; }( _
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
% c$ C9 O3 D0 z" ?( S; w- h! w( j - * kind, whether express or implied; without even the implied warranty
) C; u. \9 a) `0 k - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the4 E# j3 ^; l) M
- * GNU General Public License for more details.. z9 Y. i/ Q! p
- */
; z- B, l ^+ t - ' l' p6 O3 d8 _. S R
- #include <linux/module.h>5 n. Y2 T% h& ?( P/ p3 i( ]7 a
- #include <linux/init.h>
0 C4 w, ^1 I; K9 {6 L# Z% T2 p - #include <linux/errno.h>6 a5 a" v |+ j% |, ^+ n+ N& s
- #include <linux/types.h>8 ~$ b0 H5 p/ V! F
- #include <linux/interrupt.h>* k% T9 E+ G G
- #include <asm/io.h>
x( f, z- T; Q4 z7 J) e! A4 l0 c% D - #include <linux/moduleparam.h>, b) c Q d9 P" V2 c. w
- #include <linux/sysctl.h>
6 p+ o s0 v8 O. |4 w0 ?5 ] - #include <linux/mm.h>3 R, l+ V9 e3 U2 {% f( T; s s
- #include <linux/dma-mapping.h>& V9 D1 x+ X# d) _+ R% c
- 4 N+ R) r: a% w1 }) x# G0 s/ Y
- #include <mach/memory.h>
9 V @7 g8 o- ~( b. T - #include <mach/hardware.h>
+ f4 K4 t7 M8 N$ f1 I- A8 | - #include <mach/irqs.h>
& L$ j) A5 W1 W0 _ - #include <asm/hardware/edma.h># w, |# G+ e1 a( K9 ?
7 s5 o5 @$ ~ Y8 ?, _- #undef EDMA3_DEBUG! ?* {, S5 L3 H" V$ |/ v, i) z
- /*#define EDMA3_DEBUG*/
" o C# N3 x( Z0 Y0 X - 8 a( z; \: F a* g0 W9 [: t
- #ifdef EDMA3_DEBUG
1 d' U: J0 i, b - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
^( I" R/ @, Q0 T - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)( U0 v3 n8 z, p
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! Q. c$ U/ T$ }; e4 s$ U
- #else
* M; N$ s3 o9 _) |9 j - #define DMA_PRINTK( x... )% m( Y" }' g+ {- v
- #define DMA_FN_IN
, h1 P# t$ |" @% G - #define DMA_FN_OUT
8 @' p% M9 ]+ t @0 O* K' l, n - #endif! q4 i8 g* p8 V, E0 }1 A; u3 \
7 h& u0 x' _! V: A0 H& V3 T1 D! Y- #define MAX_DMA_TRANSFER_IN_BYTES (32768)2 O# O2 L# Z0 y2 g6 ?6 a" @
- #define STATIC_SHIFT 3
' s- c: H% z% R. p, Z% A - #define TCINTEN_SHIFT 20
3 N$ A/ ]2 ?2 M H& a - #define ITCINTEN_SHIFT 215 C- y: z5 ]8 b. r& N1 \, V
- #define TCCHEN_SHIFT 22' S' C8 U* k0 }& v9 `4 Y0 \
- #define ITCCHEN_SHIFT 23
$ l, a" r" k/ O/ E# h - 1 T# u. F) z6 ]/ ]% l3 f1 h
- static volatile int irqraised1 = 0;# C9 N/ x7 O' W- R; \; D8 L
- static volatile int irqraised2 = 0;
/ Q0 X0 a( ?) Q
8 A8 Z' i6 S- y( [- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 O, P* q9 `, T
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
U4 Z, y/ k7 r( B! G - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ d+ M. b3 H9 B - - l- @0 |4 j) b" m% h' f* S
- dma_addr_t dmaphyssrc1 = 0;
8 J! C% |# H: Z( x4 W: n! A - dma_addr_t dmaphyssrc2 = 0;
, {* U- j5 r7 N - dma_addr_t dmaphysdest1 = 0;
) W- }: E, k/ R" s - dma_addr_t dmaphysdest2 = 0;: L0 B# I5 Z( P( ]5 ~$ r
- ( X z* ]. X5 V+ k% z/ l; c5 f
- char *dmabufsrc1 = NULL;
; r) H, r. V+ p) t* d - char *dmabufsrc2 = NULL; b% v: z, @7 k# f9 t" j
- char *dmabufdest1 = NULL;
4 v$ E4 O) g" V7 j5 b2 f) T6 y - char *dmabufdest2 = NULL;: Q% e' D& f0 U5 G. N2 D2 I
- " E# r; D2 N6 s6 Z4 ]+ Z# b' G
- static int acnt = 512;: r% @( A$ J0 Y# ?3 x* Y7 N( N: G) j
- static int bcnt = 8;' o0 w' |$ M. D1 p) R( h- G
- static int ccnt = 8;2 Y9 p/ {% i2 ]! W
- 9 L4 I$ r. A1 w8 p
- module_param(acnt, int, S_IRUGO);
4 \! R9 `5 U1 b: _+ z: O, c( D/ Y - module_param(bcnt, int, S_IRUGO);) t2 U- F# |" k3 n
- module_param(ccnt, int, S_IRUGO);
复制代码 2 H) P& a9 `: B) h; Z! r
9 x# N- Y9 m" h/ U, H! S7 U8 ?
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
" Y+ d# n0 s farm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
4 k* O( {! c; S; m( a 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# [7 e0 `( f0 F
! Z" @/ J$ B1 l; w5 n
& P: v p% ?4 E% Y. \8 Q |
|