stos/amd64: cpu: Add exception handling groundwork
Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
@@ -13,4 +13,21 @@
|
||||
#define IDT_TRAP_GATE 0x8F
|
||||
#define IDT_USER_GATE 0xEE
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
/*
|
||||
* Set an IDT entry
|
||||
*
|
||||
* @Vector: Interrupt vector to set
|
||||
* @IsrBase: ISR base to set
|
||||
* @Type: Gate type
|
||||
* @Ist: Interrupt stack table index
|
||||
*/
|
||||
VOID MdIdtSetEntry(UCHAR Vector, UPTR IsrBase, UCHAR Type, UCHAR Ist);
|
||||
|
||||
/*
|
||||
* Load the IDT
|
||||
*/
|
||||
VOID MdIdtLoad(VOID);
|
||||
|
||||
#endif /* !__ASSEMBLER__ */
|
||||
#endif /* !_MACHINE_IDT_H_ */
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2026, Chloe M.
|
||||
* Provided under the BSD-3 clause.
|
||||
*
|
||||
* Description: Trap handling
|
||||
* Author: Chloe M.
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE_TRAP_H_
|
||||
#define _MACHINE_TRAP_H_ 1
|
||||
|
||||
#include <stdef.h>
|
||||
#include <machine/frame.h>
|
||||
|
||||
#define TRAP_DIVERR 0x00 /* Divide error */
|
||||
#define TRAP_DBG 0x01 /* Debug exception */
|
||||
#define TRAP_NMI 0x02 /* Non-maskable interrupt */
|
||||
#define TRAP_BP 0x03 /* Breakpoint */
|
||||
#define TRAP_OF 0x04 /* Overflow */
|
||||
#define TRAP_BR 0x05 /* BOUND range exceeded */
|
||||
#define TRAP_UD 0x06 /* Undefined opcode */
|
||||
#define TRAP_NM 0x07 /* No math coprocessor */
|
||||
#define TRAP_DF 0x08 /* Double fault */
|
||||
#define TRAP_CPR 0x09 /* Reserved */
|
||||
#define TRAP_TS 0x0A /* Invalid TSS */
|
||||
#define TRAP_NP 0x0B /* Segment not present */
|
||||
#define TRAP_SS 0x0C /* Stack segment fault */
|
||||
#define TRAP_GP 0x0D /* General protection fault */
|
||||
#define TRAP_PF 0x0E /* Page fault */
|
||||
|
||||
/*
|
||||
* Used for dispatching traps
|
||||
*
|
||||
* @Frame: Trap-frame associated with trap
|
||||
*/
|
||||
VOID MdTrapDispatch(TRAP_FRAME *Frame);
|
||||
|
||||
#endif /* !_MACHINE_TRAP_H_ */
|
||||
@@ -18,12 +18,14 @@
|
||||
* @KNOT_UNBOUND_RSRC: Unbounded resource
|
||||
* @KNOT_BAD_BOOT_PROTO: Bad boot protocol
|
||||
* @KNOT_OOM: Fatal out of memory
|
||||
* @KNOT_EXCEPTION: Fatal exception
|
||||
*/
|
||||
typedef enum {
|
||||
KNOT_MISC,
|
||||
KNOT_UNBOUND_RSRC,
|
||||
KNOT_BAD_BOOT_PROTO,
|
||||
KNOT_OOM
|
||||
KNOT_OOM,
|
||||
KNOT_EXCEPTION
|
||||
} KNOT_REASON;
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user