nibblebits / PeachOS

Simple kernel designed for a online course
GNU General Public License v2.0
133 stars 55 forks source link

size of gdt #24

Open mark-marinas opened 1 year ago

mark-marinas commented 1 year ago

On boot.asm, you subtracted 1 from the size of the gdt. But not on the c version of it. Any reason for that?

ine 80 of src/boot/boot.asm:

gdt_descriptor:

dw gdt_end - gdt_start-1

dd gdt_start

line 134 of kernel.c:

gdt_load(gdt_real, sizeof(gdt_real));

and src/gdt/gdt.asm

[BITS 32] section .asm global gdt_load

gdt_load: mov eax, [esp + 4] mov [gdt_descriptor + 2], eax mov ax, [esp + 8] ;should there be a ;sub ax, 1 mov [gdt_descriptor], ax lgdt [gdt_descriptor] ret

section .data gdt_descriptor: dw 0 ;size dd 0 ;gdt start address.

nibblebits commented 1 year ago

Hi, This issue was answered before, the comments seem to have disappeared... It is true that this

gdt_load(gdt_real, sizeof(gdt_real));

would be better as: gdt_load(gdt_real, sizeof(gdt_real)-1);

However no issues following the course were present even with the lack of a subtraction but yes it is a mistake and will be corrected.