Skip to content

Commit

Permalink
Make gdt64 asm variable global
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamos82 committed Sep 27, 2023
1 parent d350e0c commit 40990ea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/asm/boot.s
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ global multiboot_mmap_data
global multiboot_basic_meminfo
global multiboot_acpi_info
global read_multiboot
global gdt64

extern kernel_tss
extern kernel_start

[bits 32]
Expand Down Expand Up @@ -284,6 +287,7 @@ section .rodata
gdt64:
dq 0 ;first entry = 0
.code equ $ - gdt64
; equ tells the compiler to set the address of the variable at given address ($ - gdt64). $ is the current position.
; set the following values:
; descriptor type: bit 44 has to be 1 for code and data segments
; present: bit 47 has to be 1 if the entry is valid
Expand All @@ -297,6 +301,10 @@ gdt64:
dq (1 <<44) | (1 << 47) | (1 << 41) | (1 << 43) | (1 << 53) | (3 << 45) ;fourth entry=code=0x18
.udata equ $ - gdt64
dq (1 << 44) | (1 << 47) | (1 << 41) | (3 << 45) ;fifth entry = data = 0x20
.tss_low equ $ - gdt64
dq 0
.tss_high equ $ - gdt64
dq 0

.pointer:
dw .pointer - gdt64 - 1
Expand Down
6 changes: 6 additions & 0 deletions src/kernel/arch/x86_64/cpu/tss.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#include <logging.h>
#include <tss.h>

extern uint64_t gdt64[];

tss_t kernel_tss;

void initialize_tss(){

loglinef(Verbose, "(%s) Initializing tss", __FUNCTION__);
loglinef(Verbose, "(%s) gdt64[0] = 0x%x", __FUNCTION__, gdt64[1]);

// These fields are reserved and must be set to 0
kernel_tss.reserved0 = 0x0;
kernel_tss.reserved1 = 0x0;
Expand Down

0 comments on commit 40990ea

Please sign in to comment.