Debian Codegraph @

include/dma.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2002-2010 The DOSBox Team
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 /* $Id: dma.h,v 1.20 2009-07-24 09:56:14 c2woody Exp $ */
20
21 #ifndef DOSBOX_DMA_H
22 #define DOSBOX_DMA_H
23
24 enum DMAEvent {
25 DMA_REACHED_TC,
26 DMA_MASKED,
27 DMA_UNMASKED,
28 DMA_TRANSFEREND
29 };
30
31 class DmaChannel;
32 typedef void (* DMA_CallBack)(DmaChannel * chan,DMAEvent event);
33
34 class DmaChannel {
35 public:
36 Bit32u pagebase;
37 Bit16u baseaddr;
38 Bit32u curraddr;
39 Bit16u basecnt;
40 Bit16u currcnt;
41 Bit8u channum;
42 Bit8u pagenum;
43 Bit8u DMA16;
44 bool increment;
45 bool autoinit;
46 Bit8u trantype;
47 bool masked;
48 bool tcount;
49 bool request;
50 DMA_CallBack callback;
51
52 DmaChannel(Bit8u num, bool dma16);
53 void DoCallBack(DMAEvent event) {
54 if (callback) (*callback)(this,event);
55 }
56 void SetMask(bool _mask) {
57 masked=_mask;
58 DoCallBack(masked ? DMA_MASKED : DMA_UNMASKED);
59 }
60 void Register_Callback(DMA_CallBack _cb) {
61 callback = _cb;
62 SetMask(masked);
63 if (callback) Raise_Request();
64 else Clear_Request();
65 }
66 void ReachedTC(void) {
67 tcount=true;
68 DoCallBack(DMA_REACHED_TC);
69 }
70 void SetPage(Bit8u val) {
71 pagenum=val;
72 pagebase=(pagenum >> DMA16) << (16+DMA16);
73 }
74 void Raise_Request(void) {
75 request=true;
76 }
77 void Clear_Request(void) {
78 request=false;
79 }
80 Bitu Read(Bitu size, Bit8u * buffer);
81 Bitu Write(Bitu size, Bit8u * buffer);
82 };
83
84 class DmaController {
85 private:
86 Bit8u ctrlnum;
87 bool flipflop;
88 DmaChannel *DmaChannels[4];
89 public:
90 IO_ReadHandleObject DMA_ReadHandler[0x11];
91 IO_WriteHandleObject DMA_WriteHandler[0x11];
92 DmaController(Bit8u num) {
93 flipflop = false;
94 ctrlnum = num; /* first or second DMA controller */
95 for(Bit8u i=0;i<4;i++) {
96 DmaChannels[i] = new DmaChannel(i+ctrlnum*4,ctrlnum==1);
97 }
98 }
99 ~DmaController(void) {
100 for(Bit8u i=0;i<4;i++) {
101 delete DmaChannels[i];
102 }
103 }
104 DmaChannel * GetChannel(Bit8u chan) {
105 if (chan<4) return DmaChannels[chan];
106 else return NULL;
107 }
108 void WriteControllerReg(Bitu reg,Bitu val,Bitu len);
109 Bitu ReadControllerReg(Bitu reg,Bitu len);
110 };
111
112 DmaChannel * GetDMAChannel(Bit8u chan);
113
114 void CloseSecondDMAController(void);
115 bool SecondDMAControllerAvailable(void);
116
117 static Bit32u dma_wrapping = 0xffff;
118
119 #endif