From 5ea03fb258a9952846e73f3061bb4fca36ef9fd6 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sat, 24 Jul 2021 19:19:34 +0200 Subject: merge the `register` and `register_pushad` structs --- src/kernel/arch/i386/registers.h | 12 +++++------- src/kernel/arch/i386/sysenter.c | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'src/kernel/arch/i386') diff --git a/src/kernel/arch/i386/registers.h b/src/kernel/arch/i386/registers.h index 1264139..cca374d 100644 --- a/src/kernel/arch/i386/registers.h +++ b/src/kernel/arch/i386/registers.h @@ -1,15 +1,13 @@ #pragma once #include -// TODO merge registers and registers_pushad - struct registers { - uint32_t eax, ebx, ecx, edx, esi, edi; - void *ebp, *esp, *eip; -}; - -struct registers_pushad { + /* those are in the order of pushad/popad - so you can load/save this + * struct in (almost) one instruction */ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; + + // not part of pushad/popad, but still useful + uint32_t eip; } __attribute__((__packed__)); // saves a return value according to the SysV ABI diff --git a/src/kernel/arch/i386/sysenter.c b/src/kernel/arch/i386/sysenter.c index f3f5987..a7c7123 100644 --- a/src/kernel/arch/i386/sysenter.c +++ b/src/kernel/arch/i386/sysenter.c @@ -1,12 +1,12 @@ #include #include -struct registers_pushad _sysexit_regs; // a hack +struct registers _sysexit_regs; // a hack extern void _sysexit_real(); void sysexit(struct registers regs) { - _sysexit_regs = (struct registers_pushad) { + _sysexit_regs = (struct registers) { .eax = regs.eax, .ebx = regs.ebx, .ebp = regs.ebp, -- cgit v1.2.3