x86: better separation for i386 specific code
That's it, nothing major is gonna happen anymore until i get amd64 support working and deprecate the entire i386 branch. 32-bit just adds so many extra complications to memory management that i don't want to waste any more energy on this platform which is obsolete anyway.main
parent
36985f51e2
commit
03f31df67f
@ -0,0 +1,41 @@
|
||||
/* See the end of this file for copyright and license terms. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ARCH_INTERRUPT_H_
|
||||
#error "This file is not meant to be included directly, use <arch/interrupt.h>"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief A hardware stack frame on i386.
|
||||
* I have no idea whether x86 people are actually calling it hardware stack
|
||||
* frame tbh, this is just the (ARM) terminology i'm used to. Either way,
|
||||
* this is what gets pushed to the stack automatically when entering an ISR.
|
||||
*/
|
||||
struct i386_hw_frame {
|
||||
u32 eip;
|
||||
u16 cs; u16 _pad0;
|
||||
u32 eflags;
|
||||
|
||||
/*
|
||||
* On i386, these two are only pushed when entering from another
|
||||
* (i.e. lower) privilege level (???). This effectively means they don't
|
||||
* exist unless the CS above is equal to X86_USER_CS (arch/segment.h).
|
||||
*/
|
||||
u32 user_esp;
|
||||
u16 user_ss; u16 _pad1;
|
||||
} __packed;
|
||||
|
||||
/*
|
||||
* This file is part of GayBSD.
|
||||
* Copyright (c) 2021 fef <owo@fef.moe>.
|
||||
*
|
||||
* GayBSD is nonviolent software: you may only use, redistribute, and/or
|
||||
* modify it under the terms of the Cooperative Nonviolent Public License
|
||||
* (CNPL) as found in the LICENSE file in the source code root directory
|
||||
* or at <https://git.pixie.town/thufie/npl-builder>; either version 7
|
||||
* of the license, or (at your option) any later version.
|
||||
*
|
||||
* GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
|
||||
* permitted by applicable law. See the CNPL for details.
|
||||
*/
|
@ -0,0 +1,39 @@
|
||||
/* See the end of this file for copyright and license terms. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _ARCH_TRAP_H_
|
||||
#error "This file is not meant to be included directly, use <arch/trap.h>"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Complete context save on the i386.
|
||||
*/
|
||||
struct i386_trap_frame {
|
||||
/* extra pointer pushed manually, see the assembly routines */
|
||||
struct i386_hw_frame *hw_frame;
|
||||
|
||||
u32 edi;
|
||||
u32 esi;
|
||||
u32 ebp;
|
||||
u32 esp;
|
||||
u32 ebx;
|
||||
u32 edx;
|
||||
u32 ecx;
|
||||
u32 eax;
|
||||
} __packed;
|
||||
typedef struct i386_trap_frame trap_frame_t;
|
||||
|
||||
/*
|
||||
* This file is part of GayBSD.
|
||||
* Copyright (c) 2021 fef <owo@fef.moe>.
|
||||
*
|
||||
* GayBSD is nonviolent software: you may only use, redistribute, and/or
|
||||
* modify it under the terms of the Cooperative Nonviolent Public License
|
||||
* (CNPL) as found in the LICENSE file in the source code root directory
|
||||
* or at <https://git.pixie.town/thufie/npl-builder>; either version 7
|
||||
* of the license, or (at your option) any later version.
|
||||
*
|
||||
* GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
|
||||
* permitted by applicable law. See the CNPL for details.
|
||||
*/
|
@ -0,0 +1,37 @@
|
||||
/* See the end of this file for copyright and license terms. */
|
||||
|
||||
#include <arch/segment.h>
|
||||
#include <arch/trap.h>
|
||||
|
||||
#include <gay/kprintf.h>
|
||||
#include <gay/systm.h>
|
||||
|
||||
void print_regs(const struct i386_trap_frame *ctx)
|
||||
{
|
||||
u32 esp;
|
||||
if (ctx->hw_frame->cs == X86_USER_CS)
|
||||
esp = ctx->hw_frame->user_esp;
|
||||
else
|
||||
esp = ctx->esp - 3 * 4; /* eip, cs, eflags */
|
||||
|
||||
kprintf("EIP = %#x:%#08x\n", ctx->hw_frame->cs, ctx->hw_frame->eip);
|
||||
kprintf("EFLAGS = %#08x\n", ctx->hw_frame->eflags);
|
||||
kprintf("EAX = %#08x EDI = %#08x\n", ctx->eax, ctx->edi);
|
||||
kprintf("EBX = %#08x ESI = %#08x\n", ctx->ebx, ctx->esi);
|
||||
kprintf("ECX = %#08x ESP = %#08x\n", ctx->ecx, esp);
|
||||
kprintf("EDX = %#08x EBP = %#08x\n", ctx->edx, ctx->ebp);
|
||||
}
|
||||
|
||||
/*
|
||||
* This file is part of GayBSD.
|
||||
* Copyright (c) 2021 fef <owo@fef.moe>.
|
||||
*
|
||||
* GayBSD is nonviolent software: you may only use, redistribute, and/or
|
||||
* modify it under the terms of the Cooperative Nonviolent Public License
|
||||
* (CNPL) as found in the LICENSE file in the source code root directory
|
||||
* or at <https://git.pixie.town/thufie/npl-builder>; either version 7
|
||||
* of the license, or (at your option) any later version.
|
||||
*
|
||||
* GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
|
||||
* permitted by applicable law. See the CNPL for details.
|
||||
*/
|
Loading…
Reference in New Issue