From 9f774825065de210438df83c1111dd0ab14016ff Mon Sep 17 00:00:00 2001 From: pjht Date: Fri, 24 Jul 2020 10:50:06 -0500 Subject: [PATCH] Remove uncessesary asm files --- kernel/cpu/i386/gdt.c | 14 +++++++++++--- kernel/cpu/i386/paging.c | 5 ++--- kernel/cpu/i386/paging_helpers.asm | 9 --------- kernel/cpu/i386/paging_helpers.h | 6 ------ kernel/cpu/i386/seg_upd.asm | 11 ----------- kernel/cpu/i386/seg_upd.h | 6 ------ 6 files changed, 13 insertions(+), 38 deletions(-) delete mode 100644 kernel/cpu/i386/paging_helpers.asm delete mode 100644 kernel/cpu/i386/paging_helpers.h delete mode 100644 kernel/cpu/i386/seg_upd.asm delete mode 100644 kernel/cpu/i386/seg_upd.h diff --git a/kernel/cpu/i386/gdt.c b/kernel/cpu/i386/gdt.c index 44e38cb..fce16b4 100644 --- a/kernel/cpu/i386/gdt.c +++ b/kernel/cpu/i386/gdt.c @@ -1,4 +1,3 @@ -#include "seg_upd.h" #include #include @@ -129,8 +128,17 @@ void gdt_init() { write_tss(5,0x10,int_stack_top+0xC0000000); gdt_desc.size=(sizeof(gdt_entry)*NUM_ENTRIES)-1; gdt_desc.address=gdt; - asm volatile("lgdt (%%eax)"::"a"((uint32_t)&gdt_desc)); - seg_upd(); + asm volatile(" \ + lgdt (%%eax); \ + jmp $0x8,$gdt_init_asm_code_upd; \ + gdt_init_asm_code_upd: \ + mov $0x10, %%ax; \ + mov %%ax, %%ds; \ + mov %%ax, %%ss; \ + mov %%ax, %%es; \ + mov %%ax, %%fs; \ + mov %%ax, %%gs; \ + "::"a"((uint32_t)&gdt_desc)); asm volatile("mov $0x2B, %ax; \ ltr %ax; \ "); diff --git a/kernel/cpu/i386/paging.c b/kernel/cpu/i386/paging.c index 68af825..2c25391 100644 --- a/kernel/cpu/i386/paging.c +++ b/kernel/cpu/i386/paging.c @@ -3,7 +3,6 @@ #include "../halt.h" #include "../paging.h" #include "arch_consts.h" -#include "paging_helpers.h" #include #include #include @@ -136,7 +135,7 @@ void* paging_new_address_space() { } void load_address_space(void* cr3) { - load_page_directory((uint32_t*)cr3); + asm volatile("movl %0, %%eax; movl %%eax, %%cr3;":"=m"(cr3)::"%eax"); } void unmap_pages(void* start_virt,int num_pages) { @@ -176,7 +175,7 @@ void paging_init() { page_directory[i+1018]=(entry_virt-0xC0000000)|0x3; } page_directory[1023]=((uint32_t)page_directory-0xC0000000)|0x3; - load_page_directory((uint32_t*)((uint32_t)page_directory-0xC0000000)); + load_address_space((uint32_t*)((uint32_t)page_directory-0xC0000000)); } void* get_cr3() { diff --git a/kernel/cpu/i386/paging_helpers.asm b/kernel/cpu/i386/paging_helpers.asm deleted file mode 100644 index d27ee3d..0000000 --- a/kernel/cpu/i386/paging_helpers.asm +++ /dev/null @@ -1,9 +0,0 @@ -global load_page_directory -load_page_directory: -push ebp -mov ebp, esp -mov eax, [esp+8] -mov cr3, eax -mov esp, ebp -pop ebp -ret diff --git a/kernel/cpu/i386/paging_helpers.h b/kernel/cpu/i386/paging_helpers.h deleted file mode 100644 index db3c8b4..0000000 --- a/kernel/cpu/i386/paging_helpers.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef PAGING_HELPERS_H -#define PAGING_HELPERS_H - -void load_page_directory(void* dir); - -#endif diff --git a/kernel/cpu/i386/seg_upd.asm b/kernel/cpu/i386/seg_upd.asm deleted file mode 100644 index d627c8d..0000000 --- a/kernel/cpu/i386/seg_upd.asm +++ /dev/null @@ -1,11 +0,0 @@ -global seg_upd -seg_upd: -jmp 0x8:code_upd -code_upd: -mov ax, 0x10 -mov ds, ax -mov ss, ax -mov es, ax -mov fs, ax -mov gs, ax -ret diff --git a/kernel/cpu/i386/seg_upd.h b/kernel/cpu/i386/seg_upd.h deleted file mode 100644 index 76c0248..0000000 --- a/kernel/cpu/i386/seg_upd.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef SEG_UPD_H -#define SEG_UPD_H - -void seg_upd(); - -#endif