-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDevice.cs
More file actions
74 lines (59 loc) · 1.66 KB
/
Device.cs
File metadata and controls
74 lines (59 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using DotXT;
abstract class Device
{
protected i8259 _pic = null;
protected Bus _b = null;
protected List<int> next_interrupt = new();
protected long _clock = 0;
public abstract String GetName();
public virtual List<string> GetState()
{
return new List<string>();
}
public abstract void RegisterDevice(Dictionary <ushort, Device> mappings);
public abstract bool IO_Write(ushort port, byte value);
public abstract byte IO_Read(ushort port);
public virtual int GetWaitStateCycles()
{
return 0;
}
public abstract List<Tuple<uint, int> > GetAddressList();
public abstract void WriteByte(uint offset, byte value);
public abstract byte ReadByte(uint offset);
public abstract bool Ticks();
public virtual bool Tick(int cycles, long clock)
{
_clock = clock;
return false;
}
public abstract int GetIRQNumber();
public virtual void SetDma(i8237 dma_instance)
{
}
protected void ScheduleInterrupt(int cycles_delay)
{
next_interrupt.Add(cycles_delay);
}
protected bool CheckScheduledInterrupt(int cycles)
{
if (next_interrupt.Count > 0)
{
next_interrupt[0] -= cycles;
if (next_interrupt[0] <= 0)
{
next_interrupt.RemoveAt(0);
Log.DoLog($"CheckScheduledInterrupt triggered", LogLevel.DEBUG);
return true;
}
}
return false;
}
public virtual void SetPic(i8259 pic_instance)
{
_pic = pic_instance;
}
public virtual void SetBus(Bus bus_instance)
{
_b = bus_instance;
}
}