1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-10-01 11:23:25 +01:00
Atmosphere/exosphere/src/cpu_context.h

84 lines
2.3 KiB
C
Raw Normal View History

/*
* Copyright (c) 2018 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2018-02-18 02:50:39 +00:00
#ifndef EXOSPHERE_CPU_CTX_H
#define EXOSPHERE_CPU_CTX_H
2018-03-03 02:43:46 +00:00
#include "utils.h"
#include "synchronization.h"
2018-02-18 02:50:39 +00:00
/* Exosphere CPU Management functionality. */
2018-03-03 02:43:46 +00:00
extern critical_section_t g_boot_critical_section;
2018-02-18 02:50:39 +00:00
typedef struct {
2018-02-26 10:00:02 +00:00
uint64_t argument;
2018-02-18 02:50:39 +00:00
uint64_t ELR_EL3;
int is_active;
int is_saved;
uint32_t OSDTRRX_EL1;
uint32_t OSDTRTX_EL1;
uint32_t MDSCR_EL1;
uint32_t OSECCR_EL1;
uint32_t MDCCINT_EL1;
uint32_t DBGCLAIMCLR_EL1;
uint32_t DBGVCR32_EL2;
uint32_t SDER32_EL3;
uint32_t MDCR_EL2;
uint32_t MDCR_EL3;
2018-03-11 11:53:52 +00:00
uint32_t SPSR_EL3; /* not in official code */
2018-02-18 02:50:39 +00:00
uint64_t DBGBVR0_EL1;
uint64_t DBGBCR0_EL1;
uint64_t DBGBVR1_EL1;
uint64_t DBGBCR1_EL1;
uint64_t DBGBVR2_EL1;
uint64_t DBGBCR2_EL1;
uint64_t DBGBVR3_EL1;
uint64_t DBGBCR3_EL1;
uint64_t DBGBVR4_EL1;
uint64_t DBGBCR4_EL1;
uint64_t DBGBVR5_EL1;
uint64_t DBGBCR5_EL1;
uint64_t DBGWVR0_EL1;
uint64_t DBGWCR0_EL1;
uint64_t DBGWVR1_EL1;
uint64_t DBGWCR1_EL1;
uint64_t DBGWVR2_EL1;
uint64_t DBGWCR2_EL1;
uint64_t DBGWVR3_EL1;
uint64_t DBGWCR3_EL1;
} saved_cpu_context_t;
#define NUM_CPU_CORES 4
void save_current_core_context(void);
void restore_current_core_context(void);
2018-03-03 18:31:22 +00:00
bool is_core_active(uint32_t core);
void set_core_is_active(uint32_t core, bool is_active);
2018-02-28 00:10:51 +00:00
void set_current_core_active(void);
void set_current_core_inactive(void);
2018-03-01 00:40:09 +00:00
void use_core_entrypoint_and_argument(uint32_t core, uintptr_t *entrypoint_addr, uint64_t *argument);
void set_core_entrypoint_and_argument(uint32_t core, uintptr_t entrypoint_addr, uint64_t argument);
2018-03-03 18:31:22 +00:00
void __attribute__((noreturn)) core_jump_to_lower_el(void);
2018-02-18 02:50:39 +00:00
2018-03-01 00:40:09 +00:00
uint32_t cpu_on(uint32_t core, uintptr_t entrypoint_addr, uint64_t argument);
2018-02-28 00:35:35 +00:00
uint32_t cpu_off(void);
2018-02-18 02:50:39 +00:00
#endif