COM: setting IRQ

For issues with communication ports, protocols, etc.
Post Reply
gimbal-lock
Posts: 5
Joined: Apr 16, 2022 0:48

COM: setting IRQ

Post by gimbal-lock »

While attempting to get COM3 and COM4 working in DOS, I discovered my x86 board has IRQ(10) assigned to COM3 and IRQ(11) assigned to COM(4).
The OPEN COM command only allows setting the IRQ from 3-7. Is there anyway to increase this range?
coderJeff
Site Admin
Posts: 4313
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: COM: setting IRQ

Post by coderJeff »

It's been years since I wrote the dos serial driver. Seems I left myself a note:
master/src/rtlib/dos/io_serial.c
/* TODO: Support for slave PIC? */

IIRC, the set-up of the second PIC is should not be too difficult (to remember / research how to do).

FYI, the driver should already support IRQ sharing if you have more than one serial port on the same IRQ (but is limited to IRQ's 3 to 7).

The significant issue for me would be testing. I don't think I have anything that can simulate the hardware well enough. Second issue for me is that building the DOS version of fbc is a pain and not my favorite thing to do - I tend to only do it before a release.

If you or someone you know is building fbc DOS version and can test, I can (probably) guide you or someone through the changes needed.
gimbal-lock
Posts: 5
Joined: Apr 16, 2022 0:48

Re: COM: setting IRQ

Post by gimbal-lock »

coderJeff wrote: Apr 16, 2022 11:33 It's been years since I wrote the dos serial driver. Seems I left myself a note:
master/src/rtlib/dos/io_serial.c
/* TODO: Support for slave PIC? */

IIRC, the set-up of the second PIC is should not be too difficult (to remember / research how to do).

FYI, the driver should already support IRQ sharing if you have more than one serial port on the same IRQ (but is limited to IRQ's 3 to 7).

The significant issue for me would be testing. I don't think I have anything that can simulate the hardware well enough. Second issue for me is that building the DOS version of fbc is a pain and not my favorite thing to do - I tend to only do it before a release.

If you or someone you know is building fbc DOS version and can test, I can (probably) guide you or someone through the changes needed.
Sorry to say, I don't have or know anyone with the required skill set to modify and rebuild fbc. If you can overcome the pain, I'd be very happy to supply the necessary hardware for testing.
coderJeff
Site Admin
Posts: 4313
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: COM: setting IRQ

Post by coderJeff »

I see. I was hoping that someone might be able to get more hands on with the DOS port.

---
AW, I made the minimal changes I think that are needed and you can test from binaries here:
fbc-dos-1.10.0-20220417.zip
Take care copying over your existing files. This binaries are not optimized like would be in a normal release, so you may want to restore your original files after testing.

I was unable to test the higher IRQ numbers. After fighting with vmware and forcing COM ports to be recognized in winxp device manger on irq 10 and 11, vmware apparently was still triggering on irq 3 & 4 only. But I might have an older version of vmware.

You can test your serial ports and OPEN COM "COMx: ....IRnn" statement will try to open COMx on IRQ nn. Any IRQ from 3 to 15

Let me know how it goes.

---
The only thing I'm not sure about is the initial state of the PIC's. I would expect that the OS would configure them as master & slave. But maybe not, in which case there is some more port fiddling to do. But might be able to patch that through fb code.

If you could compile and run the following: it will tell me the initial condition of the PIC's on your board.

Code: Select all

dim as integer pic1_mask = inp(&h20+1)
dim as integer pic2_mask = inp(&hA0+1)

print "PIC1 mask " & bin(pic1_mask,8)
print "PIC2 mask " & bin(pic2_mask,8)
gimbal-lock
Posts: 5
Joined: Apr 16, 2022 0:48

Re: COM: setting IRQ

Post by gimbal-lock »

coderJeff wrote: Apr 17, 2022 22:18 I see. I was hoping that someone might be able to get more hands on with the DOS port.

---
AW, I made the minimal changes I think that are needed and you can test from binaries here:
fbc-dos-1.10.0-20220417.zip
Take care copying over your existing files. This binaries are not optimized like would be in a normal release, so you may want to restore your original files after testing.

I was unable to test the higher IRQ numbers. After fighting with vmware and forcing COM ports to be recognized in winxp device manger on irq 10 and 11, vmware apparently was still triggering on irq 3 & 4 only. But I might have an older version of vmware.

You can test your serial ports and OPEN COM "COMx: ....IRnn" statement will try to open COMx on IRQ nn. Any IRQ from 3 to 15

Let me know how it goes.

---
The only thing I'm not sure about is the initial state of the PIC's. I would expect that the OS would configure them as master & slave. But maybe not, in which case there is some more port fiddling to do. But might be able to patch that through fb code.

If you could compile and run the following: it will tell me the initial condition of the PIC's on your board.

Code: Select all

dim as integer pic1_mask = inp(&h20+1)
dim as integer pic2_mask = inp(&hA0+1)

print "PIC1 mask " & bin(pic1_mask,8)
print "PIC2 mask " & bin(pic2_mask,8)
Here's the results:

PIC1 mask 11111000
PIC2 mask 10001100

Hope that shows the correct configuration?

I really appreciate you working on this, many Thanks !

No luck with COM3 and COM4, both not working. COM1 and COM2 opened successfully.
coderJeff
Site Admin
Posts: 4313
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: COM: setting IRQ

Post by coderJeff »

gimbal-lock wrote: Apr 17, 2022 23:18 Here's the results:

PIC1 mask 11111000
PIC2 mask 10001100
Each zero (0) bit shows IRQ's that are already in use. PIC1 mask shows IRQ 3,4,5,6,7 not yet in use. PIC2 mask shows IRQ 10,11,15 not yet in use. An fb program will try to install it's own ISR with the OPEN statement and restore the PIC/IRQ/ISR to original state with the CLOSE statement. If the fb program abnormally aborts, it might leave the configuration in a bad state.

You could try running some other serial terminal program (before running any fbc program) to verify that COM3/4 on IRQ 10/11 is working.
No luck with COM3 and COM4, both not working. COM1 and COM2 opened successfully.
Are you checking for errors on the OPEN statement? e.g.:

Code: Select all

if( open com("COM4:9600,n,8,1,cs0,ds0,cd0,rs,IR10" As #1) <> 0 ) then
	print "serial connection error"
end if
What is your hardware? Not sure if that will give any clues to debug, but might help to know. All the pieces are in place that this should work in fb, so need to find some new information of what's not working or what I might have missed.
gimbal-lock
Posts: 5
Joined: Apr 16, 2022 0:48

Re: COM: setting IRQ

Post by gimbal-lock »

coderJeff wrote: Apr 18, 2022 8:06
gimbal-lock wrote: Apr 17, 2022 23:18 Here's the results:

PIC1 mask 11111000
PIC2 mask 10001100
Each zero (0) bit shows IRQ's that are already in use. PIC1 mask shows IRQ 3,4,5,6,7 not yet in use. PIC2 mask shows IRQ 10,11,15 not yet in use. An fb program will try to install it's own ISR with the OPEN statement and restore the PIC/IRQ/ISR to original state with the CLOSE statement. If the fb program abnormally aborts, it might leave the configuration in a bad state.

You could try running some other serial terminal program (before running any fbc program) to verify that COM3/4 on IRQ 10/11 is working.
No luck with COM3 and COM4, both not working. COM1 and COM2 opened successfully.
Are you checking for errors on the OPEN statement? e.g.:

Code: Select all

if( open com("COM4:9600,n,8,1,cs0,ds0,cd0,rs,IR10" As #1) <> 0 ) then
	print "serial connection error"
end if
What is your hardware? Not sure if that will give any clues to debug, but might help to know. All the pieces are in place that this should work in fb, so need to find some new information of what's not working or what I might have missed.
Yes, checking for errors. The hardware is the Vortex86EX. https://www.vortex86.com/products/Vortex86EX
gimbal-lock
Posts: 5
Joined: Apr 16, 2022 0:48

Re: COM: setting IRQ

Post by gimbal-lock »

Went back and retested. COM3 is working- awesome! COM4 is not. I must have mistakenly tested COM4 twice.

Since COM3 is functional now, I'm assuming the COM4 issue is no longer related to the slave PIC. Hopefully, I find a solution soon.

Update: After much research and discussion with the manufacturer, they concluded COM4 is not available in DOS :( .
I'll just have to make do with COM1,2 and 3.
coderJeff
Site Admin
Posts: 4313
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: COM: setting IRQ

Post by coderJeff »

gimbal-lock wrote: Apr 18, 2022 13:48 Since COM3 is functional now, I'm assuming the COM4 issue is no longer related to the slave PIC.
COM4 would probably work if the actual hardware was there. I'll go ahead and add to fbc/master. I found an old laptop but try as I may, could not get any com ports configured on to higher IRQ numbers.

The only changes I made were with dealing with the higher IRQ's and the interrupt service routine (ISR). I didn't add any code to configure master/slave PIC relationship.

For any interested readers:

Here are the expectations / assumptions made by the driver:

1) master/slave PIC relationship is already set-up by the bios or operating system

2) Default port addresses and IRQ's

Code: Select all

COM1: port &h3F8, IRQ 4
COM2: port &h2F8, IRQ 3
COM3: port &h3E8, IRQ 4
COM4: port &h2E8, IRQ 3
- COMn is really just a label to tell the driver which I/O port address to use
- fbc allows override of IRQ with the OPEN COM "...IRn" protocol option if needed
- no option to override base port address

3) When fbc installs an ISR, interrupt vectors are at known locations:
- IRQ 3 to 7 is on INT &hb through &hf
- IRQ 8 to 15 is on INT &h70 through &h77
- no option to override the interrupt vector
Post Reply