mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:38:10 +00:00
Kernel/Graphics: Move x86-specific support for VGA to Arch/x86 directory
The new VGAIOArbiter class is now responsible to conduct x86-specific instructions to control VGA hardware from the old ISA ports. This allows us to ensure the GraphicsManagement code doesn't use x86-specific code, thus allowing it to be compiled within non-x86 kernel builds.
This commit is contained in:
parent
8b9c056c5a
commit
48f3d762af
5 changed files with 154 additions and 30 deletions
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include <AK/Singleton.h>
|
||||
#include <Kernel/Arch/Delay.h>
|
||||
#include <Kernel/Arch/x86/IO.h>
|
||||
#if ARCH(I386) || ARCH(X86_64)
|
||||
# include <Kernel/Arch/x86/Hypervisor/BochsDisplayConnector.h>
|
||||
#endif
|
||||
|
@ -45,44 +44,38 @@ UNMAP_AFTER_INIT GraphicsManagement::GraphicsManagement()
|
|||
|
||||
void GraphicsManagement::disable_vga_emulation_access_permanently()
|
||||
{
|
||||
SpinlockLocker locker(m_main_vga_lock);
|
||||
disable_vga_text_mode_console_cursor();
|
||||
IO::out8(0x3c4, 1);
|
||||
u8 sr1 = IO::in8(0x3c5);
|
||||
IO::out8(0x3c5, sr1 | 1 << 5);
|
||||
microseconds_delay(1000);
|
||||
m_vga_access_is_disabled = true;
|
||||
#if ARCH(I386) || ARCH(X86_64)
|
||||
if (!m_vga_arbiter)
|
||||
return;
|
||||
m_vga_arbiter->disable_vga_emulation_access_permanently({});
|
||||
#endif
|
||||
}
|
||||
|
||||
void GraphicsManagement::enable_vga_text_mode_console_cursor()
|
||||
{
|
||||
SpinlockLocker locker(m_main_vga_lock);
|
||||
if (m_vga_access_is_disabled)
|
||||
#if ARCH(I386) || ARCH(X86_64)
|
||||
if (!m_vga_arbiter)
|
||||
return;
|
||||
IO::out8(0x3D4, 0xA);
|
||||
IO::out8(0x3D5, 0);
|
||||
m_vga_arbiter->enable_vga_text_mode_console_cursor({});
|
||||
#endif
|
||||
}
|
||||
|
||||
void GraphicsManagement::disable_vga_text_mode_console_cursor()
|
||||
{
|
||||
SpinlockLocker locker(m_main_vga_lock);
|
||||
if (m_vga_access_is_disabled)
|
||||
#if ARCH(I386) || ARCH(X86_64)
|
||||
if (!m_vga_arbiter)
|
||||
return;
|
||||
IO::out8(0x3D4, 0xA);
|
||||
IO::out8(0x3D5, 0x20);
|
||||
m_vga_arbiter->disable_vga_text_mode_console_cursor({});
|
||||
#endif
|
||||
}
|
||||
|
||||
void GraphicsManagement::set_vga_text_mode_cursor(size_t console_width, size_t x, size_t y)
|
||||
void GraphicsManagement::set_vga_text_mode_cursor([[maybe_unused]] size_t console_width, [[maybe_unused]] size_t x, [[maybe_unused]] size_t y)
|
||||
{
|
||||
SpinlockLocker locker(m_main_vga_lock);
|
||||
if (m_vga_access_is_disabled)
|
||||
#if ARCH(I386) || ARCH(X86_64)
|
||||
if (!m_vga_arbiter)
|
||||
return;
|
||||
enable_vga_text_mode_console_cursor();
|
||||
u16 value = y * console_width + x;
|
||||
IO::out8(0x3d4, 0x0e);
|
||||
IO::out8(0x3d5, MSB(value));
|
||||
IO::out8(0x3d4, 0x0f);
|
||||
IO::out8(0x3d5, LSB(value));
|
||||
m_vga_arbiter->set_vga_text_mode_cursor({}, console_width, x, y);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GraphicsManagement::deactivate_graphical_mode()
|
||||
|
@ -202,6 +195,9 @@ UNMAP_AFTER_INIT bool GraphicsManagement::initialize()
|
|||
}
|
||||
}
|
||||
});
|
||||
#if ARCH(I386) || ARCH(X86_64)
|
||||
m_vga_arbiter = VGAIOArbiter::must_create({});
|
||||
#endif
|
||||
|
||||
auto graphics_subsystem_mode = kernel_command_line().graphics_subsystem_mode();
|
||||
if (graphics_subsystem_mode == CommandLine::GraphicsSubsystemMode::Disabled) {
|
||||
|
@ -221,8 +217,7 @@ UNMAP_AFTER_INIT bool GraphicsManagement::initialize()
|
|||
MUST(vga_isa_bochs_display_connector->set_safe_mode_setting());
|
||||
m_platform_board_specific_display_connector = vga_isa_bochs_display_connector;
|
||||
dmesgln("Graphics: Invoking manual blanking with VGA ISA ports");
|
||||
SpinlockLocker locker(m_main_vga_lock);
|
||||
IO::out8(0x3c0, 0x20);
|
||||
m_vga_arbiter->unblank_screen({});
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue