psci_system_off.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (c) 2014-2020, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <stddef.h>
  8. #include <arch_helpers.h>
  9. #include <common/debug.h>
  10. #include <drivers/console.h>
  11. #include <plat/common/platform.h>
  12. #include "psci_private.h"
  13. void __dead2 psci_system_off(void)
  14. {
  15. psci_print_power_domain_map();
  16. assert(psci_plat_pm_ops->system_off != NULL);
  17. /* Notify the Secure Payload Dispatcher */
  18. if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_off != NULL)) {
  19. psci_spd_pm->svc_system_off();
  20. }
  21. console_flush();
  22. /* Call the platform specific hook */
  23. psci_plat_pm_ops->system_off();
  24. /* This function does not return. We should never get here */
  25. }
  26. void __dead2 psci_system_reset(void)
  27. {
  28. psci_print_power_domain_map();
  29. assert(psci_plat_pm_ops->system_reset != NULL);
  30. /* Notify the Secure Payload Dispatcher */
  31. if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_reset != NULL)) {
  32. psci_spd_pm->svc_system_reset();
  33. }
  34. console_flush();
  35. /* Call the platform specific hook */
  36. psci_plat_pm_ops->system_reset();
  37. /* This function does not return. We should never get here */
  38. }
  39. u_register_t psci_system_reset2(uint32_t reset_type, u_register_t cookie)
  40. {
  41. unsigned int is_vendor;
  42. psci_print_power_domain_map();
  43. assert(psci_plat_pm_ops->system_reset2 != NULL);
  44. is_vendor = (reset_type >> PSCI_RESET2_TYPE_VENDOR_SHIFT) & 1U;
  45. if (is_vendor == 0U) {
  46. /*
  47. * Only WARM_RESET is allowed for architectural type resets.
  48. */
  49. if (reset_type != PSCI_RESET2_SYSTEM_WARM_RESET)
  50. return (u_register_t) PSCI_E_INVALID_PARAMS;
  51. if ((psci_plat_pm_ops->write_mem_protect != NULL) &&
  52. (psci_plat_pm_ops->write_mem_protect(0) < 0)) {
  53. return (u_register_t) PSCI_E_NOT_SUPPORTED;
  54. }
  55. }
  56. /* Notify the Secure Payload Dispatcher */
  57. if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_reset != NULL)) {
  58. psci_spd_pm->svc_system_reset();
  59. }
  60. console_flush();
  61. return (u_register_t)
  62. psci_plat_pm_ops->system_reset2((int) is_vendor, reset_type,
  63. cookie);
  64. }