mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
Kernel/Graphics: Protect the list of display connectors with a Spinlock
This list could be updated in runtime if an hotplug event occurs, so we must protect it with a spin lock to avoid corruption of the list.
This commit is contained in:
parent
c246d86867
commit
b8493bf70f
Notes:
sideshowbarker
2024-07-17 11:14:30 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/b8493bf70f Pull-request: https://github.com/SerenityOS/serenity/pull/13928 Reviewed-by: https://github.com/linusg
2 changed files with 15 additions and 9 deletions
|
@ -86,24 +86,30 @@ void GraphicsManagement::set_vga_text_mode_cursor(size_t console_width, size_t x
|
|||
|
||||
void GraphicsManagement::deactivate_graphical_mode()
|
||||
{
|
||||
for (auto& connector : m_display_connector_nodes) {
|
||||
connector.set_display_mode({}, DisplayConnector::DisplayMode::Console);
|
||||
}
|
||||
return m_display_connector_nodes.with([&](auto& display_connectors) {
|
||||
for (auto& connector : display_connectors)
|
||||
connector.set_display_mode({}, DisplayConnector::DisplayMode::Console);
|
||||
});
|
||||
}
|
||||
void GraphicsManagement::activate_graphical_mode()
|
||||
{
|
||||
for (auto& connector : m_display_connector_nodes) {
|
||||
connector.set_display_mode({}, DisplayConnector::DisplayMode::Graphical);
|
||||
}
|
||||
return m_display_connector_nodes.with([&](auto& display_connectors) {
|
||||
for (auto& connector : display_connectors)
|
||||
connector.set_display_mode({}, DisplayConnector::DisplayMode::Graphical);
|
||||
});
|
||||
}
|
||||
|
||||
void GraphicsManagement::attach_new_display_connector(Badge<DisplayConnector>, DisplayConnector& connector)
|
||||
{
|
||||
m_display_connector_nodes.append(connector);
|
||||
return m_display_connector_nodes.with([&](auto& display_connectors) {
|
||||
display_connectors.append(connector);
|
||||
});
|
||||
}
|
||||
void GraphicsManagement::detach_display_connector(Badge<DisplayConnector>, DisplayConnector& connector)
|
||||
{
|
||||
m_display_connector_nodes.remove(connector);
|
||||
return m_display_connector_nodes.with([&](auto& display_connectors) {
|
||||
display_connectors.remove(connector);
|
||||
});
|
||||
}
|
||||
|
||||
static inline bool is_vga_compatible_pci_device(PCI::DeviceIdentifier const& device_identifier)
|
||||
|
|
|
@ -58,7 +58,7 @@ private:
|
|||
RefPtr<VGACompatibleAdapter> m_vga_adapter;
|
||||
unsigned m_current_minor_number { 0 };
|
||||
|
||||
IntrusiveList<&DisplayConnector::m_list_node> m_display_connector_nodes;
|
||||
SpinlockProtected<IntrusiveList<&DisplayConnector::m_list_node>> m_display_connector_nodes;
|
||||
|
||||
RecursiveSpinlock m_main_vga_lock;
|
||||
bool m_vga_access_is_disabled { false };
|
||||
|
|
Loading…
Reference in a new issue