mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-29 22:15:17 -04:00
exo2: Implement SmcReadWriteRegister
This commit is contained in:
parent
8c4c1db506
commit
e3eadcd2e3
35 changed files with 918 additions and 139 deletions
30
exosphere2/program/source/smc/secmon_define_access_table.inc
Normal file
30
exosphere2/program/source/smc/secmon_define_access_table.inc
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 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/>.
|
||||
*/
|
||||
|
||||
using __ACCESS_TABLE_NAME__ = AccessTable<__ACCESS_TABLE_ADDRESS__, [] {
|
||||
/* Declare a table. */
|
||||
std::array<u8, 0x80> table = {};
|
||||
|
||||
/* Declare a helper. */
|
||||
auto SetRegisterAllowed = [&](uintptr_t reg) { SetRegisterTableAllowed(table, reg); };
|
||||
|
||||
/* Populate the table. */
|
||||
#include __ACCESS_TABLE_INC__
|
||||
|
||||
return table;
|
||||
}()>;
|
||||
|
||||
static_assert(__ACCESS_TABLE_NAME__::Address >= __ACCESS_TABLE_ADDRESS__);
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 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/>.
|
||||
*/
|
||||
|
||||
#define __ACCESS_TABLE_NAME__ Mc01AccessTable
|
||||
#define __ACCESS_TABLE_ADDRESS__ 0
|
||||
#define __ACCESS_TABLE_INC__ "secmon_mc01_access_table_data.inc"
|
||||
|
||||
#include "secmon_define_access_table.inc"
|
||||
|
||||
#undef __ACCESS_TABLE_INC__
|
||||
#undef __ACCESS_TABLE_ADDRESS__
|
||||
#undef __ACCESS_TABLE_NAME__
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 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/>.
|
||||
*/
|
||||
|
||||
#define __ACCESS_TABLE_NAME__ McAccessTable
|
||||
#define __ACCESS_TABLE_ADDRESS__ MemoryRegionPhysicalDeviceMemoryController.GetAddress()
|
||||
#define __ACCESS_TABLE_INC__ "secmon_mc_access_table_data.inc"
|
||||
|
||||
#include "secmon_define_access_table.inc"
|
||||
|
||||
#undef __ACCESS_TABLE_INC__
|
||||
#undef __ACCESS_TABLE_ADDRESS__
|
||||
#undef __ACCESS_TABLE_NAME__
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 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/>.
|
||||
*/
|
||||
|
||||
#define __ACCESS_TABLE_NAME__ PmcAccessTable
|
||||
#define __ACCESS_TABLE_ADDRESS__ MemoryRegionPhysicalDevicePmc.GetAddress()
|
||||
#define __ACCESS_TABLE_INC__ "secmon_pmc_access_table_data.inc"
|
||||
|
||||
#include "secmon_define_access_table.inc"
|
||||
|
||||
#undef __ACCESS_TABLE_INC__
|
||||
#undef __ACCESS_TABLE_ADDRESS__
|
||||
#undef __ACCESS_TABLE_NAME__
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 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/>.
|
||||
*/
|
||||
|
||||
SetRegisterAllowed(MC_STAT_CONTROL); /* 0x100 */
|
||||
SetRegisterAllowed(MC_STAT_EMC_CLOCK_LIMIT); /* 0x108 */
|
||||
SetRegisterAllowed(MC_STAT_EMC_CLOCK_LIMIT_MSBS); /* 0x10C */
|
||||
SetRegisterAllowed(MC_STAT_EMC_FILTER_SET0_ADR_LIMIT_LO); /* 0x118 */
|
||||
SetRegisterAllowed(MC_STAT_EMC_FILTER_SET0_ADR_LIMIT_HI); /* 0x11C */
|
||||
SetRegisterAllowed(MC_STAT_EMC_FILTER_SET0_SPARE); /* 0x124 */
|
||||
SetRegisterAllowed(MC_STAT_EMC_FILTER_SET0_CLIENT_0); /* 0x128 */
|
||||
SetRegisterAllowed(MC_STAT_EMC_FILTER_SET0_CLIENT_1); /* 0x12C */
|
||||
SetRegisterAllowed(MC_STAT_EMC_FILTER_SET0_CLIENT_2); /* 0x130 */
|
||||
SetRegisterAllowed(MC_STAT_EMC_FILTER_SET0_CLIENT_3); /* 0x134 */
|
||||
SetRegisterAllowed(MC_STAT_EMC_SET0_COUNT); /* 0x138 */
|
||||
SetRegisterAllowed(MC_STAT_EMC_SET0_COUNT_MSBS); /* 0x13C */
|
||||
SetRegisterAllowed(MC_STAT_EMC_FILTER_SET1_ADR_LIMIT_LO); /* 0x158 */
|
||||
SetRegisterAllowed(MC_STAT_EMC_FILTER_SET1_ADR_LIMIT_HI); /* 0x15C */
|
||||
SetRegisterAllowed(MC_STAT_EMC_FILTER_SET1_SPARE); /* 0x164 */
|
||||
SetRegisterAllowed(MC_STAT_EMC_FILTER_SET1_CLIENT_0); /* 0x168 */
|
||||
SetRegisterAllowed(MC_STAT_EMC_FILTER_SET1_CLIENT_1); /* 0x16C */
|
||||
SetRegisterAllowed(MC_STAT_EMC_FILTER_SET1_CLIENT_2); /* 0x170 */
|
||||
SetRegisterAllowed(MC_STAT_EMC_FILTER_SET1_CLIENT_3); /* 0x174 */
|
||||
SetRegisterAllowed(MC_STAT_EMC_SET1_COUNT); /* 0x178 */
|
||||
SetRegisterAllowed(MC_STAT_EMC_SET1_COUNT_MSBS); /* 0x17C */
|
||||
SetRegisterAllowed(MC_STAT_EMC_FILTER_SET0_ADR_LIMIT_UPPER); /* 0xA20 */
|
||||
SetRegisterAllowed(MC_STAT_EMC_FILTER_SET1_ADR_LIMIT_UPPER); /* 0xA24 */
|
||||
SetRegisterAllowed(MC_STAT_EMC_FILTER_SET0_CLIENT_4); /* 0xB88 */
|
||||
SetRegisterAllowed(MC_STAT_EMC_FILTER_SET1_CLIENT_4); /* 0xB8C */
|
||||
SetRegisterAllowed(MC_STAT_EMC_FILTER_SET0_CLIENT_5); /* 0xBC4 */
|
||||
SetRegisterAllowed(MC_STAT_EMC_FILTER_SET1_CLIENT_5); /* 0xBC8 */
|
195
exosphere2/program/source/smc/secmon_mc_access_table_data.inc
Normal file
195
exosphere2/program/source/smc/secmon_mc_access_table_data.inc
Normal file
|
@ -0,0 +1,195 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 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/>.
|
||||
*/
|
||||
|
||||
SetRegisterAllowed(MC_INTSTATUS); /* 0x000 */
|
||||
SetRegisterAllowed(MC_INTMASK); /* 0x004 */
|
||||
SetRegisterAllowed(MC_ERR_STATUS); /* 0x008 */
|
||||
SetRegisterAllowed(MC_ERR_ADR); /* 0x00C */
|
||||
SetRegisterAllowed(MC_SMMU_CONFIG); /* 0x010 */
|
||||
SetRegisterAllowed(MC_SMMU_PTB_ASID); /* 0x01C */
|
||||
SetRegisterAllowed(MC_SMMU_PTB_DATA); /* 0x020 */
|
||||
SetRegisterAllowed(MC_SMMU_TLB_FLUSH); /* 0x030 */
|
||||
SetRegisterAllowed(MC_SMMU_PTC_FLUSH); /* 0x034 */
|
||||
SetRegisterAllowed(MC_EMEM_CFG); /* 0x050 */
|
||||
SetRegisterAllowed(MC_EMEM_ADR_CFG); /* 0x054 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_CFG); /* 0x090 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_OUTSTANDING_REQ); /* 0x094 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_TIMING_RCD); /* 0x098 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_TIMING_RP); /* 0x09C */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_TIMING_RC); /* 0x0A0 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_TIMING_RAS); /* 0x0A4 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_TIMING_FAW); /* 0x0A8 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_TIMING_RRD); /* 0x0AC */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_TIMING_RAP2PRE); /* 0x0B0 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_TIMING_WAP2PRE); /* 0x0B4 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_TIMING_R2R); /* 0x0B8 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_TIMING_W2W); /* 0x0BC */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_TIMING_R2W); /* 0x0C0 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_TIMING_W2R); /* 0x0C4 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_MISC2); /* 0x0C8 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_DA_TURNS); /* 0x0D0 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_DA_COVERS); /* 0x0D4 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_MISC0); /* 0x0D8 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_MISC1); /* 0x0DC */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_RING1_THROTTLE); /* 0x0E0 */
|
||||
SetRegisterAllowed(MC_CLIENT_HOTRESET_CTRL); /* 0x200 */
|
||||
SetRegisterAllowed(MC_CLIENT_HOTRESET_STATUS); /* 0x204 */
|
||||
SetRegisterAllowed(MC_SMMU_AFI_ASID); /* 0x238 */
|
||||
SetRegisterAllowed(MC_SMMU_DC_ASID); /* 0x240 */
|
||||
SetRegisterAllowed(MC_SMMU_DCB_ASID); /* 0x244 */
|
||||
SetRegisterAllowed(MC_SMMU_HC_ASID); /* 0x250 */
|
||||
SetRegisterAllowed(MC_SMMU_HDA_ASID); /* 0x254 */
|
||||
SetRegisterAllowed(MC_SMMU_ISP2_ASID); /* 0x258 */
|
||||
SetRegisterAllowed(MC_SMMU_NVENC_ASID); /* 0x264 */
|
||||
SetRegisterAllowed(MC_SMMU_NV_ASID); /* 0x268 */
|
||||
SetRegisterAllowed(MC_SMMU_NV2_ASID); /* 0x26C */
|
||||
SetRegisterAllowed(MC_SMMU_PPCS_ASID); /* 0x270 */
|
||||
SetRegisterAllowed(MC_SMMU_SATA_ASID); /* 0x274 */
|
||||
SetRegisterAllowed(MC_SMMU_VI_ASID); /* 0x280 */
|
||||
SetRegisterAllowed(MC_SMMU_VIC_ASID); /* 0x284 */
|
||||
SetRegisterAllowed(MC_SMMU_XUSB_HOST_ASID); /* 0x288 */
|
||||
SetRegisterAllowed(MC_SMMU_XUSB_DEV_ASID); /* 0x28C */
|
||||
SetRegisterAllowed(MC_SMMU_TSEC_ASID); /* 0x294 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_AVPC_0); /* 0x2E4 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_DC_0); /* 0x2E8 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_DC_1); /* 0x2EC */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_DCB_0); /* 0x2F4 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_DCB_1); /* 0x2F8 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_HC_0); /* 0x310 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_HC_1); /* 0x314 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_MPCORE_0); /* 0x320 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_NVENC_0); /* 0x328 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_PPCS_0); /* 0x344 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_PPCS_1); /* 0x348 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_ISP2_0); /* 0x370 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_ISP2_1); /* 0x374 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_XUSB_0); /* 0x37C */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_XUSB_1); /* 0x380 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_TSEC_0); /* 0x390 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_VIC_0); /* 0x394 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_VI2_0); /* 0x398 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_GPU_0); /* 0x3AC */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_SDMMCA_0); /* 0x3B8 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_SDMMCAA_0); /* 0x3BC */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_SDMMC_0); /* 0x3C0 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_SDMMCAB_0); /* 0x3C4 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_NVDEC_0); /* 0x3D8 */
|
||||
SetRegisterAllowed(MC_LATENCY_ALLOWANCE_GPU2_0); /* 0x3E8 */
|
||||
SetRegisterAllowed(MC_DIS_PTSA_RATE); /* 0x41C */
|
||||
SetRegisterAllowed(MC_DIS_PTSA_MIN); /* 0x420 */
|
||||
SetRegisterAllowed(MC_DIS_PTSA_MAX); /* 0x424 */
|
||||
SetRegisterAllowed(MC_DISB_PTSA_RATE); /* 0x428 */
|
||||
SetRegisterAllowed(MC_DISB_PTSA_MIN); /* 0x42C */
|
||||
SetRegisterAllowed(MC_DISB_PTSA_MAX); /* 0x430 */
|
||||
SetRegisterAllowed(MC_VE_PTSA_RATE); /* 0x434 */
|
||||
SetRegisterAllowed(MC_VE_PTSA_MIN); /* 0x438 */
|
||||
SetRegisterAllowed(MC_VE_PTSA_MAX); /* 0x43C */
|
||||
SetRegisterAllowed(MC_MLL_MPCORER_PTSA_RATE); /* 0x44C */
|
||||
SetRegisterAllowed(MC_RING1_PTSA_RATE); /* 0x47C */
|
||||
SetRegisterAllowed(MC_RING1_PTSA_MIN); /* 0x480 */
|
||||
SetRegisterAllowed(MC_RING1_PTSA_MAX); /* 0x484 */
|
||||
SetRegisterAllowed(MC_PCX_PTSA_RATE); /* 0x4AC */
|
||||
SetRegisterAllowed(MC_PCX_PTSA_MIN); /* 0x4B0 */
|
||||
SetRegisterAllowed(MC_PCX_PTSA_MAX); /* 0x4B4 */
|
||||
SetRegisterAllowed(MC_MSE_PTSA_RATE); /* 0x4C4 */
|
||||
SetRegisterAllowed(MC_MSE_PTSA_MIN); /* 0x4C8 */
|
||||
SetRegisterAllowed(MC_MSE_PTSA_MAX); /* 0x4CC */
|
||||
SetRegisterAllowed(MC_AHB_PTSA_RATE); /* 0x4DC */
|
||||
SetRegisterAllowed(MC_AHB_PTSA_MIN); /* 0x4E0 */
|
||||
SetRegisterAllowed(MC_AHB_PTSA_MAX); /* 0x4E4 */
|
||||
SetRegisterAllowed(MC_APB_PTSA_RATE); /* 0x4E8 */
|
||||
SetRegisterAllowed(MC_APB_PTSA_MIN); /* 0x4EC */
|
||||
SetRegisterAllowed(MC_APB_PTSA_MAX); /* 0x4F0 */
|
||||
SetRegisterAllowed(MC_FTOP_PTSA_RATE); /* 0x50C */
|
||||
SetRegisterAllowed(MC_HOST_PTSA_RATE); /* 0x518 */
|
||||
SetRegisterAllowed(MC_HOST_PTSA_MIN); /* 0x51C */
|
||||
SetRegisterAllowed(MC_HOST_PTSA_MAX); /* 0x520 */
|
||||
SetRegisterAllowed(MC_USBX_PTSA_RATE); /* 0x524 */
|
||||
SetRegisterAllowed(MC_USBX_PTSA_MIN); /* 0x528 */
|
||||
SetRegisterAllowed(MC_USBX_PTSA_MAX); /* 0x52C */
|
||||
SetRegisterAllowed(MC_USBD_PTSA_RATE); /* 0x530 */
|
||||
SetRegisterAllowed(MC_USBD_PTSA_MIN); /* 0x534 */
|
||||
SetRegisterAllowed(MC_USBD_PTSA_MAX); /* 0x538 */
|
||||
SetRegisterAllowed(MC_GK_PTSA_RATE); /* 0x53C */
|
||||
SetRegisterAllowed(MC_GK_PTSA_MIN); /* 0x540 */
|
||||
SetRegisterAllowed(MC_GK_PTSA_MAX); /* 0x544 */
|
||||
SetRegisterAllowed(MC_AUD_PTSA_RATE); /* 0x548 */
|
||||
SetRegisterAllowed(MC_AUD_PTSA_MIN); /* 0x54C */
|
||||
SetRegisterAllowed(MC_AUD_PTSA_MAX); /* 0x550 */
|
||||
SetRegisterAllowed(MC_VICPC_PTSA_RATE); /* 0x554 */
|
||||
SetRegisterAllowed(MC_VICPC_PTSA_MIN); /* 0x558 */
|
||||
SetRegisterAllowed(MC_VICPC_PTSA_MAX); /* 0x55C */
|
||||
SetRegisterAllowed(MC_JPG_PTSA_RATE); /* 0x584 */
|
||||
SetRegisterAllowed(MC_JPG_PTSA_MIN); /* 0x588 */
|
||||
SetRegisterAllowed(MC_JPG_PTSA_MAX); /* 0x58C */
|
||||
SetRegisterAllowed(MC_GK2_PTSA_RATE); /* 0x610 */
|
||||
SetRegisterAllowed(MC_GK2_PTSA_MIN); /* 0x614 */
|
||||
SetRegisterAllowed(MC_GK2_PTSA_MAX); /* 0x618 */
|
||||
SetRegisterAllowed(MC_SDM_PTSA_RATE); /* 0x61C */
|
||||
SetRegisterAllowed(MC_SDM_PTSA_MIN); /* 0x620 */
|
||||
SetRegisterAllowed(MC_SDM_PTSA_MAX); /* 0x624 */
|
||||
SetRegisterAllowed(MC_HDAPC_PTSA_RATE); /* 0x628 */
|
||||
SetRegisterAllowed(MC_HDAPC_PTSA_MIN); /* 0x62C */
|
||||
SetRegisterAllowed(MC_HDAPC_PTSA_MAX); /* 0x630 */
|
||||
SetRegisterAllowed(MC_SEC_CARVEOUT_BOM); /* 0x670 */
|
||||
SetRegisterAllowed(MC_SEC_CARVEOUT_SIZE_MB); /* 0x674 */
|
||||
SetRegisterAllowed(MC_SCALED_LATENCY_ALLOWANCE_DISPLAY0A); /* 0x690 */
|
||||
SetRegisterAllowed(MC_SCALED_LATENCY_ALLOWANCE_DISPLAY0AB); /* 0x694 */
|
||||
SetRegisterAllowed(MC_SCALED_LATENCY_ALLOWANCE_DISPLAY0B); /* 0x698 */
|
||||
SetRegisterAllowed(MC_SCALED_LATENCY_ALLOWANCE_DISPLAY0BB); /* 0x69C */
|
||||
SetRegisterAllowed(MC_SCALED_LATENCY_ALLOWANCE_DISPLAY0C); /* 0x6A0 */
|
||||
SetRegisterAllowed(MC_SCALED_LATENCY_ALLOWANCE_DISPLAY0CB); /* 0x6A4 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_TIMING_RFCPB); /* 0x6C0 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_TIMING_CCDMW); /* 0x6C4 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_REFPB_HP_CTRL); /* 0x6F0 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_REFPB_BANK_CTRL); /* 0x6F4 */
|
||||
SetRegisterAllowed(MC_PTSA_GRANT_DECREMENT); /* 0x960 */
|
||||
SetRegisterAllowed(MC_CLIENT_HOTRESET_CTRL_1); /* 0x970 */
|
||||
SetRegisterAllowed(MC_CLIENT_HOTRESET_STATUS_1); /* 0x974 */
|
||||
SetRegisterAllowed(MC_SMMU_PTC_FLUSH_1); /* 0x9B8 */
|
||||
SetRegisterAllowed(MC_SMMU_DC1_ASID); /* 0xA88 */
|
||||
SetRegisterAllowed(MC_SMMU_SDMMC1A_ASID); /* 0xA94 */
|
||||
SetRegisterAllowed(MC_SMMU_SDMMC2A_ASID); /* 0xA98 */
|
||||
SetRegisterAllowed(MC_SMMU_SDMMC3A_ASID); /* 0xA9C */
|
||||
SetRegisterAllowed(MC_SMMU_SDMMC4A_ASID); /* 0xAA0 */
|
||||
SetRegisterAllowed(MC_SMMU_ISP2B_ASID); /* 0xAA4 */
|
||||
SetRegisterAllowed(MC_SMMU_GPU_ASID); /* 0xAA8 */
|
||||
SetRegisterAllowed(MC_SMMU_GPUB_ASID); /* 0xAAC */
|
||||
SetRegisterAllowed(MC_SMMU_PPCS2_ASID); /* 0xAB0 */
|
||||
SetRegisterAllowed(MC_SMMU_NVDEC_ASID); /* 0xAB4 */
|
||||
SetRegisterAllowed(MC_SMMU_APE_ASID); /* 0xAB8 */
|
||||
SetRegisterAllowed(MC_SMMU_SE_ASID); /* 0xABC */
|
||||
SetRegisterAllowed(MC_SMMU_NVJPG_ASID); /* 0xAC0 */
|
||||
SetRegisterAllowed(MC_SMMU_HC1_ASID); /* 0xAC4 */
|
||||
SetRegisterAllowed(MC_SMMU_SE1_ASID); /* 0xAC8 */
|
||||
SetRegisterAllowed(MC_SMMU_AXIAP_ASID); /* 0xACC */
|
||||
SetRegisterAllowed(MC_SMMU_ETR_ASID); /* 0xAD0 */
|
||||
SetRegisterAllowed(MC_SMMU_TSECB_ASID); /* 0xAD4 */
|
||||
SetRegisterAllowed(MC_SMMU_TSEC1_ASID); /* 0xAD8 */
|
||||
SetRegisterAllowed(MC_SMMU_TSECB1_ASID); /* 0xADC */
|
||||
SetRegisterAllowed(MC_SMMU_NVDEC1_ASID); /* 0xAE0 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_DHYST_CTRL); /* 0xBCC */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_DHYST_TIMEOUT_UTIL_0); /* 0xBD0 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_DHYST_TIMEOUT_UTIL_1); /* 0xBD4 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_DHYST_TIMEOUT_UTIL_2); /* 0xBD8 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_DHYST_TIMEOUT_UTIL_3); /* 0xBDC */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_DHYST_TIMEOUT_UTIL_4); /* 0xBE0 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_DHYST_TIMEOUT_UTIL_5); /* 0xBE4 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_DHYST_TIMEOUT_UTIL_6); /* 0xBE8 */
|
||||
SetRegisterAllowed(MC_EMEM_ARB_DHYST_TIMEOUT_UTIL_7); /* 0xBEC */
|
||||
SetRegisterAllowed(MC_ERR_GENERALIZED_CARVEOUT_STATUS); /* 0xC00 */
|
||||
SetRegisterAllowed(MC_SECURITY_CARVEOUT2_BOM); /* 0xC5C */
|
||||
SetRegisterAllowed(MC_SECURITY_CARVEOUT3_BOM); /* 0xCAC */
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 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/>.
|
||||
*/
|
||||
|
||||
SetRegisterAllowed(APBDEV_PMC_CNTRL); /* 0x000 */
|
||||
SetRegisterAllowed(APBDEV_PMC_WAKE_MASK); /* 0x00C */
|
||||
SetRegisterAllowed(APBDEV_PMC_WAKE_LVL); /* 0x010 */
|
||||
SetRegisterAllowed(APBDEV_PMC_WAKE_STATUS); /* 0x014 */
|
||||
SetRegisterAllowed(APBDEV_PMC_DPD_PADS_ORIDE); /* 0x01C */
|
||||
SetRegisterAllowed(APBDEV_PMC_DPD_SAMPLE); /* 0x020 */
|
||||
SetRegisterAllowed(APBDEV_PMC_CLAMP_STATUS); /* 0x02C */
|
||||
SetRegisterAllowed(APBDEV_PMC_PWRGATE_TOGGLE); /* 0x030 */
|
||||
SetRegisterAllowed(APBDEV_PMC_REMOVE_CLAMPING_CMD ); /* 0x034 */
|
||||
SetRegisterAllowed(APBDEV_PMC_PWRGATE_STATUS); /* 0x038 */
|
||||
SetRegisterAllowed(APBDEV_PMC_PWRGOOD_TIMER); /* 0x03C */
|
||||
SetRegisterAllowed(APBDEV_PMC_BLINK_TIMER); /* 0x040 */
|
||||
SetRegisterAllowed(APBDEV_PMC_NO_IOPOWER); /* 0x044 */
|
||||
SetRegisterAllowed(APBDEV_PMC_PWR_DET); /* 0x048 */
|
||||
SetRegisterAllowed(APBDEV_PMC_AUTO_WAKE_LVL_MASK); /* 0x0DC */
|
||||
SetRegisterAllowed(APBDEV_PMC_WAKE_DELAY); /* 0x0E0 */
|
||||
SetRegisterAllowed(APBDEV_PMC_PWR_DET_VAL); /* 0x0E4 */
|
||||
SetRegisterAllowed(APBDEV_PMC_WAKE2_MASK); /* 0x160 */
|
||||
SetRegisterAllowed(APBDEV_PMC_WAKE2_LVL); /* 0x164 */
|
||||
SetRegisterAllowed(APBDEV_PMC_WAKE2_STATUS); /* 0x168 */
|
||||
SetRegisterAllowed(APBDEV_PMC_AUTO_WAKE2_LVL_MASK ); /* 0x170 */
|
||||
SetRegisterAllowed(APBDEV_PMC_CLK_OUT_CNTRL); /* 0x1A8 */
|
||||
SetRegisterAllowed(APBDEV_PMC_IO_DPD_REQ); /* 0x1B8 */
|
||||
SetRegisterAllowed(APBDEV_PMC_IO_DPD_STATUS); /* 0x1BC */
|
||||
SetRegisterAllowed(APBDEV_PMC_IO_DPD2_REQ); /* 0x1C0 */
|
||||
SetRegisterAllowed(APBDEV_PMC_IO_DPD2_STATUS); /* 0x1C4 */
|
||||
SetRegisterAllowed(APBDEV_PMC_SEL_DPD_TIM); /* 0x1C8 */
|
||||
SetRegisterAllowed(APBDEV_PMC_TSC_MULT); /* 0x2B4 */
|
||||
SetRegisterAllowed(APBDEV_PMC_GPU_RG_CNTRL); /* 0x2D4 */
|
||||
SetRegisterAllowed(APBDEV_PMC_CNTRL2); /* 0x440 */
|
||||
SetRegisterAllowed(APBDEV_PMC_WAKE_DEBOUNCE_EN); /* 0x4D8 */
|
|
@ -19,32 +19,32 @@
|
|||
|
||||
namespace ams::secmon::smc {
|
||||
|
||||
SmcResult SmcGenerateAesKek(const SmcArguments &args) {
|
||||
SmcResult SmcGenerateAesKek(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
||||
SmcResult SmcLoadAesKey(const SmcArguments &args) {
|
||||
SmcResult SmcLoadAesKey(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
||||
SmcResult SmcComputeAes(const SmcArguments &args) {
|
||||
SmcResult SmcComputeAes(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
||||
SmcResult SmcGenerateSpecificAesKey(const SmcArguments &args) {
|
||||
SmcResult SmcGenerateSpecificAesKey(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
||||
SmcResult SmcComputeCmac(const SmcArguments &args) {
|
||||
SmcResult SmcComputeCmac(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
||||
SmcResult SmcLoadPreparedAesKey(const SmcArguments &args) {
|
||||
SmcResult SmcLoadPreparedAesKey(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
|
||||
namespace ams::secmon::smc {
|
||||
|
||||
SmcResult SmcGenerateAesKek(const SmcArguments &args);
|
||||
SmcResult SmcLoadAesKey(const SmcArguments &args);
|
||||
SmcResult SmcComputeAes(const SmcArguments &args);
|
||||
SmcResult SmcGenerateSpecificAesKey(const SmcArguments &args);
|
||||
SmcResult SmcComputeCmac(const SmcArguments &args);
|
||||
SmcResult SmcLoadPreparedAesKey(const SmcArguments &args);
|
||||
SmcResult SmcGenerateAesKek(SmcArguments &args);
|
||||
SmcResult SmcLoadAesKey(SmcArguments &args);
|
||||
SmcResult SmcComputeAes(SmcArguments &args);
|
||||
SmcResult SmcGenerateSpecificAesKey(SmcArguments &args);
|
||||
SmcResult SmcComputeCmac(SmcArguments &args);
|
||||
SmcResult SmcLoadPreparedAesKey(SmcArguments &args);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
namespace ams::secmon::smc {
|
||||
|
||||
SmcResult SmcSetKernelCarveoutRegion(const SmcArguments &args) {
|
||||
SmcResult SmcSetKernelCarveoutRegion(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,6 @@
|
|||
|
||||
namespace ams::secmon::smc {
|
||||
|
||||
SmcResult SmcSetKernelCarveoutRegion(const SmcArguments &args);
|
||||
SmcResult SmcSetKernelCarveoutRegion(SmcArguments &args);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,23 +19,23 @@
|
|||
|
||||
namespace ams::secmon::smc {
|
||||
|
||||
SmcResult SmcDecryptDeviceUniqueData(const SmcArguments &args) {
|
||||
SmcResult SmcDecryptDeviceUniqueData(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
||||
SmcResult SmcReencryptDeviceUniqueData(const SmcArguments &args) {
|
||||
SmcResult SmcReencryptDeviceUniqueData(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
||||
/* Legacy APIs. */
|
||||
SmcResult SmcDecryptAndImportEsDeviceKey(const SmcArguments &args) {
|
||||
SmcResult SmcDecryptAndImportEsDeviceKey(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
||||
SmcResult SmcDecryptAndImportLotusKey(const SmcArguments &args) {
|
||||
SmcResult SmcDecryptAndImportLotusKey(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
|
||||
namespace ams::secmon::smc {
|
||||
|
||||
SmcResult SmcDecryptDeviceUniqueData(const SmcArguments &args);
|
||||
SmcResult SmcReencryptDeviceUniqueData(const SmcArguments &args);
|
||||
SmcResult SmcDecryptDeviceUniqueData(SmcArguments &args);
|
||||
SmcResult SmcReencryptDeviceUniqueData(SmcArguments &args);
|
||||
|
||||
/* Legacy APIs. */
|
||||
SmcResult SmcDecryptAndImportEsDeviceKey(const SmcArguments &args);
|
||||
SmcResult SmcDecryptAndImportLotusKey(const SmcArguments &args);
|
||||
SmcResult SmcDecryptAndImportEsDeviceKey(SmcArguments &args);
|
||||
SmcResult SmcDecryptAndImportLotusKey(SmcArguments &args);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
namespace ams::secmon::smc {
|
||||
|
||||
SmcResult SmcShowError(const SmcArguments &args) {
|
||||
SmcResult SmcShowError(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,6 @@
|
|||
|
||||
namespace ams::secmon::smc {
|
||||
|
||||
SmcResult SmcShowError(const SmcArguments &args);
|
||||
SmcResult SmcShowError(SmcArguments &args);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
|
||||
namespace ams::secmon::smc {
|
||||
|
||||
SmcResult SmcPrepareEsDeviceUniqueKey(const SmcArguments &args) {
|
||||
SmcResult SmcPrepareEsDeviceUniqueKey(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
||||
SmcResult SmcPrepareEsCommonKey(const SmcArguments &args) {
|
||||
SmcResult SmcPrepareEsCommonKey(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace ams::secmon::smc {
|
|||
EsKeyType_Count = 2,
|
||||
};
|
||||
|
||||
SmcResult SmcPrepareEsDeviceUniqueKey(const SmcArguments &args);
|
||||
SmcResult SmcPrepareEsCommonKey(const SmcArguments &args);
|
||||
SmcResult SmcPrepareEsDeviceUniqueKey(SmcArguments &args);
|
||||
SmcResult SmcPrepareEsCommonKey(SmcArguments &args);
|
||||
|
||||
}
|
||||
|
|
|
@ -207,7 +207,7 @@ namespace ams::secmon::smc {
|
|||
return (info.restriction_mask & secmon::GetRestrictedSmcMask()) != 0;
|
||||
}
|
||||
|
||||
SmcResult InvokeSmcHandler(const HandlerInfo &info, const SmcArguments &args) {
|
||||
SmcResult InvokeSmcHandler(const HandlerInfo &info, SmcArguments &args) {
|
||||
/* Check if the smc is restricted. */
|
||||
if (AMS_UNLIKELY(IsHandlerRestricted(info))) {
|
||||
return SmcResult::NotPermitted;
|
||||
|
|
|
@ -19,6 +19,6 @@
|
|||
|
||||
namespace ams::secmon::smc {
|
||||
|
||||
using SmcHandler = SmcResult (*)(const SmcArguments &args);
|
||||
using SmcHandler = SmcResult (*)(SmcArguments &args);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,23 +19,23 @@
|
|||
|
||||
namespace ams::secmon::smc {
|
||||
|
||||
SmcResult SmcGetConfigUser(const SmcArguments &args) {
|
||||
SmcResult SmcGetConfigUser(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
||||
SmcResult SmcGetConfigKern(const SmcArguments &args) {
|
||||
SmcResult SmcGetConfigKern(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
||||
SmcResult SmcSetConfig(const SmcArguments &args) {
|
||||
SmcResult SmcSetConfig(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
||||
/* This is an atmosphere extension smc. */
|
||||
SmcResult SmcGetEmummcConfig(const SmcArguments &args) {
|
||||
SmcResult SmcGetEmummcConfig(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
|
|
@ -49,11 +49,11 @@ namespace ams::secmon::smc {
|
|||
ExosphereAllowCalWrites = 65006,
|
||||
};
|
||||
|
||||
SmcResult SmcGetConfigUser(const SmcArguments &args);
|
||||
SmcResult SmcGetConfigKern(const SmcArguments &args);
|
||||
SmcResult SmcSetConfig(const SmcArguments &args);
|
||||
SmcResult SmcGetConfigUser(SmcArguments &args);
|
||||
SmcResult SmcGetConfigKern(SmcArguments &args);
|
||||
SmcResult SmcSetConfig(SmcArguments &args);
|
||||
|
||||
/* This is an atmosphere extension smc. */
|
||||
SmcResult SmcGetEmummcConfig(const SmcArguments &args);
|
||||
SmcResult SmcGetEmummcConfig(SmcArguments &args);
|
||||
|
||||
}
|
||||
|
|
|
@ -20,12 +20,12 @@
|
|||
namespace ams::secmon::smc {
|
||||
|
||||
/* This is an atmosphere extension smc. */
|
||||
SmcResult SmcIramCopy(const SmcArguments &args) {
|
||||
SmcResult SmcIramCopy(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
||||
SmcResult SmcWriteAddress(const SmcArguments &args) {
|
||||
SmcResult SmcWriteAddress(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
namespace ams::secmon::smc {
|
||||
|
||||
/* This is an atmosphere extension smc. */
|
||||
SmcResult SmcIramCopy(const SmcArguments &args);
|
||||
SmcResult SmcWriteAddress(const SmcArguments &args);
|
||||
SmcResult SmcIramCopy(SmcArguments &args);
|
||||
SmcResult SmcWriteAddress(SmcArguments &args);
|
||||
|
||||
}
|
||||
|
|
|
@ -96,12 +96,12 @@ namespace ams::secmon::smc {
|
|||
|
||||
}
|
||||
|
||||
SmcResult SmcPowerOffCpu(const SmcArguments &args) {
|
||||
SmcResult SmcPowerOffCpu(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
||||
SmcResult SmcPowerOnCpu(const SmcArguments &args) {
|
||||
SmcResult SmcPowerOnCpu(SmcArguments &args) {
|
||||
/* Get and validate the core to power on. */
|
||||
const int which_core = args.r[1];
|
||||
if (!(0 <= which_core && which_core < NumCores)) {
|
||||
|
@ -128,7 +128,7 @@ namespace ams::secmon::smc {
|
|||
return SmcResult::PsciSuccess;
|
||||
}
|
||||
|
||||
SmcResult SmcSuspendCpu(const SmcArguments &args) {
|
||||
SmcResult SmcSuspendCpu(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
|
||||
namespace ams::secmon::smc {
|
||||
|
||||
SmcResult SmcPowerOffCpu(const SmcArguments &args);
|
||||
SmcResult SmcPowerOnCpu(const SmcArguments &args);
|
||||
SmcResult SmcPowerOffCpu(SmcArguments &args);
|
||||
SmcResult SmcPowerOnCpu(SmcArguments &args);
|
||||
|
||||
SmcResult SmcSuspendCpu(const SmcArguments &args);
|
||||
SmcResult SmcSuspendCpu(SmcArguments &args);
|
||||
|
||||
bool IsChargerHiZModeEnabled();
|
||||
void SetChargerHiZModeEnabled(bool en);
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
|
||||
namespace ams::secmon::smc {
|
||||
|
||||
SmcResult SmcGenerateRandomBytes(const SmcArguments &args) {
|
||||
SmcResult SmcGenerateRandomBytes(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
||||
SmcResult SmcGenerateRandomBytesNonBlocking(const SmcArguments &args) {
|
||||
SmcResult SmcGenerateRandomBytesNonBlocking(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
namespace ams::secmon::smc {
|
||||
|
||||
SmcResult SmcGenerateRandomBytes(const SmcArguments &args);
|
||||
SmcResult SmcGenerateRandomBytesNonBlocking(const SmcArguments &args);
|
||||
SmcResult SmcGenerateRandomBytes(SmcArguments &args);
|
||||
SmcResult SmcGenerateRandomBytesNonBlocking(SmcArguments &args);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,9 +19,179 @@
|
|||
|
||||
namespace ams::secmon::smc {
|
||||
|
||||
SmcResult SmcReadWriteRegister(const SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
namespace {
|
||||
|
||||
template<size_t N>
|
||||
constexpr void SetRegisterTableAllowed(std::array<u8, N> &arr, uintptr_t reg) {
|
||||
/* All registers should be four byte aligned. */
|
||||
if (reg % sizeof(u32) != 0) {
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
/* Reduce the register to an index. */
|
||||
reg /= sizeof(u32);
|
||||
|
||||
/* Get the index and mask. */
|
||||
const auto index = reg / BITSIZEOF(u8);
|
||||
const auto mask = (1u << (reg % BITSIZEOF(u8)));
|
||||
|
||||
/* Check that the permission bit isn't already set. */
|
||||
if ((arr[index] & mask) != 0) {
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
/* Set the permission bit. */
|
||||
arr[index] |= mask;
|
||||
|
||||
/* Ensure that indices are set in sorted order. */
|
||||
for (auto i = (reg % BITSIZEOF(u8)) + 1; i < 8; ++i) {
|
||||
if ((arr[index] & (1u << i)) != 0) {
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto i = index + 1; i < arr.size(); ++i) {
|
||||
if (arr[i] != 0) {
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<size_t N>
|
||||
consteval std::pair<size_t, size_t> GetReducedAccessTableInfo(const std::array<u8, N> &arr) {
|
||||
for (int last = arr.size() - 1; last >= 0; --last) {
|
||||
if (arr[last] != 0) {
|
||||
const int end = last + 1;
|
||||
for (int start = 0; start < end; ++start) {
|
||||
if (arr[start] != 0) {
|
||||
return std::make_pair(static_cast<size_t>(start), static_cast<size_t>(end));
|
||||
}
|
||||
}
|
||||
return std::make_pair(static_cast<size_t>(0), static_cast<size_t>(end));
|
||||
}
|
||||
}
|
||||
|
||||
/* All empty perm table is disallowed. */
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
|
||||
template<u32 _Address, auto RawTable>
|
||||
struct AccessTable {
|
||||
static constexpr inline auto ReducedAccessTableInfo = GetReducedAccessTableInfo(RawTable);
|
||||
static constexpr inline size_t ReducedAccessTableSize = ReducedAccessTableInfo.second - ReducedAccessTableInfo.first;
|
||||
static constexpr inline auto ReducedAccessTable = []() -> std::array<u8, ReducedAccessTableSize> {
|
||||
std::array<u8, ReducedAccessTableSize> reduced = {};
|
||||
|
||||
for (size_t i = ReducedAccessTableInfo.first; i < ReducedAccessTableInfo.second; ++i) {
|
||||
reduced[i - ReducedAccessTableInfo.first] = RawTable[i];
|
||||
}
|
||||
|
||||
return reduced;
|
||||
}();
|
||||
|
||||
static constexpr u32 Address = _Address + (ReducedAccessTableInfo.first * sizeof(u32) * BITSIZEOF(u8));
|
||||
static constexpr u32 Size = static_cast<u32>(ReducedAccessTableSize * sizeof(u32) * BITSIZEOF(u8));
|
||||
|
||||
static_assert(Size <= 0x1000);
|
||||
};
|
||||
|
||||
struct AccessTableEntry {
|
||||
const u8 * const table;
|
||||
uintptr_t virtual_address;
|
||||
u32 address;
|
||||
u32 size;
|
||||
};
|
||||
|
||||
/* Include the access tables. */
|
||||
#include "secmon_define_pmc_access_table.inc"
|
||||
#include "secmon_define_mc_access_table.inc"
|
||||
#include "secmon_define_mc01_access_table.inc"
|
||||
|
||||
constexpr const AccessTableEntry AccessTables[] = {
|
||||
{ PmcAccessTable::ReducedAccessTable.data(), MemoryRegionVirtualDevicePmc.GetAddress(), PmcAccessTable::Address, PmcAccessTable::Size, },
|
||||
{ McAccessTable::ReducedAccessTable.data(), MemoryRegionVirtualDeviceMemoryController.GetAddress(), McAccessTable::Address, McAccessTable::Size, },
|
||||
{ Mc01AccessTable::ReducedAccessTable.data(), MemoryRegionVirtualDeviceMemoryController0.GetAddress(), Mc01AccessTable::Address + MemoryRegionPhysicalDeviceMemoryController0.GetAddress(), Mc01AccessTable::Size, },
|
||||
{ Mc01AccessTable::ReducedAccessTable.data(), MemoryRegionVirtualDeviceMemoryController1.GetAddress(), Mc01AccessTable::Address + MemoryRegionPhysicalDeviceMemoryController1.GetAddress(), Mc01AccessTable::Size, },
|
||||
};
|
||||
|
||||
constexpr bool IsAccessAllowed(const AccessTableEntry &entry, uintptr_t address) {
|
||||
/* Check if the address is within range. */
|
||||
if (!(entry.address <= address && address < entry.address + entry.size)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Get the offset. */
|
||||
const auto offset = address - entry.address;
|
||||
|
||||
/* Convert it to an index. */
|
||||
const auto reg_index = offset / sizeof(u32);
|
||||
|
||||
/* Get the bit fields. */
|
||||
const auto index = reg_index / BITSIZEOF(u8);
|
||||
const auto mask = (1u << (reg_index % BITSIZEOF(u8)));
|
||||
|
||||
/* Validate that we're not going out of bounds. */
|
||||
if (index >= entry.size / sizeof(u32)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (entry.table[index] & mask) != 0;
|
||||
}
|
||||
|
||||
constexpr const AccessTableEntry *GetAccessTableEntry(uintptr_t address) {
|
||||
for (const auto &entry : AccessTables) {
|
||||
if (IsAccessAllowed(entry, address)) {
|
||||
return std::addressof(entry);
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SmcResult SmcReadWriteRegister(SmcArguments &args) {
|
||||
/* Get the arguments. */
|
||||
const uintptr_t address = args.r[1];
|
||||
const u32 mask = args.r[2];
|
||||
const u32 value = args.r[3];
|
||||
|
||||
/* Validate that the address is aligned. */
|
||||
if (!util::IsAligned(address, alignof(u32))) {
|
||||
return SmcResult::InvalidArgument;
|
||||
}
|
||||
|
||||
/* Find the access table. */
|
||||
const AccessTableEntry * const entry = GetAccessTableEntry(address);
|
||||
|
||||
/* If we have no table, don't perform the write. */
|
||||
if (entry == nullptr) {
|
||||
/* For no clearly discernable reason, SmcReadWriteRegister returns success despite not doing the read/write */
|
||||
/* when accessing the SMMU controls for the BPMP and for APB-DMA. */
|
||||
/* This is "probably" to fuck with hackers who got access to the SMC and are trying to get control of the */
|
||||
/* BPMP to exploit jamais vu, deja vu, or other related DMA/wake-from-sleep vulnerabilities. */
|
||||
constexpr uintptr_t MC = MemoryRegionVirtualDeviceMemoryController.GetAddress();
|
||||
if (address == (MC + MC_SMMU_AVPC_ASID) || address == (MC + MC_SMMU_PPCS1_ASID)) {
|
||||
return SmcResult::Success;
|
||||
}
|
||||
|
||||
return SmcResult::InvalidArgument;
|
||||
}
|
||||
|
||||
/* Get the address to read or write. */
|
||||
const uintptr_t virtual_address = entry->virtual_address + (address - entry->address);
|
||||
u32 out = 0;
|
||||
|
||||
if (mask != ~static_cast<u32>(0)) {
|
||||
out = reg::Read(virtual_address);
|
||||
}
|
||||
if (mask != static_cast<u32>(0)) {
|
||||
reg::Write(virtual_address, (out & ~mask) | (value & mask));
|
||||
}
|
||||
|
||||
args.r[1] = out;
|
||||
return SmcResult::Success;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,6 @@
|
|||
|
||||
namespace ams::secmon::smc {
|
||||
|
||||
SmcResult SmcReadWriteRegister(const SmcArguments &args);
|
||||
SmcResult SmcReadWriteRegister(SmcArguments &args);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
|
||||
namespace ams::secmon::smc {
|
||||
|
||||
SmcResult SmcGetResult(const SmcArguments &args) {
|
||||
SmcResult SmcGetResult(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
||||
SmcResult SmcGetResultData(const SmcArguments &args) {
|
||||
SmcResult SmcGetResultData(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace ams::secmon::smc {
|
|||
void CancelAsyncOperation(u64 async_key);
|
||||
void EndAsyncOperation();
|
||||
|
||||
SmcResult SmcGetResult(const SmcArguments &args);
|
||||
SmcResult SmcGetResultData(const SmcArguments &args);
|
||||
SmcResult SmcGetResult(SmcArguments &args);
|
||||
SmcResult SmcGetResultData(SmcArguments &args);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
|
||||
namespace ams::secmon::smc {
|
||||
|
||||
SmcResult SmcModularExponentiate(const SmcArguments &args) {
|
||||
SmcResult SmcModularExponentiate(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
||||
SmcResult SmcModularExponentiateByStorageKey(const SmcArguments &args) {
|
||||
SmcResult SmcModularExponentiateByStorageKey(SmcArguments &args) {
|
||||
/* TODO */
|
||||
return SmcResult::NotImplemented;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
namespace ams::secmon::smc {
|
||||
|
||||
SmcResult SmcModularExponentiate(const SmcArguments &args);
|
||||
SmcResult SmcModularExponentiateByStorageKey(const SmcArguments &args);
|
||||
SmcResult SmcModularExponentiate(SmcArguments &args);
|
||||
SmcResult SmcModularExponentiateByStorageKey(SmcArguments &args);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue