Bochs-2.2

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.
Post Reply
Curufir

Bochs-2.2

Post by Curufir »

Released 28th of May.

Figured it might be useful to point out. The changelog shows quite a few bugs squashed so it's probably worth your while to update if you use Bochs for development.
AR

Re:Bochs-2.2

Post by AR »

Downloaded the source and built but I'm having a little problem - cli; hlt; no longer works (causes a PANIC). Have I just used a bad commandline option or is there an option to revert this or am I going to have to hack the code?
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:Bochs-2.2

Post by Brendan »

Hi,
AR wrote: Downloaded the source and built but I'm having a little problem - cli; hlt; no longer works (causes a PANIC). Have I just used a bad commandline option or is there an option to revert this or am I going to have to hack the code?
The "cli; hlt" sequence stopped working with version 2.2 (and all of it's pre-releases). There is no command line (or ./configure script) options for it, so you'd need to hack the code.

As an alternative, it's probably easier to use:

Code: Select all

   push ecx
   clr ecx
.zz:
   jecxz .zz
   pop ecx
Then, when you think your OS has reached this point you'd do "control+C", then type in "set $ecx = 1" and step through it like normal...


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
oswizard

Re:Bochs-2.2

Post by oswizard »

Or, start at line 61 of cpu\proc_ctrl.cc. Look at the following code:

Code: Select all

void BX_CPU_C::HLT(bxInstruction_c *i)
{
  // hack to panic if HLT comes from BIOS
  if (BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value == 0xf000)
    BX_PANIC(("HALT instruction encountered in the BIOS ROM"));

  if (CPL!=0) {
    exception(BX_GP_EXCEPTION, 0, 0);
    return;
  }

  if (! BX_CPU_THIS_PTR get_IF ()) {
    //BX_PANIC(("WARNING: HLT instruction with IF=0!"));
     BX_INFO(("WARNING: HLT instruction with IF=0!"));
  }

  // stops instruction execution and places the processor in a
  // HALT state.  An enabled interrupt, NMI, or reset will resume
  // execution.  If interrupt (including NMI) is used to resume
  // execution after HLT, the saved CS:eIP points to instruction
  // following HLT.
I just changed BX_PANIC to BX_INFO.

Mike
mystran

Re:Bochs-2.2

Post by mystran »

What do you use CLI;HLT for?
Curufir

Re:Bochs-2.2

Post by Curufir »

mystran wrote: What do you use CLI;HLT for?
It's way to set an effective breakpoint in Bochs when using the debugger (At least prior to 2.2). The emulator hits the CLI/HLT instructions and just stops. You can then halt the simulation and check out whatever values you like (Assuming #IF isn't what you're checking). When you restart the simulation the instruction following HLT will be executed.

Of course you could always set a breakpoint in Bochs, but it's often handier to just throw a CLI/HLT after the function you're interested in without needing to figure out addresses.

There are plenty of alternatives if it no longer works.
Slasher

Re:Bochs-2.2

Post by Slasher »

I've just tried out the CLI;HLT combination in Bochs 2.2 and IT STILL WORKS
It might be a problem with the os being tested.
p.s.
in my bochsrc.txt file under Log controls i use this setting for panic
panic: action=report
mystran

Re:Bochs-2.2

Post by mystran »

Hmmh.. if I want a breakpoint in bochs I'm happy to have it panic, since if somethings wrong badly enough for my OS code to fail to display it's own debug dump, then the bochs register trace is about the best I would hope to get.

But then again, that's probably because Bochs debugger refuses to work with me, causing bochs to hang indefinitely on every PANIC so that I have to kill -9 it, if the debugger is compiled in.
AR

Re:Bochs-2.2

Post by AR »

Having it PANIC makes it sort of hard to perform "x"/"xp"/"print-stack"... CLI; HLT allows you to just go:

Code: Select all

  /* ... */
   SomethingThatStuffsUpEverythingSomehow();
   __asm__ ("cli\n hlt");
Then when it gets there you Ctrl+C for the debug prompt and inspect the memory, I'll probably use Brendan's method now though.

The debugger always locks up after the panic for me as well, but I can terminate it by closing the command prompt.
Post Reply