mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 19:22:45 +00:00 
			
		
		
		
	Kernel/Graphics: Bring back the mmap interface for DisplayConnectors
The mmap interface was removed when we introduced the DisplayConnector class, as it was quite unsafe to use and didn't handle switching between graphical and text modes safely. By using the SharedFramebufferVMObject, we are able to elegantly coordinate the switch by remapping the attached mmap'ed-Memory::Region(s) with different mappings, therefore, keeping WindowServer to think that the mappings it has are still valid, while they are going to a different physical range until we are back to the graphical mode (after a switch from text mode). Most drivers take advantage of the fact that we know where is the actual framebuffer in physical memory space, the SharedFramebufferVMObject is created with that information. However, the VirtIO driver is different in that aspect, because it relies on DMA transactions to show graphics on the framebuffer, so the SharedFramebufferVMObject is created with that mindset to support the arbitrary framebuffer location in physical memory space.
This commit is contained in:
		
							parent
							
								
									3d22917548
								
							
						
					
					
						commit
						e2ed6ef741
					
				
					 19 changed files with 309 additions and 341 deletions
				
			
		|  | @ -12,9 +12,9 @@ | |||
| 
 | ||||
| namespace Kernel { | ||||
| 
 | ||||
| NonnullRefPtr<QEMUDisplayConnector> QEMUDisplayConnector::must_create(PhysicalAddress framebuffer_address, Memory::TypedMapping<BochsDisplayMMIORegisters volatile> registers_mapping) | ||||
| NonnullRefPtr<QEMUDisplayConnector> QEMUDisplayConnector::must_create(PhysicalAddress framebuffer_address, size_t framebuffer_resource_size, Memory::TypedMapping<BochsDisplayMMIORegisters volatile> registers_mapping) | ||||
| { | ||||
|     auto device_or_error = DeviceManagement::try_create_device<QEMUDisplayConnector>(framebuffer_address, move(registers_mapping)); | ||||
|     auto device_or_error = DeviceManagement::try_create_device<QEMUDisplayConnector>(framebuffer_address, framebuffer_resource_size, move(registers_mapping)); | ||||
|     VERIFY(!device_or_error.is_error()); | ||||
|     auto connector = device_or_error.release_value(); | ||||
|     MUST(connector->create_attached_framebuffer_console()); | ||||
|  | @ -31,8 +31,8 @@ ErrorOr<void> QEMUDisplayConnector::fetch_and_initialize_edid() | |||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| QEMUDisplayConnector::QEMUDisplayConnector(PhysicalAddress framebuffer_address, Memory::TypedMapping<BochsDisplayMMIORegisters volatile> registers_mapping) | ||||
|     : BochsDisplayConnector(framebuffer_address) | ||||
| QEMUDisplayConnector::QEMUDisplayConnector(PhysicalAddress framebuffer_address, size_t framebuffer_resource_size, Memory::TypedMapping<BochsDisplayMMIORegisters volatile> registers_mapping) | ||||
|     : BochsDisplayConnector(framebuffer_address, framebuffer_resource_size) | ||||
|     , m_registers(move(registers_mapping)) | ||||
| { | ||||
| } | ||||
|  | @ -111,10 +111,7 @@ ErrorOr<void> QEMUDisplayConnector::set_mode_setting(ModeSetting const& mode_set | |||
|     if ((u16)width != m_registers->bochs_regs.xres || (u16)height != m_registers->bochs_regs.yres) { | ||||
|         return Error::from_errno(ENOTIMPL); | ||||
|     } | ||||
|     auto rounded_size = TRY(Memory::page_round_up(width * sizeof(u32) * height * 2)); | ||||
|     m_framebuffer_region = TRY(MM.allocate_kernel_region(m_framebuffer_address.page_base(), rounded_size, "Framebuffer"sv, Memory::Region::Access::ReadWrite)); | ||||
|     [[maybe_unused]] auto result = m_framebuffer_region->set_write_combine(true); | ||||
|     m_framebuffer_data = m_framebuffer_region->vaddr().offset(m_framebuffer_address.offset_in_page()).as_ptr(); | ||||
| 
 | ||||
|     m_framebuffer_console->set_resolution(width, height, width * sizeof(u32)); | ||||
| 
 | ||||
|     DisplayConnector::ModeSetting mode_set { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Liav A
						Liav A