mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:42:43 +00:00 
			
		
		
		
	UserspaceEmulator: Add support for shared buffers (shbuf)
We track these separately from regular mmap() regions, as they have slightly different behaviors.
This commit is contained in:
		
							parent
							
								
									0ce4d3e942
								
							
						
					
					
						commit
						2da44dba44
					
				
					 7 changed files with 312 additions and 13 deletions
				
			
		|  | @ -25,6 +25,7 @@ | |||
|  */ | ||||
| 
 | ||||
| #include "SoftMMU.h" | ||||
| #include "SharedBufferRegion.h" | ||||
| #include <AK/ByteBuffer.h> | ||||
| 
 | ||||
| namespace UserspaceEmulator { | ||||
|  | @ -45,11 +46,15 @@ void SoftMMU::add_region(NonnullOwnPtr<Region> region) | |||
| { | ||||
|     ASSERT(!find_region({ 0x20, region->base() })); | ||||
|     // FIXME: More sanity checks pls
 | ||||
|     if (region->is_shared_buffer()) | ||||
|         m_shbuf_regions.set(static_cast<SharedBufferRegion*>(region.ptr())->shbuf_id(), region.ptr()); | ||||
|     m_regions.append(move(region)); | ||||
| } | ||||
| 
 | ||||
| void SoftMMU::remove_region(Region& region) | ||||
| { | ||||
|     if (region.is_shared_buffer()) | ||||
|         m_shbuf_regions.remove(static_cast<SharedBufferRegion&>(region).shbuf_id()); | ||||
|     m_regions.remove_first_matching([&](auto& entry) { return entry.ptr() == ®ion; }); | ||||
| } | ||||
| 
 | ||||
|  | @ -144,4 +149,9 @@ ByteBuffer SoftMMU::copy_buffer_from_vm(const FlatPtr source, size_t size) | |||
|     return buffer; | ||||
| } | ||||
| 
 | ||||
| SharedBufferRegion* SoftMMU::shbuf_region(int shbuf_id) | ||||
| { | ||||
|     return (SharedBufferRegion*)m_shbuf_regions.get(shbuf_id).value_or(nullptr); | ||||
| } | ||||
| 
 | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling