Reprogramming the PIC in Bochs

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
vhg119
Member
Member
Posts: 71
Joined: Fri Aug 24, 2007 5:56 pm
Location: CA, USA

Reprogramming the PIC in Bochs

Post by vhg119 »

When I execute my code to reprogram the PIC, Bochs popped up a dialog box telling me [PIC] >>PANIC<< write to port 20h = 21.

Then, it lets me choose to continue. Did I do something wrong?

Clicking continue proceeds and everything else looks fine.

Vince
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

The message says that you are writing an incorrect value to the first PIC port. The only values you should be sending are the ICW1 (0x11) or an EOI (0x20) The value of 0x21 or 0x15 (21 decimal) is not supported. Try to find the offending write and check its purpose.
"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 ]
vhg119
Member
Member
Posts: 71
Joined: Fri Aug 24, 2007 5:56 pm
Location: CA, USA

Post by vhg119 »

Thank you, I got my port/value parameters mixed up.

I'm trying to setup my IDT so I was remapping the IRQs to different Interrupts.

Now I'm getting alot of these errors:

[CPU0] BxError: instruction with opcode=0xff
[CPU0] mod was c0, nnn was 7, rm was 7
[CPU0] WARNING: Encountered an unkown instruction (signalling illegal instruction)

Bochs repeats that for about 10 seconds and then it'll reset itself.

I probably messed up my IDT entries.

Thanks for your help.
vhg119
Member
Member
Posts: 71
Joined: Fri Aug 24, 2007 5:56 pm
Location: CA, USA

Post by vhg119 »

I don't have a TSS set up yet so that's what I'm working on.

I have a question about the ss0 field of the TSS. Does this just point to the same SS location that the rest of the kernel uses?
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

ss0 is the stack segment to be set on a switch to ring 0. So yes, it should be your kernel SS. Which is usually 0x10. (Notice RPL of 0).
vhg119
Member
Member
Posts: 71
Joined: Fri Aug 24, 2007 5:56 pm
Location: CA, USA

Post by vhg119 »

Thanks JamesM, I got my TSS loaded and everything seems to be ok. I'm going to be doing software task switching. Do I still need to initialize all the fields of the TSS? Since I'm basically only going to use it for RING3->RING0 PL changes, is initializing only SS0 and ESP0 sufficient?

Furthermore, I assume it's a good idea to point ESP0 to a place that won't interfere with any RING0 tasks. Am I right?

My interrupts are still misbehaving with Bochs reporting many instances of:

[CPU0] BxError: instruction with opcode=0xff
[CPU0] mod was c0, nnn was 7, rm was 7
[CPU0] WARNING: Encountered an unkown instruction (signalling illegal instruction)
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

Show us how you setup your IDT entries. It may be an invalid IDT entry causing unwanted code to execute (ie. a null value would cause the real mode interrupt vector to try to be executed :D)

Edit: just noticed the second thread about the exact same thing, with the IDT setup code...
vhg119
Member
Member
Posts: 71
Joined: Fri Aug 24, 2007 5:56 pm
Location: CA, USA

Post by vhg119 »

pcmattman wrote:Show us how you setup your IDT entries. It may be an invalid IDT entry causing unwanted code to execute (ie. a null value would cause the real mode interrupt vector to try to be executed :D)

Edit: just noticed the second thread about the exact same thing, with the IDT setup code...
Yeah, sorry. I created another thread because it was a separate topic. Consider this one case closed.... Solved.
Post Reply