diff --git a/src/machine/m_ps2_mca.c b/src/machine/m_ps2_mca.c index 72776b22d..103badf61 100644 --- a/src/machine/m_ps2_mca.c +++ b/src/machine/m_ps2_mca.c @@ -418,6 +418,50 @@ ps55_model_50t_read(uint16_t port) return 0xff; } +static uint8_t +ps55_model_50v_read(uint16_t port) +{ + switch (port) + { + case 0x100: + return ps2.planar_id & 0xff; + case 0x101: + return ps2.planar_id >> 8; + case 0x102: + return ps2.option[0]; + case 0x103: + uint8_t val = 0xff; + /* + I/O 103h - Bit 7-4: Reserved + Bit 3-0: Memory Card ID (Connector 3 or 1) + + Memory Card ID: 8h = 4 MB Memory Card IV Installed + Fh = No Card Installed + */ + switch (mem_size / 1024) + { + case 4: + if (ps2.option[1] & 0x04) val = 0xff; + else val = 0xf8; + break; + case 8: + default: + if (ps2.option[1] & 0x04) val = 0xf8; + else val = 0xf8; + break; + } + return val; + case 0x104: + return ps2.option[2]; + case 0x105: + return ps2.option[3]; + case 0x106: + return ps2.subaddr_lo; + case 0x107: + return ps2.subaddr_hi; + } + return 0xff; +} static void model_50_write(uint16_t port, uint8_t val) { @@ -716,7 +760,7 @@ model_80_write(uint16_t port, uint8_t val) } static void -ps55_model_50t_write(uint16_t port, uint8_t val)//pcem55 +ps55_model_50tv_write(uint16_t port, uint8_t val) { ps2_mca_log(" Write SysBrd %04X %02X %04X:%04X\n", port, val, cs >> 4, cpu_state.pc); switch (port) @@ -1382,6 +1426,62 @@ mem_encoding_write_cached(uint16_t addr, uint8_t val, UNUSED(void *priv)) } } +static void +mem_encoding_write_cached_ps55(uint16_t addr, uint8_t val, UNUSED(void *priv)) +{ + uint8_t old; + + switch (addr) { + case 0xe0: + ps2.mem_regs[0] = val; + break; + case 0xe1: + ps2.mem_regs[1] = val; + break; + case 0xe2: + old = ps2.mem_regs[2]; + ps2.mem_regs[2] = (ps2.mem_regs[2] & 0x80) | (val & ~0x88); + if (val & 2) { + ps2_mca_log("Clear latch - %i\n", ps2.pending_cache_miss); + if (ps2.pending_cache_miss) + ps2.mem_regs[2] |= 0x80; + else + ps2.mem_regs[2] &= ~0x80; + ps2.pending_cache_miss = 0; + } + + if ((val & 0x21) == 0x20 && (old & 0x21) != 0x20) + ps2.pending_cache_miss = 1; + if ((val & 0x21) == 0x01 && (old & 0x21) != 0x01) + ps2_cache_clean(); +#if 1 + // FIXME: Look into this!!! + if (val & 0x01) + ram_mid_mapping.flags |= MEM_MAPPING_ROM_WS; + else + ram_mid_mapping.flags &= ~MEM_MAPPING_ROM_WS; +#endif + break; + + default: + break; + } + ps2_mca_log("mem_encoding_write: addr=%02x val=%02x %04x:%04x %02x %02x\n", addr, val, CS, cpu_state.pc, ps2.mem_regs[1], ps2.mem_regs[2]); + mem_encoding_update(); + if ((ps2.mem_regs[1] & 0x10) && (ps2.mem_regs[2] & 0x21) == 0x20) { + mem_mapping_disable(&ram_low_mapping); + mem_mapping_enable(&ps2.cache_mapping); + flushmmucache(); + } else { + mem_mapping_disable(&ps2.cache_mapping); + mem_mapping_enable(&ram_low_mapping); + flushmmucache(); + } + if (ps2.option[2] & 1) /* reset memstate for E0000 - E0FFFh hole */ + { + mem_set_mem_state(0xe0000, 0x1000, MEM_READ_EXTERNAL | MEM_WRITE_EXTERNAL); + } +} static void ps2_mca_board_model_70_type34_init(int is_type4, int slots) { @@ -1750,7 +1850,7 @@ ps55_mca_board_model_50t_init() device_add(&keyboard_ps2_mca_1_device); ps2.planar_read = ps55_model_50t_read; - ps2.planar_write = ps55_model_50t_write; + ps2.planar_write = ps55_model_50tv_write; device_add(&ps2_nvr_device); @@ -1790,6 +1890,51 @@ ps55_mca_board_model_50t_init() ps2.mb_vga = (vga_t *)device_add(&ps1vga_mca_device); } +void +ps55_mca_board_model_50v_init() +{ + ps2_mca_board_common_init(); + + //mem_remap_top(256); + ps2.split_addr = mem_size * 1024; + /* The slot 5 is reserved for the Integrated Fixed Disk II (an internal ESDI hard drive). */ + mca_init(5); + device_add(&keyboard_ps2_mca_1_device); + + ps2.planar_read = ps55_model_50v_read; + ps2.planar_write = ps55_model_50tv_write; + + device_add(&ps2_nvr_device); + + io_sethandler(0x00e0, 0x0002, mem_encoding_read_cached, NULL, NULL, mem_encoding_write_cached_ps55, NULL, NULL, NULL); + + ps2.mem_regs[1] = 2; + ps2.option[2] &= 0xf2; /* Bit 3-2: -Cache IDs, Bit 1: Reserved + Bit 0: Disable E0000-E0FFFh (4 KB) */ + + mem_mapping_add(&ps2.split_mapping, + (mem_size + 256) * 1024, + 256 * 1024, + ps2_read_split_ram, + ps2_read_split_ramw, + ps2_read_split_raml, + ps2_write_split_ram, + ps2_write_split_ramw, + ps2_write_split_raml, + &ram[0xa0000], + MEM_MAPPING_INTERNAL, + NULL); + mem_mapping_disable(&ps2.split_mapping); + + if (mem_size > 8192) { + /* Only 8 MB supported on planar, create a memory expansion card for the rest */ + ps2_mca_mem_fffc_init(8); + } + + if (gfxcard[0] == VID_INTERNAL) + ps2.mb_vga = (vga_t *)device_add(&ps1vga_mca_device); +} + int machine_ps55_model_50t_init(const machine_t* model) { @@ -1814,3 +1959,28 @@ machine_ps55_model_50t_init(const machine_t* model) return ret; } + +int +machine_ps55_model_50v_init(const machine_t* model) +{ + int ret; + + ret = bios_load_interleaved("roms/machines/ibmps55_m50v/56F7416.BIN", + "roms/machines/ibmps55_m50v/56F7417.BIN", + 0x000e0000, 131072, 0); + + if (bios_only || !ret) + return ret; + + machine_ps2_common_init(model); + + /* + * Planar ID + * F1FFh - PS/55 model 5551-V0x, V1x + * POST (P/N 38F6933) determination: FBxx -> 5 slots (ok), F1xx -> 5 slots (ok), others -> 8 (error) + */ + ps2.planar_id = 0xf1ff; + ps55_mca_board_model_50v_init(); + + return ret; +} diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index c005c9282..bb0f0cd80 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -5508,6 +5508,46 @@ const machine_t machines[] = { .snd_device = NULL, .net_device = NULL }, + /* Has IBM PS/55 5551-V0x, V1x firmware. */ + { + .name = "[MCA] IBM PS/55 model 5550-V0", + .internal_name = "ibmps55_m50v", + .type = MACHINE_TYPE_386DX, + .chipset = MACHINE_CHIPSET_PROPRIETARY, + .init = machine_ps55_model_50v_init, + .p1_handler = NULL, + .gpio_handler = NULL, + .available_flag = MACHINE_AVAILABLE, + .gpio_acpi_handler = NULL, + .cpu = { + .package = CPU_PKG_386DX | CPU_PKG_486BL, + .block = CPU_BLOCK_NONE, + .min_bus = 0, + .max_bus = 0, + .min_voltage = 0, + .max_voltage = 0, + .min_multi = 0, + .max_multi = 0 + }, + .bus_flags = MACHINE_PS2_MCA, + .flags = MACHINE_VIDEO | MACHINE_APM, + .ram = { + .min = 4096, + .max = 16384, + .step = 4096 + }, + .nvrmask = 63, + .kbc_device = NULL, + .kbc_p1 = 0xff, + .gpio = 0xffffffff, + .gpio_acpi = 0xffffffff, + .device = NULL, + .fdc_device = NULL, + .sio_device = NULL, + .vid_device = NULL, + .snd_device = NULL, + .net_device = NULL + }, /* 386DX/486 machines */ /* Has AMIKey F KBC firmware. */ diff --git a/src/video/vid_ps55da2.c b/src/video/vid_ps55da2.c index 6d4f43ca6..610e272fb 100644 --- a/src/video/vid_ps55da2.c +++ b/src/video/vid_ps55da2.c @@ -60,6 +60,7 @@ //#define DA2_DCONFIG_FONT_HANS 2 /* for Code page 936 Simplified Chinese */ #define DA2_DCONFIG_FONT_HANT 3 /* for Code page 938 Traditional Chinese */ #define DA2_DCONFIG_MONTYPE_COLOR 0x0A +#define DA2_DCONFIG_MONTYPE_8515 0x0B #define DA2_DCONFIG_MONTYPE_MONO 0x09 #define DA2_BLT_CIDLE 0 @@ -104,9 +105,7 @@ | EFD8h | Display Adapter /J | | | X | X | X | */ /* IO 3E0/3E1:0Ah Hardware Configuration Value L (imported from OS/2 DDK) */ -//2501 -//2500 mono -#define OldLSI 0x20 /* DA-2 or DA-3,5 */ +#define OldLSI 0x20 /* 1 = DA-2, 0 = DA-3 */ //#define Mon_ID3 0x10 #define FontCard 0x08 /* ? */ /* Page Number Mask : Memory Size? = (110b and 111b): vram size is 512k (256 color mode is not supported). */ @@ -122,8 +121,8 @@ /* Monitor ID (imported from OS/2 DDK 1.2) */ //#define StarbuckC 0x0A //1 010b IBM 8514, 9518 color 1040x768 //#define StarbuckM 0x09 //1 001b IBM 8507, 8604 grayscale -//#define Lark_B 0x02 //0 010b IBM 9517 color 1040x768 but 4pp -//#define Dallas 0x0B //1 011b IBM 8515, 9515 color 1040x740 B palette +//#define Lark_B 0x02 //0 010b IBM 9517 color 1040x768 but 4bpp +//#define Dallas 0x0B //1 011b IBM 8515, 9515 color 1040x740 palette B /* DA2 Registers (imported from OS/2 DDK) */ #define AC_REG 0x3EE @@ -277,8 +276,6 @@ typedef struct da2_t int fctladdr; int crtcaddr; - uint8_t miscout; - uint32_t decode_mask; uint32_t vram_max; uint32_t vram_mask; @@ -319,8 +316,6 @@ typedef struct da2_t pc_timer_t timer; uint64_t da2const; - //uint8_t scrblank; - int dispon; int hdisp_on; @@ -346,7 +341,6 @@ typedef struct da2_t uint8_t *changedvram; /* (vram size - 1) >> 3 = 0x1FFFF */ uint32_t vram_display_mask; - uint32_t banked_mask; //uint32_t write_bank, read_bank; @@ -364,16 +358,9 @@ typedef struct da2_t int enable; mem_mapping_t mapping; uint8_t ram[256 * 1024]; - uint8_t font[DA2_FONTROM_SIZE]; + uint8_t *font; } mmio; - //mem_mapping_t linear_mapping; - - //uint32_t bank[2]; - //uint32_t mask; - - //int type; - struct { int bitshift_destr; int raster_op; @@ -2295,7 +2282,8 @@ static uint8_t da2_mmio_read(uint32_t addr, void* p) return da2->mmio.ram[addr]; break; case 0x10://Font ROM - //if (addr >= 0x180000) addr -= 0x40000; + if (addr >= 0x1a0000) return DA2_INVALIDACCESS8; + if (addr >= 0x180000) addr -= 0x40000; if (addr >= DA2_FONTROM_SIZE) return DA2_INVALIDACCESS8; //da2_log("PS55_MemHnd: Read from mem %x, bank %x, chr %x (%x), val %x\n", da2->fctl[LF_MMIO_MODE], da2->fctl[LF_MMIO_ADDR], addr / 72, addr, da2->mmio.font[addr]); return da2->mmio.font[addr]; @@ -2975,8 +2963,8 @@ da2_reset(void* priv) da2->pos_regs[0] = DA2_POSID_L; /* Adapter Identification Byte (Low byte) */ da2->pos_regs[1] = DA2_POSID_H; /* Adapter Identification Byte (High byte) */ da2->pos_regs[2] = 0x40; /* Bit 7-5: 010=Mono, 100=Color, Bit 0 : Card Enable (they are changed by system software) */ - da2->ioctl[LS_CONFIG1] = OldLSI | Page_Two; /* Configuration 1 : DA - 2, 1024 KB */ - da2->ioctl[LS_CONFIG1] |= ((da2->monitorid & 0x8 ) << 2); /* Configuration 1 : Monitor ID 3 */ + da2->ioctl[LS_CONFIG1] = OldLSI | Page_Two; /* Configuration 1 : DA-II, 1024 KB */ + da2->ioctl[LS_CONFIG1] |= ((da2->monitorid & 0x8 ) << 1); /* Configuration 1 : Monitor ID 3 */ da2->ioctl[LS_CONFIG2] = (da2->monitorid & 0x7); /* Configuration 2: Monitor ID 0-2 */ da2->fctl[0] = 0x2b; /* 3E3h:0 */ da2->fctl[LF_MMIO_MODE] = 0xb0; /* 3E3h:0bh */ @@ -3019,7 +3007,8 @@ static void *da2_init() da2->changedvram = malloc(/*(memsize >> 12) << 1*/0x1000000 >> 12);//XX000h da2->monitorid = device_get_config_int("montype"); /* Configuration for Monitor ID (aaaa) -> (xxax xxxx, xxxx xaaa) */ - int fonttype = device_get_config_int("font"); + int fonttype = device_get_config_int("charset"); + da2->mmio.font= malloc(DA2_FONTROM_SIZE); switch(fonttype) { case DA2_DCONFIG_FONT_HANT: @@ -3142,6 +3131,7 @@ void da2_close(void *p) free(da2->cram); free(da2->vram); free(da2->changedvram); + free(da2->mmio.font); free(da2); } @@ -3162,17 +3152,17 @@ void da2_force_redraw(void *p) static const device_config_t da2_configuration[] = { // clang-format off { - .name = "font", + .name = "charset", .description = "Charset", .type = CONFIG_SELECTION, .default_int = DA2_DCONFIG_FONT_JPAN, .selection = { { - .description = "CP932 (Japanese)", + .description = "932 (Japanese)", .value = DA2_DCONFIG_FONT_JPAN }, { - .description = "CP938 (Traditional Chinese)", + .description = "938 (Traditional Chinese)", .value = DA2_DCONFIG_FONT_HANT }, { .description = "" } @@ -3188,6 +3178,10 @@ static const device_config_t da2_configuration[] = { .description = "Color", .value = DA2_DCONFIG_MONTYPE_COLOR }, + { + .description = "IBM 8515", + .value = DA2_DCONFIG_MONTYPE_8515 + }, { .description = "Grayscale", .value = DA2_DCONFIG_MONTYPE_MONO