shutdown.h 1015 B

123456789101112131415161718192021222324252627282930313233343536
  1. /* Copyright 2018 SiFive, Inc */
  2. /* SPDX-License-Identifier: Apache-2.0 */
  3. #ifndef METAL__SHUTDOWN_H
  4. #define METAL__SHUTDOWN_H
  5. /*!
  6. * @file shutdown.h
  7. * @brief API for shutting down a machine
  8. */
  9. struct __metal_shutdown;
  10. struct __metal_shutdown_vtable {
  11. void (*exit)(const struct __metal_shutdown *sd, int code) __attribute__((noreturn));
  12. };
  13. struct __metal_shutdown {
  14. const struct __metal_shutdown_vtable *vtable;
  15. };
  16. __inline__ void __metal_shutdown_exit(const struct __metal_shutdown *sd, int code) __attribute__((noreturn));
  17. __inline__ void __metal_shutdown_exit(const struct __metal_shutdown *sd, int code) { sd->vtable->exit(sd, code); }
  18. /*!
  19. * @brief The public METAL shutdown interface
  20. *
  21. * Shuts down the machine, if the machine enables an interface for
  22. * shutting down. When no interface is provided, will cause the machine
  23. * to spin indefinitely.
  24. *
  25. * @param code The return code to set. 0 indicates program success.
  26. */
  27. void metal_shutdown(int code) __attribute__((noreturn));
  28. #endif