blob: f067f1509f6019d0e31fe3fc30a594e2dfa8d544 [file] [log] [blame]
Miguel Young de la Sotadddf1ed2019-12-18 12:24:43 -06001// Copyright lowRISC contributors.
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
5#include "sw/device/lib/runtime/hart.h"
6
7#include <stdbool.h>
8
Miguel Young de la Sota76526c32020-01-28 10:24:41 -05009#include "sw/device/lib/arch/device.h"
Miguel Young de la Sota998c4e62022-03-15 15:35:52 -040010#include "sw/device/lib/base/math.h"
Miguel Young de la Sotadddf1ed2019-12-18 12:24:43 -060011#include "sw/device/lib/runtime/ibex.h"
12
Miguel Young de la Sotae63ea1e2022-02-17 12:33:24 -050013void busy_spin_micros(uint32_t usec) {
Alphan Ulusoy3e4cd9d2020-01-21 15:03:01 -050014 uint64_t start = ibex_mcycle_read();
Guillermo Maturanac16937e2022-06-15 20:19:01 -070015 uint64_t cycles = to_cpu_cycles(usec);
Alphan Ulusoy3e4cd9d2020-01-21 15:03:01 -050016 while ((ibex_mcycle_read() - start) < cycles) {
17 }
Miguel Young de la Sotadddf1ed2019-12-18 12:24:43 -060018}
19
20noreturn void abort(void) {
Miguel Young de la Sotadddf1ed2019-12-18 12:24:43 -060021 while (true) {
22 wait_for_interrupt();
23 }
24}
Luís Marques88720152021-11-14 22:28:36 +000025
26// `extern` declarations to give the inline functions in the
27// corresponding header a link location.
28
29extern void wait_for_interrupt(void);
Alphan Ulusoyf2ca9112022-09-21 14:29:53 -040030extern void icache_invalidate(void);