summaryrefslogtreecommitdiff
path: root/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_FreedomStudio/freedom-metal/metal/shutdown.h
blob: 3bebfa742c4c140df7250214af2c00f9c034374b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* Copyright 2018 SiFive, Inc */
/* SPDX-License-Identifier: Apache-2.0 */

#ifndef METAL__SHUTDOWN_H
#define METAL__SHUTDOWN_H

/*!
 * @file shutdown.h
 * @brief API for shutting down a machine
 */

struct __metal_shutdown;

struct __metal_shutdown_vtable {
    void (*exit)(const struct __metal_shutdown *sd, int code) __attribute__((noreturn));
};

struct __metal_shutdown {
    const struct __metal_shutdown_vtable *vtable;
};

inline void __metal_shutdown_exit(const struct __metal_shutdown *sd, int code) __attribute__((noreturn));
inline void __metal_shutdown_exit(const struct __metal_shutdown *sd, int code) { sd->vtable->exit(sd, code); }

/*!
 * @brief The public METAL shutdown interface
 *
 * Shuts down the machine, if the machine enables an interface for
 * shutting down. When no interface is provided, will cause the machine
 * to spin indefinitely.
 *
 * @param code The return code to set. 0 indicates program success.
 */
void metal_shutdown(int code) __attribute__((noreturn));

#endif