blob: 5403e054a22774927ea0628777fe86764cd82852 [file]
// Copyright 2026 The Fuchsia Authors
//
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT
#include <lib/arch/arm64/paging-traits.h>
#include <lib/arch/arm64/system.h>
#include <phys/address-space/address-space.h>
#include "identity-map.h"
#include <ktl/enforce.h>
namespace {
constexpr arch::ArmMairNormalAttribute kNormalMemoryUncached{
.inner = arch::ArmCacheabilityAttribute::kNonCacheable,
.outer = arch::ArmCacheabilityAttribute::kNonCacheable,
};
} // namespace
void ArchSetUpIdentityMap(AddressSpace& aspace) {
// The following four attributes and indices must be kept in sync with those
// used in the kernel proper
//
// LINT.IfChange
auto mair = arch::ArmMemoryAttrIndirectionRegister::Get()
.FromValue(0)
.SetAttribute(0, arch::ArmDeviceMemory::kNonGatheringNonReorderingNoEarlyAck)
.SetAttribute(1, ArchMmioMemoryType())
.SetAttribute(2, kArchNormalMemoryType)
.SetAttribute(3, kNormalMemoryUncached);
// LINT.ThenChange(/zircon/kernel/arch/arm64/include/arch/arm64/mmu.h)
aspace.Init(mair);
IdentityMapRam(aspace);
IdentityMapUart(aspace);
aspace.Install();
}