1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 04:27:44 +00:00

Kernel: Add PCI::get_BAR convenience method

Based on pull #3236 by tomuta

Co-authored-by: Tom <tomut@yahoo.com>
This commit is contained in:
Idan Horowitz 2021-01-02 19:43:45 +02:00 committed by Andreas Kling
parent 172d23deae
commit 40a1f89d67
2 changed files with 22 additions and 0 deletions

View file

@ -252,6 +252,27 @@ u32 get_BAR5(Address address)
return read32(address, PCI_BAR5); return read32(address, PCI_BAR5);
} }
u32 get_BAR(Address address, u8 bar)
{
ASSERT(bar <= 5);
switch (bar) {
case 0:
return get_BAR0(address);
case 1:
return get_BAR1(address);
case 2:
return get_BAR2(address);
case 3:
return get_BAR3(address);
case 4:
return get_BAR4(address);
case 5:
return get_BAR5(address);
default:
ASSERT_NOT_REACHED();
}
}
u8 get_revision_id(Address address) u8 get_revision_id(Address address)
{ {
return read8(address, PCI_REVISION_ID); return read8(address, PCI_REVISION_ID);

View file

@ -235,6 +235,7 @@ u32 get_BAR2(Address);
u32 get_BAR3(Address); u32 get_BAR3(Address);
u32 get_BAR4(Address); u32 get_BAR4(Address);
u32 get_BAR5(Address); u32 get_BAR5(Address);
u32 get_BAR(Address address, u8 bar);
u8 get_revision_id(Address); u8 get_revision_id(Address);
u8 get_programming_interface(Address); u8 get_programming_interface(Address);
u8 get_subclass(Address); u8 get_subclass(Address);