Port InterruptIOs
This commit is contained in:
parent
1143f73f9b
commit
a0cef63369
|
@ -4,42 +4,42 @@
|
||||||
|
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
struct Interrupt {
|
struct Interrupt {
|
||||||
static constexpr auto VBlank = Bit<uint32_t>(0);
|
static constexpr auto VBlank = IOBitSet(0);
|
||||||
static constexpr auto GPU = Bit<uint32_t>(1);
|
static constexpr auto GPU = IOBitSet(1);
|
||||||
static constexpr auto CDROM = Bit<uint32_t>(2);
|
static constexpr auto CDROM = IOBitSet(2);
|
||||||
static constexpr auto DMA = Bit<uint32_t>(3);
|
static constexpr auto DMA = IOBitSet(3);
|
||||||
static constexpr auto Timer0 = Bit<uint32_t>(4);
|
static constexpr auto Timer0 = IOBitSet(4);
|
||||||
static constexpr auto Timer1 = Bit<uint32_t>(5);
|
static constexpr auto Timer1 = IOBitSet(5);
|
||||||
static constexpr auto Timer2 = Bit<uint32_t>(6);
|
static constexpr auto Timer2 = IOBitSet(6);
|
||||||
static constexpr auto Periphery = Bit<uint32_t>(7);
|
static constexpr auto Periphery = IOBitSet(7);
|
||||||
static constexpr auto SIO = Bit<uint32_t>(8);
|
static constexpr auto SIO = IOBitSet(8);
|
||||||
static constexpr auto SPU = Bit<uint32_t>(9);
|
static constexpr auto SPU = IOBitSet(9);
|
||||||
static constexpr auto Controller = Bit<uint32_t>(10);
|
static constexpr auto Controller = IOBitSet(10);
|
||||||
static constexpr auto LightPen = Controller;
|
static constexpr auto LightPen = Controller;
|
||||||
|
|
||||||
typedef struct Status : public ComplexBitMap<uint32_t> {
|
__declare_io_type(Status, uint32_t,
|
||||||
} Status_t;
|
);
|
||||||
|
|
||||||
typedef struct Mask : public ComplexBitMap<uint32_t> {
|
__declare_io_type(Mask, uint32_t,
|
||||||
} Mask_t;
|
);
|
||||||
|
|
||||||
__declare_io_port_member(Status_t, Status, 0x1F801070);
|
__declare_new_io_port(Status, 0x1F801070);
|
||||||
__declare_io_port_member(Mask_t, Mask, 0x1F801074);
|
__declare_new_io_port(Mask, 0x1F801074);
|
||||||
|
|
||||||
static bool is_irq(Bit<uint32_t> irq) {
|
static constexpr bool is_irq(IOBitSet irq) {
|
||||||
return Status.read().is_bit_set(irq);
|
return Status.is_set(irq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ack_irq(Bit<uint32_t> irq) {
|
static constexpr void ack_irq(IOBitSet irq) {
|
||||||
Status.write({Status.read().clear_bit(irq)});
|
Status.clear(irq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void disable_irq(Bit<uint32_t> irq) {
|
static constexpr void disable_irq(IOBitSet irq) {
|
||||||
Mask.write({Mask.read().clear_bit(irq)});
|
Mask.clear(irq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void enable_irq(Bit<uint32_t> irq) {
|
static void enable_irq(IOBitSet irq) {
|
||||||
Mask.write({Mask.read().set_bit(irq)});
|
Mask.set(irq);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue