summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2022-06-10 22:33:07 +0300
committerLinus Groh <mail@linusgroh.de>2022-06-10 22:32:54 +0100
commit20c9e4c05c428f4a6ae6d955abb0429475446865 (patch)
tree9500b2afe7571dc2ba87bb0b0659b93bdec91a26
parent3d36b194d1732bc92df128559b5d577614674535 (diff)
downloadserenity-20c9e4c05c428f4a6ae6d955abb0429475446865.zip
Kernel/Graphics: Ensure VMWare and VirtualBox EDIDs have manufacturer ID
-rw-r--r--Kernel/Graphics/Bochs/DisplayConnector.cpp7
-rw-r--r--Kernel/Graphics/Bochs/DisplayConnector.h2
-rw-r--r--Kernel/Graphics/Bochs/GraphicsAdapter.cpp6
-rw-r--r--Kernel/Graphics/DisplayConnector.cpp14
-rw-r--r--Kernel/Graphics/DisplayConnector.h2
-rw-r--r--Kernel/Graphics/VGA/DisplayConnector.cpp2
-rw-r--r--Kernel/Graphics/VMWare/DisplayConnector.cpp2
7 files changed, 24 insertions, 11 deletions
diff --git a/Kernel/Graphics/Bochs/DisplayConnector.cpp b/Kernel/Graphics/Bochs/DisplayConnector.cpp
index 5e9c74711c..b51bb2b329 100644
--- a/Kernel/Graphics/Bochs/DisplayConnector.cpp
+++ b/Kernel/Graphics/Bochs/DisplayConnector.cpp
@@ -14,13 +14,16 @@
namespace Kernel {
-NonnullRefPtr<BochsDisplayConnector> BochsDisplayConnector::must_create(PhysicalAddress framebuffer_address, size_t framebuffer_resource_size)
+NonnullRefPtr<BochsDisplayConnector> BochsDisplayConnector::must_create(PhysicalAddress framebuffer_address, size_t framebuffer_resource_size, bool virtual_box_hardware)
{
auto device_or_error = DeviceManagement::try_create_device<BochsDisplayConnector>(framebuffer_address, framebuffer_resource_size);
VERIFY(!device_or_error.is_error());
auto connector = device_or_error.release_value();
MUST(connector->create_attached_framebuffer_console());
- MUST(connector->initialize_edid_for_generic_monitor());
+ if (virtual_box_hardware)
+ MUST(connector->initialize_edid_for_generic_monitor(Array<u8, 3> { 'V', 'B', 'X' }));
+ else
+ MUST(connector->initialize_edid_for_generic_monitor({}));
return connector;
}
diff --git a/Kernel/Graphics/Bochs/DisplayConnector.h b/Kernel/Graphics/Bochs/DisplayConnector.h
index 445e5dcc7c..a8d4277e0d 100644
--- a/Kernel/Graphics/Bochs/DisplayConnector.h
+++ b/Kernel/Graphics/Bochs/DisplayConnector.h
@@ -24,7 +24,7 @@ class BochsDisplayConnector
public:
TYPEDEF_DISTINCT_ORDERED_ID(u16, IndexID);
- static NonnullRefPtr<BochsDisplayConnector> must_create(PhysicalAddress framebuffer_address, size_t framebuffer_resource_size);
+ static NonnullRefPtr<BochsDisplayConnector> must_create(PhysicalAddress framebuffer_address, size_t framebuffer_resource_size, bool virtual_box_hardware);
virtual IndexID index_id() const;
diff --git a/Kernel/Graphics/Bochs/GraphicsAdapter.cpp b/Kernel/Graphics/Bochs/GraphicsAdapter.cpp
index 82e63686ee..8ba489a918 100644
--- a/Kernel/Graphics/Bochs/GraphicsAdapter.cpp
+++ b/Kernel/Graphics/Bochs/GraphicsAdapter.cpp
@@ -43,10 +43,10 @@ UNMAP_AFTER_INIT ErrorOr<void> BochsGraphicsAdapter::initialize_adapter(PCI::Dev
// Note: If we use VirtualBox graphics adapter (which is based on Bochs one), we need to use IO ports
// Note: Bochs (the real bochs graphics adapter in the Bochs emulator) uses revision ID of 0x0
// and doesn't support memory-mapped IO registers.
+ bool virtual_box_hardware = (pci_device_identifier.hardware_id().vendor_id == 0x80ee && pci_device_identifier.hardware_id().device_id == 0xbeef);
auto bar0_space_size = PCI::get_BAR_space_size(pci_device_identifier.address(), 0);
- if (pci_device_identifier.revision_id().value() == 0x0
- || (pci_device_identifier.hardware_id().vendor_id == 0x80ee && pci_device_identifier.hardware_id().device_id == 0xbeef)) {
- m_display_connector = BochsDisplayConnector::must_create(PhysicalAddress(PCI::get_BAR0(pci_device_identifier.address()) & 0xfffffff0), bar0_space_size);
+ if (pci_device_identifier.revision_id().value() == 0x0 || virtual_box_hardware) {
+ m_display_connector = BochsDisplayConnector::must_create(PhysicalAddress(PCI::get_BAR0(pci_device_identifier.address()) & 0xfffffff0), bar0_space_size, virtual_box_hardware);
} else {
auto registers_mapping = TRY(Memory::map_typed_writable<BochsDisplayMMIORegisters volatile>(PhysicalAddress(PCI::get_BAR2(pci_device_identifier.address()) & 0xfffffff0)));
VERIFY(registers_mapping.region);
diff --git a/Kernel/Graphics/DisplayConnector.cpp b/Kernel/Graphics/DisplayConnector.cpp
index bd353f1115..88ccc14d7c 100644
--- a/Kernel/Graphics/DisplayConnector.cpp
+++ b/Kernel/Graphics/DisplayConnector.cpp
@@ -112,11 +112,21 @@ void DisplayConnector::set_display_mode(Badge<GraphicsManagement>, DisplayMode m
}
}
-ErrorOr<void> DisplayConnector::initialize_edid_for_generic_monitor()
+ErrorOr<void> DisplayConnector::initialize_edid_for_generic_monitor(Optional<Array<u8, 3>> possible_manufacturer_id_string)
{
+ u8 raw_manufacturer_id[2] = { 0x0, 0x0 };
+ if (possible_manufacturer_id_string.has_value()) {
+ Array<u8, 3> manufacturer_id_string = possible_manufacturer_id_string.release_value();
+ u8 byte1 = (((static_cast<u8>(manufacturer_id_string[0]) - '@') & 0x1f) << 2) | (((static_cast<u8>(manufacturer_id_string[1]) - '@') >> 3) & 3);
+ u8 byte2 = ((static_cast<u8>(manufacturer_id_string[2]) - '@') & 0x1f) | (((static_cast<u8>(manufacturer_id_string[1]) - '@') << 5) & 0xe0);
+ Array<u8, 2> manufacturer_id_string_packed_bytes = { byte1, byte2 };
+ raw_manufacturer_id[0] = manufacturer_id_string_packed_bytes[1];
+ raw_manufacturer_id[1] = manufacturer_id_string_packed_bytes[0];
+ }
+
Array<u8, 128> virtual_monitor_edid = {
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, /* header */
- 0x0, 0x0, /* manufacturer */
+ raw_manufacturer_id[1], raw_manufacturer_id[0], /* manufacturer */
0x00, 0x00, /* product code */
0x00, 0x00, 0x00, 0x00, /* serial number goes here */
0x01, /* week of manufacture */
diff --git a/Kernel/Graphics/DisplayConnector.h b/Kernel/Graphics/DisplayConnector.h
index ceeac71114..e45dd7defb 100644
--- a/Kernel/Graphics/DisplayConnector.h
+++ b/Kernel/Graphics/DisplayConnector.h
@@ -112,7 +112,7 @@ protected:
virtual ErrorOr<void> flush_first_surface() = 0;
virtual ErrorOr<void> flush_rectangle(size_t buffer_index, FBRect const& rect);
- ErrorOr<void> initialize_edid_for_generic_monitor();
+ ErrorOr<void> initialize_edid_for_generic_monitor(Optional<Array<u8, 3>> manufacturer_id_string);
mutable Spinlock m_control_lock;
mutable Mutex m_flushing_lock;
diff --git a/Kernel/Graphics/VGA/DisplayConnector.cpp b/Kernel/Graphics/VGA/DisplayConnector.cpp
index da3ce993b2..d394e8f2fa 100644
--- a/Kernel/Graphics/VGA/DisplayConnector.cpp
+++ b/Kernel/Graphics/VGA/DisplayConnector.cpp
@@ -19,7 +19,7 @@ NonnullRefPtr<GenericDisplayConnector> GenericDisplayConnector::must_create_with
VERIFY(!device_or_error.is_error());
auto connector = device_or_error.release_value();
MUST(connector->create_attached_framebuffer_console());
- MUST(connector->initialize_edid_for_generic_monitor());
+ MUST(connector->initialize_edid_for_generic_monitor({}));
return connector;
}
diff --git a/Kernel/Graphics/VMWare/DisplayConnector.cpp b/Kernel/Graphics/VMWare/DisplayConnector.cpp
index a50d22ebcf..651d93ec60 100644
--- a/Kernel/Graphics/VMWare/DisplayConnector.cpp
+++ b/Kernel/Graphics/VMWare/DisplayConnector.cpp
@@ -16,7 +16,7 @@ NonnullRefPtr<VMWareDisplayConnector> VMWareDisplayConnector::must_create(VMWare
{
auto connector = MUST(DeviceManagement::try_create_device<VMWareDisplayConnector>(parent_adapter, framebuffer_address, framebuffer_resource_size));
MUST(connector->create_attached_framebuffer_console());
- MUST(connector->initialize_edid_for_generic_monitor());
+ MUST(connector->initialize_edid_for_generic_monitor(Array<u8, 3> { 'V', 'M', 'W' }));
return connector;
}