MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / Init

Function Init

Kernel/src/arch/x86_64/pci.cpp:199–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197 }
198
199 void Init(){
200 unknownDevice = new PCIDevice();
201 unknownDevice->vendorID = unknownDevice->deviceID = 0xFFFF;
202
203 devices = new Vector<PCIDevice>();
204 enhancedBaseAddresses = new Vector<PCIMCFGBaseAddress>();
205
206 mcfgTable = ACPI::mcfg;
207 if(mcfgTable){
208 configMode = PCIConfigurationAccessMode::Enhanced;
209 for(unsigned i = 0; i < (mcfgTable->header.length - sizeof(PCIMCFG)) / sizeof(PCIMCFGBaseAddress); i++){
210 PCIMCFGBaseAddress& base = mcfgTable->baseAddresses[i];
211 if(base.segmentGroupNumber > 0){
212 Log::Warning("No support for PCI express segments > 0");
213 continue;
214 }
215
216 enhancedBaseAddresses->add_back(base);
217 }
218 }
219
220 for(uint16_t i = 0; i < 256; i++){ // Bus
221 for(uint16_t j = 0; j < 32; j++){ // Slot
222 if(CheckDevice(i, j, 0)){
223 int index = AddDevice(i, j, 0);
224 if(devices->get_at(index).HeaderType() & 0x80){
225 for(int k = 1; k < 8; k++){ // Func
226 if(CheckDevice(i,j,k)){
227 AddDevice(i,j,k);
228 }
229 }
230 }
231
232 }
233 }
234 }
235 }
236}
237
238

Callers

nothing calls this directly

Calls 6

WarningFunction · 0.85
CheckDeviceFunction · 0.85
AddDeviceFunction · 0.85
HeaderTypeMethod · 0.80
get_atMethod · 0.80
add_backMethod · 0.45

Tested by

no test coverage detected