kern: finish implementing assembly init routines

This commit is contained in:
Michael Scire 2020-01-24 00:47:43 -08:00
parent b3bfd6c4c9
commit 32fb22e361
11 changed files with 270 additions and 40 deletions

View file

@ -34,33 +34,6 @@ namespace ams::kern::init::loader {
constexpr size_t InitialPageTableRegionSize = 0x200000;
class KInitialPageAllocator : public KInitialPageTable::IPageAllocator {
private:
uintptr_t next_address;
public:
constexpr ALWAYS_INLINE KInitialPageAllocator() : next_address(Null<uintptr_t>) { /* ... */ }
ALWAYS_INLINE void Initialize(uintptr_t address) {
this->next_address = address;
}
ALWAYS_INLINE uintptr_t Finalize() {
const uintptr_t final_address = this->next_address;
this->next_address = Null<uintptr_t>;
return final_address;
}
public:
virtual KPhysicalAddress Allocate() override {
MESOSPHERE_ABORT_UNLESS(this->next_address != Null<uintptr_t>);
const uintptr_t allocated = this->next_address;
this->next_address += PageSize;
std::memset(reinterpret_cast<void *>(allocated), 0, PageSize);
return allocated;
}
/* No need to override free. The default does nothing, and so would we. */
};
/* Global Allocator. */
KInitialPageAllocator g_initial_page_allocator;
@ -335,8 +308,8 @@ namespace ams::kern::init::loader {
return GetInteger(virtual_base_address) - base_address;
}
uintptr_t Finalize() {
return g_initial_page_allocator.Finalize();
uintptr_t GetFinalPageAllocatorState() {
return g_initial_page_allocator.GetFinalState();
}
}