mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 12:42:45 +00:00 
			
		
		
		
	Kernel: Add support for SD host controllers on the PCI bus
This commit is contained in:
		
							parent
							
								
									47cae8005f
								
							
						
					
					
						commit
						5fe6c6fc24
					
				
					 5 changed files with 124 additions and 5 deletions
				
			
		
							
								
								
									
										37
									
								
								Kernel/Storage/SD/PCISDHostController.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								Kernel/Storage/SD/PCISDHostController.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,37 @@ | |||
| /*
 | ||||
|  * Copyright (c) 2023, the SerenityOS developers. | ||||
|  * | ||||
|  * SPDX-License-Identifier: BSD-2-Clause | ||||
|  */ | ||||
| 
 | ||||
| #include <Kernel/Bus/PCI/API.h> | ||||
| #include <Kernel/Storage/SD/PCISDHostController.h> | ||||
| 
 | ||||
| namespace Kernel { | ||||
| 
 | ||||
| ErrorOr<NonnullRefPtr<PCISDHostController>> PCISDHostController::try_initialize(PCI::DeviceIdentifier const& device_identifier) | ||||
| { | ||||
|     auto sdhc = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) PCISDHostController(device_identifier))); | ||||
|     TRY(sdhc->initialize()); | ||||
| 
 | ||||
|     return sdhc; | ||||
| } | ||||
| 
 | ||||
| PCISDHostController::PCISDHostController(PCI::DeviceIdentifier const& device_identifier) | ||||
|     : PCI::Device(device_identifier) | ||||
|     , SDHostController() | ||||
| { | ||||
|     auto slot_information_register = read_slot_information(); | ||||
| 
 | ||||
|     if (slot_information_register.slots_available() != 1) { | ||||
|         // TODO: Support multiple slots
 | ||||
|         dmesgln("SD Host Controller has {} slots, but we currently only support using only one", slot_information_register.slots_available()); | ||||
|     } | ||||
| 
 | ||||
|     auto physical_address_of_sdhc_registers = PhysicalAddress { | ||||
|         PCI::get_BAR(device_identifier, static_cast<PCI::HeaderType0BaseRegister>(slot_information_register.first_bar_number)) | ||||
|     }; | ||||
|     m_registers = Memory::map_typed_writable<SD::HostControlRegisterMap volatile>(physical_address_of_sdhc_registers).release_value_but_fixme_should_propagate_errors(); | ||||
| } | ||||
| 
 | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Marco Cutecchia
						Marco Cutecchia