Why do I need a GDT
- beauhefley
- Posts: 13
- Joined: Mon Feb 20, 2017 1:01 am
- Location: The Moon
- Contact:
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".
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".
Last edited by beauhefley on Mon Feb 20, 2017 1:42 pm, edited 2 times in total.
Developing an OS that is so early in development, it can't do anything because stupid me can't figure out interrupts
- dchapiesky
- Member
- Posts: 204
- Joined: Sun Dec 25, 2016 1:54 am
- Libera.chat IRC: dchapiesky
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
You should start here...
http://wiki.osdev.org/Main_Page
and maybe here...
http://wiki.osdev.org/Bare_Bones
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
You have no choice but to implement interrupts...Is it possible to make a good functioning OS and/or implement interrupts?
You should start here...
http://wiki.osdev.org/Main_Page
and maybe here...
http://wiki.osdev.org/Bare_Bones
Plagiarize. Plagiarize. Let not one line escape thine eyes...
Re: Why do I need a GPT
GPT - GUID partition table, you need it if your disk is GPT-formatted. 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.)
- beauhefley
- Posts: 13
- Joined: Mon Feb 20, 2017 1:01 am
- Location: The Moon
- Contact:
Re: Why do I need a GPT
Oh. I have read that wrong.Presumably he meant "GDT"...
Developing an OS that is so early in development, it can't do anything because stupid me can't figure out interrupts
- zesterer
- Member
- Posts: 59
- Joined: Mon Feb 22, 2016 4:40 am
- Libera.chat IRC: zesterer
- Location: United Kingdom
- Contact:
Re: Why do I need a GDT
Yes, you need a GDT. It is required in 32-bit protected mode on the x86 architecture.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?
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.
Current developing Tupai, a monolithic x86 operating system
http://zesterer.homenet.org/projects.shtml
http://zesterer.homenet.org/projects.shtml
Re: Why do I need a GDT
You can pretty much hardcode 3 (if you have only kernel mode) or 5 entries with constants - they will always be the same anyway.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.
Learn to read.
- beauhefley
- Posts: 13
- Joined: Mon Feb 20, 2017 1:01 am
- Location: The Moon
- Contact:
Re: Why do I need a GDT
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.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 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.
Developing an OS that is so early in development, it can't do anything because stupid me can't figure out interrupts
Re: Why do I need a GDT
Welcome to osdev, where every single bit of the system matters
- beauhefley
- Posts: 13
- Joined: Mon Feb 20, 2017 1:01 am
- Location: The Moon
- Contact:
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.
Developing an OS that is so early in development, it can't do anything because stupid me can't figure out interrupts