Finish GDT code

This commit is contained in:
Jenny Curle 2019-04-06 20:25:31 +01:00
parent 913c2d2844
commit 7c3dc4cacc
4 changed files with 24 additions and 20 deletions

View File

@ -17,22 +17,6 @@ stack_bottom:
.skip 16384
stack_top:
# GDT segment register setup
.global _gdt_flush
.extern _gp
_gdt_flush:
lgdt (_gp) #load the GDT with the special pointer
mov %ax, 0x10 #offset from GDT to data segment
mov %ds, ax
mov %es, ax
mov %fs, ax
mov %gs, ax
mov %ss, ax
jmp 0x08:flush2 #long jump
flush2:
ret #return to c code
# start function - calls kernel_main
.section .text
.global _start
@ -50,3 +34,22 @@ _start:
jmp 1b
.size _start, . - _start
# GDT segment register setup
.global gdt_flush
.extern gp
gdt_flush:
lgdt (gp) #load the GDT with the special pointer
mov %eax,0x10 #offset from GDT to data segment
mov %eax, %ds
mov %eax, %es
mov %eax, %fs
mov %eax, %gs
mov %eax, %ss
pushl 12(%esp)
push $flush2
ljmp *(%esp) #long jump
flush2:
ret #return to c code

View File

@ -1,7 +1,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
//#include <string.h>
#include "kernel/tty.h"
#include "kernel/utils.h"

View File

@ -48,3 +48,4 @@ void gdt_install() {
//Apply changes
gdt_flush();
}

View File

@ -6,7 +6,7 @@
int kernel_main(void) {
//Prepare the GDT
gdt_install()
gdt_install();
//Prepare the screen, and blank it out.
screen_initialize();