1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:57:45 +00:00

Kernel+Userland: Remove dependency on i386-specific registers

This commit is contained in:
Liav A 2022-10-04 05:39:57 +03:00 committed by Andreas Kling
parent 445b5e1e94
commit 85b453c2e4
18 changed files with 47 additions and 124 deletions

View file

@ -7,7 +7,7 @@
#pragma once #pragma once
#include <AK/Types.h> #include <AK/Types.h>
#include <LibC/sys/arch/i386/regs.h> #include <LibC/sys/arch/regs.h>
#include <Kernel/Arch/CPU.h> #include <Kernel/Arch/CPU.h>
#include <Kernel/Arch/x86/ASM_wrapper.h> #include <Kernel/Arch/x86/ASM_wrapper.h>

View file

@ -10,7 +10,7 @@
#include <AK/OwnPtr.h> #include <AK/OwnPtr.h>
#include <Kernel/Arch/RegisterState.h> #include <Kernel/Arch/RegisterState.h>
#include <Kernel/Forward.h> #include <Kernel/Forward.h>
#include <LibC/sys/arch/i386/regs.h> #include <LibC/sys/arch/regs.h>
namespace Kernel { namespace Kernel {

View file

@ -129,7 +129,7 @@ index 0000000..034252a
+#include "regset.h" +#include "regset.h"
+#include "target.h" +#include "target.h"
+ +
+#include <sys/arch/i386/regs.h> +#include <sys/arch/regs.h>
+#include <sys/ptrace.h> +#include <sys/ptrace.h>
+ +
+#include "i386-tdep.h" +#include "i386-tdep.h"

View file

@ -11,7 +11,7 @@
#include <AK/Platform.h> #include <AK/Platform.h>
#include <AK/StringBuilder.h> #include <AK/StringBuilder.h>
#include <AK/Try.h> #include <AK/Try.h>
#include <LibC/sys/arch/i386/regs.h> #include <LibC/sys/arch/regs.h>
#include <LibCore/ArgsParser.h> #include <LibCore/ArgsParser.h>
#include <LibCore/System.h> #include <LibCore/System.h>
#include <LibDebug/DebugInfo.h> #include <LibDebug/DebugInfo.h>

View file

@ -10,7 +10,7 @@
#include <LibDebug/ProcessInspector.h> #include <LibDebug/ProcessInspector.h>
#include <LibGUI/ListView.h> #include <LibGUI/ListView.h>
#include <LibGUI/Model.h> #include <LibGUI/Model.h>
#include <sys/arch/i386/regs.h> #include <sys/arch/regs.h>
namespace Debug { namespace Debug {

View file

@ -17,7 +17,7 @@
#include <LibGUI/ToolbarContainer.h> #include <LibGUI/ToolbarContainer.h>
#include <LibGUI/TreeView.h> #include <LibGUI/TreeView.h>
#include <LibGUI/Widget.h> #include <LibGUI/Widget.h>
#include <sys/arch/i386/regs.h> #include <sys/arch/regs.h>
namespace HackStudio { namespace HackStudio {

View file

@ -10,7 +10,7 @@
#include <AK/Vector.h> #include <AK/Vector.h>
#include <LibGUI/Model.h> #include <LibGUI/Model.h>
#include <LibX86/Instruction.h> #include <LibX86/Instruction.h>
#include <sys/arch/i386/regs.h> #include <sys/arch/regs.h>
namespace Debug { namespace Debug {

View file

@ -12,7 +12,7 @@
#include <LibGUI/Model.h> #include <LibGUI/Model.h>
#include <LibGUI/TableView.h> #include <LibGUI/TableView.h>
#include <LibGUI/Widget.h> #include <LibGUI/Widget.h>
#include <sys/arch/i386/regs.h> #include <sys/arch/regs.h>
namespace HackStudio { namespace HackStudio {

View file

@ -9,7 +9,7 @@
#include <AK/Vector.h> #include <AK/Vector.h>
#include <LibGUI/Model.h> #include <LibGUI/Model.h>
#include <sys/arch/i386/regs.h> #include <sys/arch/regs.h>
namespace HackStudio { namespace HackStudio {

View file

@ -10,7 +10,7 @@
#include <AK/NonnullOwnPtr.h> #include <AK/NonnullOwnPtr.h>
#include <LibGUI/Model.h> #include <LibGUI/Model.h>
#include <LibGUI/TreeView.h> #include <LibGUI/TreeView.h>
#include <sys/arch/i386/regs.h> #include <sys/arch/regs.h>
namespace HackStudio { namespace HackStudio {

View file

@ -6,118 +6,41 @@
#pragma once #pragma once
#include <AK/Types.h> #include <AK/Platform.h>
#define RREGISTER(num) \ #if defined(__cplusplus) && defined(__cpp_concepts)
union { \ # include <AK/Types.h>
u64 r##num; \ #else
struct { \ # include <sys/types.h>
u32 _unused##num; \ #endif
union { \
u32 r##num##d; \ #include <Kernel/Arch/mcontext.h>
struct { \
u16 __unused##num; \ #ifdef __cplusplus
union { \ struct [[gnu::packed]] PtraceRegisters : public __mcontext {
u16 r##num##w; \ #if defined(__cplusplus) && defined(__cpp_concepts)
struct { \ FlatPtr ip() const
u8 ___unused##num; \ {
u8 r##num##b; \ return rip;
}; \
}; \
}; \
}; \
}; \
} }
#define GPREGISTER(letter) \ void set_ip(FlatPtr ip)
union { \ {
u64 r##letter##x; \ rip = ip;
struct \
{ \
u32 _unused##letter; \
union { \
u32 e##letter##x; \
struct \
{ \
u16 __unused##letter; \
union { \
u16 letter##x; \
struct { \
u8 letter##h; \
u8 letter##l; \
}; \
}; \
}; \
}; \
}; \
} }
#define SPREGISTER(name) \ FlatPtr bp() const
union { \ {
u64 r##name; \ return rbp;
struct \
{ \
u32 _unused##name; \
union { \
u32 e##name; \
struct \
{ \
u16 __unused##name; \
union { \
u16 name; \
struct { \
u8 ___unused##name; \
u8 name##l; \
}; \
}; \
}; \
}; \
}; \
} }
struct [[gnu::packed]] PtraceRegisters { void set_bp(FlatPtr bp)
GPREGISTER(a); {
GPREGISTER(b); rbp = bp;
GPREGISTER(c); }
GPREGISTER(d); #endif
SPREGISTER(sp);
SPREGISTER(bp);
SPREGISTER(si);
SPREGISTER(di);
SPREGISTER(ip); // technically there is no ipl, but what ever
RREGISTER(8);
RREGISTER(9);
RREGISTER(10);
RREGISTER(11);
RREGISTER(12);
RREGISTER(13);
RREGISTER(14);
RREGISTER(15);
// flags
union {
u64 rflags;
struct {
u32 _;
union {
u32 eflags;
struct {
u16 __;
u16 flags;
};
};
};
};
// These may not be used, unless we go back into compatibility mode
u32 cs;
u32 ss;
u32 ds;
u32 es;
u32 fs;
u32 gs;
// FIXME: Add FPU registers and Flags
// FIXME: Add Ymm Xmm etc.
}; };
#else
typedef struct __mcontext PthreadRegisters;
#endif

View file

@ -15,7 +15,7 @@
#include <LibDebug/Dwarf/DwarfInfo.h> #include <LibDebug/Dwarf/DwarfInfo.h>
#include <LibDebug/Dwarf/LineProgram.h> #include <LibDebug/Dwarf/LineProgram.h>
#include <LibELF/Image.h> #include <LibELF/Image.h>
#include <sys/arch/i386/regs.h> #include <sys/arch/regs.h>
namespace Debug { namespace Debug {

View file

@ -13,7 +13,7 @@
#include <AK/NonnullRefPtr.h> #include <AK/NonnullRefPtr.h>
#include <AK/Optional.h> #include <AK/Optional.h>
#include <AK/OwnPtr.h> #include <AK/OwnPtr.h>
#include <LibC/sys/arch/i386/regs.h> #include <LibC/sys/arch/regs.h>
#include <LibCore/MappedFile.h> #include <LibCore/MappedFile.h>
#include <LibDebug/DebugInfo.h> #include <LibDebug/DebugInfo.h>
#include <LibDebug/ProcessInspector.h> #include <LibDebug/ProcessInspector.h>

View file

@ -8,7 +8,7 @@
#include <AK/Format.h> #include <AK/Format.h>
#include <AK/MemoryStream.h> #include <AK/MemoryStream.h>
#include <sys/arch/i386/regs.h> #include <sys/arch/regs.h>
namespace Debug::Dwarf::Expression { namespace Debug::Dwarf::Expression {

View file

@ -9,7 +9,7 @@
#include "LoadedLibrary.h" #include "LoadedLibrary.h"
#include <AK/Types.h> #include <AK/Types.h>
#include <LibC/sys/arch/i386/regs.h> #include <LibC/sys/arch/regs.h>
namespace Debug { namespace Debug {

View file

@ -7,7 +7,7 @@
#pragma once #pragma once
#include <AK/Types.h> #include <AK/Types.h>
#include <LibC/sys/arch/i386/regs.h> #include <LibC/sys/arch/regs.h>
#ifndef KERNEL #ifndef KERNEL
# include <AK/DeprecatedString.h> # include <AK/DeprecatedString.h>

View file

@ -9,7 +9,7 @@
#include <AK/NonnullOwnPtr.h> #include <AK/NonnullOwnPtr.h>
#include <AK/StringBuilder.h> #include <AK/StringBuilder.h>
#include <Kernel/API/SyscallString.h> #include <Kernel/API/SyscallString.h>
#include <LibC/sys/arch/i386/regs.h> #include <LibC/sys/arch/regs.h>
#include <LibCore/ArgsParser.h> #include <LibCore/ArgsParser.h>
#include <LibCore/File.h> #include <LibCore/File.h>
#include <LibCore/System.h> #include <LibCore/System.h>

View file

@ -10,7 +10,7 @@
#include <AK/StdLibExtras.h> #include <AK/StdLibExtras.h>
#include <AK/Types.h> #include <AK/Types.h>
#include <Kernel/API/SyscallString.h> #include <Kernel/API/SyscallString.h>
#include <LibC/sys/arch/i386/regs.h> #include <LibC/sys/arch/regs.h>
#include <LibCore/ArgsParser.h> #include <LibCore/ArgsParser.h>
#include <LibCore/Stream.h> #include <LibCore/Stream.h>
#include <LibCore/System.h> #include <LibCore/System.h>