From c862960a3e854c18b980122d77399dbfba78ecf5 Mon Sep 17 00:00:00 2001 From: angelosa Date: Mon, 22 Jan 2024 04:12:00 +0100 Subject: pci/virge_pci: move new MMIO mapping to map_extra * fix Ubuntu-flavored & BeOS 3.x black screen when switching to display managers. --- src/devices/bus/pci/virge_pci.cpp | 78 ++++++++++++++++++++++----------------- src/devices/bus/pci/virge_pci.h | 1 + src/devices/video/s3virge.cpp | 3 ++ src/devices/video/s3virge.h | 1 + src/mame/pc/pcipc.cpp | 13 +++++-- 5 files changed, 60 insertions(+), 36 deletions(-) diff --git a/src/devices/bus/pci/virge_pci.cpp b/src/devices/bus/pci/virge_pci.cpp index 0222602e81b..fbc36775fe5 100644 --- a/src/devices/bus/pci/virge_pci.cpp +++ b/src/devices/bus/pci/virge_pci.cpp @@ -25,38 +25,37 @@ virgedx_pci_device::virgedx_pci_device(const machine_config &mconfig, const char { } +// TODO: this is repeated in old MMIO mode inside the VGA legacy memory space void virge_pci_device::mmio_map(address_map& map) { // image transfer ports - map(0x1000000,0x1007fff).w(m_vga, FUNC(s3virge_vga_device::image_xfer)); + map(0x0000,0x7fff).w(m_vga, FUNC(s3virge_vga_device::image_xfer)); - //map(0x1008180,0x10081ff) primary/secondary stream control + //map(0x8180,0x81ff) primary/secondary stream control - //map(0x1008200,0x100821f) memory port controller - //map(0x1008220,0x1008227) DMA control + //map(0x8200,0x821f) memory port controller + //map(0x8220,0x8227) DMA control // MMIO address map - map(0x10083b0,0x10083df).m(m_vga, FUNC(s3virge_vga_device::io_map)); - map(0x1008504,0x1008507).rw(m_vga, FUNC(s3virge_vga_device::s3d_sub_status_r), FUNC(s3virge_vga_device::s3d_sub_control_w)); - map(0x100850c,0x100850f).r(m_vga, FUNC(s3virge_vga_device::s3d_func_ctrl_r)); + map(0x83b0,0x83df).m(m_vga, FUNC(s3virge_vga_device::io_map)); + map(0x8504,0x8507).rw(m_vga, FUNC(s3virge_vga_device::s3d_sub_status_r), FUNC(s3virge_vga_device::s3d_sub_control_w)); + map(0x850c,0x850f).r(m_vga, FUNC(s3virge_vga_device::s3d_func_ctrl_r)); - //map(0x1008580,0x100858b) video DMA - //map(0x1008590,0x100859f) command DMA + //map(0x8580,0x858b) video DMA + //map(0x8590,0x859f) command DMA // S3D engine registers - map(0x100a000,0x100b7ff).rw(m_vga, FUNC(s3virge_vga_device::s3d_register_r), FUNC(s3virge_vga_device::s3d_register_w)); + map(0xa000,0xb7ff).rw(m_vga, FUNC(s3virge_vga_device::s3d_register_r), FUNC(s3virge_vga_device::s3d_register_w)); // alternate image transfer ports - map(0x100d000,0x100efff).w(m_vga, FUNC(s3virge_vga_device::image_xfer)); + map(0xd000,0xefff).w(m_vga, FUNC(s3virge_vga_device::image_xfer)); - //map(0x100ff00, 0x100ff43) LPB control + //map(0xff00, 0xff43) LPB control } void virge_pci_device::lfb_map(address_map& map) { map(0x0, 0x00ffffff).rw(m_vga, FUNC(s3virge_vga_device::fb_r), FUNC(s3virge_vga_device::fb_w)); - if(downcast(m_vga.target())->is_new_mmio_active()) - mmio_map(map); } void virge_pci_device::config_map(address_map &map) @@ -70,30 +69,34 @@ void virge_pci_device::legacy_io_map(address_map &map) map(0x00, 0x2f).m(m_vga, FUNC(s3virge_vga_device::io_map)); } +// FIXME: belongs to s3virge_vga_device. +u32 virge_pci_device::get_vga_linear_address() +{ + switch(downcast(m_vga.target())->get_linear_address_size() & 0x03) + { + case LAW_64K: + return downcast(m_vga.target())->get_linear_address() & 0xffff0000; + + case LAW_1MB: + return downcast(m_vga.target())->get_linear_address() & 0xfff00000; + + case LAW_2MB: + return downcast(m_vga.target())->get_linear_address() & 0xffe00000; + + default: + case LAW_4MB: + return downcast(m_vga.target())->get_linear_address() & 0xffc00000; + } +} + void virge_pci_device::refresh_linear_window() { if(downcast(m_vga.target())->is_linear_address_active()) { set_map_flags(0, M_MEM); - switch(downcast(m_vga.target())->get_linear_address_size() & 0x03) - { - case LAW_64K: - set_map_address(0,downcast(m_vga.target())->get_linear_address() & 0xffff0000); - logerror("Linear window set to 0x%08x\n",downcast(m_vga.target())->get_linear_address() & 0xffff0000); - break; - case LAW_1MB: - set_map_address(0,downcast(m_vga.target())->get_linear_address() & 0xfff00000); - logerror("Linear window set to 0x%08x\n",downcast(m_vga.target())->get_linear_address() & 0xfff00000); - break; - case LAW_2MB: - set_map_address(0,downcast(m_vga.target())->get_linear_address() & 0xffe00000); - logerror("Linear window set to 0x%08x\n",downcast(m_vga.target())->get_linear_address() & 0xffe00000); - break; - case LAW_4MB: - set_map_address(0,downcast(m_vga.target())->get_linear_address() & 0xffc00000); - logerror("Linear window set to 0x%08x\n",downcast(m_vga.target())->get_linear_address() & 0xffc00000); - break; - } + const u32 get_bar_address = get_vga_linear_address(); + logerror("Linear window set to 0x%08x\n", get_bar_address); + set_map_address(0, get_bar_address); remap_cb(); } else @@ -176,6 +179,15 @@ void virge_pci_device::map_extra(uint64_t memory_window_start, uint64_t memory_w memory_space->install_readwrite_handler(0xa0000, 0xbffff, read8sm_delegate(*this, FUNC(virge_pci_device::vram_r)), write8sm_delegate(*this, FUNC(virge_pci_device::vram_w))); io_space->install_device(0x03b0, 0x03df, *this, &virge_pci_device::legacy_io_map); + + // NOTE: this looks unrelated to the linear addressing + // xubuntu 6.10 and BeOS 3.x definitely wants it this way. + if(downcast(m_vga.target())->is_new_mmio_active()) + { + const u32 get_bar_address = get_vga_linear_address() | 0x01000000; + + memory_space->install_device(get_bar_address, get_bar_address | 0xffff, *this, &virge_pci_device::mmio_map); + } } void virge_pci_device::device_add_mconfig(machine_config &config) diff --git a/src/devices/bus/pci/virge_pci.h b/src/devices/bus/pci/virge_pci.h index 390edc98d9e..d820e686514 100644 --- a/src/devices/bus/pci/virge_pci.h +++ b/src/devices/bus/pci/virge_pci.h @@ -63,6 +63,7 @@ protected: private: void refresh_linear_window(); + u32 get_vga_linear_address(); }; class virgedx_pci_device : public virge_pci_device diff --git a/src/devices/video/s3virge.cpp b/src/devices/video/s3virge.cpp index 331f8b2056e..7e16a217c9c 100644 --- a/src/devices/video/s3virge.cpp +++ b/src/devices/video/s3virge.cpp @@ -238,6 +238,9 @@ void s3virge_vga_device::crtc_map(address_map &map) }), NAME([this] (offs_t offset, u8 data) { s3.cr53 = data; + LOGREG("CR53: write %02x\n", data); + // FIXME: this is just to make PCI to catch up for the side effect of relocating MMIO. + // TODO: Big Endian at bits 2-1 m_linear_config_changed_cb(s3virge.linear_address_enable); }) ); diff --git a/src/devices/video/s3virge.h b/src/devices/video/s3virge.h index 0e17f6b1bbb..85bc1026627 100644 --- a/src/devices/video/s3virge.h +++ b/src/devices/video/s3virge.h @@ -32,6 +32,7 @@ public: uint32_t s3d_sub_status_r(); void s3d_sub_control_w(uint32_t data); uint32_t s3d_func_ctrl_r(); + void s3d_func_ctrl_w(offs_t offset, uint32_t data, u32 mem_mask = ~0); uint32_t s3d_register_r(offs_t offset); void s3d_register_w(offs_t offset, uint32_t data); diff --git a/src/mame/pc/pcipc.cpp b/src/mame/pc/pcipc.cpp index 3b66f59f1c0..48236f66dd5 100644 --- a/src/mame/pc/pcipc.cpp +++ b/src/mame/pc/pcipc.cpp @@ -41,6 +41,10 @@ #include "machine/w83977tf.h" #include "video/clgd546x_laguna.h" +// enable ISA verbose messaging at I/O $80 +// NOTE: xubuntu 6.10 will ping the port a lot once it gets to GNOME. +#define VERBOSE_ISA_DEBUG 0 + namespace { class pcipc_state : public driver_device @@ -454,6 +458,7 @@ const pcipc_state::boot_state_info pcipc_state::boot_state_infos_award[] = { void pcipc_state::boot_state_phoenix_w(uint8_t data) { +#if VERBOSE_ISA_DEBUG const char *desc = ""; for(int i=0; boot_state_infos_phoenix[i].message; i++) if(boot_state_infos_phoenix[i].val == data) { @@ -461,11 +466,12 @@ void pcipc_state::boot_state_phoenix_w(uint8_t data) break; } logerror("Boot state %02x - %s\n", data, desc); - +#endif } void pcipc_state::boot_state_phoenix_ver40_rev6_w(uint8_t data) { +#if VERBOSE_ISA_DEBUG const char *desc = ""; for(int i=0; boot_state_infos_phoenix_ver40_rev6[i].message; i++) if(boot_state_infos_phoenix_ver40_rev6[i].val == data) { @@ -473,12 +479,13 @@ void pcipc_state::boot_state_phoenix_ver40_rev6_w(uint8_t data) break; } logerror("Boot state %02x - %s\n", data, desc); -// printf("[%02X]",data); +#endif } void pcipc_state::boot_state_award_w(uint8_t data) { +#if VERBOSE_ISA_DEBUG const char *desc = ""; for(int i=0; boot_state_infos_award[i].message; i++) if(boot_state_infos_award[i].val == data) { @@ -486,7 +493,7 @@ void pcipc_state::boot_state_award_w(uint8_t data) break; } logerror("Boot state %02x - %s\n", data, desc); - +#endif } static void isa_internal_devices(device_slot_interface &device) -- cgit v1.2.3