openMSX
IRQHelper.cc
Go to the documentation of this file.
1 #include "IRQHelper.hh"
2 #include "DeviceConfig.hh"
3 #include "MSXCPU.hh"
4 #include "MSXException.hh"
5 #include "one_of.hh"
6 #include "unreachable.hh"
7 
8 namespace openmsx {
9 
10 // class IRQSource
11 
13  : cpu(cpu_)
14 {
15 }
16 
18 {
19  cpu.raiseIRQ();
20 }
21 
23 {
24  cpu.lowerIRQ();
25 }
26 
27 
28 // class OptionalIRQ
29 
31  : cpu(cpu_)
32  , type([&] {
33  auto connected = config.getChildData("irq_connected", "irq");
34  if (connected == one_of("irq", "true")) {
35  return Maskable;
36  } else if (connected == "nmi") {
37  return NonMaskable;
38  } else if (connected == "false") {
39  return NotConnected;
40  } else {
41  throw MSXException(
42  "Unknown IRQ sink \"", connected, "\" in <irq_connected>");
43  }
44  }())
45 {
46 }
47 
49 {
50  switch (type) {
51  case NotConnected:
52  // nothing
53  break;
54  case Maskable:
55  cpu.raiseIRQ();
56  break;
57  case NonMaskable:
58  cpu.raiseNMI();
59  break;
60  default:
62  }
63 }
64 
66 {
67  switch (type) {
68  case NotConnected:
69  // nothing
70  break;
71  case Maskable:
72  cpu.lowerIRQ();
73  break;
74  case NonMaskable:
75  cpu.lowerNMI();
76  break;
77  default:
79  }
80 }
81 
82 } // namespace openmsx
Definition: one_of.hh:7
std::string_view getChildData(std::string_view name) const
Definition: DeviceConfig.cc:48
IRQSource(MSXCPU &cpu)
Definition: IRQHelper.cc:12
void lowerNMI()
This methods lowers the non-maskable interrupt again.
Definition: MSXCPU.cc:300
void raiseIRQ()
This method raises a maskable interrupt.
Definition: MSXCPU.cc:285
void raiseNMI()
This method raises a non-maskable interrupt.
Definition: MSXCPU.cc:295
void lowerIRQ()
This methods lowers the maskable interrupt again.
Definition: MSXCPU.cc:290
OptionalIRQ(MSXCPU &cpu, const DeviceConfig &config)
Definition: IRQHelper.cc:30
This file implemented 3 utility functions:
Definition: Autofire.cc:9
#define UNREACHABLE
Definition: unreachable.hh:38