diff options
author | Liav A <liavalb@gmail.com> | 2021-09-07 12:08:38 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-07 13:47:37 +0200 |
commit | 25ea7461a0e5a6c2ed1a43b80b1db8b2ac3b3764 (patch) | |
tree | 135923d84d2dc4244148b9dcd3cb3c77f43378ad /Kernel/Bus/PCI/API.h | |
parent | d1378339f6f4457457167fcf79cbca5f5549a336 (diff) | |
download | serenity-25ea7461a0e5a6c2ed1a43b80b1db8b2ac3b3764.zip |
Kernel/PCI: Simplify the entire subsystem
A couple of things were changed:
1. Semantic changes - PCI segments are now called PCI domains, to better
match what they are really. It's also the name that Linux gave, and it
seems that Wikipedia also uses this name.
We also remove PCI::ChangeableAddress, because it was used in the past
but now it's no longer being used.
2. There are no WindowedMMIOAccess or MMIOAccess classes anymore, as
they made a bunch of unnecessary complexity. Instead, Windowed access is
removed entirely (this was tested, but never was benchmarked), so we are
left with IO access and memory access options. The memory access option
is essentially mapping the PCI bus (from the chosen PCI domain), to
virtual memory as-is. This means that unless needed, at any time, there
is only one PCI bus being mapped, and this is changed if access to
another PCI bus in the same PCI domain is needed. For now, we don't
support mapping of different PCI buses from different PCI domains at the
same time, because basically it's still a non-issue for most machines
out there.
2. OOM-safety is increased, especially when constructing the Access
object. It means that we pre-allocating any needed resources, and we try
to find PCI domains (if requested to initialize memory access) after we
attempt to construct the Access object, so it's possible to fail at this
point "gracefully".
3. All PCI API functions are now separated into a different header file,
which means only "clients" of the PCI subsystem API will need to include
that header file.
4. Functional changes - we only allow now to enumerate the bus after
a hardware scan. This means that the old method "enumerate_hardware"
is removed, so, when initializing an Access object, the initializing
function must call rescan on it to force it to find devices. This makes
it possible to fail rescan, and also to defer it after construction from
both OOM-safety terms and hotplug capabilities.
Diffstat (limited to 'Kernel/Bus/PCI/API.h')
-rw-r--r-- | Kernel/Bus/PCI/API.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Kernel/Bus/PCI/API.h b/Kernel/Bus/PCI/API.h new file mode 100644 index 0000000000..6d23a6e594 --- /dev/null +++ b/Kernel/Bus/PCI/API.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include <Kernel/Bus/PCI/Definitions.h> + +namespace Kernel::PCI { + +void write8(Address address, u32 field, u8 value); +void write16(Address address, u32 field, u16 value); +void write32(Address address, u32 field, u32 value); +u8 read8(Address address, u32 field); +u16 read16(Address address, u32 field); +u32 read32(Address address, u32 field); + +ID get_id(PCI::Address); +bool is_io_space_enabled(Address); +void enumerate(Function<void(Address, ID)> callback); +void enable_interrupt_line(Address); +void disable_interrupt_line(Address); +u8 get_interrupt_line(Address); +void raw_access(Address, u32, size_t, u32); +u32 get_BAR0(Address); +u32 get_BAR1(Address); +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); +u8 get_class(Address); +u16 get_subsystem_id(Address); +u16 get_subsystem_vendor_id(Address); +size_t get_BAR_space_size(Address, u8); +void enable_bus_mastering(Address); +void disable_bus_mastering(Address); +void enable_io_space(Address); +void disable_io_space(Address); +void enable_memory_space(Address); +void disable_memory_space(Address); +PhysicalID get_physical_id(Address address); + +} |