sbi_system.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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),
  17. cold_boot);
  18. }
  19. int sbi_system_final_init(struct sbi_scratch *scratch, bool cold_boot)
  20. {
  21. return sbi_platform_final_init(sbi_platform_ptr(scratch),
  22. cold_boot);
  23. }
  24. void __attribute__((noreturn)) sbi_system_reboot(struct sbi_scratch *scratch,
  25. u32 type)
  26. {
  27. sbi_platform_system_reboot(sbi_platform_ptr(scratch), type);
  28. sbi_hart_hang();
  29. }
  30. void __attribute__((noreturn)) sbi_system_shutdown(struct sbi_scratch *scratch,
  31. u32 type)
  32. {
  33. /* First try the platform-specific method */
  34. sbi_platform_system_shutdown(sbi_platform_ptr(scratch), type);
  35. /* If that fails (or is not implemented) send an IPI on every
  36. * hart to hang and then hang the current hart */
  37. sbi_ipi_send_many(scratch, NULL, SBI_IPI_EVENT_HALT, NULL);
  38. sbi_hart_hang();
  39. }