summaryrefslogtreecommitdiff
path: root/platform/generic/tenstorrent/ascalon.c
blob: 485144cdbf5f4d517a48564578902ea5268ec0ee (plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 * SPDX-FileCopyrightText: (c) 2025-2026 Tenstorrent USA, Inc.
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <sbi/riscv_asm.h>
#include <sbi/sbi_console.h>
#include <sbi/sbi_csr_detect.h>

#include <tenstorrent/ascalon.h>
#include <tenstorrent/pma.h>

#define CSR_PMACFG0	0x7e0

void tt_ascalon_discover_pmas_from_boot_hart(void)
{
	struct sbi_trap_info trap = {0};

	/* Whisper virtual platform does not implement PMA */
	csr_read_allowed(CSR_PMACFG0, &trap);
	if (trap.cause)
		return;

	for (unsigned int i = 0; i < TT_MAX_PMAS; i++) {
		u64 pma = csr_read_num(CSR_PMACFG0 + i);
		if (!tt_pma_validate(i, pma)) {
			sbi_printf("HART%d: Bad boot PMA%02d 0x%016lx\n",
				   current_hartid(), i, pma);
		}
		tt_pma_set(i, pma);

		if (pma)
			tt_pma_print(i, pma);
	}
}

void tt_ascalon_verify_pmas_nonboot_hart(void)
{
	struct sbi_trap_info trap = {0};

	/* Whisper virtual platform does not implement PMA */
	csr_read_allowed(CSR_PMACFG0, &trap);
	if (trap.cause)
		return;

	for (unsigned int i = 0; i < TT_MAX_PMAS; i++) {
		u64 pma = csr_read_num(CSR_PMACFG0 + i);
		if (pma != tt_pma_get(i)) {
			sbi_printf("HART%d: Bad boot PMA%02d 0x%016lx does not match boot HART\n",
				   current_hartid(), i, pma);
		}
	}
}