Serenity Operating System

Kernel+Userland: Remove dependency on i386-specific registers

authored by

Liav A and committed by
Andreas Kling
85b453c2 445b5e1e

+47 -124
+1 -1
Kernel/Arch/x86/RegisterState.h
··· 7 7 #pragma once 8 8 9 9 #include <AK/Types.h> 10 - #include <LibC/sys/arch/i386/regs.h> 10 + #include <LibC/sys/arch/regs.h> 11 11 12 12 #include <Kernel/Arch/CPU.h> 13 13 #include <Kernel/Arch/x86/ASM_wrapper.h>
+1 -1
Kernel/ThreadTracer.h
··· 10 10 #include <AK/OwnPtr.h> 11 11 #include <Kernel/Arch/RegisterState.h> 12 12 #include <Kernel/Forward.h> 13 - #include <LibC/sys/arch/i386/regs.h> 13 + #include <LibC/sys/arch/regs.h> 14 14 15 15 namespace Kernel { 16 16
+1 -1
Ports/gdb/patches/0002-serenity-Add-basic-ptrace-based-native-target-for-Se.patch
··· 129 129 +#include "regset.h" 130 130 +#include "target.h" 131 131 + 132 - +#include <sys/arch/i386/regs.h> 132 + +#include <sys/arch/regs.h> 133 133 +#include <sys/ptrace.h> 134 134 + 135 135 +#include "i386-tdep.h"
+1 -1
Userland/Applications/Debugger/main.cpp
··· 11 11 #include <AK/Platform.h> 12 12 #include <AK/StringBuilder.h> 13 13 #include <AK/Try.h> 14 - #include <LibC/sys/arch/i386/regs.h> 14 + #include <LibC/sys/arch/regs.h> 15 15 #include <LibCore/ArgsParser.h> 16 16 #include <LibCore/System.h> 17 17 #include <LibDebug/DebugInfo.h>
+1 -1
Userland/DevTools/HackStudio/Debugger/BacktraceModel.h
··· 10 10 #include <LibDebug/ProcessInspector.h> 11 11 #include <LibGUI/ListView.h> 12 12 #include <LibGUI/Model.h> 13 - #include <sys/arch/i386/regs.h> 13 + #include <sys/arch/regs.h> 14 14 15 15 namespace Debug { 16 16
+1 -1
Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.h
··· 17 17 #include <LibGUI/ToolbarContainer.h> 18 18 #include <LibGUI/TreeView.h> 19 19 #include <LibGUI/Widget.h> 20 - #include <sys/arch/i386/regs.h> 20 + #include <sys/arch/regs.h> 21 21 22 22 namespace HackStudio { 23 23
+1 -1
Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h
··· 10 10 #include <AK/Vector.h> 11 11 #include <LibGUI/Model.h> 12 12 #include <LibX86/Instruction.h> 13 - #include <sys/arch/i386/regs.h> 13 + #include <sys/arch/regs.h> 14 14 15 15 namespace Debug { 16 16
+1 -1
Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.h
··· 12 12 #include <LibGUI/Model.h> 13 13 #include <LibGUI/TableView.h> 14 14 #include <LibGUI/Widget.h> 15 - #include <sys/arch/i386/regs.h> 15 + #include <sys/arch/regs.h> 16 16 17 17 namespace HackStudio { 18 18
+1 -1
Userland/DevTools/HackStudio/Debugger/RegistersModel.h
··· 9 9 10 10 #include <AK/Vector.h> 11 11 #include <LibGUI/Model.h> 12 - #include <sys/arch/i386/regs.h> 12 + #include <sys/arch/regs.h> 13 13 14 14 namespace HackStudio { 15 15
+1 -1
Userland/DevTools/HackStudio/Debugger/VariablesModel.h
··· 10 10 #include <AK/NonnullOwnPtr.h> 11 11 #include <LibGUI/Model.h> 12 12 #include <LibGUI/TreeView.h> 13 - #include <sys/arch/i386/regs.h> 13 + #include <sys/arch/regs.h> 14 14 15 15 namespace HackStudio { 16 16
+30 -107
Userland/Libraries/LibC/sys/arch/x86_64/regs.h
··· 6 6 7 7 #pragma once 8 8 9 - #include <AK/Types.h> 9 + #include <AK/Platform.h> 10 10 11 - #define RREGISTER(num) \ 12 - union { \ 13 - u64 r##num; \ 14 - struct { \ 15 - u32 _unused##num; \ 16 - union { \ 17 - u32 r##num##d; \ 18 - struct { \ 19 - u16 __unused##num; \ 20 - union { \ 21 - u16 r##num##w; \ 22 - struct { \ 23 - u8 ___unused##num; \ 24 - u8 r##num##b; \ 25 - }; \ 26 - }; \ 27 - }; \ 28 - }; \ 29 - }; \ 11 + #if defined(__cplusplus) && defined(__cpp_concepts) 12 + # include <AK/Types.h> 13 + #else 14 + # include <sys/types.h> 15 + #endif 16 + 17 + #include <Kernel/Arch/mcontext.h> 18 + 19 + #ifdef __cplusplus 20 + struct [[gnu::packed]] PtraceRegisters : public __mcontext { 21 + #if defined(__cplusplus) && defined(__cpp_concepts) 22 + FlatPtr ip() const 23 + { 24 + return rip; 30 25 } 31 26 32 - #define GPREGISTER(letter) \ 33 - union { \ 34 - u64 r##letter##x; \ 35 - struct \ 36 - { \ 37 - u32 _unused##letter; \ 38 - union { \ 39 - u32 e##letter##x; \ 40 - struct \ 41 - { \ 42 - u16 __unused##letter; \ 43 - union { \ 44 - u16 letter##x; \ 45 - struct { \ 46 - u8 letter##h; \ 47 - u8 letter##l; \ 48 - }; \ 49 - }; \ 50 - }; \ 51 - }; \ 52 - }; \ 27 + void set_ip(FlatPtr ip) 28 + { 29 + rip = ip; 53 30 } 54 31 55 - #define SPREGISTER(name) \ 56 - union { \ 57 - u64 r##name; \ 58 - struct \ 59 - { \ 60 - u32 _unused##name; \ 61 - union { \ 62 - u32 e##name; \ 63 - struct \ 64 - { \ 65 - u16 __unused##name; \ 66 - union { \ 67 - u16 name; \ 68 - struct { \ 69 - u8 ___unused##name; \ 70 - u8 name##l; \ 71 - }; \ 72 - }; \ 73 - }; \ 74 - }; \ 75 - }; \ 32 + FlatPtr bp() const 33 + { 34 + return rbp; 76 35 } 77 36 78 - struct [[gnu::packed]] PtraceRegisters { 79 - GPREGISTER(a); 80 - GPREGISTER(b); 81 - GPREGISTER(c); 82 - GPREGISTER(d); 83 - 84 - SPREGISTER(sp); 85 - SPREGISTER(bp); 86 - SPREGISTER(si); 87 - SPREGISTER(di); 88 - SPREGISTER(ip); // technically there is no ipl, but what ever 89 - 90 - RREGISTER(8); 91 - RREGISTER(9); 92 - RREGISTER(10); 93 - RREGISTER(11); 94 - RREGISTER(12); 95 - RREGISTER(13); 96 - RREGISTER(14); 97 - RREGISTER(15); 98 - // flags 99 - union { 100 - u64 rflags; 101 - struct { 102 - u32 _; 103 - union { 104 - u32 eflags; 105 - struct { 106 - u16 __; 107 - u16 flags; 108 - }; 109 - }; 110 - }; 111 - }; 112 - 113 - // These may not be used, unless we go back into compatibility mode 114 - u32 cs; 115 - u32 ss; 116 - u32 ds; 117 - u32 es; 118 - u32 fs; 119 - u32 gs; 37 + void set_bp(FlatPtr bp) 38 + { 39 + rbp = bp; 40 + } 41 + #endif 42 + }; 120 43 121 - // FIXME: Add FPU registers and Flags 122 - // FIXME: Add Ymm Xmm etc. 123 - }; 44 + #else 45 + typedef struct __mcontext PthreadRegisters; 46 + #endif
+1 -1
Userland/Libraries/LibDebug/DebugInfo.h
··· 15 15 #include <LibDebug/Dwarf/DwarfInfo.h> 16 16 #include <LibDebug/Dwarf/LineProgram.h> 17 17 #include <LibELF/Image.h> 18 - #include <sys/arch/i386/regs.h> 18 + #include <sys/arch/regs.h> 19 19 20 20 namespace Debug { 21 21
+1 -1
Userland/Libraries/LibDebug/DebugSession.h
··· 13 13 #include <AK/NonnullRefPtr.h> 14 14 #include <AK/Optional.h> 15 15 #include <AK/OwnPtr.h> 16 - #include <LibC/sys/arch/i386/regs.h> 16 + #include <LibC/sys/arch/regs.h> 17 17 #include <LibCore/MappedFile.h> 18 18 #include <LibDebug/DebugInfo.h> 19 19 #include <LibDebug/ProcessInspector.h>
+1 -1
Userland/Libraries/LibDebug/Dwarf/Expression.cpp
··· 8 8 9 9 #include <AK/Format.h> 10 10 #include <AK/MemoryStream.h> 11 - #include <sys/arch/i386/regs.h> 11 + #include <sys/arch/regs.h> 12 12 13 13 namespace Debug::Dwarf::Expression { 14 14
+1 -1
Userland/Libraries/LibDebug/ProcessInspector.h
··· 9 9 10 10 #include "LoadedLibrary.h" 11 11 #include <AK/Types.h> 12 - #include <LibC/sys/arch/i386/regs.h> 12 + #include <LibC/sys/arch/regs.h> 13 13 14 14 namespace Debug { 15 15
+1 -1
Userland/Libraries/LibELF/Core.h
··· 7 7 #pragma once 8 8 9 9 #include <AK/Types.h> 10 - #include <LibC/sys/arch/i386/regs.h> 10 + #include <LibC/sys/arch/regs.h> 11 11 12 12 #ifndef KERNEL 13 13 # include <AK/DeprecatedString.h>
+1 -1
Userland/Utilities/functrace.cpp
··· 9 9 #include <AK/NonnullOwnPtr.h> 10 10 #include <AK/StringBuilder.h> 11 11 #include <Kernel/API/SyscallString.h> 12 - #include <LibC/sys/arch/i386/regs.h> 12 + #include <LibC/sys/arch/regs.h> 13 13 #include <LibCore/ArgsParser.h> 14 14 #include <LibCore/File.h> 15 15 #include <LibCore/System.h>
+1 -1
Userland/Utilities/strace.cpp
··· 10 10 #include <AK/StdLibExtras.h> 11 11 #include <AK/Types.h> 12 12 #include <Kernel/API/SyscallString.h> 13 - #include <LibC/sys/arch/i386/regs.h> 13 + #include <LibC/sys/arch/regs.h> 14 14 #include <LibCore/ArgsParser.h> 15 15 #include <LibCore/Stream.h> 16 16 #include <LibCore/System.h>