From 7c3dc4cacc2badb82c5bfe97c10b9277a2da10be Mon Sep 17 00:00:00 2001 From: Jenny Curle Date: Sat, 6 Apr 2019 20:25:31 +0100 Subject: [PATCH] Finish GDT code --- arch/i386/boot.s | 37 ++++++++++++++++++++----------------- arch/i386/tty.c | 2 +- kernel/gdt.c | 3 ++- kernel/kernel.c | 2 +- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/arch/i386/boot.s b/arch/i386/boot.s index b1be172..76b5444 100755 --- a/arch/i386/boot.s +++ b/arch/i386/boot.s @@ -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 @@ -49,4 +33,23 @@ _start: 1: hlt jmp 1b -.size _start, . - _start \ No newline at end of file +.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 \ No newline at end of file diff --git a/arch/i386/tty.c b/arch/i386/tty.c index 7774c35..a9cc9af 100644 --- a/arch/i386/tty.c +++ b/arch/i386/tty.c @@ -1,7 +1,7 @@ #include #include #include -#include +//#include #include "kernel/tty.h" #include "kernel/utils.h" diff --git a/kernel/gdt.c b/kernel/gdt.c index f2bbd93..9f97fe5 100755 --- a/kernel/gdt.c +++ b/kernel/gdt.c @@ -47,4 +47,5 @@ void gdt_install() { gdt_set_gate(2, 0, 0xFFFFFFFF, 0x92, 0xCF); //Apply changes - gdt_flush(); \ No newline at end of file + gdt_flush(); +} \ No newline at end of file diff --git a/kernel/kernel.c b/kernel/kernel.c index 877b27a..2edb848 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -6,7 +6,7 @@ int kernel_main(void) { //Prepare the GDT - gdt_install() + gdt_install(); //Prepare the screen, and blank it out. screen_initialize();