Page 1 of 2

What do i put in gdt_start and idt_start?

Posted: Mon Jan 02, 2017 3:25 pm
by NunoLava1998
I'm trying to load the GDT/IDT using the same method as you would use in Assembly. However, i have no idea what to put in the gdt_start and idt_start sections (I need code this time, since i don't know what are the things that are usually put in there).

Can anyone help?

EDIT: I figured out the idt_start is the one in the struct in the IDT page (dw = uint16_t, db = uint8_t). Only need gdt_start

By "idt_end" and that, i mean:

In Assembly, you only can initialize the IDT or GDT with using lidt or lgdt [gdt_info]/[idt_info]. This needs (g/i)dt_start and (g/i)dt_end. I know what is the value of the _end, but not of the gdt_start one.
I'm trying to implement this in C/C++, however.

Re: What do i put in gdt_start and idt_start?

Posted: Mon Jan 02, 2017 3:31 pm
by moondeck
What exactly are you talking about? gdt_start? idt_start? huh?

Re: What do i put in gdt_start and idt_start?

Posted: Mon Jan 02, 2017 3:38 pm
by Kevin
He is just copying code from http://wiki.osdev.org/LGDT without understanding it.

And as the comment there says, what you should put there is "Some GDT entries, like null, kernel code, kernel data, user code, user data, TSS..."

Re: What do i put in gdt_start and idt_start?

Posted: Mon Jan 02, 2017 3:40 pm
by Roman
Please stop copy-pasting code like a parrot.

Re: What do i put in gdt_start and idt_start?

Posted: Mon Jan 02, 2017 3:41 pm
by moondeck
faith in humanity is lost

Re: What do i put in gdt_start and idt_start?

Posted: Mon Jan 02, 2017 3:43 pm
by NunoLava1998
Kevin wrote:He is just copying code from http://wiki.osdev.org/LGDT without understanding it.

And as the comment there says, what you should put there is "Some GDT entries, like null, kernel code, kernel data, user code, user data, TSS..."
So? I don't know what those are. I implemented a big part of my IDT/GDT almost-complete loader, not copy pasting.
Besides, i wasn't copy pasting, i was actually chatting with some os devers for 3 hours trying to get IDT to work.

Re: What do i put in gdt_start and idt_start?

Posted: Mon Jan 02, 2017 3:44 pm
by NunoLava1998
Roman wrote:Please stop copy-pasting code like a parrot.
i am not in this aspect (tbh just a bit, but not everything).

Re: What do i put in gdt_start and idt_start?

Posted: Mon Jan 02, 2017 3:45 pm
by moondeck
Yeah, you were chatting with us, but you didnt wanna understand, and kept telling us GDT isnt needed (LOL).
Please, read and understand before attempting to do this.

Re: What do i put in gdt_start and idt_start?

Posted: Mon Jan 02, 2017 3:48 pm
by NunoLava1998
moondeck wrote:Yeah, you were chatting with us, but you didnt wanna understand, and kept telling us GDT isnt needed (LOL).
Please, read and understand before attempting to do this.
So? I am reading and understanding. It was a while ago actually. And yes, i don't need idt_start (the struct was the idt_start equivalent.). Only gdt_start.

Anyway, can we resume to the question?

Re: What do i put in gdt_start and idt_start?

Posted: Mon Jan 02, 2017 3:50 pm
by moondeck
NunoLava1998 wrote: Anyway, can we resume to the question?

NOOOO! WE CANT RESUME! BECAUSE YOU HAVE NO IDEA WHAT YOU'RE DOING!
AND NOOOO! YOU ARE NOT UNDERSTANDING ANYTHING! ALL YOU DO IS COPY THE DAMN CODE!

Re: What do i put in gdt_start and idt_start?

Posted: Mon Jan 02, 2017 3:50 pm
by iansjack
Have you no pride whatsoever?

Re: What do i put in gdt_start and idt_start?

Posted: Mon Jan 02, 2017 3:52 pm
by Roman
Please read carefully what GDT/IDT and GDTR/IDTR are and what LGDT/LIDT do.

Re: What do i put in gdt_start and idt_start?

Posted: Mon Jan 02, 2017 3:54 pm
by NunoLava1998
Roman wrote:Please read carefully what GDT/IDT and GDTR/IDTR are and what LGDT/LIDT do.
GDT: Global Descriptor Table
IDT: Interrupt Descriptor Table

GDTR: Global Descriptor Table Register
IDTR: Interrupt Descriptor Table Register

LGDT: Loads the specified GDT.
LIDT: Loads the specified IDT.

Re: What do i put in gdt_start and idt_start?

Posted: Mon Jan 02, 2017 4:02 pm
by Love4Boobies
I think we should calm down a bit. Understanding these data structures means more than just knowing what those acronyms expand to. Their representation and semantics are described in the Intel and AMD manuals. There, you'll find out how they work and if you read their descriptions, you'll know what to put in each entry to get the results you expect in your OS.

Re: What do i put in gdt_start and idt_start?

Posted: Mon Jan 02, 2017 4:05 pm
by NunoLava1998
moondeck wrote:
NunoLava1998 wrote: Anyway, can we resume to the question?

NOOOO! WE CANT RESUME! BECAUSE YOU HAVE NO IDEA WHAT YOU'RE DOING!
AND NOOOO! YOU ARE NOT UNDERSTANDING ANYTHING! ALL YOU DO IS COPY THE DAMN CODE!
I'm doing this now for several reasons:
  • 1. Later i'll write my own code, i can't write too much code for the very low level of C.
    2. I'm learning, i have to understand code.
    3. I actually have started making code myself.
Can't you just (and other OSDevers in the forum) treat me like a normal user? Can't i just get a nice answer?