aboutsummaryrefslogtreecommitdiff
path: root/src/arch/x86_64/arch_regs.rs
diff options
context:
space:
mode:
authorTianhao Wang <shrik3@mailbox.org>2024-06-05 07:56:16 +0200
committerTianhao Wang <shrik3@mailbox.org>2024-06-11 15:17:13 +0200
commitd6815a5903716c058c4f8bee89bfa745ee752c9d (patch)
tree1f3027cf3b98571b7a5fe24b80cf0382209bc69a /src/arch/x86_64/arch_regs.rs
parente35e9f4c88be4ca7bf08970109c1ff8d90018b02 (diff)
proc: interrupt: define context and trap frame
Signed-off-by: Tianhao Wang <shrik3@mailbox.org>
Diffstat (limited to 'src/arch/x86_64/arch_regs.rs')
-rw-r--r--src/arch/x86_64/arch_regs.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/arch/x86_64/arch_regs.rs b/src/arch/x86_64/arch_regs.rs
new file mode 100644
index 0000000..a49926e
--- /dev/null
+++ b/src/arch/x86_64/arch_regs.rs
@@ -0,0 +1,43 @@
+use core::arch::asm;
+
+/// arch specific registers
+#[repr(C)]
+#[repr(packed)]
+#[derive(Debug)]
+pub struct Context64 {
+ pub rbx: u64,
+ pub r12: u64,
+ pub r13: u64,
+ pub r14: u64,
+ pub r15: u64,
+ pub rbp: u64,
+ pub rsp: u64,
+ pub fpu: [u8; 108],
+}
+
+/// arch specific registers
+#[repr(C)]
+#[repr(packed)]
+#[derive(Debug)]
+pub struct TrapFrame {
+ pub r11: u64,
+ pub r10: u64,
+ pub r9: u64,
+ pub r8: u64,
+ pub rsi: u64,
+ pub rdi: u64,
+ pub rdx: u64,
+ pub rcx: u64,
+ pub rax: u64,
+ pub err_code: u64,
+}
+
+// this will get the current (kernel) stack pointer
+#[inline]
+pub fn get_sp() -> u64 {
+ let sp: u64;
+ unsafe {
+ asm!("mov {}, rsp", out(reg) sp);
+ }
+ return sp;
+}