1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-04 11:57:35 +00:00
serenity/Kernel/PCI/MMIOAccess.h
Liav A 2a4a19aed8 Kernel: Fixing PCI MMIO access mechanism
During initialization of PCI MMIO access mechanism we ensure that we
have an allocation from the kernel virtual address space that cannot be
taken by other components in the OS.
Also, now we ensure that interrupts are disabled so mapping the region
doesn't fail.
In order to reduce overhead, map_device() will map the requested PCI
address only if it's not mapped already.

The run script has been changed so now we can boot a Q35 machine, that
supports PCI ECAM.
To ensure we will be able to load the machine, a PIIX3 IDE controller
was added to the Q35 machine configuration in the run script.
An AHCI controller was added to the i440fx machine configuration.
2020-01-02 21:45:04 +01:00

57 lines
No EOL
1.8 KiB
C++

#pragma once
#include <AK/HashMap.h>
#include <AK/OwnPtr.h>
#include <AK/Types.h>
#include <Kernel/ACPI/Definitions.h>
#include <Kernel/PCI/Access.h>
#include <Kernel/VM/AnonymousVMObject.h>
#include <Kernel/VM/PhysicalRegion.h>
#include <Kernel/VM/Region.h>
#include <Kernel/VM/VMObject.h>
class PCI::MMIOAccess final : public PCI::Access {
public:
static void initialize(ACPI_RAW::MCFG&);
virtual void enumerate_all(Function<void(Address, ID)>&) override final;
virtual String get_access_type() override final { return "MMIO-Access"; };
protected:
explicit MMIOAccess(ACPI_RAW::MCFG&);
private:
virtual u8 read8_field(Address address, u32) override final;
virtual u16 read16_field(Address address, u32) override final;
virtual u32 read32_field(Address address, u32) override final;
virtual void write8_field(Address address, u32, u8) override final;
virtual void write16_field(Address address, u32, u16) override final;
virtual void write32_field(Address address, u32, u32) override final;
void map_device(Address address);
void mmap(VirtualAddress preferred_vaddr, PhysicalAddress paddr, u32);
void mmap_region(Region& region, PhysicalAddress paddr);
virtual u32 get_segments_count();
virtual u8 get_segment_start_bus(u32);
virtual u8 get_segment_end_bus(u32);
ACPI_RAW::MCFG& m_mcfg;
HashMap<u16, MMIOSegment*>& m_segments;
RefPtr<VMObject> m_mmio_window;
OwnPtr<Region> m_mmio_window_region;
PCI::ChangeableAddress m_mapped_address;
};
class PCI::MMIOSegment {
public:
MMIOSegment(PhysicalAddress, u8, u8);
u8 get_start_bus();
u8 get_end_bus();
size_t get_size();
PhysicalAddress get_paddr();
private:
PhysicalAddress m_base_addr;
u8 m_start_bus;
u8 m_end_bus;
};