initialise a memory structure or smth

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2023-09-11 10:23:46 +05:30
parent 84c68a4e00
commit 332f0b87d6
26 changed files with 763 additions and 163 deletions

49
src/cpu/psr.cc Normal file
View File

@@ -0,0 +1,49 @@
#include "psr.hh"
#include "util/bits.hh"
Psr::Psr(uint32_t raw) {
psr = raw & PSR_CLEAR_RESERVED;
}
Mode
Psr::mode() const {
return static_cast<Mode>(psr & ~PSR_CLEAR_MODE);
}
void
Psr::set_mode(Mode mode) {
psr &= PSR_CLEAR_MODE;
psr |= static_cast<uint32_t>(mode);
}
bool
Psr::state() const {
return get_nth_bit(psr, 5);
}
void
Psr::set_state(State state) {
chg_nth_bit(psr, 5, static_cast<bool>(state));
}
#define GET_SET_NTH_BIT_FUNCTIONS(name, n) \
bool Psr::name() const { \
return get_nth_bit(psr, n); \
} \
void Psr::set_##name(bool val) { \
chg_nth_bit(psr, n, val); \
}
GET_SET_NTH_BIT_FUNCTIONS(fiq_disabled, 6)
GET_SET_NTH_BIT_FUNCTIONS(irq_disabled, 7)
GET_SET_NTH_BIT_FUNCTIONS(v, 28);
GET_SET_NTH_BIT_FUNCTIONS(c, 29);
GET_SET_NTH_BIT_FUNCTIONS(z, 30);
GET_SET_NTH_BIT_FUNCTIONS(n, 31);
#undef GET_SET_NTH_BIT_FUNCTIONS