|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
8 P0 {, L( K: O( ?( q( q- [code]EDMA sample test application
+ T3 ^ ], S, r8 u% n% C# U9 N - /*& i1 x# Z2 X- t* J0 Q
- * edma_test.c
$ \9 p" P6 ]: t1 l# {+ e - *8 f( w; t% l, c
- * brief EDMA3 Test Application0 i- W" Q5 t j& f0 i. ?
- *! ~* T! T) o8 b' e9 _" G
- * This file contains EDMA3 Test code.
" i0 d! |4 y8 H. g* v$ [ - *
& @( K& ^9 x8 [, e. s8 ` - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
! \, p* i. B& j - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT! J- e a( N. U- F9 S! P
- * TO CHANGE.6 D1 ~; y8 Q i! j
- *# @3 Q* Y: p. ?8 |" w
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/+ z5 S' n/ O( y) B0 a% \
- *
( V# C' |) R8 z& J3 }. v8 r: U: N - * This program is free software; you can redistribute it and/or
/ h2 z( ?9 l+ Y - * modify it under the terms of the GNU General Public License as3 R! d: h J$ G" ^$ T8 e) u
- * published by the Free Software Foundation version 2.
+ N7 N* B) J; v8 Z# j% m - *! e4 m# V) d) z7 n7 L c. d
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any9 U* G; W! A$ U( V1 C$ Z2 Z
- * kind, whether express or implied; without even the implied warranty
6 l6 r4 D8 Y4 |: i4 {$ w - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the! Y* ]* X) q C
- * GNU General Public License for more details.
j0 Q% q' o! p% I5 u; t - */
- d& N7 b |) n/ S3 `8 { - - Z# P, c& g7 s/ n$ v
- #include <linux/module.h>
5 z5 Q7 r9 u) @9 N, o - #include <linux/init.h>
# U+ i j8 D& B6 d$ O0 j; g. ? - #include <linux/errno.h>. m/ y8 A- V+ J$ n9 C% E
- #include <linux/types.h>! C' f) e: I4 r: W) R N( N
- #include <linux/interrupt.h>
/ k5 l6 B- _5 k- v8 G9 ~7 m - #include <asm/io.h>% J5 R) u, a0 ?- i! r: w6 K' [
- #include <linux/moduleparam.h>
' C1 [1 q3 V: u9 d7 Q& ~* @* ]0 | - #include <linux/sysctl.h>5 }# w& O- `4 d! V) g
- #include <linux/mm.h>- a8 ?& S3 U! f) X
- #include <linux/dma-mapping.h>) \$ e1 c3 F# A2 r' L6 B4 K' W
. ? ?4 R; q. ?- #include <mach/memory.h>& N8 X8 P2 t7 W/ G! L2 Y2 P' o1 R. a
- #include <mach/hardware.h>
: j1 B) b' d) ?: M2 {3 r8 t& Y; U - #include <mach/irqs.h>! u0 `& f* v2 {+ C, M! N9 Z
- #include <asm/hardware/edma.h>, \/ I, ?5 Q ]% R( \
: Q' Y% _% O* J7 D3 A- #undef EDMA3_DEBUG4 U. P/ {. i, Z+ V7 S
- /*#define EDMA3_DEBUG*/
% A& D5 R6 E7 v, p# q2 s
: y9 j7 q+ v9 B/ m* Y0 e, q- #ifdef EDMA3_DEBUG
x5 ], t3 i5 z O2 }9 ` - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
8 X- b/ w. q$ H% O; G. S; E - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)/ t. ?5 i& K* N1 D: j
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 a7 @1 ~* y; l - #else3 N* F( C q1 K9 t# v' W
- #define DMA_PRINTK( x... )
7 i+ `5 [ M% c o6 Q - #define DMA_FN_IN% ]- w5 e: S+ x. Z8 G% _/ ]
- #define DMA_FN_OUT
7 p) s Q) S% g$ A0 C4 d - #endif/ w& Q; d- }! @
- / a1 J* D* K# P9 U
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)4 M# {3 ^0 L- M8 [8 l4 Q- e1 w& K; |
- #define STATIC_SHIFT 3
1 m9 t( f+ d' e5 K& H8 K N - #define TCINTEN_SHIFT 20
3 e: n5 h$ s" E. { - #define ITCINTEN_SHIFT 21
, M8 D. ]" b9 m8 f! F8 O4 D - #define TCCHEN_SHIFT 22
- o1 N# L! k& a" P+ X) b - #define ITCCHEN_SHIFT 23
1 b' n' x) {1 U2 x. `6 y - ; n( K* ]: H3 D+ f
- static volatile int irqraised1 = 0;) p- s1 h7 E& r* [
- static volatile int irqraised2 = 0;7 c+ I5 n1 U5 ?/ F$ Y9 m7 T
( }+ D% @8 v5 y1 c. a- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' l( S0 x5 a$ u9 f$ t - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( k: I* P# L, r5 w
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) _ `6 g8 g* o, q! |! K7 q
- D# O$ j7 q! z( x- dma_addr_t dmaphyssrc1 = 0;
% X9 K3 D/ P" V& P# [) E - dma_addr_t dmaphyssrc2 = 0;6 X6 M; r& Y' K
- dma_addr_t dmaphysdest1 = 0;. W! E9 m5 t( l% b3 Z
- dma_addr_t dmaphysdest2 = 0;( R; h/ h3 ~' l! N* o- n
- $ ~( e' W- }) C3 W$ T8 `
- char *dmabufsrc1 = NULL;
' T' t3 x) r" V, ~ - char *dmabufsrc2 = NULL;. w% A# O, R6 x% r
- char *dmabufdest1 = NULL;% y M4 q& B' q! j- G, g
- char *dmabufdest2 = NULL;' ^/ E1 i; L5 U& `8 @7 @
# Q1 V. | v/ p9 t& l. e- static int acnt = 512;
3 A# ^, S2 l) o - static int bcnt = 8;; V" d3 s# G0 T6 P1 K
- static int ccnt = 8;+ a2 f" J8 B& p* O1 H
- 7 N5 y( j$ B: F: |# |0 M
- module_param(acnt, int, S_IRUGO);7 g, h" w# n+ n( g; p
- module_param(bcnt, int, S_IRUGO);
& E9 o) U+ H6 R& K9 ~ - module_param(ccnt, int, S_IRUGO);
复制代码 & v8 H+ o: g# V1 e' F
k2 b" K6 t5 N7 L) N2 H 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用% X* O9 Z* b% ?! H0 y
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
6 C+ R9 S* e7 T0 \7 n 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' ^0 q5 ?5 B6 E& U
: Q$ D, r, V( H [. {
& U# P0 r. \4 d! v1 z# f |
|