From 06aa177eef43579955b772dc4039997834ce720d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Fri, 9 Mar 2018 18:19:52 +0100 Subject: [PATCH] Getting ready to add a TSS. --- src/kernel/arch/x86/boot.s | 9 +++++ src/kernel/arch/x86/tss.h | 67 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 src/kernel/arch/x86/tss.h diff --git a/src/kernel/arch/x86/boot.s b/src/kernel/arch/x86/boot.s index c3f761c..cbb2926 100644 --- a/src/kernel/arch/x86/boot.s +++ b/src/kernel/arch/x86/boot.s @@ -86,6 +86,15 @@ gdt_udata: .byte 0b11001111 # 2nd flags | limit .byte 0x0 # base +# TODO: setup the TSS +gdt_tss: +.word 0x0 # size of TSS (set later) +.word 0x0 # address of TSS (set later) +.byte 0x0 # address of TSS (set later) +.byte 0b10010001 # 1st flags | type flags +.byte 0b01000000 # 2nd flags | size of TSS (set later +.byte 0x0 # address of TSS (set later) + gdt_end: gdtr: diff --git a/src/kernel/arch/x86/tss.h b/src/kernel/arch/x86/tss.h new file mode 100644 index 0000000..c3e8d45 --- /dev/null +++ b/src/kernel/arch/x86/tss.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2018 Ortega Froysa, Nicolás + * Author: Ortega Froysa, Nicolás + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +volatile struct tss { + uint16_t link; + uint16_t link_r; // reserved + + uint32_t esp0; + uint16_t ss0; + uint16_t ss0_r; // reserved + + uint32_t esp1; + uint16_t ss1; + uint16_t ss1_r; // reserved + + uint32_t esp2; + uint16_t ss2; + uint16_t ss2_r; // reserved + + uint32_t cr3; + uint32_t eip; + uint32_t eflags; + uint32_t eax; + uint32_t ecx; + uint32_t edx; + uint32_t ebx; + uint32_t esp; + uint32_t ebp; + uint32_t esi; + uint32_t edi; + + uint16_t es; + uint16_t es_r; // reserved + uint16_t cs; + uint16_t cs_r; // reserved + uint16_t ss; + uint16_t ss_r; // reserved + uint16_t ds; + uint16_t ds_r; // reserved + uint16_t fs; + uint16_t fs_r; // reserved + uint16_t gs; + uint16_t gs_r; // reserved + uint16_t ldtr; + uint16_t ldtr_r; // reserved + uint16_t iopb_r; // reserved + uint16_t iopb; +} __attribute__((packed)); + +struct tss tss;