kern: add SvcQueryIoMapping (NOTE: pre-10.x, ABI needs update)

This commit is contained in:
Michael Scire
2020-07-13 13:24:32 -07:00
parent 57867d6ced
commit 18698bf1d3
6 changed files with 204 additions and 2 deletions

View File

@@ -268,6 +268,16 @@ namespace ams::kern {
MESOSPHERE_INIT_ABORT();
}
iterator TryFindFirstRegionByType(u32 type_id) {
for (auto it = this->begin(); it != this->end(); it++) {
if (it->GetType() == type_id) {
return it;
}
}
return this->end();
}
iterator FindFirstDerivedRegion(u32 type_id) {
for (auto it = this->begin(); it != this->end(); it++) {
if (it->IsDerivedFrom(type_id)) {
@@ -277,6 +287,16 @@ namespace ams::kern {
MESOSPHERE_INIT_ABORT();
}
iterator TryFindFirstDerivedRegion(u32 type_id) {
for (auto it = this->begin(); it != this->end(); it++) {
if (it->IsDerivedFrom(type_id)) {
return it;
}
}
return this->end();
}
DerivedRegionExtents GetDerivedRegionExtents(u32 type_id) const {
DerivedRegionExtents extents;
@@ -504,6 +524,33 @@ namespace ams::kern {
return *GetVirtualLinearMemoryRegionTree().FindContainingRegion(GetInteger(address));
}
static NOINLINE const KMemoryRegion *TryGetKernelTraceBufferRegion() {
auto &tree = GetPhysicalMemoryRegionTree();
if (KMemoryRegionTree::const_iterator it = tree.TryFindFirstDerivedRegion(KMemoryRegionType_KernelTraceBuffer); it != tree.end()) {
return std::addressof(*it);
} else {
return nullptr;
}
}
static NOINLINE const KMemoryRegion *TryGetOnMemoryBootImageRegion() {
auto &tree = GetPhysicalMemoryRegionTree();
if (KMemoryRegionTree::const_iterator it = tree.TryFindFirstDerivedRegion(KMemoryRegionType_OnMemoryBootImage); it != tree.end()) {
return std::addressof(*it);
} else {
return nullptr;
}
}
static NOINLINE const KMemoryRegion *TryGetDTBRegion() {
auto &tree = GetPhysicalMemoryRegionTree();
if (KMemoryRegionTree::const_iterator it = tree.TryFindFirstDerivedRegion(KMemoryRegionType_DTB); it != tree.end()) {
return std::addressof(*it);
} else {
return nullptr;
}
}
static NOINLINE bool IsHeapPhysicalAddress(const KMemoryRegion **out, KPhysicalAddress address, const KMemoryRegion *hint = nullptr) {
auto &tree = GetPhysicalLinearMemoryRegionTree();
KMemoryRegionTree::const_iterator it = tree.end();