Miguel Young de la Sota | dddf1ed | 2019-12-18 12:24:43 -0600 | [diff] [blame] | 1 | // 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 Sota | 76526c3 | 2020-01-28 10:24:41 -0500 | [diff] [blame] | 9 | #include "sw/device/lib/arch/device.h" |
Miguel Young de la Sota | 998c4e6 | 2022-03-15 15:35:52 -0400 | [diff] [blame] | 10 | #include "sw/device/lib/base/math.h" |
Miguel Young de la Sota | dddf1ed | 2019-12-18 12:24:43 -0600 | [diff] [blame] | 11 | #include "sw/device/lib/runtime/ibex.h" |
| 12 | |
Miguel Young de la Sota | e63ea1e | 2022-02-17 12:33:24 -0500 | [diff] [blame] | 13 | void busy_spin_micros(uint32_t usec) { |
Alphan Ulusoy | 3e4cd9d | 2020-01-21 15:03:01 -0500 | [diff] [blame] | 14 | uint64_t start = ibex_mcycle_read(); |
Guillermo Maturana | c16937e | 2022-06-15 20:19:01 -0700 | [diff] [blame] | 15 | uint64_t cycles = to_cpu_cycles(usec); |
Alphan Ulusoy | 3e4cd9d | 2020-01-21 15:03:01 -0500 | [diff] [blame] | 16 | while ((ibex_mcycle_read() - start) < cycles) { |
| 17 | } |
Miguel Young de la Sota | dddf1ed | 2019-12-18 12:24:43 -0600 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | noreturn void abort(void) { |
Miguel Young de la Sota | dddf1ed | 2019-12-18 12:24:43 -0600 | [diff] [blame] | 21 | while (true) { |
| 22 | wait_for_interrupt(); |
| 23 | } |
| 24 | } |
Luís Marques | 8872015 | 2021-11-14 22:28:36 +0000 | [diff] [blame] | 25 | |
| 26 | // `extern` declarations to give the inline functions in the |
| 27 | // corresponding header a link location. |
| 28 | |
| 29 | extern void wait_for_interrupt(void); |
Alphan Ulusoy | f2ca911 | 2022-09-21 14:29:53 -0400 | [diff] [blame] | 30 | extern void icache_invalidate(void); |