Software APIs
hart.h
Go to the documentation of this file.
1// Copyright lowRISC contributors (OpenTitan project).
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
5#ifndef OPENTITAN_SW_DEVICE_LIB_RUNTIME_HART_H_
6#define OPENTITAN_SW_DEVICE_LIB_RUNTIME_HART_H_
7
8#include <stddef.h>
9#include <stdint.h>
10#include <stdnoreturn.h>
11
14
15/**
16 * @file
17 * @brief This header provides functions for controlling the excution of a hart,
18 * such as halt-like functionality.
19 */
20
21/**
22 * Hints to the processor that we don't have anything better to be doing, and to
23 * go into low-power mode until an interrupt is serviced.
24 *
25 * This function may behave as if it is a no-op.
26 */
27inline void wait_for_interrupt(void) {
28#ifdef OT_PLATFORM_RV32
29 asm volatile("wfi");
30#endif
31}
32
33/**
34 * Invalidates the instruction cache.
35 */
36inline void icache_invalidate(void) {
37#ifdef OT_PLATFORM_RV32
38 asm volatile("fence.i");
39#endif
40}
41
42/**
43 * Spin for at least the given number of microseconds.
44 *
45 * @param usec Duration in microseconds.
46 */
47void busy_spin_micros(uint32_t usec);
48
49/**
50 * Immediately halt program execution.
51 *
52 * This function conforms to the semantics defined in ISO C11 S7.22.4.1.
53 */
54noreturn void abort(void);
55
56#endif // OPENTITAN_SW_DEVICE_LIB_RUNTIME_HART_H_