Bochs: Difference between revisions

39 bytes added ,  11 years ago
m
no edit summary
[unchecked revision][unchecked revision]
mNo edit summary
Line 1:
{{Emulators}}
 
'''Bochs''' is a steadily improving simulatoremulator for the [[:Category:x86|IA32x86]] platform. AmongIt othergreatly nicetiesimproves (suchOS asdevelopment removingbecause the needvirtual formachine arestarts rebootmuch toquicker testthan yourreal latest kernel buildhardware, just restart Bochs),plus it offers detailed debugging functionality that can help greatly during kernel development.
 
It is strongly suggested to get two installations of Bochs - in addition to the out-of-the-box version (which might well be one of the binary downloads), you should also compile a second instance with the internal debugger enabled - so when something strange occurs that your 'normal' debugging tools can't trace, you can cross-check it with the debug version. You may also wish to enable (and use) the debug i/oIO ports.
 
 
==Frequent error messages==
===Running in Bogus Memory===
You sent your code pointer (eipEIP) to some uninitialized memory area. This means you either followed a nullNULL (or uninitialized) pointer, or you damaged the return address of your [[Stack#Stack example on the X86 architecture|stack frame]]. Make your code more clean, test pointers before you follow them, initialize every pointer (especially those who are on the stack) and enable *-Wall* in GCC.
 
=== 3rd exception with no resolution===
Line 30:
 
===I/O Operand Size===
Bochs performs some paranoiacrather paranoid checks on I/O operand size. Reading a byte from port 0x1234 is usually not the same thing as reading a dword. Go back to your chip's datasheetdata sheet and double-check that your sizes are correct.
 
=== fetch_raw_descriptor: LDTR.valid=0 ===
Many of you have said "but ... I do not have an LDT and I read it wasn't mandatory!?". You're right. And so is BOCHSBochs. This message usually means that your program tried to load a selector with some garbage value, which happened to have the 3rd bit (Table Indicator) set. The CPU will try to look up the descriptor in the LDT, but there's no LDT registered! In most cases, the error comes from some mispairing of push and pop on the stack, which lead to a non-selector value to be loaded in a segment register.
 
If you're still stuck, download the Bochs sourcessource package and search for the message you received. Then, maybe you can add extra information to the message-printing code (like the faulty offset of a segfault, the segment limit, etc). But keep away from modifying Bochs' operations! Every time I suspected a bug in Bochs, I was just misunderstanding the Intel Manual...
 
==Differences between Bochs and real hardware==
;Bochs enables A20Linethe A20 line in the BIOS
:Your PC doesn't necessarily do so. Sometimes there's a BIOS option, sometimes there isn't. Check your code that enables A20Linethe A20 line and make sure it has no issues with faster hardware.
 
;Bochs wipes out its memory
Line 45:
 
;Bochs does not properly emulate CPU cache/TLB
:Although Bochs does have these constructs, they do not work the same as a regular CPU cache/ or TLB and do not change based on which CPU is being emulated. If you're not handling caching or TLB refreshes correctly, behavior may differ in Bochs vs. hardware (ie,i.e. it may work on Bochs but not on hardware, or vice versa).
 
;Bochs floppy has no errors
:In a normalphysical PC, it's common to issue up to 3 read commands on a sector/track before it can be read fine. If you don't have proper error check/recovery in your bootsector, you're likely to run something that is not your kernel...
 
;Bochs is flexible about returning to real mode
:UnlikeDespite what Chris Giese's Protected Mode tutorial states, you do not have to be in 16-bit protected mode to clear the PE bit of cr0CR0. If you fail to enter 16-bit protected mode on a real PC, it will hang, without giving any error indication - no triple fault or anything!
 
;Bochs' timer is not realtimereal time
:(unless you configure it closer to real time). Waiting for 2 second on bochs will let any virtual device that needs 2 seconds to be ready be ready, but that could be just 0.02 seconds for you ... or that could be 200 seconds.
 
Line 101:
 
===Magic Breakpoint===
When you're using bochs with the internal debugger, then you can trigger the debugger via a system called magic breakpoints. To trigger a breakpoint, you can insert <tt>XCHGxchg BXbx, BXbx</tt> anywhere in the code and bochs will trap into the debugger as soon as it executes it. On real systems this has no effect as it only replaces BX with itself.
 
You should put the following line in your bochs configuration to have it listen to magic breakpoints:
Line 148:
A few notes:
* If you are on Windows, that last line should probably read "--with-win32".
* Bochs has GDB- stub support, and its own internal debugger. These cannot be compiled into the same Bochs binary. The internal debugger is very useful, itits flag is --enable-debugger
* The GDB- stub in Bochs does not support SMP, last time I checked.
* If you do not enable PCI, then the Intel Multiprocessing tables will not appear in memory.
* I was unable to successfully load the GUI debugger without specifying <tt>--disable-plugins</tt>. Otherwise, I get dynamic loading symbol errors.
Anonymous user