mirror of
https://github.com/TomHarte/CLK.git
synced 2026-04-21 02:17:08 +00:00
Add TSS deserialiser.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "Resolver.hpp"
|
||||
#include "Stack.hpp"
|
||||
#include "InstructionSets/x86/TaskStateSegment.hpp"
|
||||
#include "InstructionSets/x86/AccessType.hpp"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// TaskStateSegment.hpp
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 20/05/2025.
|
||||
// Copyright © 2025 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Mode.hpp"
|
||||
|
||||
namespace InstructionSet::x86 {
|
||||
|
||||
template <Mode mode>
|
||||
struct TaskStateSegment;
|
||||
|
||||
template <>
|
||||
struct TaskStateSegment<Mode::Protected286> {
|
||||
static constexpr uint32_t Size = 44;
|
||||
|
||||
template <typename LinearMemoryT>
|
||||
static TaskStateSegment read(LinearMemoryT &memory, const uint32_t base, const uint32_t limit) {
|
||||
uint32_t c = 0;
|
||||
const auto read = [&]() {
|
||||
const auto value = memory.template access<uint16_t, AccessType::Read>(base + c, limit);
|
||||
c += 2;
|
||||
return value;
|
||||
};
|
||||
|
||||
TaskStateSegment result;
|
||||
result.back_link = read();
|
||||
result.stacks[0].offset = read();
|
||||
result.stacks[0].segment = read();
|
||||
result.stacks[1].offset = read();
|
||||
result.stacks[1].segment = read();
|
||||
result.stacks[2].offset = read();
|
||||
result.stacks[2].segment = read();
|
||||
result.instruction_pointer = read();
|
||||
result.flags = read();
|
||||
|
||||
result.ax = read();
|
||||
result.cx = read();
|
||||
result.dx = read();
|
||||
result.bx = read();
|
||||
|
||||
result.sp = read();
|
||||
result.bp = read();
|
||||
result.si = read();
|
||||
result.di = read();
|
||||
|
||||
result.es_selector = read();
|
||||
result.cs_selector = read();
|
||||
result.ss_selector = read();
|
||||
result.ds_selector = read();
|
||||
|
||||
result.ldt_selector = read();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
uint16_t back_link;
|
||||
struct StackPointer {
|
||||
uint16_t offset;
|
||||
uint16_t segment;
|
||||
};
|
||||
StackPointer stacks[3]; // Indexed by CPL.
|
||||
uint16_t instruction_pointer;
|
||||
uint16_t flags;
|
||||
uint16_t ax, cx, dx, bx;
|
||||
uint16_t sp, bp, si, di;
|
||||
uint16_t es_selector;
|
||||
uint16_t cs_selector;
|
||||
uint16_t ss_selector;
|
||||
uint16_t ds_selector;
|
||||
uint16_t ldt_selector;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1472,6 +1472,7 @@
|
||||
4B228CDA24DA41880077EF25 /* ScanTarget.metal */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.metal; path = ScanTarget.metal; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.metal; };
|
||||
4B24095A1C45DF85004DA684 /* Stepper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Stepper.hpp; sourceTree = "<group>"; };
|
||||
4B2530F3244E6773007980BF /* fm.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = fm.json; sourceTree = "<group>"; };
|
||||
4B25BC1E2DDD64AA002044CA /* TaskStateSegment.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = TaskStateSegment.hpp; sourceTree = "<group>"; };
|
||||
4B262BFF29691F55002EC0F7 /* PersonalityTraits.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = PersonalityTraits.hpp; sourceTree = "<group>"; };
|
||||
4B2A1CD92BA775C5004496CE /* I2C.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = I2C.cpp; sourceTree = "<group>"; };
|
||||
4B2A1CDA2BA775C5004496CE /* I2C.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = I2C.hpp; sourceTree = "<group>"; };
|
||||
@@ -5376,6 +5377,7 @@
|
||||
4B8671EB2D8FABA0009E1610 /* Mode.hpp */,
|
||||
4BE3C69527CBC540000EAD28 /* Model.hpp */,
|
||||
42437B352ACF0AA2006DFED1 /* Perform.hpp */,
|
||||
4B25BC1E2DDD64AA002044CA /* TaskStateSegment.hpp */,
|
||||
42437B372ACF2798006DFED1 /* Implementation */,
|
||||
);
|
||||
path = x86;
|
||||
|
||||
Reference in New Issue
Block a user