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.
The linker script is the same that can be finded in Bare bones PS: I reposted this in a different thread, because the original was taking to much pages and the thread went out of the original theme.
Your answer appeared just before I published my answer. I tried the code you passed through pastebin (is it the same code I posted?), but I get this error:
I just looked through your git repo and you seem to be having a weird combination of a custom bootloader and GRUB. Please read through Bare Bones and choose one GRUB or custom. Or if the git repo is outdated please update it so I can see your entire codebase and see what is going wrong.
thomtl wrote:I just looked through your git repo and you seem to be having a weird combination of a custom bootloader and GRUB. Please read through Bare Bones and choose one GRUB or custom. Or if the git repo is outdated please update it so I can see your entire codebase and see what is going wrong.
No, there's no "weird" combination. It's just that I haven't commited the current code yet.
The code that is in my repo uses custom bootloader, but now I'm working to use GRUB instead.
First, GRUB loads ELF and A.OUT files and not flat binaries, so you'd want to change your build script (also make a makefile)
and you set the A.OUT kludge flag when you don't even have a A.OUT file
EDIT: you might also want to change the stublet label to not infinetly loop
In gdt.inc you have an STI instruction after loading the GDT but you don't have an IDT installed. You will probably want to remove that STI. Your InstallGDT doesn't reload the segment registers so it should probably look something like:
InstallGDT:
pusha ; save registers
lgdt[toc] ; load GDT into GDTR
jmp 0x08:.setcs ; Set CS to 0x08
.setcs:
mov ax, 0x10 ; Set the data segment registers
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
popa ; restore registers
ret ; All done!
I'd also highly recommend putting a section .text at the top of idt.inc. a section .text before InstallGDT in gdt.inc and a section .data before the GDT data in gdt.inc . This is useful to put the code and data in the right sections when they are included by bootg.asm .
My kernel is compiled into an ELF, but then transformed into a flat binary using objdump. It doesn't make sense (at least for me).
That means you successfully negotiated the first pass (having GRUB find the multiboot header). But since your kernel isn't ELF (you make it a flat bin, after all), your multiboot header also needs the a.out kludge in order for GRUB to know where to load your kernel and where to jump to for the start. The specification calls those the address fields, and you need to set flags[16] as well.
My kernel is compiled into an ELF, but then transformed into a flat binary using objdump. It doesn't make sense (at least for me).
That means you successfully negotiated the first pass (having GRUB find the multiboot header). But since your kernel isn't ELF (you make it a flat bin, after all), your multiboot header also needs the a.out kludge in order for GRUB to know where to load your kernel and where to jump to for the start. The specification calls those the address fields, and you need to set flags[16] as well.
Well, now my kernel is an ELF, and thanks, now it works properly.
Now I'm trying to get a memory map, so I can get available memory, total memory and well you know...
But I get a incorrect value, In VirtualBox with 512MB of RAM. I get 33486463.
I use this to get total memory: