Skip to content

Commit

Permalink
arch: Move Context struct into its own header
Browse files Browse the repository at this point in the history
  • Loading branch information
marv7000 committed Nov 24, 2024
1 parent 62f1cba commit 3810c3e
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 70 deletions.
3 changes: 1 addition & 2 deletions include/menix/system/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

#include <menix/system/boot.h>

#define MENIX_BITS_INCLUDE
#include <bits/arch.h>
#include <bits/asm.h>
#undef MENIX_BITS_INCLUDE
#include <bits/context.h>

#define arch_log(fmt, ...) kmesg("[" CONFIG_arch "]\t" fmt, ##__VA_ARGS__)

Expand Down
37 changes: 0 additions & 37 deletions kernel/arch/riscv64/include/bits/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,3 @@
#pragma once

#include <menix/common.h>

struct Context
{
u64 x31;
u64 x30;
u64 x29;
u64 x28;
u64 x27;
u64 x26;
u64 x25;
u64 x24;
u64 x23;
u64 x22;
u64 x21;
u64 x20;
u64 x19;
u64 x18;
u64 x17;
u64 x16;
u64 x15;
u64 x14;
u64 x13;
u64 x12;
u64 x11;
u64 x10;
u64 x9;
u64 x8;
u64 x7;
u64 x6;
u64 x5;
u64 x4;
u64 x3;
u64 x2;
u64 x1;

u64 pc;
};
40 changes: 40 additions & 0 deletions kernel/arch/riscv64/include/bits/context.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#pragma once

#include <menix/common.h>

struct Context
{
u64 x31;
u64 x30;
u64 x29;
u64 x28;
u64 x27;
u64 x26;
u64 x25;
u64 x24;
u64 x23;
u64 x22;
u64 x21;
u64 x20;
u64 x19;
u64 x18;
u64 x17;
u64 x16;
u64 x15;
u64 x14;
u64 x13;
u64 x12;
u64 x11;
u64 x10;
u64 x9;
u64 x8;
u64 x7;
u64 x6;
u64 x5;
u64 x4;
u64 x3;
u64 x2;
u64 x1;

u64 pc;
};
31 changes: 0 additions & 31 deletions kernel/arch/x86_64/include/bits/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,37 +208,6 @@
#define INT_TIMER 0x30
#define INT_SYSCALL 0x80

struct Context
{
u64 r15;
u64 r14;
u64 r13;
u64 r12;
u64 r11;
u64 r10;
u64 r9;
u64 r8;
u64 rsi;
u64 rdi;
u64 rbp;
u64 rdx;
u64 rcx;
u64 rbx;
u64 rax;

// Pushed onto the stack by the interrupt handler stub.
u64 core;
u64 isr;
// Pushed onto the stack by the CPU if exception has an error code.
u64 error;
// Pushed onto the stack by the CPU during an interrupt.
u64 rip;
u64 cs;
u64 rflags;
u64 rsp;
u64 ss;
};

typedef struct
{
u16 fcw;
Expand Down
33 changes: 33 additions & 0 deletions kernel/arch/x86_64/include/bits/context.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#pragma once
#include <menix/common.h>

struct Context
{
u64 r15;
u64 r14;
u64 r13;
u64 r12;
u64 r11;
u64 r10;
u64 r9;
u64 r8;
u64 rsi;
u64 rdi;
u64 rbp;
u64 rdx;
u64 rcx;
u64 rbx;
u64 rax;

// Pushed onto the stack by the interrupt handler stub.
u64 core;
u64 isr;
// Pushed onto the stack by the CPU if exception has an error code.
u64 error;
// Pushed onto the stack by the CPU during an interrupt.
u64 rip;
u64 cs;
u64 rflags;
u64 rsp;
u64 ss;
};

0 comments on commit 3810c3e

Please sign in to comment.