mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 07:22:45 +00:00 
			
		
		
		
	Kernel: Convert PCI Capability struct to class with convenience methods
Based on pull #3236 by tomuta Co-authored-by: Tom <tomut@yahoo.com>
This commit is contained in:
		
							parent
							
								
									dfb23babbb
								
							
						
					
					
						commit
						172d23deae
					
				
					 3 changed files with 61 additions and 7 deletions
				
			
		|  | @ -67,6 +67,11 @@ namespace Kernel { | |||
| #define PCI_MAX_BUSES 256 | ||||
| #define PCI_MAX_FUNCTIONS_PER_DEVICE 8 | ||||
| 
 | ||||
| #define PCI_CAPABILITY_NULL 0x0 | ||||
| #define PCI_CAPABILITY_MSI 0x5 | ||||
| #define PCI_CAPABILITY_VENDOR_SPECIFIC 0x9 | ||||
| #define PCI_CAPABILITY_MSIX 0x11 | ||||
| 
 | ||||
| namespace PCI { | ||||
| struct ID { | ||||
|     u16 vendor_id { 0 }; | ||||
|  | @ -171,9 +176,28 @@ struct ChangeableAddress : public Address { | |||
|     } | ||||
| }; | ||||
| 
 | ||||
| struct Capability { | ||||
|     u8 m_id; | ||||
|     u8 m_next_pointer; | ||||
| class Capability { | ||||
| public: | ||||
|     Capability(const Address& address, u8 id, u8 ptr) | ||||
|         : m_address(address) | ||||
|         , m_id(id) | ||||
|         , m_ptr(ptr) | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     u8 id() const { return m_id; } | ||||
| 
 | ||||
|     u8 read8(u32) const; | ||||
|     u16 read16(u32) const; | ||||
|     u32 read32(u32) const; | ||||
|     void write8(u32, u8); | ||||
|     void write16(u32, u16); | ||||
|     void write32(u32, u32); | ||||
| 
 | ||||
| private: | ||||
|     Address m_address; | ||||
|     const u8 m_id; | ||||
|     const u8 m_ptr; | ||||
| }; | ||||
| 
 | ||||
| class PhysicalID { | ||||
|  | @ -185,7 +209,7 @@ public: | |||
|     { | ||||
|         if constexpr (PCI_DEBUG) { | ||||
|             for (auto capability : capabilities) | ||||
|                 dbgln("{} has capability {}", address, capability.m_id); | ||||
|                 dbgln("{} has capability {}", address, capability.id()); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Idan Horowitz
						Idan Horowitz