GDT Issues

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
jzgriffin
Member
Member
Posts: 190
Joined: Tue Sep 26, 2006 1:40 pm
Libera.chat IRC: Nokurn
Location: Ontario, CA, USA
Contact:

GDT Issues

Post by jzgriffin »

I've recently implemented the GDT from http://www.osdever.net/bkerndev. When I compile GDT.c, I get a warning that I believe is causing the renewed Virtual PC errors. Here it is:

Code: Select all

Source/GDT.c:75: warning: assignment makes integer from pointer without a cast
Line 75 of Source/GDT.c:

Code: Select all

GDTPointer.Base = &GDTEntry;
GDTPointer:

Code: Select all

struct TGDTPointer GDTPointer;
TGDTPointer:

Code: Select all

struct TGDTPointer
{
    unsigned short Limit;
    unsigned int Base;
} __attribute__((packed));
GDTEntry:

Code: Select all

struct TGDTEntry GDTEntry[3];
TGDTEntry:

Code: Select all

struct TGDTEntry
{
    unsigned short LimitLow;
    unsigned short BaseLow;
    unsigned char BaseMiddle;
    unsigned char Access;
    unsigned char Granularity;
    unsigned char BaseHigh;
} __attribute__((packed));
Any ideas what might be going wrong here?

P.S.: If you need more code, just ask.
turtling
Posts: 8
Joined: Sun Mar 11, 2007 2:01 pm

Post by turtling »

If you do this: GDTPointer.Base = (unsigned int)&GDTEntry; ?
It's just a warning, it's not a problem.
jzgriffin
Member
Member
Posts: 190
Joined: Tue Sep 26, 2006 1:40 pm
Libera.chat IRC: Nokurn
Location: Ontario, CA, USA
Contact:

Post by jzgriffin »

That got rid of the warning, but I still can't boot the kernel...the full source code is on SVN at svn://svn.griffinsoft.net/grakos for anyone who wants to have a look.
oscoder
Member
Member
Posts: 59
Joined: Mon Mar 27, 2006 12:00 am
Location: UK

Post by oscoder »

Do you know exactly what is causing it not to boot? Do you think its in your gdt code? There are a number of things that can go wrong. In order you might like to try instruction tracing, or simply halting the cpu (in c: asm("hlt");) before the points you think might be causing the error - the first thing I'd try is putting one of these just before you load the new gdt.
jzgriffin
Member
Member
Posts: 190
Joined: Tue Sep 26, 2006 1:40 pm
Libera.chat IRC: Nokurn
Location: Ontario, CA, USA
Contact:

Post by jzgriffin »

I've commented out GDTInitialize() (where GDTPointer.Base = ... is located) in Kernel.c to stop the GDT from initializing, yet the problem is still there. The results of ConsoleInitialize(), which was before GDTInitialize(), are never printed. Based on facts, I think that the problem is in Start.asm.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

GDTEntry[x] is one gdt entry (equivalent to TGDTEntry)
GDTEntry is an array of gdt entries
which is has the same type as TGDTEntry *
which is a pointer

by setting GDT.base to &GDTEntry you are setting the base as a pointer to a pointer to the GDT. (!)

The correct form is GDTPointer.base = (unsigned int) GDTEntry;

Besides, warnings are symptoms of bad code.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
jzgriffin
Member
Member
Posts: 190
Joined: Tue Sep 26, 2006 1:40 pm
Libera.chat IRC: Nokurn
Location: Ontario, CA, USA
Contact:

Post by jzgriffin »

I've done that, and it just prevents warning. Also, I've added the IDT/ISR/IRQ, and it still fails to boot. All of that's on the SVN repository. Please help? :-(
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

hmm, you have serious trouble:

Code: Select all

OUTPUT_FORMAT("binary")
ENTRY(Start)

SECTIONS
{
    .text 0xFF800000 :
    {
        *(.text)
    }
    .data :
    {
        *(.data)
    }
    .bss :
    { 					
        *(.bss)
    }
}
Linking to higherhalf, WITHOUT Stub, WITHOUT Paging, WITHOUT bootloader and you still expect it to work? :shock:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
jzgriffin
Member
Member
Posts: 190
Joined: Tue Sep 26, 2006 1:40 pm
Libera.chat IRC: Nokurn
Location: Ontario, CA, USA
Contact:

Post by jzgriffin »

I tried changing the linker script (I used the one from that tutorial, the second time around) and it still didn't boot. *tries again*

Edit: No luck with that. *commits to SVN anyways*
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

Just changing things randomly wont get you anywhere... Methinks you have no clue about the changes you just did to your linker script :roll:

What happens, your binary is loaded at some address (i dont know which - you dont use grub and your own bootloader has no sourcecode) but the code is designed to run at a different address. ATM its set to the 1MB mark, which simple bootloaders cant access as it lies outside bill gates' famous 640k. Check with whatever proprietary code you use where your kernel is actually loaded, and put the correct value into your linker script.

If that does not help, please post the bootloader's specs when you come back.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

He's using bootf02 last time I checked Combuster.. He also has a custom one in his repository.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
Post Reply