mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-27 21:24:11 -04:00
kern: Implement most of memory init (all cores hit main, but still more to do)
This commit is contained in:
parent
b2e522c0a0
commit
e7dee2a9fc
22 changed files with 1246 additions and 81 deletions
|
@ -40,9 +40,10 @@ _start:
|
|||
|
||||
/* Stack is now set up. */
|
||||
/* Apply relocations and call init array for KernelLdr. */
|
||||
sub sp, sp, #0x20
|
||||
sub sp, sp, #0x30
|
||||
stp x0, x1, [sp, #0x00]
|
||||
stp x2, x30, [sp, #0x10]
|
||||
stp xzr, xzr, [sp, #0x20]
|
||||
adr x0, _start
|
||||
adr x1, __external_references
|
||||
ldr x1, [x1, #0x18] /* .dynamic. */
|
||||
|
@ -75,6 +76,11 @@ _start:
|
|||
bl _ZN3ams4kern4init6loader4MainEmPNS1_12KernelLayoutEm
|
||||
str x0, [sp, #0x00]
|
||||
|
||||
/* Get ams::kern::init::loader::AllocateKernelInitStack(). */
|
||||
bl _ZN3ams4kern4init6loader23AllocateKernelInitStackEv
|
||||
str x0, [sp, #0x20]
|
||||
|
||||
|
||||
/* Call ams::kern::init::loader::GetFinalPageAllocatorState() */
|
||||
bl _ZN3ams4kern4init6loader26GetFinalPageAllocatorStateEv
|
||||
|
||||
|
@ -85,6 +91,8 @@ _start:
|
|||
ldr x1, [sp, #0x18] /* Return address to Kernel */
|
||||
ldr x2, [sp, #0x00] /* Relocated kernel base address diff. */
|
||||
add x1, x2, x1
|
||||
ldr x2, [sp, #0x20]
|
||||
mov sp, x2
|
||||
br x1
|
||||
|
||||
|
||||
|
|
|
@ -97,8 +97,8 @@ namespace ams::kern::init::loader {
|
|||
/* TODO: Define these bits properly elsewhere, document exactly what each bit set is doing .*/
|
||||
constexpr u64 MairValue = 0x0000000044FF0400ul;
|
||||
constexpr u64 TcrValue = 0x00000011B5193519ul;
|
||||
cpu::SetMairEl1(MairValue);
|
||||
cpu::SetTcrEl1(TcrValue);
|
||||
cpu::MemoryAccessIndirectionRegisterAccessor(MairValue).Store();
|
||||
cpu::TranslationControlRegisterAccessor(TcrValue).Store();
|
||||
|
||||
/* Perform cpu-specific setup. */
|
||||
{
|
||||
|
@ -308,6 +308,10 @@ namespace ams::kern::init::loader {
|
|||
return GetInteger(virtual_base_address) - base_address;
|
||||
}
|
||||
|
||||
KPhysicalAddress AllocateKernelInitStack() {
|
||||
return g_initial_page_allocator.Allocate() + PageSize;
|
||||
}
|
||||
|
||||
uintptr_t GetFinalPageAllocatorState() {
|
||||
return g_initial_page_allocator.GetFinalState();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue