I am modifying the source code of a driver for an ISA card that uses IRQ2. The case, as we all know, IBM added a second PIC and chained it using IRQ2, and the IRQ2 present in the ISA bus was replaced by IRQ9.
Since the code I am modifying was thought to be used on a PC / PC/XT, which don't carry the slave PIC (with the exception of the 5162), I would like to check if the chip is installed in order to execute the appropriate code for managing it so the driver continues to be compatible with old IRQ2 devices and the slightly newer IRQ9 ones.
Is there a reliable way to do so in x86 assembly?
Call BIOS service INT 15h, AH=C0H Get System Parameters. This service gives you a pointer in ES:BXto an array that has this information at byte 5, bit 0x40. Here's some assembly code to call this service:
; returns CF clear if 2nd PIC present, CF set otherwise
pic2_present:
mov ah, 0xc0
int 0x15 ; GET SYSTEM PARAMETERS
jc .fail ; failure: must be an early BIOS
test byte [es:bx+5], 0x40 ; 2nd PIC present?
jz .ret ; on success, return CF=0
stc ; on failure, return CF=1
.ret: ret
; INT 15h AX=C0h not supported, check machine type byte
.fail: mov bx, 0xf000
mov es, bx
cmp byte [es:0xfffe], 0xfe ; CF clear if PC or XT
cmc ; CF set if PC or XT
ret
If the call is not supported, this must be a fairly early board. In this case, evaluate the machine type byte at f000:fffe which is FF on PC boards, FE on XT boards and FD on AT boards (other values exist, but not on boards that old).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With