mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-28 13:44:11 -04:00
exosphere: commit WIP warmboot progress
-15+ bugs fixed -We now receive ~0x400 SMCs from user processes (including from psm) on wake-from-sleep
This commit is contained in:
parent
de49cfefac
commit
f41aaccaa2
12 changed files with 105 additions and 25 deletions
|
@ -2,6 +2,8 @@
|
|||
#include <stdint.h>
|
||||
#include "arm.h"
|
||||
#include "cpu_context.h"
|
||||
#include "car.h"
|
||||
#include "exocfg.h"
|
||||
#include "flow.h"
|
||||
#include "pmc.h"
|
||||
#include "timers.h"
|
||||
|
@ -18,7 +20,7 @@
|
|||
#define RESTORE_SYSREG64(reg) do { temp_reg = g_cpu_contexts[current_core].reg; __asm__ __volatile__ ("msr " #reg ", %0" :: "r"(temp_reg) : "memory"); } while(false)
|
||||
#define RESTORE_SYSREG32(reg) RESTORE_SYSREG64(reg)
|
||||
#define RESTORE_BP_REG(i, _) RESTORE_SYSREG64(DBGBVR##i##_EL1); RESTORE_SYSREG64(DBGBCR##i##_EL1);
|
||||
#define RESTORE_WP_REG(i, _) RESTORE_SYSREG64(DBGBVR##i##_EL1); RESTORE_SYSREG64(DBGBCR##i##_EL1);
|
||||
#define RESTORE_WP_REG(i, _) RESTORE_SYSREG64(DBGWVR##i##_EL1); RESTORE_SYSREG64(DBGWCR##i##_EL1);
|
||||
|
||||
/* start.s */
|
||||
void __attribute__((noreturn)) __jump_to_lower_el(uint64_t arg, uintptr_t ep, uint32_t spsr);
|
||||
|
@ -79,8 +81,13 @@ uint32_t cpu_on(uint32_t core, uintptr_t entrypoint_addr, uint64_t argument) {
|
|||
|
||||
set_core_entrypoint_and_argument(core, entrypoint_addr, argument);
|
||||
|
||||
const uint32_t status_masks[NUM_CPU_CORES] = {0x4000, 0x200, 0x400, 0x800};
|
||||
const uint32_t toggle_vals[NUM_CPU_CORES] = {0xE, 0x9, 0xA, 0xB};
|
||||
static const uint32_t status_masks[NUM_CPU_CORES] = {0x4000, 0x200, 0x400, 0x800};
|
||||
static const uint32_t toggle_vals[NUM_CPU_CORES] = {0xE, 0x9, 0xA, 0xB};
|
||||
|
||||
if (exosphere_get_target_firmware() >= EXOSPHERE_TARGET_FIRMWARE_400) {
|
||||
/* Reset the core */
|
||||
CLK_RST_CONTROLLER_RST_CPUG_CMPLX_SET_0 = (1 << (core + 0x10)) | (1 << core);
|
||||
}
|
||||
|
||||
/* Check if we're already in the correct state. */
|
||||
if ((APBDEV_PMC_PWRGATE_STATUS_0 & status_masks[core]) != status_masks[core]) {
|
||||
|
@ -91,7 +98,7 @@ uint32_t cpu_on(uint32_t core, uintptr_t entrypoint_addr, uint64_t argument) {
|
|||
wait(1);
|
||||
counter--;
|
||||
if (counter < 1) {
|
||||
return 0;
|
||||
goto CPU_ON_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,6 +115,13 @@ uint32_t cpu_on(uint32_t core, uintptr_t entrypoint_addr, uint64_t argument) {
|
|||
counter--;
|
||||
}
|
||||
}
|
||||
|
||||
CPU_ON_SUCCESS:
|
||||
if (exosphere_get_target_firmware() >= EXOSPHERE_TARGET_FIRMWARE_400) {
|
||||
/* Start the core */
|
||||
CLK_RST_CONTROLLER_RST_CPUG_CMPLX_CLR_0 = (1 << (core + 0x10)) | (1 << core);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -145,6 +159,7 @@ void save_current_core_context(void) {
|
|||
/* Save system registers. */
|
||||
|
||||
SAVE_SYSREG32(OSDTRRX_EL1);
|
||||
SAVE_SYSREG32(OSDTRTX_EL1);
|
||||
SAVE_SYSREG32(MDSCR_EL1);
|
||||
SAVE_SYSREG32(OSECCR_EL1);
|
||||
SAVE_SYSREG32(MDCCINT_EL1);
|
||||
|
@ -168,6 +183,7 @@ void restore_current_core_context(void) {
|
|||
|
||||
if (g_cpu_contexts[current_core].is_saved) {
|
||||
RESTORE_SYSREG32(OSDTRRX_EL1);
|
||||
RESTORE_SYSREG32(OSDTRTX_EL1);
|
||||
RESTORE_SYSREG32(MDSCR_EL1);
|
||||
RESTORE_SYSREG32(OSECCR_EL1);
|
||||
RESTORE_SYSREG32(MDCCINT_EL1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue