mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:17:35 +00:00
Kernel/Graphics: Introduce a new mechanism to initialize a PCI device
Instead of using a clunky switch-case paradigm, we now have all drivers being declaring two methods for their adapter class - create and probe. These methods are linked in each PCIGraphicsDriverInitializer structure, in a new s_initializers static list of them. Then, when we probe for a PCI device, we use each probe method and if there's a match, then the corresponding create method is called. As a result of this change, it's much more easy to add more drivers and the initialization code is more readable.
This commit is contained in:
parent
7625f7db73
commit
72b144e9e9
12 changed files with 85 additions and 71 deletions
|
@ -175,20 +175,18 @@ Optional<IntelGraphics::PLLSettings> IntelNativeDisplayConnector::create_pll_set
|
|||
return {};
|
||||
}
|
||||
|
||||
NonnullLockRefPtr<IntelNativeDisplayConnector> IntelNativeDisplayConnector::must_create(PhysicalAddress framebuffer_address, size_t framebuffer_resource_size, PhysicalAddress registers_region_address, size_t registers_region_length)
|
||||
ErrorOr<NonnullLockRefPtr<IntelNativeDisplayConnector>> IntelNativeDisplayConnector::try_create(PhysicalAddress framebuffer_address, size_t framebuffer_resource_size, PhysicalAddress registers_region_address, size_t registers_region_length)
|
||||
{
|
||||
auto registers_region = MUST(MM.allocate_kernel_region(PhysicalAddress(registers_region_address), registers_region_length, "Intel Native Graphics Registers"sv, Memory::Region::Access::ReadWrite));
|
||||
auto device_or_error = DeviceManagement::try_create_device<IntelNativeDisplayConnector>(framebuffer_address, framebuffer_resource_size, move(registers_region));
|
||||
VERIFY(!device_or_error.is_error());
|
||||
auto connector = device_or_error.release_value();
|
||||
MUST(connector->initialize_gmbus_settings_and_read_edid());
|
||||
auto registers_region = TRY(MM.allocate_kernel_region(PhysicalAddress(registers_region_address), registers_region_length, "Intel Native Graphics Registers"sv, Memory::Region::Access::ReadWrite));
|
||||
auto connector = TRY(DeviceManagement::try_create_device<IntelNativeDisplayConnector>(framebuffer_address, framebuffer_resource_size, move(registers_region)));
|
||||
TRY(connector->initialize_gmbus_settings_and_read_edid());
|
||||
// Note: This is very important to set the resolution to something safe so we
|
||||
// can create a framebuffer console with valid resolution.
|
||||
{
|
||||
SpinlockLocker control_lock(connector->m_control_lock);
|
||||
MUST(connector->set_safe_mode_setting());
|
||||
TRY(connector->set_safe_mode_setting());
|
||||
}
|
||||
MUST(connector->create_attached_framebuffer_console());
|
||||
TRY(connector->create_attached_framebuffer_console());
|
||||
return connector;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue