exosphere: improve nested switch format

This commit is contained in:
Michael Scire 2019-01-20 02:51:27 -08:00
parent a52e601f2e
commit 295574740d

View file

@ -36,25 +36,28 @@ uint32_t configitem_set(bool privileged, ConfigItem item, uint64_t value) {
g_battery_profile = (value != 0); g_battery_profile = (value != 0);
break; break;
case CONFIGITEM_NEEDS_REBOOT: case CONFIGITEM_NEEDS_REBOOT:
/* Force a reboot to RCM, if requested. */ /* Force a reboot, if requested. */
switch (value) { {
case REBOOT_KIND_NO_REBOOT: switch (value) {
return 0; case REBOOT_KIND_NO_REBOOT:
case REBOOT_KIND_TO_RCM: return 0;
/* Set reboot kind = rcm. */ case REBOOT_KIND_TO_RCM:
MAKE_REG32(MMIO_GET_DEVICE_ADDRESS(MMIO_DEVID_RTC_PMC) + 0x450ull) = 0x2; /* Set reboot kind = rcm. */
break; MAKE_REG32(MMIO_GET_DEVICE_ADDRESS(MMIO_DEVID_RTC_PMC) + 0x450ull) = 0x2;
case REBOOT_KIND_TO_WB_PAYLOAD: break;
/* Set reboot kind = warmboot. */ case REBOOT_KIND_TO_WB_PAYLOAD:
MAKE_REG32(MMIO_GET_DEVICE_ADDRESS(MMIO_DEVID_RTC_PMC) + 0x450ull) = 0x1; /* Set reboot kind = warmboot. */
/* Patch bootrom to jump to payload. */ MAKE_REG32(MMIO_GET_DEVICE_ADDRESS(MMIO_DEVID_RTC_PMC) + 0x450ull) = 0x1;
MAKE_REG32(MMIO_GET_DEVICE_ADDRESS(MMIO_DEVID_RTC_PMC) + 0x118) = 0x40010000; /* Return to start of payload. */ /* Patch bootrom to jump to payload. */
MAKE_REG32(MMIO_GET_DEVICE_ADDRESS(MMIO_DEVID_RTC_PMC) + 0x11C) = 0x4000FFA4; /* Overwrite bootrom return address on stack. */ MAKE_REG32(MMIO_GET_DEVICE_ADDRESS(MMIO_DEVID_RTC_PMC) + 0x118) = 0x40010000; /* Return to start of payload. */
break; MAKE_REG32(MMIO_GET_DEVICE_ADDRESS(MMIO_DEVID_RTC_PMC) + 0x11C) = 0x4000FFA4; /* Overwrite bootrom return address on stack. */
default: break;
return 2; default:
return 2;
}
MAKE_REG32(MMIO_GET_DEVICE_ADDRESS(MMIO_DEVID_RTC_PMC) + 0x400ull) = 0x10;
while (1) { }
} }
MAKE_REG32(MMIO_GET_DEVICE_ADDRESS(MMIO_DEVID_RTC_PMC) + 0x400ull) = 0x10;
break; break;
default: default:
return 2; return 2;