1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-04-19 20:37:34 +00:00

Adopt more consistent 'Pointer' naming; eliminate size warning.

This commit is contained in:
Thomas Harte 2025-03-20 15:33:07 -04:00
parent 5d1e3b6c93
commit 0c502fc9cf
4 changed files with 30 additions and 7 deletions

View File

@ -14,13 +14,36 @@ enum class DescriptorTable {
Global, Local, Interrupt,
};
struct DescriptorTableLocation {
struct DescriptorTablePointer {
uint16_t limit;
uint32_t base;
};
struct Descriptor {
void set_segment(const uint16_t segment) {
base_ = uint32_t(segment) << 4;
limit_ = std::numeric_limits<uint32_t>::max();
}
void set(uint64_t);
// 286:
// 47...32 = 16-bit limit;
// 31 = P
// 30...29 = DPL
// 28 = S
// 27...24 = type;
// 23...00 = 4-bit base.
template <typename IntT>
IntT to_linear(const IntT address) {
return base_ + address;
}
private:
uint32_t base_;
uint32_t limit_;
// TODO: permissions, type, etc.
};
}

View File

@ -98,7 +98,7 @@ void ldt(
source_address,
6);
DescriptorTableLocation location;
DescriptorTablePointer location;
location.limit =
context.memory.template access<uint16_t, AccessType::PreauthorisedRead>(segment, source_address);
location.base =

View File

@ -105,8 +105,8 @@ public:
// Words that straddle the segment end must be split in two.
if(offset == 0xffff) {
memory[address(segment, offset) & 0xf'ffff] = value & 0xff;
memory[address(segment, 0x0000) & 0xf'ffff] = value >> 8;
memory[address(segment, offset) & 0xf'ffff] = uint8_t(value & 0xff);
memory[address(segment, 0x0000) & 0xf'ffff] = uint8_t(value >> 8);
return;
}
@ -114,8 +114,8 @@ public:
// Words that straddle the end of physical RAM must also be split in two.
if(target == 0xf'ffff) {
memory[0xf'ffff] = value & 0xff;
memory[0x0'0000] = value >> 8;
memory[0xf'ffff] = uint8_t(value & 0xff);
memory[0x0'0000] = uint8_t(value >> 8);
return;
}

View File

@ -89,7 +89,7 @@ public:
uint16_t msw() const { return machine_status_; }
using DescriptorTable = InstructionSet::x86::DescriptorTable;
using DescriptorTableLocation = InstructionSet::x86::DescriptorTableLocation;
using DescriptorTableLocation = InstructionSet::x86::DescriptorTablePointer;
template <DescriptorTable table>
void set(const DescriptorTableLocation location) {