@@ -36,9 +36,14 @@ UNMAP_AFTER_INIT GraphicsManagement::GraphicsManagement()
36
36
{
37
37
}
38
38
39
- bool GraphicsManagement::framebuffer_devices_allowed () const
39
+ bool GraphicsManagement::framebuffer_devices_use_bootloader_framebuffer () const
40
40
{
41
- return kernel_command_line ().are_framebuffer_devices_enabled ();
41
+ return kernel_command_line ().are_framebuffer_devices_enabled () == CommandLine::FrameBufferDevices::BootloaderOnly;
42
+ }
43
+
44
+ bool GraphicsManagement::framebuffer_devices_console_only () const
45
+ {
46
+ return kernel_command_line ().are_framebuffer_devices_enabled () == CommandLine::FrameBufferDevices::ConsoleOnly;
42
47
}
43
48
44
49
void GraphicsManagement::deactivate_graphical_mode ()
@@ -73,60 +78,71 @@ UNMAP_AFTER_INIT bool GraphicsManagement::determine_and_initialize_graphics_devi
73
78
VERIFY (is_vga_compatible_pci_device (device_identifier) || is_display_controller_pci_device (device_identifier));
74
79
auto add_and_configure_adapter = [&](GenericGraphicsAdapter& graphics_device) {
75
80
m_graphics_devices.append (graphics_device);
76
- if (! framebuffer_devices_allowed ()) {
81
+ if (framebuffer_devices_console_only ()) {
77
82
graphics_device.enable_consoles ();
78
83
return ;
79
84
}
80
85
graphics_device.initialize_framebuffer_devices ();
81
86
};
82
87
83
88
RefPtr<GenericGraphicsAdapter> adapter;
84
- switch (device_identifier.hardware_id ().vendor_id ) {
85
- case PCI::VendorID::QEMUOld:
86
- if (device_identifier.hardware_id ().device_id == 0x1111 )
87
- adapter = BochsGraphicsAdapter::initialize (device_identifier);
88
- break ;
89
- case PCI::VendorID::VirtualBox:
90
- if (device_identifier.hardware_id ().device_id == 0xbeef )
91
- adapter = BochsGraphicsAdapter::initialize (device_identifier);
92
- break ;
93
- case PCI::VendorID::Intel:
94
- adapter = IntelNativeGraphicsAdapter::initialize (device_identifier);
95
- break ;
96
- case PCI::VendorID::VirtIO:
97
- dmesgln (" Graphics: Using VirtIO console" );
98
- adapter = Graphics::VirtIOGPU::GraphicsAdapter::initialize (device_identifier);
99
- break ;
100
- default :
101
- if (!is_vga_compatible_pci_device (device_identifier))
89
+
90
+ auto create_bootloader_framebuffer_device = [&]() {
91
+ if (multiboot_framebuffer_type == MULTIBOOT_FRAMEBUFFER_TYPE_RGB) {
92
+ dmesgln (" Graphics: Using a preset resolution from the bootloader" );
93
+ adapter = VGACompatibleAdapter::initialize_with_preset_resolution (device_identifier,
94
+ multiboot_framebuffer_addr,
95
+ multiboot_framebuffer_width,
96
+ multiboot_framebuffer_height,
97
+ multiboot_framebuffer_pitch);
98
+ }
99
+ };
100
+
101
+ if (framebuffer_devices_use_bootloader_framebuffer ())
102
+ create_bootloader_framebuffer_device ();
103
+
104
+ if (!adapter) {
105
+ switch (device_identifier.hardware_id ().vendor_id ) {
106
+ case PCI::VendorID::QEMUOld:
107
+ if (device_identifier.hardware_id ().device_id == 0x1111 )
108
+ adapter = BochsGraphicsAdapter::initialize (device_identifier);
109
+ break ;
110
+ case PCI::VendorID::VirtualBox:
111
+ if (device_identifier.hardware_id ().device_id == 0xbeef )
112
+ adapter = BochsGraphicsAdapter::initialize (device_identifier);
113
+ break ;
114
+ case PCI::VendorID::Intel:
115
+ adapter = IntelNativeGraphicsAdapter::initialize (device_identifier);
102
116
break ;
103
- // Note: Although technically possible that a system has a
104
- // non-compatible VGA graphics device that was initialized by the
105
- // Multiboot bootloader to provide a framebuffer, in practice we
106
- // probably want to support these devices natively instead of
107
- // initializing them as some sort of a generic GenericGraphicsAdapter. For now,
108
- // the only known example of this sort of device is qxl in QEMU. For VGA
109
- // compatible devices we don't have a special driver for (e.g. ati-vga,
110
- // qxl-vga, cirrus-vga, vmware-svga in QEMU), it's much more likely that
111
- // these devices will be supported by the Multiboot loader that will
112
- // utilize VESA BIOS extensions (that we don't currently) of these cards
113
- // support, so we want to utilize the provided framebuffer of these
114
- // devices, if possible.
115
- if (!m_vga_adapter && PCI::is_io_space_enabled (device_identifier.address ())) {
116
- if (multiboot_framebuffer_type == MULTIBOOT_FRAMEBUFFER_TYPE_RGB) {
117
- dmesgln (" Graphics: Using a preset resolution from the bootloader" );
118
- adapter = VGACompatibleAdapter::initialize_with_preset_resolution (device_identifier,
119
- multiboot_framebuffer_addr,
120
- multiboot_framebuffer_width,
121
- multiboot_framebuffer_height,
122
- multiboot_framebuffer_pitch);
117
+ case PCI::VendorID::VirtIO:
118
+ dmesgln (" Graphics: Using VirtIO console" );
119
+ adapter = Graphics::VirtIOGPU::GraphicsAdapter::initialize (device_identifier);
120
+ break ;
121
+ default :
122
+ if (!is_vga_compatible_pci_device (device_identifier))
123
+ break ;
124
+ // Note: Although technically possible that a system has a
125
+ // non-compatible VGA graphics device that was initialized by the
126
+ // Multiboot bootloader to provide a framebuffer, in practice we
127
+ // probably want to support these devices natively instead of
128
+ // initializing them as some sort of a generic GenericGraphicsAdapter. For now,
129
+ // the only known example of this sort of device is qxl in QEMU. For VGA
130
+ // compatible devices we don't have a special driver for (e.g. ati-vga,
131
+ // qxl-vga, cirrus-vga, vmware-svga in QEMU), it's much more likely that
132
+ // these devices will be supported by the Multiboot loader that will
133
+ // utilize VESA BIOS extensions (that we don't currently) of these cards
134
+ // support, so we want to utilize the provided framebuffer of these
135
+ // devices, if possible.
136
+ if (!m_vga_adapter && PCI::is_io_space_enabled (device_identifier.address ())) {
137
+ create_bootloader_framebuffer_device ();
138
+ } else {
139
+ dmesgln (" Graphics: Using a VGA compatible generic adapter" );
140
+ adapter = VGACompatibleAdapter::initialize (device_identifier);
123
141
}
124
- } else {
125
- dmesgln (" Graphics: Using a VGA compatible generic adapter" );
126
- adapter = VGACompatibleAdapter::initialize (device_identifier);
142
+ break ;
127
143
}
128
- break ;
129
144
}
145
+
130
146
if (!adapter)
131
147
return false ;
132
148
add_and_configure_adapter (*adapter);
@@ -179,8 +195,10 @@ UNMAP_AFTER_INIT bool GraphicsManagement::initialize()
179
195
* be created, so SystemServer will not try to initialize WindowServer.
180
196
*/
181
197
182
- if (!framebuffer_devices_allowed ())
183
- dbgln (" Forcing non-initialization of framebuffer devices" );
198
+ if (framebuffer_devices_console_only ())
199
+ dbgln (" Forcing non-initialization of framebuffer devices (console only)" );
200
+ else if (framebuffer_devices_use_bootloader_framebuffer ())
201
+ dbgln (" Forcing use of framebuffer set up by the bootloader" );
184
202
185
203
PCI::enumerate ([&](PCI::DeviceIdentifier const & device_identifier) {
186
204
// Note: Each graphics controller will try to set its native screen resolution
0 commit comments