From 0df6e64ecde564605c0f8cf8b56dbdb19d3e8c01 Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Thu, 19 Sep 2019 19:05:46 +0900 Subject: [PATCH] Remove the kernel stack from the struct cpu structure, since each task will be allocated its own kernel-mode stack; instead, the initial kernel stack will start at 0x200000 and disappear when the kernel switches into user mode --- kernel/arch/boot.S | 4 ++-- kernel/arch/cpu.h | 1 - kernel/arch/defs.h | 5 ++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/kernel/arch/boot.S b/kernel/arch/boot.S index 41b8551..c4d8517 100644 --- a/kernel/arch/boot.S +++ b/kernel/arch/boot.S @@ -36,8 +36,8 @@ _mb_header: loader: cli - movl $_cpu, %esp - addl $STACK0_TOP, %esp + movl $0x200000, %esp + movl %esp, %ebp movl %esp, %ebp pushl %eax pushl %ebx diff --git a/kernel/arch/cpu.h b/kernel/arch/cpu.h index 3b20b9a..53a671f 100644 --- a/kernel/arch/cpu.h +++ b/kernel/arch/cpu.h @@ -133,7 +133,6 @@ struct stack_frame { } __attribute__((packed)); struct cpu { - u8_t cpu_stack0[STACK0_SIZE]; segment_descriptor_t cpu_gdt[GDT_ENTRIES]; segment_descriptor_t cpu_idt[IDT_ENTRIES]; tss32_t cpu_tss; diff --git a/kernel/arch/defs.h b/kernel/arch/defs.h index cc2b14b..c0a6f0e 100644 --- a/kernel/arch/defs.h +++ b/kernel/arch/defs.h @@ -55,13 +55,12 @@ #define GDT_ENTRIES 16 #define IDT_ENTRIES 256 -#define STACK0_SIZE CONFIG_KERNEL_STACK_SIZE -#define STACK0_TOP STACK0_SIZE -#define GDT_OFFSET STACK0_SIZE +#define GDT_OFFSET 0 #define IDT_OFFSET (GDT_OFFSET + (GDT_ENTRIES * 8)) #define TSS_OFFSET (IDT_OFFSET + (IDT_ENTRIES * 8)) #define TSS_SIZE 102 +/* FIXME: Should this be RPL_USER for RPL_DRIVER / RPL_SYSTEM tasks? */ #define TSS_SEL (0x48 | RPL_USER) #define CR0_PG_BIT 0x80000000 -- 2.47.3