File: steps.c

package info (click to toggle)
crust-firmware 0.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,900 kB
  • sloc: ansic: 19,341; yacc: 596; lex: 479; makefile: 334; asm: 215; sh: 136; python: 42
file content (34 lines) | stat: -rw-r--r-- 688 bytes parent folder | download | duplicates (2)
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
/*
 * Copyright © 2021-2022 The Crust Firmware Authors.
 * SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-only
 */

#include <debug.h>
#include <mmio.h>
#include <steps.h>
#include <platform/devices.h>

#define RTC_GP_DATA_REG(n) (DEV_RTC + 0x0100 + 0x4 * (n))
#define LAST_EXCEPTION_REG RTC_GP_DATA_REG(2)
#define LAST_STEP_REG      RTC_GP_DATA_REG(3)

void
record_exception(uint32_t exception, uint32_t pc)
{
	mmio_write_32(LAST_EXCEPTION_REG, exception << 24 | pc);
}

void
record_step(uint32_t step)
{
	mmio_write_32(LAST_STEP_REG, step);
}

void
report_last_step(void)
{
	uint32_t step = mmio_read_32(LAST_STEP_REG);

	if (step != STEP_NONE)
		error("Step %04x failed!", step);
}