Help with code
Re:Help with code
I think either it doesn't even jump to the cli part or bochs doesn't like your GDT ( most probly ).
Re:Help with code
wait...if it doesn't set cli...must be a prob with your jmp's.
Try simpling it out, and see if it works...
Try simpling it out, and see if it works...
Re:Help with code
http://www.geocrawler.com/mail/msg.php3?msg_id=7706039&list=11758 The power of Google
Re:Help with code
I changed my code a bit and I get this message in bochsout.txt. Can anybody tell me what this means?
Code: Select all
00016466214p[CPU ] >>PANIC<< prefetch: EIP > CS.limit
00016466214i[SYS ] Last time is 1037040133
00016466214i[CPU ] real mode
00016466214i[CPU ] CS.d_b = 16 bit
00016466214i[CPU ] SS.d_b = 16 bit
00016466214i[CPU ] | EAX=00180e00 EBX=00000000 ECX=000b0001 EDX=00000000
00016466214i[CPU ] | ESP=00001fff EBP=00000000 ESI=00007ce5 EDI=0000ffe4
00016466214i[CPU ] | IOPL=0 NV UP EI PL ZR NA PE NC
00016466214i[CPU ] | SEG selector base limit G D
00016466214i[CPU ] | SEG sltr(index|ti|rpl) base limit G D
00016466214i[CPU ] | DS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00016466214i[CPU ] | ES:9000( 0000| 0| 0) 00090000 0000ffff 0 0
00016466214i[CPU ] | FS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00016466214i[CPU ] | GS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00016466214i[CPU ] | SS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00016466214i[CPU ] | CS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00016466214i[CPU ] | EIP=00010000 (0000ffff)
Re:Help with code
Means you've messed up the memory locations somewhere. Just looking at that register dump it's still in real mode, no selectors are loaded and eip is pointing beyond the end of the code segment. It probably broke when you tried to jump somewhere (The 16->32bit pmode jump? Maybe you've got a short form eip only jump instead of selector:eip jump).
Check your gdt and pmode switch code. Chances are that the error is in there somewhere. You should have loaded a valid gdt before entering pmode, and the first pmode instructions (After the far jump to your 32 bit code) should be to load the selectors so you start things in a stable position. A working idt wouldn't go amiss either.
Hmm, have you tried halting just before the jump to your kernel code? Maybe something along the lines of:
In theory that would print a ! and hang instead of your kernel far jump.
Reason I say this is that it would be useful to know if it's the jump to pmode that's causing the problem or the jump to the kernel.
Curufir
Check your gdt and pmode switch code. Chances are that the error is in there somewhere. You should have loaded a valid gdt before entering pmode, and the first pmode instructions (After the far jump to your 32 bit code) should be to load the selectors so you start things in a stable position. A working idt wouldn't go amiss either.
Hmm, have you tried halting just before the jump to your kernel code? Maybe something along the lines of:
Code: Select all
MOV ESI, 0xB8000
MOV WORD [DS:ESI], 0x0421
JMP $
Reason I say this is that it would be useful to know if it's the jump to pmode that's causing the problem or the jump to the kernel.
Curufir
Re:Help with code
It looks like it's not jumping to the right place...probly with the a20_ok or something else...
Re:Help with code
Hey, I figured out why it was going crasy in bochs. I decided to take out all my code and just write a simple bootsector that prints a message.
I probally will still need help with my bootsector when I add the rest of the non-working bootsector code that I posted. Thanks for the help guys!
By the way the problem was with the stack.
This is what I had:
And this is how it really should be
It took me three days to figure that out. Damm, I hate debugging my code!.
Heres the snapshot of it running in bochs:
I probally will still need help with my bootsector when I add the rest of the non-working bootsector code that I posted. Thanks for the help guys!
By the way the problem was with the stack.
This is what I had:
Code: Select all
mov ax,0x9000
mov es,ax
mov sp,0xffff
Code: Select all
mov ax,0x9000
mov ss,ax
mov sp,0xffff
Heres the snapshot of it running in bochs:
Code: Select all
VGA BIOS - Version 2.40
Copyright (C) 1990-2000 Elpin Systems, Inc.
All rights reserved.
Licensed for use with bochs, courtesy of MandrakeSoft.
For information on this or other VGA development products, contact
Elpin Systems at: (800) 723-9038 or www.elpin.com
Bochs BIOS, $Revision: 1.42.2.1 $ $Date: 2002/05/15 13:41:03 $
Booting from Floppy...
Booting from FLOPPY!
Re:Help with code
I have changed some things in my original bootsector. I am getting some weird errors in bochs. I have narrowed it down to the part where I make the long jump to protected mode and setup the segment registers.
I don't know whats wrong. Heres the error I getting in bochs, could someone explain this to me?
It repeats this same line of code for about 100-200 lines more. If you need to see the code, then just ask.
I don't know whats wrong. Heres the error I getting in bochs, could someone explain this to me?
Code: Select all
00000212158i[CPU ] BxError: instruction with op1=0xff
00000212158i[CPU ] nnn was 7
00000212158i[CPU ] WARNING: Encountered an unknown instruction (signalling illegal instruction):
00000212159i[CPU ] BxError: instruction with op1=0xff
00000212159i[CPU ] nnn was 7
00000212159i[CPU ] WARNING: Encountered an unknown instruction (signalling illegal instruction):
00000212160i[CPU ] BxError: instruction with op1=0xff
Re:Help with code
wait a minute, if bochs dosnt mimic what a computer will do, why use it? are you supposed to try to get your code to run on bochs, instead of a PC? please correct me if im horribly wrong, cuz im new to bochs, and cant even get it to work right
Re:Help with code
Bochs works, but it isn't perfect. If it runs on a PC it will probably run under Bochs, but if you do all your development under Bochs, then try it on a PC, you will be disappointed.
Re:Help with code
That means that you try to do an illegal instructionbeyondsociety wrote: IIt repeats this same line of code for about 100-200 lines more. If you need to see the code, then just ask.Code: Select all
00000212158i[CPU ] BxError: instruction with op1=0xff 00000212158i[CPU ] nnn was 7 00000212158i[CPU ] WARNING: Encountered an unknown instruction (signalling illegal instruction): 00000212159i[CPU ] BxError: instruction with op1=0xff 00000212159i[CPU ] nnn was 7 00000212159i[CPU ] WARNING: Encountered an unknown instruction (signalling illegal instruction): 00000212160i[CPU ] BxError: instruction with op1=0xff
Perhaps you try to "ret" or "iret" to an illegal address...Check your interrupt handlers or show us some code...
Re:Help with code
In my experience, the best way to work is to use Bochs as the basic test platform, and then when it seems to work, test it out on a live machine. The main advantage of Bochs is that it can shorten the turn around time when testing, allowing you to get a close approximation of running code quickly; a typical Bochs run will be over faster than even a quick machine can reboot, usually. Because it cannot exactly simulate the exact behavior of a real machine, code will generally fail on Bochs more often than on a real machine; it is rare for something to work under Bochs but fail on the actual hardware.Tim Robinson wrote: Bochs works, but it isn't perfect. If it runs on a PC it will probably run under Bochs, but if you do all your development under Bochs, then try it on a PC, you will be disappointed.
Keep in mind that, when you are coding at this low level, you will often find equally serious differences between real machines. For what it does, Bochs is actually quite good (though VMware is definitely better if you can afford it).
If you can, it is a good idea to run the tests on a separate machine from the one you are developing on, if only so that you don't trash your working PC. While I cannot speak of other countries, in the major urban areas of the US it is surprisingly easy to pick up a Pentium in the 100MHz range for cheap; I know people who keep themselves in equipment just from dumpster diving, and they often find machines in the 300Mhz class or higher, usually in working order or needing only minor repairs.