OSDev.org
https://forum.osdev.org/

Why do I need a GDT
https://forum.osdev.org/viewtopic.php?f=1&t=31378
Page 1 of 1

Author:  beauhefley [ Mon Feb 20, 2017 1:28 am ]
Post subject:  Why do I need a GDT

I want to add interrupts because I want to add keyboard input without polling port 0x60. My design for my OS has the kernel parse each executable file. Why do I need a GDT and a TSS? Without one, is it possible to make a good functioning OS and/or implement interrupts?

Edit: I had GPT originally, I always thought that the wiki said GPT. Sorry for any confusion.
Edit 2: I am stupid. I meant to say "without one".

Author:  alexfru [ Mon Feb 20, 2017 2:09 am ]
Post subject:  Re: Why do I need a GPT

GPT?

Author:  dchapiesky [ Mon Feb 20, 2017 4:11 am ]
Post subject:  Re: Why do I need a GPT

Presumably he meant "GDT"...

http://wiki.osdev.org/Global_Descriptor_Table

http://wiki.osdev.org/GDT_Tutorial

https://en.wikipedia.org/wiki/Global_Descriptor_Table

http://wiki.osdev.org/Getting_to_Ring_3

TSS:

http://wiki.osdev.org/Task_State_Segment

Interrupts:

http://wiki.osdev.org/Interrupt_Descriptor_Table

https://en.wikipedia.org/wiki/Interrupt ... ptor_table

Keyboard:

http://wiki.osdev.org/PS/2_Keyboard

Loading:

http://wiki.osdev.org/ELF

Quote:
Is it possible to make a good functioning OS and/or implement interrupts?


You have no choice but to implement interrupts...

You should start here...

http://wiki.osdev.org/Main_Page

and maybe here...

http://wiki.osdev.org/Bare_Bones

Author:  zaval [ Mon Feb 20, 2017 7:33 am ]
Post subject:  Re: Why do I need a GPT

GPT - GUID partition table, you need it if your disk is GPT-formatted. :D Specified in the UEFI specification, It's actully quite easy, interesting, modern and needed to be understood by OS developers, but this is not what you were asking about.)

Author:  beauhefley [ Mon Feb 20, 2017 1:38 pm ]
Post subject:  Re: Why do I need a GPT

Quote:
Presumably he meant "GDT"...

Oh. I have read that wrong.

Author:  zesterer [ Mon Feb 20, 2017 7:02 pm ]
Post subject:  Re: Why do I need a GDT

beauhefley wrote:
I want to add interrupts because I want to add keyboard input without polling port 0x60. My design for my OS has the kernel parse each executable file. Why do I need a GDT and a TSS? Without one, is it possible to make a good functioning OS and/or implement interrupts?


Yes, you need a GDT. It is required in 32-bit protected mode on the x86 architecture.

You may not think you already have one. But you're probably booting your OS with GRUB. GRUB automatically creates one. When GRUB hands control over to your OS, the old GDT GRUB created still resides within the CPU's internal cache. It's a good idea to replace it with your own one ASAP in the boot process to avoid problems later.

Truth be told, the GDT has few purposes in modern systems that make use of paging. It's a dinosaur of the x86's past, but it's still required for backwards-compatibility.

My advise? Just set one up. It's not as hard as it seems, honest. Provided you know C and some simple ASM, it shouldn't take you long to figure it out from the wiki documentation. If you don't know C and simple ASM, I highly recommend that you put OS development on hold and spend a week teaching yourself C and assembly on your normal operating system before jumping into your own.

Author:  dozniak [ Tue Feb 21, 2017 5:56 am ]
Post subject:  Re: Why do I need a GDT

zesterer wrote:
My advise? Just set one up. It's not as hard as it seems, honest. Provided you know C and some simple ASM, it shouldn't take you long to figure it out from the wiki documentation. If you don't know C and simple ASM, I highly recommend that you put OS development on hold and spend a week teaching yourself C and assembly on your normal operating system before jumping into your own.


You can pretty much hardcode 3 (if you have only kernel mode) or 5 entries with constants - they will always be the same anyway.

Author:  beauhefley [ Wed Feb 22, 2017 1:32 pm ]
Post subject:  Re: Why do I need a GDT

Quote:
Provided you know C and some simple ASM, it shouldn't take you long to figure it out from the wiki documentation. If you don't know C and simple ASM, I highly recommend that you put OS development on hold and spend a week teaching yourself C and assembly on your normal operating system before jumping into your own.

I know C++ and a very small amount of Assembly using Linux system calls and int 0x80. I am not used to writing code in this low level, and I rely heavily on libraries such as the standard libraries, boost, and Qt.
I found a guide, I created a struct with the bytes in order. I couldn't figure out what to name each variable to get the CPU to know what to read, but according to the guide the bytes just have to be in order. Loading my GDT does triple fault, but I found out that removing my IDT headers and not linking my assembly object for my ISR does make it boot properly.

Author:  FusT [ Wed Feb 22, 2017 1:50 pm ]
Post subject:  Re: Why do I need a GDT

Welcome to osdev, where every single bit of the system matters :-P

Author:  beauhefley [ Wed Feb 22, 2017 2:02 pm ]
Post subject:  Re: Why do I need a GDT

Got my GDT and IDT to load my kernel without triple faulting! Now I just have to test and see if I can use interrupts.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/