sbi_system.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * SPDX-License-Identifier: BSD-2-Clause
  3. *
  4. * Copyright (c) 2019 Western Digital Corporation or its affiliates.
  5. *
  6. * Authors:
  7. * Anup Patel <anup.patel@wdc.com>
  8. * Nick Kossifidis <mick@ics.forth.gr>
  9. */
  10. #include <sbi/sbi_hart.h>
  11. #include <sbi/sbi_platform.h>
  12. #include <sbi/sbi_system.h>
  13. #include <sbi/sbi_ipi.h>
  14. int sbi_system_early_init(struct sbi_scratch *scratch, bool cold_boot)
  15. {
  16. return sbi_platform_early_init(sbi_platform_ptr(scratch), cold_boot);
  17. }
  18. int sbi_system_final_init(struct sbi_scratch *scratch, bool cold_boot)
  19. {
  20. return sbi_platform_final_init(sbi_platform_ptr(scratch), cold_boot);
  21. }
  22. void __attribute__((noreturn))
  23. sbi_system_reboot(struct sbi_scratch *scratch, u32 type)
  24. {
  25. sbi_platform_system_reboot(sbi_platform_ptr(scratch), type);
  26. sbi_hart_hang();
  27. }
  28. void __attribute__((noreturn))
  29. sbi_system_shutdown(struct sbi_scratch *scratch, u32 type)
  30. {
  31. /* First try the platform-specific method */
  32. sbi_platform_system_shutdown(sbi_platform_ptr(scratch), type);
  33. /* If that fails (or is not implemented) send an IPI on every
  34. * hart to hang and then hang the current hart */
  35. sbi_ipi_send_many(scratch, NULL, NULL, SBI_IPI_EVENT_HALT, NULL);
  36. sbi_hart_hang();
  37. }