[zion] Add a method for duplicating and scoping down VMMOs.
Use the AHCI section of the PCI config as an example POC of this. We can now pass a memory capability instead of just the physical address.
This commit is contained in:
parent
8f84f8c3ca
commit
48c6e5b3a4
12 changed files with 62 additions and 18 deletions
|
|
@ -27,8 +27,11 @@ PciReader::PciReader() {
|
|||
header_ = PciHeader(vaddr, 0, 0, 0);
|
||||
}
|
||||
|
||||
uint64_t PciReader::GetAhciPhysical() {
|
||||
return phys_mem_offset_ + achi_device_offset_;
|
||||
z_cap_t PciReader::GetAhciVmmo() {
|
||||
uint64_t new_cap;
|
||||
check(ZMemoryObjectDuplicate(gBootPciVmmoCap, achi_device_offset_,
|
||||
kPcieConfigurationSize, &new_cap));
|
||||
return new_cap;
|
||||
}
|
||||
|
||||
void PciReader::FunctionDump(uint64_t base, uint64_t bus, uint64_t dev,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
struct PciDeviceHeader {
|
||||
uint16_t vendor_id;
|
||||
|
|
@ -17,16 +18,19 @@ struct PciDeviceHeader {
|
|||
uint8_t bist;
|
||||
} __attribute__((packed));
|
||||
|
||||
// TODO: Figure out if it safe to hardcode this.
|
||||
// For the memory mapped access to PCI, it may be true that
|
||||
// each configuration item is always the size of a single page.
|
||||
const uint64_t kPcieConfigurationSize = 0x1000;
|
||||
|
||||
class PciReader {
|
||||
public:
|
||||
PciReader();
|
||||
|
||||
uint64_t GetAhciPhysical();
|
||||
z_cap_t GetAhciVmmo();
|
||||
|
||||
private:
|
||||
PciDeviceHeader* header_;
|
||||
// FIXME: Don't hardcode this (It is available from ACPI).
|
||||
uint64_t phys_mem_offset_ = 0xB000'0000;
|
||||
|
||||
uint64_t achi_device_offset_ = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue