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.
Anyway, I was developing an operating system under DJGPP (following Bran's Kernel Development Tutorial) and it worked until I had to switch to using FreeDOS (due to getting a new 64 bit computer). Whenever I try to run it, I always get GRUB Error 7.
[BITS 32]
[extern code]
[extern bss]
[extern end]
[extern _main]
[global start]
; This part MUST be 4byte aligned, so we solve that issue using 'ALIGN 4'
ALIGN 4
mboot:
; Multiboot macros to make a few lines later more readable
MULTIBOOT_PAGE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_INFO equ 1<<1
MULTIBOOT_AOUT_KLUDGE equ 1<<16
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE
MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
EXTERN code, bss, end
; This is the GRUB Multiboot header. A boot signature
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
; AOUT kludge - must be physical addresses. Make a note of these:
; The linker script fills in the data for these ones!
dd mboot
dd code
dd bss
dd end
dd start
Last edited by Marionumber1 on Thu Dec 29, 2011 9:10 am, edited 1 time in total.
That looks like a problem with the boot image. How do you create the boot image? Are you booting from a disk image or a real floppy / CD / HDD? Are you booting a real computer or a virtual one, such as Bochs, QEMU, VBox...? Which GRUB version are you using?
Just one quick remark about your multiboot header: In which section does it end up? Did you check that it is placed somewhere in the first 8k of the kernel binary? If not, GRUB will complain and give you an error 13.
I was creating an ELF with my cross compiler (i586-elf-xxx). I was using AS because LD wouldn't recognize the format of a NASM output file. And I took my ELF file, put it in /boot, and used GRUB legacy to load it on real hardware.
In that case I recommend that you test your ELF kernel using a PC simulator before you try it on real hardware - that makes debugging much easier.
The best debugging support I found is that of Bochs, but you can also try QEMU, which has the nice feature that it can directly load multiboot kernels with the "-kernel" option.
Marionumber1 wrote:I was using AS because LD wouldn't recognize the format of a NASM output file.
Then you're not using your tools correctly. NASM has a host of formats it can output to, ELF included. It does not magically know however that you want an ELF-formatted file.
Have you tried the Bare Bones tutorial exactly as described, or are you trying to work out your own approach?
"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 ]
Sorry that I've been away for a while, but I've just been busy. Anyway, I was following Bran's Kernel Dev tutorial and when I used i586-elf-ld to link, it said that my ISR and IRQ routines couldn't be found. His tutorial says that you add leading underscores to every symbol name, but that didn't work. I also tried removing those underscores, which also failed.
Have you tried the Bare Bones tutorial exactly as described
"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 ]