mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 19:32:45 +00:00 
			
		
		
		
	 428d4ae337
			
		
	
	
		428d4ae337
		
	
	
	
	
		
			
			This is mainly useful when adding an HostController but due to OOM condition, we abort temporary Vector insertion of a DeviceIdentifier and then exit the iteration loop to report back the error if occured.
		
			
				
	
	
		
			45 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/Bitmap.h>
 | |
| #include <AK/Vector.h>
 | |
| #include <Kernel/Bus/PCI/Definitions.h>
 | |
| #include <Kernel/Locking/Spinlock.h>
 | |
| 
 | |
| namespace Kernel::PCI {
 | |
| 
 | |
| TYPEDEF_DISTINCT_ORDERED_ID(u8, BusNumber);
 | |
| TYPEDEF_DISTINCT_ORDERED_ID(u8, DeviceNumber);
 | |
| TYPEDEF_DISTINCT_ORDERED_ID(u8, FunctionNumber);
 | |
| 
 | |
| class HostController {
 | |
| public:
 | |
|     virtual ~HostController() = default;
 | |
| 
 | |
|     virtual void write8_field(BusNumber, DeviceNumber, FunctionNumber, u32 field, u8 value) = 0;
 | |
|     virtual void write16_field(BusNumber, DeviceNumber, FunctionNumber, u32 field, u16 value) = 0;
 | |
|     virtual void write32_field(BusNumber, DeviceNumber, FunctionNumber, u32 field, u32 value) = 0;
 | |
| 
 | |
|     virtual u8 read8_field(BusNumber, DeviceNumber, FunctionNumber, u32 field) = 0;
 | |
|     virtual u16 read16_field(BusNumber, DeviceNumber, FunctionNumber, u32 field) = 0;
 | |
|     virtual u32 read32_field(BusNumber, DeviceNumber, FunctionNumber, u32 field) = 0;
 | |
| 
 | |
|     u32 domain_number() const { return m_domain.domain_number(); }
 | |
| 
 | |
|     virtual void enumerate_attached_devices(Function<IterationDecision(DeviceIdentifier)> callback) = 0;
 | |
| 
 | |
| protected:
 | |
|     explicit HostController(PCI::Domain const& domain)
 | |
|         : m_domain(domain)
 | |
|     {
 | |
|     }
 | |
| 
 | |
|     const PCI::Domain m_domain;
 | |
| };
 | |
| 
 | |
| }
 |