fix (kernel): fixed #GPF on iretq bug
This commit is contained in:
parent
e28a2eb2ff
commit
1f290c3414
|
@ -20,38 +20,8 @@
|
|||
|
||||
typedef enum {
|
||||
GDT_SELECTOR_NULL = 0x00,
|
||||
GDT_SELECTOR_KERNEL_CODE = 0x08,
|
||||
GDT_SELECTOR_KERNEL_DATA = 0x10,
|
||||
GDT_SELECTOR_USER_NULL = 0x18,
|
||||
GDT_SELECTOR_USER_CODE = 0x20,
|
||||
GDT_SELECTOR_USER_DATA = 0x28
|
||||
GDT_SELECTOR_KERNEL_CODE = 0x28,
|
||||
GDT_SELECTOR_KERNEL_DATA = 0x30,
|
||||
} gdt_selector_E;
|
||||
|
||||
typedef struct {
|
||||
uint16_t size;
|
||||
uint64_t offset;
|
||||
}__attribute__((packed)) gdt_descriptor_T;
|
||||
|
||||
typedef struct {
|
||||
uint16_t limit0;
|
||||
uint16_t base0;
|
||||
uint8_t base1;
|
||||
uint8_t access;
|
||||
uint8_t limit1_flags;
|
||||
uint8_t base2;
|
||||
}__attribute__((packed)) gdt_entry_T;
|
||||
|
||||
typedef struct {
|
||||
gdt_entry_T null; // 0x00
|
||||
gdt_entry_T kernel_code; // 0x08
|
||||
gdt_entry_T kernel_data; // 0x10
|
||||
gdt_entry_T user_null; // 0x18
|
||||
gdt_entry_T user_code; // 0x20
|
||||
gdt_entry_T user_data; // 0x28
|
||||
}__attribute__((packed)) __attribute__((aligned(0x1000))) gdt_T;
|
||||
|
||||
extern gdt_T g_default_gdt;
|
||||
|
||||
void gdt_init();
|
||||
|
||||
#endif //NOX_GDT_H
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
/* Copyright (C) Antifallobst <antifallobst@systemausfall.org>
|
||||
*
|
||||
* NoxOS 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.
|
||||
*
|
||||
* NoxOS 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "platform/gdt.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
extern void gdt_load(gdt_descriptor_T* gdt_descriptor);
|
||||
|
||||
__attribute__((aligned(0x1000)))
|
||||
gdt_T g_default_gdt = {
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x9A, 0xA0, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x92, 0xA0, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x9A, 0xA0, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x92, 0xA0, 0x00}
|
||||
};
|
||||
|
||||
void gdt_init() {
|
||||
gdt_descriptor_T descriptor;
|
||||
|
||||
descriptor.size = sizeof(gdt_T) - 1;
|
||||
descriptor.offset = (uint64_t)&g_default_gdt;
|
||||
|
||||
gdt_load(&descriptor);
|
||||
log(LOG_INFO, "GDT loaded");
|
||||
}
|
Loading…
Reference in New Issue