Page 1 of 1
GDT Issues
Posted: Wed Mar 21, 2007 12:41 pm
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:
GDTPointer:
TGDTPointer:
Code: Select all
struct TGDTPointer
{
unsigned short Limit;
unsigned int Base;
} __attribute__((packed));
GDTEntry:
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.
Posted: Wed Mar 21, 2007 1:33 pm
by turtling
If you do this: GDTPointer.Base = (unsigned int)&GDTEntry; ?
It's just a warning, it's not a problem.
Posted: Wed Mar 21, 2007 1:50 pm
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.
Posted: Wed Mar 21, 2007 2:02 pm
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.
Posted: Wed Mar 21, 2007 2:09 pm
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.
Posted: Wed Mar 21, 2007 2:46 pm
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.
Posted: Wed Mar 21, 2007 7:48 pm
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?
Posted: Thu Mar 22, 2007 1:30 am
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?
Posted: Thu Mar 22, 2007 10:43 am
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*
Posted: Thu Mar 22, 2007 5:23 pm
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
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.
Posted: Thu Mar 22, 2007 6:40 pm
by Brynet-Inc
He's using bootf02 last time I checked Combuster.. He also has a custom one in his repository.