I was able to use the Limine terminal in my 64-bit OS, though. If I have to, I'll use the Multiboot protocol, but I wouldn't like to if I don't have to.devc1 wrote:I looked in to limines github repo and It seems that limines GDT 32 bit. And you are trying to run 64 bit code in 32 bit mode ? If yes and the kernel loads perfectly into the startup function, I can help you but you will not be able to use the terminal, otherwise you can just create your own terminal.
When you create a kernel, you are nomore dependent of bootloader stuff, the bootloader passed the initdata, now its your turn to startup the OS (a long trip).
How to make a GDT?
Re: How to make a GDT?
Re: How to make a GDT?
So is there a reason why my GDT isn't working?
-
- Member
- Posts: 5562
- Joined: Mon Mar 25, 2013 7:01 pm
Re: How to make a GDT?
OS development requires lots of reading. Perhaps you should choose a different hobby.devc1 wrote:Yeahhh, I am not a fan of reading btw.
I don't see any obvious problems. Try using your debugger to examine the memory contents at the address your GDTR points to.zap8600 wrote:So is there a reason why my GDT isn't working?
Re: How to make a GDT?
Has anyone ever using limine here ?
Re: How to make a GDT?
Of course, I mainly read if I have to solve my own problems or problems that I know I will face later. Otherwise, I don't see myself reading the whole limine documentation because I'll never use it, as you've already seen in my github repo, All the programs are written from scratch with no included libraries.OS development requires lots of reading. Perhaps you should choose a different hobby.
I don't recommend any begineer to start with a premade bootloader, to learn he should start from scratch and discover things from the root of the tree, not from the middle.
Re: How to make a GDT?
No. It's best for a beginner to skip the headache of the bootloader stage and start working on stuff that will actually motivate them.devc1 wrote:I don't recommend any begineer to start with a premade bootloader
In that case, don't post about subjects you aren't very familiar with, and potentially mislead someone. I'm telling you this from experiencedevc1 wrote:Otherwise, I don't see myself reading the whole limine documentation because I'll never use it
Re: How to make a GDT?
Why stop at the boot loader? I recommend beginners to write their own BIOS. Best to start at the root of the tree.
Hardcore enthusiasts would recommend writing your own microcode.
Hardcore enthusiasts would recommend writing your own microcode.
Re: How to make a GDT?
Invent your own CPU, build it from discrete components. Next step: Use uranium to cause bit flips in RAM precisely in such a way as to write whatever program you wanted in there.iansjack wrote:Why stop at the boot loader? I recommend beginners to write their own BIOS. Best to start at the root of the tree.
Hardcore enthusiasts would recommend writing your own microcode.
In case anyone wonders what my sincere opinion is: The kernel is the important thing, everything else is just getting the machine ready for the kernel. Build the kernel!
Carpe diem!
Re: How to make a GDT?
That's actually quite a fun exercise (the designing, not the building). It's even the basis of a computer game or two.nullplan wrote:Invent your own CPU, build it from discrete components.
But I agree with you. Before the kernel it's just building blocks that teach you very little (other than how to write a boot loader). The interesting stuff starts once your kernel is loaded.
Re: How to make a GDT?
Is there any way I could set up my own framebuffer from my OS? I could use Limine's framebuffer, but I'm not sure how I would print to it.Octocontrabass wrote: I don't see any obvious problems. Try using your debugger to examine the memory contents at the address your GDTR points to.
-
- Member
- Posts: 5562
- Joined: Mon Mar 25, 2013 7:01 pm
Re: How to make a GDT?
In theory yes, but in practice probably not. You would need a driver for the display adapter, and each display adapter requires a different driver.zap8600 wrote:Is there any way I could set up my own framebuffer from my OS?
It's a bitmap. You plot pixels on it the same way you plot pixels in any bitmap.zap8600 wrote:I could use Limine's framebuffer, but I'm not sure how I would print to it.
Is there any particular reason why you don't want to use a debugger to check your GDT?
Re: How to make a GDT?
I was wanting to make progress. That usually gives me the motivation to continue working on my OS.Octocontrabass wrote: Is there any particular reason why you don't want to use a debugger to check your GDT?
Re: How to make a GDT?
The best way to make progress is to learn how to use a debugger. That stops you wasting a lot of time on uninformed guesses.zap8600 wrote:I was wanting to make progress. That usually gives me the motivation to continue working on my OS.Octocontrabass wrote: Is there any particular reason why you don't want to use a debugger to check your GDT?
Re: How to make a GDT?
That sort of makes sense. I should look at some new problems that I've noticed with my code.iansjack wrote: The best way to make progress is to learn how to use a debugger. That stops you wasting a lot of time on uninformed guesses.
First, when the assembly code reloads the segments, it doesn't point to the 64-bit data segment.
Code: Select all
asm volatile (
"mov %0, %%rdi\n"
"lgdt (%%rdi)\n"
"mov $0x10, %%ax\n"
"mov %%ax, %%ds\n"
"mov %%ax, %%es\n"
"mov %%ax, %%ss\n"
"mov $0x2b, %%ax\n"
"ltr %%ax\n"
: : "r"(&gdt[0].pointer)
);
Second, I think that the TSS data isn't being written to the write entry.
Code: Select all
for (int i = 0; i < 32; ++i) {
gdt[i].pointer.limit = sizeof(gdt[i].entries)+sizeof(gdt[i].tss_extra)-1;
gdt[i].pointer.base = (uintptr_t)&gdt[i].entries;
uintptr_t addr = (uintptr_t)&gdt[i].tss;
gdt[i].entries[5].limit_low = sizeof(gdt[i].tss);
gdt[i].entries[5].base_low = (addr & 0xFFFF);
gdt[i].entries[5].base_middle = (addr >> 16) & 0xFF;
gdt[i].entries[5].base_high = (addr >> 24) & 0xFF;
gdt[i].tss_extra.base_highest = (addr >> 32) & 0xFFFFFFFF;
}
I may also add this mini debugger to my kernel.
Re: How to make a GDT?
I think I have found another problem. I think that my TSS's offset (base) is located in one of the GDT entries.
Is this wrong with my current segments?
Code: Select all
void init_gdt()
{
for (int i = 1; i < 32; ++i) {
memcpy(&gdt[i], &gdt[0], sizeof(*gdt));
}
for (int i = 0; i < 32; ++i) {
gdt[i].pointer.limit = sizeof(gdt[i].entries)+sizeof(gdt[i].tss_extra)-1;
gdt[i].pointer.base = (uintptr_t)&gdt[i].entries;
uintptr_t addr = (uintptr_t)&gdt[i].tss;
gdt[i].entries[7].limit_low = sizeof(gdt[i].tss);
gdt[i].entries[7].base_low = (addr & 0xFFFF);
gdt[i].entries[7].base_middle = (addr >> 16) & 0xFF;
gdt[i].entries[7].base_high = (addr >> 24) & 0xFF;
gdt[i].tss_extra.base_highest = (addr >> 32) & 0xFFFFFFFF;
}
...
}