mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-18 08:22:04 +00:00
Uncomment more sleep/suspend code
This commit is contained in:
parent
235b7b65e1
commit
7a9e031bff
5 changed files with 33 additions and 6 deletions
|
@ -17,4 +17,7 @@ void invalidate_dcache_range(const void *start, const void *end);
|
||||||
|
|
||||||
void invalidate_icache_inner_shareable(void);
|
void invalidate_icache_inner_shareable(void);
|
||||||
|
|
||||||
|
|
||||||
|
void call_with_stack_pointer(uintptr_t stack_pointer, void (*function)(void));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -227,3 +227,12 @@ invalidate_icache_inner_shareable:
|
||||||
dsb ish
|
dsb ish
|
||||||
isb
|
isb
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
/* Call a function with desired stack pointer. */
|
||||||
|
.section .text.call_with_stack_pointer, "ax", %progbits
|
||||||
|
.type call_with_stack_pointer, %function
|
||||||
|
.global call_with_stack_pointer
|
||||||
|
call_with_stack_pointer:
|
||||||
|
mov sp, x0
|
||||||
|
br x1
|
|
@ -5,6 +5,7 @@
|
||||||
#include "flow.h"
|
#include "flow.h"
|
||||||
#include "pmc.h"
|
#include "pmc.h"
|
||||||
#include "timers.h"
|
#include "timers.h"
|
||||||
|
#include "smc_api.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
static saved_cpu_context_t g_cpu_contexts[NUM_CPU_CORES] = {0};
|
static saved_cpu_context_t g_cpu_contexts[NUM_CPU_CORES] = {0};
|
||||||
|
@ -72,10 +73,11 @@ void power_down_current_core(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t cpu_off(void) {
|
uint32_t cpu_off(void) {
|
||||||
if (get_core_id() == 3) {
|
unsigned int current_core = get_core_id();
|
||||||
|
if (current_core == 3) {
|
||||||
power_down_current_core();
|
power_down_current_core();
|
||||||
} else {
|
} else {
|
||||||
/* TODO: call_with_stack_pointer(get_powerdown_stack(), power_down_current_core); */
|
call_with_stack_pointer(get_exception_entry_stack_address(current_core), power_down_current_core);
|
||||||
}
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
/* Wait forever. */
|
/* Wait forever. */
|
||||||
|
@ -220,3 +222,13 @@ void restore_current_core_context(void) {
|
||||||
g_cpu_contexts[current_core].is_saved = 0;
|
g_cpu_contexts[current_core].is_saved = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void set_current_core_active(void) {
|
||||||
|
g_cpu_contexts[get_core_id()].is_active = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_current_core_inactive(void) {
|
||||||
|
g_cpu_contexts[get_core_id()].is_active = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,9 @@ typedef struct {
|
||||||
void save_current_core_context(void);
|
void save_current_core_context(void);
|
||||||
void restore_current_core_context(void);
|
void restore_current_core_context(void);
|
||||||
|
|
||||||
|
void set_current_core_active(void);
|
||||||
|
void set_current_core_inactive(void);
|
||||||
|
|
||||||
void set_core_entrypoint_and_argument(uint32_t core, uint64_t entrypoint_addr, uint64_t argument);
|
void set_core_entrypoint_and_argument(uint32_t core, uint64_t entrypoint_addr, uint64_t argument);
|
||||||
|
|
||||||
uint32_t cpu_on(uint32_t core, uint64_t entrypoint_addr, uint64_t argument);
|
uint32_t cpu_on(uint32_t core, uint64_t entrypoint_addr, uint64_t argument);
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "bpmp.h"
|
#include "bpmp.h"
|
||||||
#include "arm.h"
|
#include "arm.h"
|
||||||
#include "configitem.h"
|
#include "configitem.h"
|
||||||
|
#include "cpu_context.h"
|
||||||
#include "flow.h"
|
#include "flow.h"
|
||||||
#include "fuse.h"
|
#include "fuse.h"
|
||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
|
@ -121,10 +122,9 @@ uint32_t cpu_suspend(uint64_t power_state, uint64_t entrypoint, uint64_t argumen
|
||||||
|
|
||||||
/* Save core context. */
|
/* Save core context. */
|
||||||
set_core_entrypoint_and_argument(current_core, entrypoint, argument);
|
set_core_entrypoint_and_argument(current_core, entrypoint, argument);
|
||||||
/* TODO: save_current_core_context(); */
|
save_current_core_context();
|
||||||
/* TODO: set_current_core_inacctive(); */
|
set_current_core_inactive();
|
||||||
/* TODO: set_current_core_saved(true); */
|
call_with_stack_pointer(get_smc_core012_stack_address(), save_se_and_power_down_cpu);
|
||||||
/* TODO: call_with_stack_pointer(TZRAM_GET_SEGMENT_ADDR(TZRAM_SEGMENT_ID_CORE012_STACK) + 0x1000ULL, save_se_and_power_down_cpu); */
|
|
||||||
|
|
||||||
/* NOTE: This return never actually occurs. */
|
/* NOTE: This return never actually occurs. */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue