summaryrefslogtreecommitdiff
path: root/kernel/cpu
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-04-04 12:00:48 -0400
committerFreya Murphy <freya@freyacat.org>2025-04-04 12:00:48 -0400
commitceef8e2d87ec60042827e6d6aaf73b6df774051c (patch)
tree16721f404e8aeeba05d8769ceabab8334ed4d176 /kernel/cpu
parentswitch to c11 (diff)
downloadcomus-ceef8e2d87ec60042827e6d6aaf73b6df774051c.tar.gz
comus-ceef8e2d87ec60042827e6d6aaf73b6df774051c.tar.bz2
comus-ceef8e2d87ec60042827e6d6aaf73b6df774051c.zip
fmt
Diffstat (limited to 'kernel/cpu')
-rw-r--r--kernel/cpu/idt.c45
-rw-r--r--kernel/cpu/idt.h32
2 files changed, 22 insertions, 55 deletions
diff --git a/kernel/cpu/idt.c b/kernel/cpu/idt.c
index 3bdbe8d..3929990 100644
--- a/kernel/cpu/idt.c
+++ b/kernel/cpu/idt.c
@@ -1,7 +1,7 @@
-#include "stdlib.h"
#include <lib.h>
#include <comus/memory.h>
#include <comus/asm.h>
+#include <comus/cpu.h>
#include "idt.h"
#include "pic.h"
@@ -70,7 +70,7 @@ void idt_init(void)
__asm__ volatile("lidt %0" : : "m"(idtr));
}
-static void isr_print_regs(struct isr_regs *regs)
+static void isr_print_regs(regs_t *regs)
{
printf("rax: %#016lx (%lu)\n", regs->rax, regs->rax);
printf("rbx: %#016lx (%lu)\n", regs->rbx, regs->rbx);
@@ -89,44 +89,43 @@ static void isr_print_regs(struct isr_regs *regs)
printf("r14: %#016lx (%lu)\n", regs->r14, regs->r14);
printf("r15: %#016lx (%lu)\n", regs->r15, regs->r15);
printf("rip: %#016lx (%lu)\n", regs->rip, regs->rip);
- printf("rflags: %#016lx (%lu)\n", regs->rflags, regs->rflags);
- struct rflags *rflags = (struct rflags *)regs->rflags;
+ printf("rflags: %#016lx (%lu)\n", (uint64_t)regs->rflags.raw, (uint64_t)regs->rflags.raw);
puts("rflags: ");
- if (rflags->cf)
+ if (regs->rflags.cf)
puts("CF ");
- if (rflags->pf)
+ if (regs->rflags.pf)
puts("PF ");
- if (rflags->af)
+ if (regs->rflags.af)
puts("AF ");
- if (rflags->zf)
+ if (regs->rflags.zf)
puts("ZF ");
- if (rflags->sf)
+ if (regs->rflags.sf)
puts("SF ");
- if (rflags->tf)
+ if (regs->rflags.tf)
puts("TF ");
- if (rflags->if_)
+ if (regs->rflags.if_)
puts("IF ");
- if (rflags->df)
+ if (regs->rflags.df)
puts("DF ");
- if (rflags->of)
+ if (regs->rflags.of)
puts("OF ");
- if (rflags->iopl)
+ if (regs->rflags.iopl)
puts("IOPL ");
- if (rflags->nt)
+ if (regs->rflags.nt)
puts("NT ");
- if (rflags->md)
+ if (regs->rflags.md)
puts("MD ");
- if (rflags->rf)
+ if (regs->rflags.rf)
puts("RF ");
- if (rflags->vm)
+ if (regs->rflags.vm)
puts("VM ");
- if (rflags->ac)
+ if (regs->rflags.ac)
puts("AC ");
- if (rflags->vif)
+ if (regs->rflags.vif)
puts("VIF ");
- if (rflags->vip)
+ if (regs->rflags.vip)
puts("VIP ");
- if (rflags->id)
+ if (regs->rflags.id)
puts("ID ");
puts("\n");
}
@@ -172,7 +171,7 @@ char *EXCEPTIONS[] = {
};
void idt_exception_handler(uint64_t exception, uint64_t code,
- struct isr_regs *state)
+ regs_t *state)
{
uint64_t cr2;
diff --git a/kernel/cpu/idt.h b/kernel/cpu/idt.h
index 7f1d9e6..99a811d 100644
--- a/kernel/cpu/idt.h
+++ b/kernel/cpu/idt.h
@@ -11,38 +11,6 @@
#include <stdint.h>
-struct isr_regs {
- uint64_t r15;
- uint64_t r14;
- uint64_t r13;
- uint64_t r12;
- uint64_t r11;
- uint64_t r10;
- uint64_t r9;
- uint64_t r8;
- uint64_t rbp;
- uint64_t rdi;
- uint64_t rsi;
- uint64_t rdx;
- uint64_t rcx;
- uint64_t rbx;
- uint64_t rax;
-
- uint64_t rip;
- uint64_t cs;
- uint64_t rflags;
- uint64_t rsp;
- uint64_t ss;
-};
-
-struct rflags {
- uint64_t cf : 1, : 1, pf : 1, : 1, af : 1, : 1, zf : 1, sf : 1,
-
- tf : 1, if_ : 1, df : 1, of : 1, iopl : 2, nt : 1, md : 1,
-
- rf : 1, vm : 1, ac : 1, vif : 1, vip : 1, id : 1, : 42;
-};
-
void idt_init(void);
#endif /* idt.h */