|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
+ P1 v8 }( U g0 n: T- [code]EDMA sample test application
. a8 ^% a. ^! e* L7 F- A' E - /*; g/ @7 Z! ?! t6 y
- * edma_test.c
* u; U3 y. A3 ~' S - *2 N8 m. X" n- A3 D# f% a- f% D
- * brief EDMA3 Test Application3 i1 ^* g0 v8 x0 x2 F
- *! e& a+ a4 `1 ]/ \: e6 v3 @1 ~
- * This file contains EDMA3 Test code.% \* U' G! I% Z) d; r8 }! o
- *' s# S5 ]4 |" G- U- n% M) g7 n
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE3 A& N, W: R4 B7 X9 w% d
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT9 p$ {0 J: N5 [. M& a
- * TO CHANGE.1 m) P0 X& `- c" r
- *
8 O# y5 `$ |! ~# I3 i& p - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/4 e. A( u9 w" I8 W! p9 C2 \% Z
- *
+ t& L9 x2 {" G6 y) R8 Q# u - * This program is free software; you can redistribute it and/or
, M2 V3 O* v+ ^2 l# T - * modify it under the terms of the GNU General Public License as
8 w: p7 d# D4 R - * published by the Free Software Foundation version 2./ l+ s4 e: X7 ~3 i. o1 d+ `4 y
- *
" _( `4 C( J4 m$ U - * This program is distributed "as is" WITHOUT ANY WARRANTY of any& X2 K6 y2 l ?7 G3 T# I
- * kind, whether express or implied; without even the implied warranty
% n L: P2 u0 g; G - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# a! `- T1 U$ _7 \5 ~7 k - * GNU General Public License for more details.$ F" T; ?* M$ p3 t4 ]3 u0 _, R
- */9 I" \& V5 n6 ]
4 _* Q* Y" V- m3 K3 x" d# z- #include <linux/module.h>: L4 n s9 H' c- s# Z
- #include <linux/init.h>
# d$ C' @( \$ h7 v - #include <linux/errno.h>. \2 t4 ^( `% F0 X" j9 r* j/ e
- #include <linux/types.h>
0 i# t- ^. V0 q - #include <linux/interrupt.h>
/ k4 f& ^ U5 g( Z( G1 B - #include <asm/io.h>8 u: [7 b1 u: M- ^9 B
- #include <linux/moduleparam.h>
! B# Y/ Y$ w8 M% ]: o, b - #include <linux/sysctl.h>5 d7 C* h- z% S, Y# S
- #include <linux/mm.h>
1 p5 D! i; \8 Q) H - #include <linux/dma-mapping.h>
( X& D3 z& r; @4 [; o, O - 2 X+ O1 y( b* Q, ]; J2 ]
- #include <mach/memory.h>
) Q: t8 s) o( _ - #include <mach/hardware.h>
4 S$ C9 N# ]; @9 ^ - #include <mach/irqs.h>, a$ [ k; r+ i! G5 R0 [0 x5 r
- #include <asm/hardware/edma.h>' m: m$ b' F' c2 \: I& P' [
- 8 f" S, D6 _0 q
- #undef EDMA3_DEBUG& B% N3 |! L% a3 |
- /*#define EDMA3_DEBUG*/
' B4 n9 D' P0 K# i' A - # k( z% h& p' v
- #ifdef EDMA3_DEBUG% H8 A2 b6 b% p4 Q5 e& O
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
' @9 R7 j! ^6 U* [ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 c& L2 v4 z( N& L - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)$ z% d* y4 @3 t/ ]4 S7 J; [
- #else
2 i" T2 A* P, t - #define DMA_PRINTK( x... )4 j t) X0 M5 r+ g4 z, a$ @
- #define DMA_FN_IN
3 S7 F4 w" w+ F# M- \) H - #define DMA_FN_OUT
% s% J0 A6 R7 f - #endif
% B$ q s- o9 f, q4 g( f8 [
, W* f! e5 s) v8 G) V6 a5 V- #define MAX_DMA_TRANSFER_IN_BYTES (32768); p- ]# P+ N' \8 M6 Y- C
- #define STATIC_SHIFT 3
" J1 ~, o" G0 `9 E - #define TCINTEN_SHIFT 209 h6 [! @2 q" i& a4 N
- #define ITCINTEN_SHIFT 21
. `" N" W" D0 z* o - #define TCCHEN_SHIFT 22
0 F- Z5 E4 A; S! x: f- I, d5 { - #define ITCCHEN_SHIFT 23. U' H+ C6 l, W0 m0 [! H% d5 F' u
7 z6 O( Z9 z$ a3 @4 `- static volatile int irqraised1 = 0;
, L; c. F/ x1 m5 l4 C - static volatile int irqraised2 = 0;/ J+ R4 k' ]1 s+ C0 o7 m, |
- " {! c; u0 _& [" B
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 y" {8 a$ W% r# n) C" M7 z - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 [# X8 A- o: c
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 X6 x4 G* n: e/ Z. x
- 7 |# ?9 Q7 ]* `0 L; i2 P' i0 B
- dma_addr_t dmaphyssrc1 = 0;- i! W+ B& g9 y0 M' f6 p% A# I
- dma_addr_t dmaphyssrc2 = 0;2 p9 U4 i$ o6 N& x& P: @5 T4 {; I
- dma_addr_t dmaphysdest1 = 0;+ O& \+ j* _6 s4 S1 g
- dma_addr_t dmaphysdest2 = 0;6 c: E. Z- V1 R6 \2 O
; }2 B6 N' q9 F9 B$ c ]8 V5 @ ^- char *dmabufsrc1 = NULL;& |; m1 h$ W N8 g
- char *dmabufsrc2 = NULL;
2 b8 Z% j7 x3 D% q% E0 X' C) V - char *dmabufdest1 = NULL;6 Z6 U6 G Y t$ H
- char *dmabufdest2 = NULL;0 p/ M0 x4 {. C
- ) q3 @, M8 {& d% q+ k5 k
- static int acnt = 512;5 E/ T* M* L6 c7 J3 R7 F" D
- static int bcnt = 8;. ]( W- S9 O8 U, i$ w' f g
- static int ccnt = 8;' e8 ]+ s N: Q: Z! Q3 @
. x* _! k- H& E; ]9 X- module_param(acnt, int, S_IRUGO);
. s" M5 S8 x6 M! l# r" v - module_param(bcnt, int, S_IRUGO);
) y4 F" |8 i: }( J7 t, Y$ E8 S# S# } - module_param(ccnt, int, S_IRUGO);
复制代码 5 U6 t- k. B7 l; d
# [4 J) y7 h+ |9 e* P4 Q 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 N2 y2 a# b) P! D! carm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
/ _/ f0 x6 j) Q) h/ I# I6 g8 J 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# U2 i, t" `0 G7 g; k
" V- _2 t% n1 t( P- C& y7 R. T
! ?; E# t, }4 I9 R8 B W" Q- e |
|