From 5bd7198f63d5bcc90f300a9d2d0580f84b68132e Mon Sep 17 00:00:00 2001 From: WNT50 <173389620+WNT50@users.noreply.github.com> Date: Fri, 10 Oct 2025 12:08:39 +0800 Subject: [PATCH] Memory detection fixes for IBM PS/2 machines (#6309) Fix IBM PS/2 model 50 and 60 with 1MB memory, and correct IBM PS/2 model 30-286 maximum onboard memory --- src/machine/m_ps2_mca.c | 58 ++++++++++++++++++++++++++++++++++--- src/machine/machine_table.c | 4 +-- 2 files changed, 56 insertions(+), 6 deletions(-) diff --git a/src/machine/m_ps2_mca.c b/src/machine/m_ps2_mca.c index e9f813f32..f02dd265a 100644 --- a/src/machine/m_ps2_mca.c +++ b/src/machine/m_ps2_mca.c @@ -507,7 +507,7 @@ model_50_write(uint16_t port, uint8_t val) ps2.option[0] = val; break; case 0x103: - ps2.option[1] = val; + ps2.option[1] = (ps2.option[1] & 0xfe) | (val & 0x01); break; case 0x104: ps2.option[2] = val; @@ -1163,6 +1163,29 @@ ps2_mca_board_model_50_init(void) ps2.planar_read = model_50_read; ps2.planar_write = model_50_write; + /* + I/O 103h - Bit 3: Memory Presence Detect 2 + Bit 2: Memory Presence Detect 1 + Bit 1: Password Override Jumper + Bit 0: Enable System Board RAM + */ + + switch (mem_size / 1024) { + case 0: /*256Kx2*/ + ps2.option[1] = 0xf8; + break; + case 1: /*512Kx2*/ + ps2.option[1] = 0xf4; + break; + case 2: /*1Mx2*/ + default: + ps2.option[1] = 0xf0; + break; + } + + /* Enable password function */ + ps2.option[1] |= 0x02; + if (mem_size > 2048) { /* Only 2 MB supported on planar, create a memory expansion card for the rest */ ps2_mca_mem_fffc_init(2); @@ -1183,9 +1206,36 @@ ps2_mca_board_model_60_init(void) ps2.planar_read = model_50_read; ps2.planar_write = model_50_write; - if (mem_size > 2048) { - /* Only 2 MB supported on planar, create a memory expansion card for the rest */ - ps2_mca_mem_fffc_init(2); + /* + I/O 103h - Bit 3: Memory Presence Detect 2 (Reversed) + Bit 2: Memory Presence Detect 1 (Reversed) + Bit 1: Password Override Jumper + Bit 0: Enable System Board RAM + */ + + switch (mem_size / 1024) { + case 0: /*256Kx2*/ + ps2.option[1] = 0xf0; + break; + case 1: /*256Kx4*/ + ps2.option[1] = 0xf4; + break; + case 2: /*512Kx4*/ + case 3: /*Not supported*/ + ps2.option[1] = 0xf8; + break; + case 4: /*1Mx4*/ + default: + ps2.option[1] = 0xfc; + break; + } + + /* Enable password function */ + ps2.option[1] |= 0x02; + + if (mem_size > 4096) { + /* Only 4 MB supported on planar, create a memory expansion card for the rest */ + ps2_mca_mem_fffc_init(4); } device_add(&ps2_nvr_55ls_device); diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 8ca38771a..180628e9f 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -3105,7 +3105,7 @@ const machine_t machines[] = { .flags = MACHINE_XTA | MACHINE_VIDEO_FIXED, .ram = { .min = 512, - .max = 16384, + .max = 4096, .step = 512 }, .nvrmask = 127, @@ -4959,7 +4959,7 @@ const machine_t machines[] = { .flags = MACHINE_VIDEO, .ram = { .min = 1024, - .max = 10240, + .max = 12288, .step = 1024 }, .nvrmask = 63,