summaryrefslogtreecommitdiff
path: root/src/kernel/arch/i386
diff options
context:
space:
mode:
authordzwdz2022-04-11 23:29:30 +0200
committerdzwdz2022-04-11 23:29:30 +0200
commit75ec633805db108bfddb6454ff7f8d812475feaf (patch)
tree6d558a64569648b9b425e3a568edc67c6d06298b /src/kernel/arch/i386
parent07b7e8ad787180b7e3eaccc819b9e5c4802edfcd (diff)
kernel: implement `cpu_pause()` in assembly, remove `irq_interrupt_flag()`
Diffstat (limited to 'src/kernel/arch/i386')
-rw-r--r--src/kernel/arch/i386/boot.s9
-rw-r--r--src/kernel/arch/i386/interrupts/irq.c5
-rw-r--r--src/kernel/arch/i386/interrupts/irq.h2
-rw-r--r--src/kernel/arch/i386/sysenter.c3
-rw-r--r--src/kernel/arch/i386/sysenter.s2
5 files changed, 11 insertions, 10 deletions
diff --git a/src/kernel/arch/i386/boot.s b/src/kernel/arch/i386/boot.s
index ea31aa1..24c076f 100644
--- a/src/kernel/arch/i386/boot.s
+++ b/src/kernel/arch/i386/boot.s
@@ -23,3 +23,12 @@ halt_cpu:
cli
1: hlt
jmp 1b
+
+
+.global cpu_pause
+.type cpu_pause, @function
+cpu_pause:
+ sti
+ hlt
+ cli
+ ret
diff --git a/src/kernel/arch/i386/interrupts/irq.c b/src/kernel/arch/i386/interrupts/irq.c
index 7b8c166..5918169 100644
--- a/src/kernel/arch/i386/interrupts/irq.c
+++ b/src/kernel/arch/i386/interrupts/irq.c
@@ -31,8 +31,3 @@ void irq_eoi(uint8_t line) {
if (line >= 8)
port_out8(PIC2, 0x20);
}
-
-void irq_interrupt_flag(bool flag) {
- if (flag) asm("sti" : : : "memory");
- else asm("cli" : : : "memory");
-}
diff --git a/src/kernel/arch/i386/interrupts/irq.h b/src/kernel/arch/i386/interrupts/irq.h
index 73d4af2..f523154 100644
--- a/src/kernel/arch/i386/interrupts/irq.h
+++ b/src/kernel/arch/i386/interrupts/irq.h
@@ -4,5 +4,3 @@
void irq_init(void);
void irq_eoi(uint8_t line);
-
-void irq_interrupt_flag(bool flag);
diff --git a/src/kernel/arch/i386/sysenter.c b/src/kernel/arch/i386/sysenter.c
index 1aee254..5712ee3 100644
--- a/src/kernel/arch/i386/sysenter.c
+++ b/src/kernel/arch/i386/sysenter.c
@@ -1,5 +1,4 @@
#include <kernel/arch/generic.h>
-#include <kernel/arch/i386/interrupts/irq.h>
#include <kernel/arch/i386/sysenter.h>
#include <kernel/proc.h>
#include <shared/syscalls.h>
@@ -22,8 +21,6 @@ _Noreturn void sysenter_stage2(void) {
regs->esp = (userptr_t) regs->ecx; // fix them up
regs->eip = (userptr_t) regs->edx;
- irq_interrupt_flag(false);
-
val = _syscall(regs->eax, regs->ebx,
regs->esi, regs->edi, (uintptr_t)regs->ebp);
if (process_current->state == PS_RUNNING) { // TODO move to _syscall()
diff --git a/src/kernel/arch/i386/sysenter.s b/src/kernel/arch/i386/sysenter.s
index db65a8c..ade69ec 100644
--- a/src/kernel/arch/i386/sysenter.s
+++ b/src/kernel/arch/i386/sysenter.s
@@ -48,6 +48,8 @@ sysenter_setup:
ret
sysenter_stage1:
+ cli /* prevent random IRQs in the middle of kernel code */
+
// disable paging
// I don't want to damage any of the registers passed in by the user,
// so i'm using ESP as a temporary register. At this point there's nothing