Page 1 of 1

Problem with OS in Bochs/Qemu

Posted: Fri Jan 30, 2009 5:06 pm
by xnemesis
Ok, before I start I would just like to say I spent a long time searching the forums and googling around before I considered posting. I then spent further time doing the same before I actually decided to click the button :P So lets hope that will reduce the flaming :D
I'm new to the idea of OS development so I decided to follow the Wiki here http://wiki.osdev.org/Bare_bones as C is my language of choice. My code matches to that on the wiki and I have followed the instructions exactly. However, running Bochs I get a stream of "you suck messages":

Code: Select all

00000321341d[CPU0 ] UndefinedOpcode: ff causes exception 6
00000321341d[CPU0 ] exception(06 h)
00000321341d[CPU0 ] interrupt(): vector = 6, INT = 0, EXT = 1
00000321342i[CPU0 ] BxError: instruction with opcode=0xff
00000321342i[CPU0 ] mod was c0, nnn was 7, rm was 7
00000321342i[CPU0 ] WARNING: Encountered an unknown instruction (signalling illegal instruction)
I then played around some more and if I use the legacy BIOS for bochs or qemu there are no errors. It goes nicely to the grub screen (which is a nice start), and then obviously wants me to load the kernel and boot the OS. But there are no drives or anything mounted so I cannot point it to a kernel file or to anything. I'm loading it from floppy.img file (made using the instructions on the wiki above), and just wondered if someone could at the least point this noob in the right direction :)
Many thanks!

Re: Problem with OS in Bochs/Qemu

Posted: Fri Jan 30, 2009 5:16 pm
by Combuster
if you get into grub, it'll show the command prompt (if not, press c).

then, as per the wiki, type
kernel 200+18
boot

Re: Problem with OS in Bochs/Qemu

Posted: Fri Jan 30, 2009 5:20 pm
by xnemesis
Oh my god. All I can say is thanks for not flaming me as I have read that wiki countless times and clearly missed something slapping me in the face. I do however get an error message, which I know is my fault but ...

Code: Select all

[multiboot-elf, <0x100000:0x38:0x4000>
Error 28: Selected Item cannot fit into memory
Ok I've read around and everywhere seems to point to rodata, but I can't see how this is my problem. This is the linker code:

Code: Select all

ENTRY (loader)

SECTIONS{
    . = 0x00100000;

    .text :{
        *(.text)
        *(.rodata)
    }

    .data ALIGN (0x1000) : {
        *(.data)
    }

    .bss : {
        sbss = .;
        *(COMMON)
        *(.bss)
        ebss = .;
    }
}
And here is the output from `objdump -h kernel.bin`

Code: Select all

kernel.bin:     file format elf32-i386

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00000038  00100000  00100000  00001000  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .bss          00004000  00100038  00100038  00001038  2**2
                  ALLOC
  2 .comment      00000047  00000000  00000000  00001038  2**0
                  CONTENTS, READONLY
I can only guess that it's to do with .bss because of that output, but that's me making an uneducated guess :P Any chance of an educated guess? :P

Edit: Wow I hate myself tonight. It was nothing to do with the code, all I needed to do was configure grub to have an amount of uppermemory.

Code: Select all

uppermem 64
Or however much you want, hope this helps someone :)