OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 4:07 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Why do I need a GDT
PostPosted: Mon Feb 20, 2017 1:28 am 
Offline
User avatar

Joined: Mon Feb 20, 2017 1:01 am
Posts: 13
Location: The Moon
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".

_________________
Developing an OS that is so early in development, it can't do anything because stupid me can't figure out interrupts
Image


Last edited by beauhefley on Mon Feb 20, 2017 1:42 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Why do I need a GPT
PostPosted: Mon Feb 20, 2017 2:09 am 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 1108
GPT?


Top
 Profile  
 
 Post subject: Re: Why do I need a GPT
PostPosted: Mon Feb 20, 2017 4:11 am 
Offline
Member
Member
User avatar

Joined: Sun Dec 25, 2016 1:54 am
Posts: 204
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

_________________
Plagiarize. Plagiarize. Let not one line escape thine eyes...


Top
 Profile  
 
 Post subject: Re: Why do I need a GPT
PostPosted: Mon Feb 20, 2017 7:33 am 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 641
Location: Ukraine, Bachmut
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.)

_________________
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).


Top
 Profile  
 
 Post subject: Re: Why do I need a GPT
PostPosted: Mon Feb 20, 2017 1:38 pm 
Offline
User avatar

Joined: Mon Feb 20, 2017 1:01 am
Posts: 13
Location: The Moon
Quote:
Presumably he meant "GDT"...

Oh. I have read that wrong.

_________________
Developing an OS that is so early in development, it can't do anything because stupid me can't figure out interrupts
Image


Top
 Profile  
 
 Post subject: Re: Why do I need a GDT
PostPosted: Mon Feb 20, 2017 7:02 pm 
Offline
Member
Member
User avatar

Joined: Mon Feb 22, 2016 4:40 am
Posts: 59
Location: United Kingdom
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.

_________________
Current developing Tupai, a monolithic x86 operating system
http://zesterer.homenet.org/projects.shtml


Top
 Profile  
 
 Post subject: Re: Why do I need a GDT
PostPosted: Tue Feb 21, 2017 5:56 am 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 723
Location: Tallinn, Estonia
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.

_________________
Learn to read.


Top
 Profile  
 
 Post subject: Re: Why do I need a GDT
PostPosted: Wed Feb 22, 2017 1:32 pm 
Offline
User avatar

Joined: Mon Feb 20, 2017 1:01 am
Posts: 13
Location: The Moon
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.

_________________
Developing an OS that is so early in development, it can't do anything because stupid me can't figure out interrupts
Image


Top
 Profile  
 
 Post subject: Re: Why do I need a GDT
PostPosted: Wed Feb 22, 2017 1:50 pm 
Offline
Member
Member

Joined: Wed Sep 19, 2012 3:43 am
Posts: 91
Location: The Netherlands
Welcome to osdev, where every single bit of the system matters :-P


Top
 Profile  
 
 Post subject: Re: Why do I need a GDT
PostPosted: Wed Feb 22, 2017 2:02 pm 
Offline
User avatar

Joined: Mon Feb 20, 2017 1:01 am
Posts: 13
Location: The Moon
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
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Amazonbot [bot], cloudapio, DotBot [Bot] and 69 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group