From ebdc816d82a667983625bc7e1bee3f99702d2bc8 Mon Sep 17 00:00:00 2001 From: Edgaru089 Date: Thu, 14 Oct 2021 14:45:57 +0800 Subject: [PATCH] interrupt: make LoadIDT/GDT() inline --- interrupt/interrupt.h | 11 +++++++++-- interrupt/load_gdt.S | 18 ------------------ 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/interrupt/interrupt.h b/interrupt/interrupt.h index e9347cb..335272d 100644 --- a/interrupt/interrupt.h +++ b/interrupt/interrupt.h @@ -51,10 +51,17 @@ SYSV_ABI void interrupt_MapHandler(void *handler, int interrupt); SYSV_ABI void interrupt_Handler(int vec, int errcode, uint64_t rip, uint64_t rax, uint64_t rbx, uint64_t rcx, uint64_t rdx, uint64_t rsi, uint64_t rdi, uint64_t rbp, uint64_t rsp, uint64_t r8, uint64_t r9, uint64_t r10, uint64_t r11, uint64_t r12, uint64_t r13, uint64_t r14, uint64_t r15); // defined in assembly -SYSV_ABI void interrupt_LoadGDT(void *gdtr); -SYSV_ABI void interrupt_LoadIDT(void *idtr); SYSV_ABI void interrupt_ReloadSegments(); +inline void interrupt_LoadGDT(interrupt_DescriptorTableReference *gdtr) { + asm volatile("lgdt %0" + : "=m"(*gdtr)); +} +inline void interrupt_LoadIDT(interrupt_DescriptorTableReference *idtr) { + asm volatile("lidt %0" + : "=m"(*idtr)); +} + #define INTERRUPT_DISABLE \ uintptr_t __interrupt_flags; \ diff --git a/interrupt/load_gdt.S b/interrupt/load_gdt.S index 79a9d70..8f549a6 100644 --- a/interrupt/load_gdt.S +++ b/interrupt/load_gdt.S @@ -1,20 +1,10 @@ format elf64 public interrupt_ReloadSegments -public interrupt_LoadGDT -public interrupt_LoadIDT section '.text' executable -; sysvx64call void interrupt_LoadGDT(void* gdtr) -; -; Input: (void* rdi) -; Clobbers: none -interrupt_LoadGDT: - lgdt [rdi] - ret - ; sysvx64call void interrupt_ReloadSegments() ; ; Clobbers: rax @@ -35,11 +25,3 @@ interrupt_ReloadSegments: push rax retfq -; sysvx64call void interrupt_LoadIDT(void* idtr) -; -; Input: (void* rdi) -; Clobbers: none -interrupt_LoadIDT: - lidt [rdi] - ret -