Page 1 of 1

Code for 8295A runs well on xAPIC

Posted: Tue Dec 16, 2014 9:03 pm
by angwer
Hi everyone, I am learning OS development and come across a questsion.

When handling interrupts the book I choose tells me to use 8295A and IDT. I wrote some code according to the book, init 8295A and IDT. The code runs well. (The interrupt can be triggered and the handler is calleld) But the point is I think the code should report error.

The environment is bochs 2.6.7 with Pentium 4 cpu. The cpu uses xAPIC instead of 8295A. So I think the code I wrote for 8295A should not work on the platform, but it does work. I have searched a lot and it seems that they are not compatible.

So why my code for 8295A can run on the xAPIC platform? Does this mean Pentium 4 cpu still have 8295A inside, and how about the newer cpus?

Note: From the Intel manual I know APIC can be disabled but in my code I don't do this and I don't even know what will happen if APIC is disabled. And the code I wrote is compiled into a com file running on freedos since I have not written a complete boot loader. The book tells me right now it is OK to treat it as a com file on freedos.

Sorry if the question is stupid and thanks everyone in advance.

Re: Code for 8295A runs well on xAPIC

Posted: Tue Dec 16, 2014 9:20 pm
by Brendan
Hi,
angwer wrote:The environment is bochs 2.6.7 with Pentium 4 cpu. The cpu uses xAPIC instead of 8295A. So I think the code I wrote for 8295A should not work on the platform, but it does work. I have searched a lot and it seems that they are not compatible.
It doesn't support xAPIC instead of 8295A - it supports xAPIC/IO APIC in addition to 8295A/PIC chips. When you first boot, the system is using PIC chips (for backward compatibility). To use IO APIC you need to disable the PIC chips and enable/configure the IO APIC.
angwer wrote:Does this mean Pentium 4 cpu still have 8295A inside, and how about the newer cpus?
The IO APIC and/or PIC chip is in the chipset, not in the CPU. Almost all newer chipsets still provide the PIC chips; however there are some (designed for UEFI only with none of the old stuff needed for backward compatibility) which do not have PIC chips.
angwer wrote:Note: From the Intel manual I know APIC can be disabled but in my code I don't do this and I don't even know what will happen if APIC is disabled. And the code I wrote is compiled into a com file running on freedos since I have not written a complete boot loader. The book tells me right now it is OK to treat it as a com file on freedos.
Don't forget that there's 2 separate pieces - the IO APIC (which mostly does what the PIC chip did, but has more IRQ lines and supports multi-CPU properly) in the chipset; plus the local APIC in the CPU (which receives interrupts from the IO APIC, and allows you to send "inter-processor interrupts" from one CPU to another, and has other "miscellaneous" stuff built into it like the local APIC timer).


Cheers,

Brendan

Re: Code for 8295A runs well on xAPIC

Posted: Tue Dec 16, 2014 11:53 pm
by angwer
Thanks to Brendan. You do solve my problem. Thanks!!!!!!!!!!!!!!!

By the way, it is the first time to use osdev forum. When I want to reply I treat the report this post as reply this post. Shamed!!! :oops: And sorry to Brendan, I report the answer that helps me....