From 98d5547cfd89be04e3a0c0c7b6db02c00084bb25 Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Mon, 4 Nov 2019 10:46:32 +0900 Subject: [PATCH] Move definition of struct stack_frame to arch.h --- kernel/arch/cpu.h | 22 ---------------------- kernel/arch/interrupt.c | 1 + kernel/include/arch.h | 32 ++++++++++++++++++++++++++++++-- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/kernel/arch/cpu.h b/kernel/arch/cpu.h index f5b1349..da1062a 100644 --- a/kernel/arch/cpu.h +++ b/kernel/arch/cpu.h @@ -111,28 +111,6 @@ struct tss64 { u16_t rss64_iomap; } __attribute__((packed)); -typedef struct stack_frame stack_frame_t; - -struct stack_frame { - u32_t cr3; - u32_t ds; - u32_t edi; - u32_t esi; - u32_t ebp; - u32_t esp; - u32_t ebx; - u32_t edx; - u32_t ecx; - u32_t eax; - u32_t intn; - u32_t error; - u32_t eip; - u32_t cs; - u32_t eflags; - u32_t prevesp; - u32_t ss; -} __attribute__((packed)); - struct cpu { segment_descriptor_t cpu_gdt[GDT_ENTRIES]; segment_descriptor_t cpu_idt[IDT_ENTRIES]; diff --git a/kernel/arch/interrupt.c b/kernel/arch/interrupt.c index 346e404..c6af750 100644 --- a/kernel/arch/interrupt.c +++ b/kernel/arch/interrupt.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include "cpu.h" diff --git a/kernel/include/arch.h b/kernel/include/arch.h index 2d97c34..9722a9a 100644 --- a/kernel/include/arch.h +++ b/kernel/include/arch.h @@ -19,14 +19,39 @@ #ifndef __ARCH_H #define __ARCH_H -#include - #define TASK_STATE_NEW 0 #define TASK_STATE_RUNNING 1 #define TASK_STATE_READY 2 #define TASK_STATE_WAITING 3 #define TASK_STATE_BROKEN 4 #define TASK_STATE_EXIT 5 +#define TASK_STATE_FORKED 6 + +#ifndef __ASSEMBLY_SOURCE + +#include + +typedef struct stack_frame stack_frame_t; + +struct stack_frame { + u32_t cr3; + u32_t ds; + u32_t edi; + u32_t esi; + u32_t ebp; + u32_t esp; + u32_t ebx; + u32_t edx; + u32_t ecx; + u32_t eax; + u32_t intn; + u32_t error; + u32_t eip; + u32_t cs; + u32_t eflags; + u32_t prevesp; + u32_t ss; +} __attribute__((packed)); typedef struct task task_t; @@ -52,6 +77,7 @@ u64_t cpu_timestamp(void); u32_t cpu_set_pstate(int pstate); int task_prepare(struct task*, u32_t cr3, u32_t eip, u32_t esp0, u32_t esp, u32_t priv); +int task_prepare_fork(struct task*); int task_switch(struct task*); task_t* task_get_current(void); @@ -96,4 +122,6 @@ void* pg_dir_get_ustack(pg_dir_t*); int pg_dir_memcpy(pg_dir_t*, void*, pg_dir_t*, void*, u32_t); +#endif /* !__ASSEMBLY_SOURCE */ + #endif /* __ARCH_H */ -- 2.47.3