diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-01-02 19:43:45 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-17 10:21:23 +0200 |
commit | 40a1f89d6788306ea617cb52584db47d5dd13ce0 (patch) | |
tree | 720757605fe96eeed1a2b7cb14268ca473902d58 | |
parent | 172d23deaef7f646f7a79bfad86a88a70adf8b32 (diff) | |
download | serenity-40a1f89d6788306ea617cb52584db47d5dd13ce0.zip |
Kernel: Add PCI::get_BAR convenience method
Based on pull #3236 by tomuta
Co-authored-by: Tom <tomut@yahoo.com>
-rw-r--r-- | Kernel/PCI/Access.cpp | 21 | ||||
-rw-r--r-- | Kernel/PCI/Definitions.h | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/Kernel/PCI/Access.cpp b/Kernel/PCI/Access.cpp index e877cf150e..763e0aadc5 100644 --- a/Kernel/PCI/Access.cpp +++ b/Kernel/PCI/Access.cpp @@ -252,6 +252,27 @@ u32 get_BAR5(Address address) 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) { return read8(address, PCI_REVISION_ID); diff --git a/Kernel/PCI/Definitions.h b/Kernel/PCI/Definitions.h index 1cc92144e8..541f0383ff 100644 --- a/Kernel/PCI/Definitions.h +++ b/Kernel/PCI/Definitions.h @@ -235,6 +235,7 @@ u32 get_BAR2(Address); u32 get_BAR3(Address); u32 get_BAR4(Address); u32 get_BAR5(Address); +u32 get_BAR(Address address, u8 bar); u8 get_revision_id(Address); u8 get_programming_interface(Address); u8 get_subclass(Address); |