skiselev / 8088_bios

BIOS for Intel 8088 based computers
GNU General Public License v3.0
510 stars 61 forks source link

Micro8088 BIOS on Ericsson PC XT #66

Open explit7 opened 4 months ago

explit7 commented 4 months ago

Hello @skiselev This is not really an issue, rather an question. My collegue has an Ericsson PC XT PCXT1

here is some infotmation about it: https://theretroweb.com/motherboards/s/ericsson-8301-60-52-10

Its very similar to IBM PC XT, but has some parts which are different. Originally it was sold with an MDA Monitor with an proprietary connector, where the DC voltage for the monitor was given over the graphic card. Also the keyboard is different, it has a normal DIN Connector, but its not an XT, nor AT Keyboard.

My colleagues wish was to use CGA graphics card on this system. The first problem was BIOS. Its a special BIOS (somehow made by NOKIA). And it doesn't support CGA. EGA and VGA running like a charm, because of the own BIOS on the graphics card. We tried also the new CGA graphics card made by the same bad guys, who made Book8088. It has own BIOS - but it also refuse to work on this PC.

The original BIOS is 16Kb, split on two 2764 EPROMs. My Idea was, to take your Micro8088 BIOS, the binary for the IBM PC XT, split it in two 8Kb halfs an burn it to the 2x 2764 EPROMs.

The result was - it works! And it works with CGA cards! But with one nasty issue: Keyboard is not working now. Original Ericsson Keyboard doesn't work, and standart XT keyboard doesn't work also.

Maybe you have an idea, what need to be changed in Micro8088 BIOS, so that the original keyboard works? It would be very cool.

Thank you!

I attach some pictures and original Ericsson ROM Images. PCXT_Mainboard CGA_ISA PCXT_CGA1 PCXT_CGA2 Ericcsson_PCXT_BIOS.zip

skiselev commented 4 months ago

This system doesn't appear to use a 8255 PPI, which, among other things, is used for the keyboard interfacing on IBM PC, IBM PC/XT, and most clones. So I suspect the keyboard interface on this system implemented differently from IBM PC/XT and it is not quite compatible with it. That would explain why the keyboard is not working.

I searched the net a bit regarding this system. There is almost no documentation for it. Supposedly Matsushita Electric aka Panasonic manufactured these systems for Ericsson. There is an older system also manufactured by Panasonic - Panasonic JB-3000 which was also sold by Ericsson, named step/one.

For that system particularly, it appears that the keyboard uses IRQ1 (just as it does on the IBM PC), but it uses I/O port 0x04 to read scancodes from the keyboard.

For test purposes, you can replace the ppi_pa_reg here with 0x04 , rebuild the BIOS, and test it. Maybe that's all what is needed to make it work... Otherwise, we could try disassembling the original BIOS from Ericsson PC and looking at the INT 09h / IRQ1 handler.

P.S. The Cycle Logic CGA card doesn't have its own BIOS. CGA, MDA, HGC cards generally don't have their own BIOSes. The EPROM chip you see is the font ROM. The system BIOS typically provides support for these controllers. Although, it appears that Ericsson PC used its own version of CGA and didn't support other controllers.

explit7 commented 4 months ago

Thanks, very informative, we will try it!

That seems, that 8255 is onboard, but the keyboard is really connected some unusual way.

The original keyboard has LEDs for Caps Lock, Scroll lock and NumLock, but its not AT Keyboard.

image

skiselev commented 4 months ago

Oh. I missed it. In this case, it is possible that the keyboard just uses standard XT protocol (not an AT one though! An AT keyboard will not work with an XT, unless using AT2XT Converter) Let me see check the XT keyboard code for potential issues...

skiselev commented 4 months ago

The keyboard code in 8088 BIOS should be XT compatible... Below is partial disassembly of the INT 9 / IRQ1 handler from the BIOS you've attached. Looks mostly XT compatible. But it also checks port 71 (unused on XT).

C000:CB32  FB       STI
C000:CB33  50       PUSH    AX
C000:CB34  53       PUSH    BX
C000:CB35  51       PUSH    CX
C000:CB36  52       PUSH    DX
C000:CB37  1E       PUSH    DS
C000:CB38  B80000   MOV AX,0000
C000:CB3B  8ED8     MOV DS,AX
C000:CB3D  E460     IN  AL,60       ; AL = scan code
C000:CB3F  8AD8     MOV BL,AL       ; save scan code to BL
C000:CB41  E461     IN  AL,61       ; read PPI port B
C000:CB43  8AE0     MOV AH,AL
C000:CB45  0C80     OR  AL,80       ; clear keyboard shift register, clear IRQ1
C000:CB47  E661     OUT 61,AL
C000:CB49  8AC4     MOV AL,AH
C000:CB4B  E661     OUT 61,AL       ; enable keyboard clock
C000:CB4D  8AC3     MOV AL,BL       ; restore scan code to AL
C000:CB4F  8AD8     MOV BL,AL       ; save scan code to BL (what's the point? I/O delay?)
C000:CB51  E471     IN  AL,71       ; 71 is not a PC/XT standard port...
C000:CB53  2438     AND AL,38       ; AND with a mask (bits #5,#4,#3) / test
C000:CB55  8AC3     MOV AL,BL       ; restore scan code to AL
C000:CB57  7504     JNZ CB5D        ; jump if any of the bits above are set
C000:CB59  3CFF     CMP AL,FF
C000:CB5B  7511     JNZ CB6E        ; jump if the scan code is not FF
C000:CB5D  E471     IN  AL,71       ; otherwise read port 71 again
C000:CB5F  D0C0     ROL AL,1        ; rotate left twice
C000:CB61  D0C0     ROL AL,1
C000:CB63  2402     AND AL,02       ; clear all but bit #1 (originally bit #7)
C000:CB65  0C15     OR  AL,15       ; set bits #4,#2,#0
C000:CB67  E671     OUT 71,AL       ; output to port 71
; procedure at CE10 tests byte 0000:0418, bit #0 - keyboard flags / CTRL flag.
; If the CTRL flag is not set, the procedure sets it, calls CE30 (end of interrupt interrupt), calls E76A and then clears CTRL flag and returns.
; Otherwise it just returns.
C000:CB69  E8A402   CALL    CE10
C000:CB6C  EB1A     JMP     CB88
; The loop below checks for special keys scancodes (Shifts, Alt, Ctrl, Print Screen, etc)
; It walks through a table at CAED which contains of 16 entries, each one containing a scancode - one byte and a subroutine adddress - one word
; 1D CBC2 - Ctrl pressed
; 2A CB91 - Left Shift pressed
; AA CB9D - Left Shift released
; B6 CBA3 - Right Shift released
; 36 CB97 - Right Shift pressed
; 38 CBBC - Alt pressed
; 9D CBC8 - Ctrl released
; B8 CBA9 - Alt released
; 39 CCB6 - Spacebar pressed
; 4E CCCA - Plus Sign pressed
; 80 CCBC - ??
; 78 CCC2 - ??
; 52 CC62 - Ins pressed
; D2 CC97 - Ins released
; 53 CBDA - Del pressed
; 3A CBCE - Caps Lock pressed
; BA CBD4 - Caps Lock released
; 45 CBF1 - Num Lock pressed
; C5 CC1D - Num Lock released
; 46 CC28 - Scroll Lock pressed
; C6 CC57 - Scroll Lock released
; 37 CC9D - Print Screen pressed
; 00 CCF7 - Default vector
; If there is no match, it falls through, and calls the generic scancode handling routine at CCF7
C000:CB6E  BBEDCA   MOV BX,CAED
C000:CB71  B91600   MOV CX,0016
C000:CB74  2E       CS:
C000:CB75  3A07     CMP AL,[BX]
C000:CB77  7405     JZ  CB7E
C000:CB79  830303   ADD BX,+03
C000:CB7C  E2F6     LOOP    CB74
C000:CB7E  8A361704     MOV DH,[0417]
C000:CB82  8AE0     MOV AH,AL
C000:CB84  2E       CS:
C000:CB85  FF5701   CALL    [BX+01]
; procedure at CE30 signals end of interrupt to PIC
C000:CB88  E8A502   CALL    CE30
C000:CB8B  1F       POP DS
C000:CBBC  5A       POP DX
C000:CB8D  59       POP CX
C000:CB8E  5B       POP BX
C000:CB8F  58       POP AX
C000:CB90  CF       IRET
explit7 commented 4 months ago

Wow, thanks for your work Sergey!

We tried 2 switchable AT/XT Keyboards and 1 AT Keyboad connected to AT2XT Adapter. None of them worked on Ericcsson, so i am pretty sure there are some differenties in keyboard handling.

TaggerTie83 commented 4 months ago

Dear @skiselev, dear @explit7

first of all many thanks for your both work an communication still now. your Micro 8088 Bios brought CGA compatibility to my special Ericsson Machine many many thanks for that. I am very happy about that.

May it be possible, that Port 71 is used to communicate with the Keyboard LED`s or part of a special check routine to check what kind of keyboard ist connected? There are 2 versions i am knowing about one small 84 Keys with LEDs (which i have) and one big (the Foto above).

If you need further information to assist you please let me know. Since the Foto from the board is taken from the WEB i will check today if the same keyboard kontroller is installed in my machine.

TaggerTie83 commented 4 months ago

Since the System was made by NOKIA / ERICCSON... maybe it will be helpful to understand the NOKIA Keyboard where i found some interesting stuff right here: https://www.win.tue.nl/~aeb/linux/kbd/scancodes-5.html

skiselev commented 4 months ago

Unless Ericsson/Nokia use a keyboard protocol very different from IBM PC/XT (unlikely), it wouldn't be possible to control the keyboard LEDs from the computer. The communication protocol is unidirectional - from the keyboard to the PC, excluding the RESET signal, that not all keyboards use. Some newer keyboards, e.g. keyboard with AT/XT switches handle the LEDs by themselves, without any support from the computer.

Technically, an XT or your Ericsson PC doesn't have a dedicated keyboard controller. The keyboard interface is implemented using a shift register and an Intel 8255 Parallel Peripheral Interface (PPI), which also used to read configuration switches, control speaker, control NMI sources, etc.

I'd like to understand if the keyboard is not working because the keyboard interface in the Ericsson PC different, or because something is broken with the XT keyboard support in my BIOS (although it works on Micro 8088, for example, which has XT-like keyboard interface). So, a couple of questions:

  1. Does your Ericsson PC with the original BIOS work with your Ericsson/Nokia keyboard? If not, it would tell me that perhaps there's a hardware problem...
  2. Does your Ericsson PC with the original BIOS work with an XT keyboard or AT keyboard and AT2XT converter? If the original keyboard works, but this doesn't, when maybe there are some differences in the interface or the protocol.
TaggerTie83 commented 4 months ago

Hi, to answer your questions:

  1. Yes with the original Bios everything is working fine. I have also the original ericsson Keyboard (searching over 2 years for it and this points me to question 2...
  2. The ericsson pc seems to be only working with the original ericsson keyboard. As i get this pc from the waste, i was looking over 2 years for the right keyboard. I've tried everything...
    • several AT Keyboards switchable to XT, or autosense
    • at2xt converter
    • xt keyboard from amstrad/schneider
    • AT/XT Switchable keyboard from honeywell which also have a Switch for 104 / 83 Keys None of them was working. It was like winning a lottery to get the exact needed keyboard

The main reason i was trying your micro8088 bios was the support of CGA Do you think it will be easier to implement the CGA routine over to the ericsson bios ?

skiselev commented 4 months ago

I am not sure how easy it will be to implement the INT 10h CGA support in Ericsson BIOS. There are some "holes" in the BIOS, so potentially, these can used for the CGA code. It would be a lot of work.

Looking at your answers, it is indeed possible that the Ericsson keyboard interface is slightly different from the XT. Just different enough to break compatibility with XT keyboards and the low-level code that handles these keyboards... Maybe that port 71 reads/writes is what different and needed for Ericsson keyboard interface to work?

TaggerTie83 commented 4 months ago

The funny thing is, everything else with your micro8088 bios is working, also the nice beep melody as soon i powering on the system. The DIP Switches have the same behaviour as on the original XT and also the system is booting fine from HDD straight into DOS 4.01 and NC (autoecex.bat). The one and only part is this f#*:!ing keyboad :D If we will investigate this things further please let me support you, "buying you some coffee" ;)

The only thing i was never checking was... is to try out the ericsson with a real IBM XT keyboard... because i did not have an original one.

explit7 commented 4 months ago

Maybe as first step we do, like @skiselev suggest:

For test purposes, you can replace the ppi_pa_reg here with 0x04 , rebuild the BIOS, and test it.

When i am back from holiday on 27.03. we will UV erase the both 2764 chips (i have only two of them), rebuild the BIOS and test it.

Or do you think, it is useless, when 8255 PPI is onboar, @skiselev ?

skiselev commented 4 months ago

I don't see any references to port 0x04 in the code. It must be specific to Ericsson step/one computer. Ignore that recommendation.

skiselev commented 4 months ago

Looking at the motherboard, I see there is a 8251 USART right next to the 8255. And that is in addition to the 8250 UART at the top left corner, that is used for the serial port. I am now wondering if that 8251 USART is what used to interface to the keyboard. That would allow using a proper RS-232 protocol instead of the half-baked serial that IBM PC uses... Assuming that USART's command register is mapped to I/O port 71h, reads and writes to that port make sense.

C000:CB51  E471     IN  AL,71       ; Read USART status register
C000:CB53  2438     AND AL,38       ; Check for Framing Error - FE, bit 5, Overrun Error - OE, bit 4, and Parity Error - PE, bit 3
C000:CB55  8AC3     MOV AL,BL       ; restore the scancode to AL
C000:CB57  7504     JNZ CB5D        ; Jump on USART errors
C000:CB59  3CFF     CMP AL,FF       ; Possibly an empty transmission?! No keyboard?
C000:CB5B  7511     JNZ CB6E        ; jump if the scan code is not FF
; Handle USART errors
C000:CB5D  E471     IN  AL,71       ; Read USART status register again
C000:CB5F  D0C0     ROL AL,1        ; Rotate the Data Set Ready - DSR, bit 7 to Data Terminal Ready - DTR, bit 1
C000:CB61  D0C0     ROL AL,1
C000:CB63  2402     AND AL,02       ; Leave only the DTR - bit 1
C000:CB65  0C15     OR  AL,15       ; Set Error Reset - ER, bit 4, Receive Enable - RE, bit 2, and Transmit Enable - TE, bit 0
C000:CB67  E671     OUT 71,AL       ; Output to USART command port

This actually results in a few questions:

skiselev commented 4 months ago

A bit more of disassembly. Subroutine at F000:E76A appears to be a simple "beep" routine. It generates 500 pulses to the speaker. Not very important ;)

F000:E76A  50       PUSH    AX
F000:E76B  51       PUSH    CX
F000:E76C  57       PUSH    DI
F000:E76D  BFE803   MOV DI,03E8     ; Repeat 1000 times
F000:E770  E461     IN  AL,61       ; Read PPI port B register
F000:E772  8AE0     MOV AH,AL       ; Save original register value to AH
F000:E774  24FC     AND AL,FC       ; Turn off speaker, bit 1 and Disable PIT channel 2 / speaker, bit 0
F000:E776  B94800   MOV CX,0048     ; delay loop count - 72 times
F000:E779  3402     XOR AL,02       ; Flip speaker bit 1 - turn on or off the speaker
F000:E77B  E661     OUT 61,AL       ; Write the new value to PPI port B
F000:E77D  90       NOP
F000:E77E  90       NOP
F000:E77F  E2FE     LOOPW   E77F        ; Delay
F000:E781  4F       DEC DI
F000:E782  75F2     JNZ E776        ; repeat
F000:E784  8AC4     MOV AL,AH
F000:E786  E661     OUT 61,AL       ; Write original value to PPI port B
F000:E788  5F       POP DI
F000:E789  59       POP CX
F000:E78A  58       POP AX
F000:E78B  C3       RET
skiselev commented 4 months ago

The BIOS uses a loop to initialize 25h I/O ports (table at C07D). The corresponding USART initialization instructions are:

; Set USART to command mode: configure sync operation, write two dummy sync characters
OUT 71,00 
OUT 71,00
OUT 71,00
; Issue reset command
OUT 71,40
; Write mode instruction: 1 stop bit, no parity, 8 bits, divide clock by 16
OUT 71,4E
; Write command instruction: Set Error Reset - ER, bit 4, and Transmit Enable - TE, bit 0
OUT 71,11
explit7 commented 4 months ago

Wow, that really deep dive into low-level Ericsson BIOS, thanks very much @skiselev !

Do you think we can Build a Micro8088 BIOS which has this USART initialisation routines ?

skiselev commented 4 months ago

That's what I am trying to figure out. It should be possible to simply initialize the USART and enable receive. It is quite possible that the communication to the keyboard is bi-directional. It appears that the code writes to port 60h, which is unusual for a typical PC/XT. So it is possible that the BIOS sends some commands to the keyboard.

I found another routine at CEC8, which seems to be the keyboard initialization routine. It initializes the BIOS data area corresponding to the keyboard buffer and its pointers. It also writes to port 60 and 71:

CEC8:
    PUSH    AX
    PUSH    CX
    MOV AX,001E         ; Pointer to the beginning of the keyboard buffer in the BIOS Data Area
    MOV [041A],AX       ; Keyboard buffer head
    MOV [041C],AX       ; Keyboard buffer tail
    MOV [0480],AX       ; Keyboard buffer start offset
    MOV WORD PTR [0482],003E    ; Keyboard buffer end offset
    MOV AL,40
    OUT 61,AL           ; Enable keyboard clock
    MOV AL,00
    OUT 60,AL           ; Send 0 to the keyboard?! What does it do? Resets the keyboard? Runs diagnostics?
CEE4:
    IN  AL,71           ; Read USART status register
    AND AL,04           ; Isolate TxEMPTY bit
    JZ  CEE4            ; Wait until TxEMPTY is set
    MOV AL,05
    OUT AL,71           ; Set Receive Enable, bit 2 and Transmit Enable, bit 0
    MOV BYTE PTR [046B],00  ; This location is unused on a typical PC/XT, but it appears to be used as some kind of flag here
    IN  AL,21           ; Read interrupt mask from PIC to AL
    AND AL,FD           ; Reset bit 1 - unmask IRQ1
    OUT 21,AL           ; Write new interrupt mask to PIC
    STI
    MOV CX,0000         ; Timeout counter
    MOV AH,03           ; High byte of timeout counter
CEFF:
    TEST    BYTE PTR [046B],02  ; check if bit 1 set
    JNZ CF0E            ; Bit 1 is set, exit the loop
    LOOPW   CEFF
    DEC AH
    JNZ CEFF
    JMP CF20            ; Jump if timeout waiting for bit 1
    CLI
    IN  AL,71           ; Read USART status register
    AND AL,38           ; Check Error bits
    JNZ CF20            ; Jump if USART error bits set
    IN  AL,60           ; Read the keyboard. What are we expecting to get here? Keyboard diagnostics / POST status?
    MOV [04EE],AL       ; Store in the BIOS Data Area, note 04EE is not typically used on PC/XT
    AND AL,F0           ; Isolate top 4 bits
    CMP AL,A0           ; Check bits 7 and 5
    JZ  CF2D            ; Jump if bits 7 and 5 are not set
CF20:
    PUSH    SI
    MOV SI,CF3E         ; "Keyboard Error"
    CALL    E05E            ; Print zero-terminated string pointed by CS:SI on the screen
    POP SI
    MOV BYTE PTR [0412],FF  ; 0412 is IBM PCjr infrared keyboard error count... Perhaps indicates keyboard error here?!
    MOV AL,C0
    OUT 61,AL           ; Clear keyboard shift regiser, enable keyboard clock
    MOV AL,40
    OUT 61,AL           ; Enable keyboard, enable keyboard clock
    MOV WORD PTR [0024],CB32    ; Set IRQ1 handler offset to CB32 (what was the offset before?!)
    POP CX
    POP AX
    RET
explit7 commented 4 months ago

Very interesting... 0412 is IBM PCjr infrared keyboard error count.... Hm.... IBM PCjunior Infrared Keyboard... Will try to find something to read about it

skiselev commented 4 months ago

Very interesting... 0412 is IBM PCjr infrared keyboard error count.... Hm.... IBM PCjunior Infrared Keyboard... Will try to find something to read about it

I don't think it is used in the same way... Whoever wrote the BIOS just found an unused location in the BIOS Data Area and repurposed it...

skiselev commented 4 months ago

A bit more progress on the disassembling the BIOS to understand the keyboard interface. The progress is documented here

Indeed it looks that 8251 USART is used for interfacing, the implementation is fairly straight forward. It is quite possible to make it work with 8088 BIOS, will take probably a couple of hours + testing ;)

I am on vacation most of the next week, not sure if I'll have time to implement it, but it is in my plans...

explit7 commented 4 months ago

Thanks for the time you invest in this Project @skiselev I am also on vacation, but after 27.03 /me and @TaggerTie83 - we can do all the testing needed!

TaggerTie83 commented 2 months ago

@skiselev

We can take this project on hold but if you need more information or testing please let me know. Since i have get two Turbo XT Clones which are able to run CGA out of the BOX, so i left my ericsson with Hercules and Stock bios.

The two Turbo XT Clones are equipped with your micro 8088 Bios and seems to running fine by now. If you are interested in the Original Bios dumps let me know... I will have a session with @explit7

One is a "MEWA XT" some German Company which shows the name "MEWA" XT and the Ram Checking based on Phoenix Rom Bios Ver 2.28

The other is unknown

TaggerTie83 commented 1 month ago

@skiselev

Just two Updates:

I switched out the Floppy Controller to a newer one "LONGSHINE" with Floppy drive seek and the 8088 XT Bios showing again two 1,44 MB Drivers but then detecting and displaying the 360k drives during typical seeking.

Long story short did you have any Idea how the 8088 XT supporting two 360K drives only when the Controller is not able to seek by themselve?

explit7 commented 1 month ago

Just my small 5 cents: @TaggerTie83 uses the Micro8088 BIOS 1.0 in the IBM PC/XT Version on a TurboXT Mainboard (8MHz). I spitted the 16KB Micro8088 IBM PC/XT BIOS into the 2x 8KB files and burned on 2x 27C64 EPROMs. While the "normal" Micro8088 BIOS on my Micro8088 has BIOS options to setup Floppy drives, the Micro8088 IBM PC/XT Version doesn't have such menu. Are the Floppy drives configured in the BIOS config file? Maybe you can give a short explanation here, @skiselev ? Thank you!

explit7 commented 1 month ago

I think we can close the issue here. Ericsson PCXT can work with original IBM CGA Card and with Graphics Gremlin. So no need to invent the bicycle again. What do you think @TaggerTie83 ?

TaggerTie83 commented 1 month ago

Feel free to close... as iam playing with real XTs now.