| // Copyright lowRISC contributors. |
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| // SPDX-License-Identifier: Apache-2.0 |
| |
| #include "sw/device/mask_rom/mask_rom.h" |
| |
| #include <stdbool.h> |
| #include <stdint.h> |
| |
| #include "sw/device/lib/base/stdasm.h" |
| #include "sw/device/lib/pinmux.h" |
| #include "sw/device/lib/runtime/hart.h" |
| #include "sw/device/rom_exts/rom_ext_manifest_parser.h" |
| |
| #include "hw/top_earlgrey/sw/autogen/top_earlgrey.h" |
| |
| // This is the expected ROM_EXT Manifest Identifier |
| static const uint32_t kRomExtIdentifierExpected = 0x4552544F; |
| |
| typedef void(boot_fn)(void); |
| |
| void mask_rom_boot(void) { |
| pinmux_init(); |
| |
| rom_ext_manifest_t rom_ext = rom_ext_get_parameters(kRomExtManifestSlotA); |
| |
| // Check we have a valid ROM_EXT |
| if (rom_ext_get_identifier(rom_ext) == kRomExtIdentifierExpected) { |
| // Set mtvec for ROM_EXT. |
| uintptr_t interrupt_vector = rom_ext_get_interrupt_vector(rom_ext); |
| asm volatile("csrw mtvec, %0" ::"r"(interrupt_vector)); |
| |
| boot_fn *rom_ext_entry = (boot_fn *)rom_ext_get_entry(rom_ext); |
| |
| // Jump to ROM_EXT entry point. |
| rom_ext_entry(); |
| } else { |
| // Not yet implemented, intent is to throw simulation error. |
| asm volatile("unimp"); |
| } |
| while (true) { |
| wait_for_interrupt(); |
| } |
| } |
| |
| void mask_rom_exception_handler(void) { wait_for_interrupt(); } |
| |
| void mask_rom_nmi_handler(void) { wait_for_interrupt(); } |