1 /* Copyright 2018 SiFive, Inc */
2 /* SPDX-License-Identifier: Apache-2.0 */
4 #ifndef METAL__SHUTDOWN_H
5 #define METAL__SHUTDOWN_H
9 * @brief API for shutting down a machine
12 struct __metal_shutdown;
14 struct __metal_shutdown_vtable {
15 void (*exit)(const struct __metal_shutdown *sd, int code) __attribute__((noreturn));
18 struct __metal_shutdown {
19 const struct __metal_shutdown_vtable *vtable;
22 inline void __metal_shutdown_exit(const struct __metal_shutdown *sd, int code) __attribute__((noreturn));
23 inline void __metal_shutdown_exit(const struct __metal_shutdown *sd, int code) { sd->vtable->exit(sd, code); }
26 * @brief The public METAL shutdown interface
28 * Shuts down the machine, if the machine enables an interface for
29 * shutting down. When no interface is provided, will cause the machine
30 * to spin indefinitely.
32 * @param code The return code to set. 0 indicates program success.
34 void metal_shutdown(int code) __attribute__((noreturn));