mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:27:35 +00:00
Kernel: Add bar_address_mask to mask the last 4 bits of a BAR address
Create a bar_address_mask constant to mask the last 4 bits of a BAR address instead of hand coding the mask all over the kernel.
This commit is contained in:
parent
20d517f1da
commit
83b87a5ade
8 changed files with 14 additions and 15 deletions
|
@ -227,7 +227,7 @@ size_t get_BAR_space_size(DeviceIdentifier const& identifier, HeaderType0BaseReg
|
|||
write32_offsetted(identifier, field, 0xFFFFFFFF);
|
||||
u32 space_size = read32_offsetted(identifier, field);
|
||||
write32_offsetted(identifier, field, bar_reserved);
|
||||
space_size &= 0xfffffff0;
|
||||
space_size &= bar_address_mask;
|
||||
space_size = (~space_size) + 1;
|
||||
return space_size;
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ size_t get_expansion_rom_space_size(DeviceIdentifier const& identifier)
|
|||
write32_offsetted(identifier, field, 0xFFFFFFFF);
|
||||
u32 space_size = read32_offsetted(identifier, field);
|
||||
write32_offsetted(identifier, field, bar_reserved);
|
||||
space_size &= 0xfffffff0;
|
||||
space_size &= bar_address_mask;
|
||||
space_size = (~space_size) + 1;
|
||||
return space_size;
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ static constexpr u16 value_port = 0xcfc;
|
|||
static constexpr size_t mmio_device_space_size = 4096;
|
||||
static constexpr u16 none_value = 0xffff;
|
||||
static constexpr size_t memory_range_per_bus = mmio_device_space_size * to_underlying(Limits::MaxFunctionsPerDevice) * to_underlying(Limits::MaxDevicesPerBus);
|
||||
static constexpr u32 bar_address_mask = 0xfffffff0;
|
||||
|
||||
// Taken from https://pcisig.com/sites/default/files/files/PCI_Code-ID_r_1_11__v24_Jan_2019.pdf
|
||||
enum class ClassID {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue