From 551a0696c0b341cf771074e2fdc0224bf1f82e25 Mon Sep 17 00:00:00 2001 From: Luigi Ghionda Date: Thu, 9 May 2024 15:57:57 +0200 Subject: [PATCH] Add APIs for ECC-extended HCI These APIs are needed to access memory-mapped registers holding the number of detected errors by the ECC decoders of the interconnect --- .../archi/chips/astral-cluster/memory_map.h | 3 ++ include/archi/chips/astral-cluster/pulp.h | 3 +- include/archi/hwpe_hci_ecc/hwpe_hci_ecc.h | 44 +++++++++++++++++++ include/hal/chips/astral-cluster/pulp.h | 1 + include/hal/hwpe_hci_ecc/hwpe_hci_ecc.h | 43 ++++++++++++++++++ 5 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 include/archi/hwpe_hci_ecc/hwpe_hci_ecc.h create mode 100644 include/hal/hwpe_hci_ecc/hwpe_hci_ecc.h diff --git a/include/archi/chips/astral-cluster/memory_map.h b/include/archi/chips/astral-cluster/memory_map.h index 729021e..10db2bb 100644 --- a/include/archi/chips/astral-cluster/memory_map.h +++ b/include/archi/chips/astral-cluster/memory_map.h @@ -100,6 +100,7 @@ #define ARCHI_MCHAN_EXT_OFFSET 0x00001800 #define ARCHI_HMR_OFFSET 0x00002000 #define ARCHI_TCDM_SCRUBBER_OFFSET 0x00002400 +#define ARCHI_HWPE_HCI_ECC_OFFSET 0x00002800 #define ARCHI_CLUSTER_PERIPHERALS_ADDR ( ARCHI_CLUSTER_ADDR + ARCHI_CLUSTER_PERIPHERALS_OFFSET ) #define ARCHI_CLUSTER_PERIPHERALS_GLOBAL_ADDR(cid) ( ARCHI_CLUSTER_GLOBAL_ADDR(cid) + ARCHI_CLUSTER_PERIPHERALS_OFFSET ) @@ -111,6 +112,7 @@ #define ARCHI_MCHAN_EXT_ADDR ( ARCHI_CLUSTER_PERIPHERALS_ADDR + ARCHI_MCHAN_EXT_OFFSET ) #define ARCHI_HMR_ADDR ( ARCHI_CLUSTER_PERIPHERALS_ADDR + ARCHI_HMR_OFFSET ) #define ARCHI_TCDM_SCRUBBER_ADDR ( ARCHI_CLUSTER_PERIPHERALS_ADDR + ARCHI_TCDM_SCRUBBER_OFFSET ) +#define ARCHI_HWPE_HCI_ECC_ADDR ( ARCHI_CLUSTER_PERIPHERALS_ADDR + ARCHI_HWPE_HCI_ECC_OFFSET ) #define ARCHI_CLUSTER_CTRL_GLOBAL_ADDR(cid) ( ARCHI_CLUSTER_PERIPHERALS_GLOBAL_ADDR(cid) + ARCHI_CLUSTER_CTRL_OFFSET ) #define ARCHI_ICACHE_CTRL_GLOBAL_ADDR(cid) ( ARCHI_CLUSTER_PERIPHERALS_GLOBAL_ADDR(cid) + ARCHI_ICACHE_CTRL_OFFSET ) @@ -120,6 +122,7 @@ #define ARCHI_IDMA_EXT_GLOBAL_ADDR(cid) ( ARCHI_CLUSTER_PERIPHERALS_GLOBAL_ADDR(cid) + ARCHI_IDMA_EXT_OFFSET ) #define ARCHI_HMR_GLOBAL_ADDR(cid) ( ARCHI_CLUSTER_PERIPHERALS_GLOBAL_ADDR(cid) + ARCHI_HMR_OFFSET ) #define ARCHI_TCDM_SCRUBBER_GLOBAL_ADDR(cid) ( ARCHI_CLUSTER_PERIPHERALS_GLOBAL_ADDR(cid) + ARCHI_TCDM_SCRUBBER_OFFSET ) +#define ARCHI_HWPE_HCI_ECC_GLOBAL_ADDR(cid) ( ARCHI_CLUSTER_PERIPHERALS_GLOBAL_ADDR(cid) + ARCHI_HWPE_HCI_ECC_OFFSET ) /* diff --git a/include/archi/chips/astral-cluster/pulp.h b/include/archi/chips/astral-cluster/pulp.h index 58fca3c..1ebc2d8 100644 --- a/include/archi/chips/astral-cluster/pulp.h +++ b/include/archi/chips/astral-cluster/pulp.h @@ -34,7 +34,7 @@ #include "archi/itc/itc_v1.h" #include "archi/riscv/priv_1_10.h" -#include "archi/chips/carfield-cluster/memory_map.h" +#include "archi/chips/astral-cluster/memory_map.h" #include "archi/chips/carfield-cluster/apb_soc.h" #include "archi/stdout/stdout_v3.h" #include "archi/dma/mchan_v7.h" @@ -47,5 +47,6 @@ #include "archi/udma/udma_v3.h" #include "archi/hmr/hmr_v1.h" #include "archi/tcdm_scrubber/tcdm_scrubber.h" +#include "archi/hwpe_hci_ecc/hwpe_hci_ecc.h" #endif diff --git a/include/archi/hwpe_hci_ecc/hwpe_hci_ecc.h b/include/archi/hwpe_hci_ecc/hwpe_hci_ecc.h new file mode 100644 index 0000000..b720090 --- /dev/null +++ b/include/archi/hwpe_hci_ecc/hwpe_hci_ecc.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2024 ETH Zurich and University of Bologna + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Generated register defines for HCI_ECC_manager + +#ifndef _HCI_ECC_MANAGER_REG_DEFS_ +#define _HCI_ECC_MANAGER_REG_DEFS_ + +#ifdef __cplusplus +extern "C" { +#endif +// Register width +#define HCI_ECC_MANAGER_PARAM_REG_WIDTH 32 + +// Correctable errors on data caught by ecc on interconnect +#define HCI_ECC_MANAGER_DATA_CORRECTABLE_ERRORS_REG_OFFSET 0x0 + +// Uncorrectable errors on data caught by ecc on interconnect +#define HCI_ECC_MANAGER_DATA_UNCORRECTABLE_ERRORS_REG_OFFSET 0x4 + +// Correctable errors caught on metadata by ecc on interconnect +#define HCI_ECC_MANAGER_METADATA_CORRECTABLE_ERRORS_REG_OFFSET 0x8 + +// Uncorrectable errors caught on metadata by ecc on interconnect +#define HCI_ECC_MANAGER_METADATA_UNCORRECTABLE_ERRORS_REG_OFFSET 0xc + +#ifdef __cplusplus +} // extern "C" +#endif +#endif // _HCI_ECC_MANAGER_REG_DEFS_ +// End generated register defines for HCI_ECC_manager diff --git a/include/hal/chips/astral-cluster/pulp.h b/include/hal/chips/astral-cluster/pulp.h index 1cf1d49..671dd44 100644 --- a/include/hal/chips/astral-cluster/pulp.h +++ b/include/hal/chips/astral-cluster/pulp.h @@ -43,5 +43,6 @@ #include "hal/udma/uart/udma_uart_v1.h" #include "hal/hmr/hmr_v1.h" #include "hal/tcdm_scrubber/tcdm_scrubber.h" +#include "hal/hwpe_hci_ecc/hwpe_hci_ecc.h" #endif diff --git a/include/hal/hwpe_hci_ecc/hwpe_hci_ecc.h b/include/hal/hwpe_hci_ecc/hwpe_hci_ecc.h new file mode 100644 index 0000000..891a039 --- /dev/null +++ b/include/hal/hwpe_hci_ecc/hwpe_hci_ecc.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2024 ETH Zurich and University of Bologna + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __HAL_HWPE_HCI_ECC_H__ +#define __HAL_HWPE_HCI_ECC_H__ + +#include "archi/hwpe_hci_ecc/hwpe_hci_ecc.h" +#include "archi/pulp.h" + +// Get the number of correctable errors on data detected by the ECC decoders on the interconnect +static inline unsigned int hwpe_hci_ecc_get_data_correctable_count(unsigned int cid) { + return pulp_read32(ARCHI_HWPE_HCI_ECC_GLOBAL_ADDR(cid) + HCI_ECC_MANAGER_DATA_CORRECTABLE_ERRORS_REG_OFFSET); +} + +// Get the number of uncorrectable errors on data detected by the ECC decoders on the interconnect +static inline unsigned int hwpe_hci_ecc_get_data_uncorrectable_count(unsigned int cid) { + return pulp_read32(ARCHI_HWPE_HCI_ECC_GLOBAL_ADDR(cid) + HCI_ECC_MANAGER_DATA_UNCORRECTABLE_ERRORS_REG_OFFSET); +} + +// Get the number of correctable errors on metadata detected by the ECC decoders on the interconnect +static inline unsigned int hwpe_hci_ecc_get_meta_correctable_count(unsigned int cid) { + return pulp_read32(ARCHI_HWPE_HCI_ECC_GLOBAL_ADDR(cid) + HCI_ECC_MANAGER_METADATA_CORRECTABLE_ERRORS_REG_OFFSET); +} + +// Get the number of uncorrectable errors on metadata detected by the ECC decoders on the interconnect +static inline unsigned int hwpe_hci_ecc_get_meta_uncorrectable_count(unsigned int cid) { + return pulp_read32(ARCHI_HWPE_HCI_ECC_GLOBAL_ADDR(cid) + HCI_ECC_MANAGER_METADATA_UNCORRECTABLE_ERRORS_REG_OFFSET); +} + +#endif // __HAL_HWPE_HCI_ECC_H__