From 333553caf2fb1decd9c115f8a97971ecc55aeb58 Mon Sep 17 00:00:00 2001 From: "Planck (Lu Zeyu)" Date: Wed, 5 Jul 2023 17:33:32 +0800 Subject: [PATCH] fix(hal): check the public header files and fix violations fix(hal/include): fix header violations in hal component fix(hal/include): Move type definitions from `xx_hal.h` to `xx_types.h` fix(hal/include): Move type definitions from `xx_hal.h` to `xx_types.h` fix(hal/include): Add comment for a far away `#endif` fix(hal/include): change scope for cpp guard ci: Remove components/hal/ comment from public headers check exceptions Add missing include macro sdkconfig.h for header files Add missing include macro stdbool.h for header files Add missing include macro stdint.h for header files Add missing capability guard macro for header files Add missing cpp guard macro for header files Remove some useless include macros Add some missing `inline` attribute for functions defined in header files Remove components/hal/ from public headers check exceptions fix(hal/include): fix invalid licenses fix(hal/include): fix invalid licenses fix(hal/include): add missing soc_caps.h fix(hal): include soc_caps.h before cap macro is used fix(hal): Remove unnecessary target check fix(hal): fix header and macro problems Add missing include macro Remove loop dependency in hal Add comment for far-away endif fix(hal): Add missing soc_caps.h ci: update check_copyright_ignore.txt Change the sequence of `#include` macro, cpp guard macro Change the wrap scope of capacity macro fix(hal): Change position of C++ guard to pass test --- components/hal/aes_hal.c | 18 +- components/hal/ds_hal.c | 18 +- components/hal/esp32/include/hal/aes_ll.h | 18 +- components/hal/esp32/include/hal/dac_ll.h | 1 + components/hal/esp32/include/hal/emac_ll.h | 1 + components/hal/esp32/include/hal/mmu_ll.h | 1 + components/hal/esp32/include/hal/mpi_ll.h | 1 + components/hal/esp32/include/hal/mpu_ll.h | 18 +- .../hal/esp32/include/hal/sdio_slave_ll.h | 10 +- .../include/hal/spi_flash_encrypted_ll.h | 18 +- .../hal/esp32/include/hal/touch_sensor_hal.h | 18 +- components/hal/esp32/include/hal/trace_ll.h | 27 +- .../hal/esp32c2/include/hal/clk_gate_ll.h | 4 +- components/hal/esp32c2/include/hal/ecc_ll.h | 1 + .../hal/esp32c2/include/hal/memprot_ll.h | 564 ------------------ .../hal/esp32c2/include/hal/regi2c_ctrl_ll.h | 1 + .../hal/esp32c3/include/hal/clk_gate_ll.h | 4 +- components/hal/esp32c3/include/hal/ds_ll.h | 19 +- components/hal/esp32c3/include/hal/hmac_ll.h | 20 +- .../hal/esp32c3/include/hal/memprot_ll.h | 2 + components/hal/esp32c3/include/hal/mpi_ll.h | 1 + components/hal/esp32c3/include/hal/mpu_ll.h | 18 +- components/hal/esp32c3/include/hal/sha_ll.h | 18 +- .../hal/esp32c3/include/hal/spimem_flash_ll.h | 1 + components/hal/esp32c3/include/hal/uhci_ll.h | 18 +- components/hal/esp32c3/rtc_cntl_hal.c | 18 +- .../hal/esp32c6/include/hal/clk_gate_ll.h | 4 +- components/hal/esp32c6/include/hal/ds_ll.h | 2 + components/hal/esp32c6/include/hal/ecc_ll.h | 1 + components/hal/esp32c6/include/hal/hmac_ll.h | 2 +- .../include/hal/lp_periph_clk_ctrl_ll.h | 4 +- .../hal/esp32c6/include/hal/modem_lpcon_ll.h | 1 + .../hal/esp32c6/include/hal/modem_syscon_ll.h | 1 + components/hal/esp32c6/include/hal/mpi_ll.h | 1 + .../hal/esp32c6/include/hal/sdio_slave_ll.h | 10 +- .../hal/esp32c6/include/hal/spimem_flash_ll.h | 1 + components/hal/esp32c6/include/hal/twai_ll.h | 3 +- .../hal/esp32h2/include/hal/clk_gate_ll.h | 4 +- components/hal/esp32h2/include/hal/ds_ll.h | 1 + components/hal/esp32h2/include/hal/ecc_ll.h | 1 + components/hal/esp32h2/include/hal/hmac_ll.h | 2 +- .../hal/esp32h2/include/hal/lp_clkrst_ll.h | 1 + .../hal/esp32h2/include/hal/lp_timer_ll.h | 1 + .../hal/esp32h2/include/hal/modem_lpcon_ll.h | 1 + .../hal/esp32h2/include/hal/modem_syscon_ll.h | 1 + components/hal/esp32h2/include/hal/mpi_ll.h | 1 + components/hal/esp32h2/include/hal/mwdt_ll.h | 24 +- .../hal/esp32s2/include/hal/crypto_dma_ll.h | 20 +- components/hal/esp32s2/include/hal/dac_ll.h | 1 + .../hal/esp32s2/include/hal/dedic_gpio_ll.h | 18 +- .../hal/esp32s2/include/hal/memprot_ll.h | 2 + .../hal/esp32s2/include/hal/memprot_peri_ll.h | 2 + components/hal/esp32s2/include/hal/mmu_ll.h | 3 +- components/hal/esp32s2/include/hal/mpi_ll.h | 1 + components/hal/esp32s2/include/hal/mpu_ll.h | 18 +- components/hal/esp32s2/include/hal/sha_ll.h | 18 +- .../include/hal/spi_flash_encrypted_ll.h | 18 +- .../hal/esp32s2/include/hal/spimem_flash_ll.h | 1 + components/hal/esp32s2/include/hal/trace_ll.h | 26 +- components/hal/esp32s2/include/hal/usb_ll.h | 26 +- .../hal/esp32s3/include/hal/clk_gate_ll.h | 4 +- components/hal/esp32s3/include/hal/ds_ll.h | 1 + components/hal/esp32s3/include/hal/hmac_ll.h | 1 + .../hal/esp32s3/include/hal/memprot_ll.h | 23 +- components/hal/esp32s3/include/hal/mpi_ll.h | 1 + components/hal/esp32s3/include/hal/mpu_ll.h | 18 +- .../hal/esp32s3/include/hal/regi2c_ctrl_ll.h | 1 + components/hal/esp32s3/include/hal/rwdt_ll.h | 1 + components/hal/esp32s3/include/hal/sha_ll.h | 18 +- .../include/hal/spi_flash_encrypted_ll.h | 18 +- .../hal/esp32s3/include/hal/spimem_flash_ll.h | 1 + components/hal/esp32s3/include/hal/trace_ll.h | 8 + components/hal/esp32s3/include/hal/uhci_ll.h | 18 +- components/hal/esp32s3/include/hal/usb_ll.h | 26 +- components/hal/include/hal/adc_types.h | 8 + components/hal/include/hal/aes_hal.h | 18 +- components/hal/include/hal/aes_types.h | 26 +- components/hal/include/hal/apm_hal.h | 8 +- components/hal/include/hal/assist_debug_hal.h | 3 + components/hal/include/hal/cache_hal.h | 1 + components/hal/include/hal/ds_hal.h | 39 +- components/hal/include/hal/ds_types.h | 30 + components/hal/include/hal/ecc_types.h | 8 + components/hal/include/hal/emac_hal.h | 13 +- components/hal/include/hal/esp_flash_err.h | 18 +- components/hal/include/hal/eth_types.h | 8 + components/hal/include/hal/gdma_hal.h | 6 + components/hal/include/hal/hmac_hal.h | 12 +- components/hal/include/hal/hmac_types.h | 25 + components/hal/include/hal/i2s_hal.h | 5 + .../hal/include/hal/ieee802154_common_ll.h | 8 + components/hal/include/hal/ledc_hal.h | 8 + components/hal/include/hal/lp_timer_hal.h | 6 + components/hal/include/hal/lp_timer_types.h | 2 + components/hal/include/hal/memprot_types.h | 7 + components/hal/include/hal/modem_clock_hal.h | 11 +- components/hal/include/hal/mpi_hal.h | 3 +- components/hal/include/hal/mpi_types.h | 9 + components/hal/include/hal/mpu_hal.h | 18 +- components/hal/include/hal/mpu_types.h | 26 +- components/hal/include/hal/pau_hal.h | 4 + components/hal/include/hal/pau_types.h | 11 + components/hal/include/hal/rtc_hal.h | 11 + components/hal/include/hal/rtc_io_types.h | 26 +- components/hal/include/hal/sdio_slave_hal.h | 15 + components/hal/include/hal/sdio_slave_types.h | 8 + components/hal/include/hal/sha_hal.h | 18 +- .../hal/include/hal/spi_flash_encrypt_hal.h | 26 +- components/hal/include/hal/spi_flash_hal.h | 8 + components/hal/include/hal/spi_hal.h | 8 + components/hal/include/hal/spi_slave_hal.h | 8 + components/hal/include/hal/spi_slave_hd_hal.h | 8 + components/hal/include/hal/spi_types.h | 8 + components/hal/include/hal/systimer_types.h | 4 + components/hal/include/hal/touch_sensor_hal.h | 5 + .../hal/include/hal/touch_sensor_types.h | 9 + components/hal/include/hal/twai_hal.h | 7 + components/hal/include/hal/uart_types.h | 3 +- components/hal/include/hal/uhci_types.h | 18 +- components/hal/include/hal/usb_dwc_hal.h | 7 +- components/hal/include/hal/usb_dwc_ll.h | 6 + components/hal/include/hal/usb_hal.h | 20 +- components/hal/include/hal/usb_phy_hal.h | 8 + .../hal/include/hal/usb_types_private.h | 18 +- components/hal/include/hal/xt_wdt_hal.h | 11 +- components/hal/mpu_hal.c | 18 +- .../hal/platform_port/include/hal/misc.h | 8 + components/hal/sha_hal.c | 18 +- components/hal/spi_flash_encrypt_hal_iram.c | 18 +- components/hal/spi_flash_hal_gpspi.c | 18 +- components/hal/touch_sensor_hal.c | 18 +- components/hal/uart_hal_iram.c | 18 +- components/hal/usb_hal.c | 18 +- tools/ci/check_copyright_ignore.txt | 44 -- tools/ci/check_public_headers_exceptions.txt | 2 - 135 files changed, 711 insertions(+), 1268 deletions(-) delete mode 100644 components/hal/esp32c2/include/hal/memprot_ll.h create mode 100644 components/hal/include/hal/ds_types.h create mode 100644 components/hal/include/hal/hmac_types.h diff --git a/components/hal/aes_hal.c b/components/hal/aes_hal.c index 26df0640ca..e789123223 100644 --- a/components/hal/aes_hal.c +++ b/components/hal/aes_hal.c @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ // The HAL layer for AES diff --git a/components/hal/ds_hal.c b/components/hal/ds_hal.c index 6a8fec9afd..53f9279456 100644 --- a/components/hal/ds_hal.c +++ b/components/hal/ds_hal.c @@ -1,16 +1,8 @@ -// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include "hal/systimer_hal.h" #include "hal/ds_hal.h" diff --git a/components/hal/esp32/include/hal/aes_ll.h b/components/hal/esp32/include/hal/aes_ll.h index b0142cbe68..86d0c0e3c3 100644 --- a/components/hal/esp32/include/hal/aes_ll.h +++ b/components/hal/esp32/include/hal/aes_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020-2021 Espressif Systems (Shanghai) CO LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/components/hal/esp32/include/hal/dac_ll.h b/components/hal/esp32/include/hal/dac_ll.h index 143b7ff7cb..3426ed97e2 100644 --- a/components/hal/esp32/include/hal/dac_ll.h +++ b/components/hal/esp32/include/hal/dac_ll.h @@ -13,6 +13,7 @@ #pragma once #include +#include #include "hal/misc.h" #include "soc/dac_periph.h" #include "soc/rtc_io_struct.h" diff --git a/components/hal/esp32/include/hal/emac_ll.h b/components/hal/esp32/include/hal/emac_ll.h index 1c8e705215..7c81da8978 100644 --- a/components/hal/esp32/include/hal/emac_ll.h +++ b/components/hal/esp32/include/hal/emac_ll.h @@ -15,6 +15,7 @@ #pragma once #include +#include #include "hal/misc.h" #include "hal/eth_types.h" #include "soc/emac_dma_struct.h" diff --git a/components/hal/esp32/include/hal/mmu_ll.h b/components/hal/esp32/include/hal/mmu_ll.h index 8a572a5455..a747b1e95d 100644 --- a/components/hal/esp32/include/hal/mmu_ll.h +++ b/components/hal/esp32/include/hal/mmu_ll.h @@ -8,6 +8,7 @@ #pragma once +#include #include "soc/ext_mem_defs.h" #include "soc/dport_reg.h" #include "soc/dport_access.h" diff --git a/components/hal/esp32/include/hal/mpi_ll.h b/components/hal/esp32/include/hal/mpi_ll.h index 5d333151fa..17ceb6ad6b 100644 --- a/components/hal/esp32/include/hal/mpi_ll.h +++ b/components/hal/esp32/include/hal/mpi_ll.h @@ -8,6 +8,7 @@ #include #include #include "hal/assert.h" +#include "hal/mpi_types.h" #include "soc/dport_reg.h" #include "soc/hwcrypto_periph.h" #include "soc/mpi_periph.h" diff --git a/components/hal/esp32/include/hal/mpu_ll.h b/components/hal/esp32/include/hal/mpu_ll.h index 2ec955b48f..fa00a39954 100644 --- a/components/hal/esp32/include/hal/mpu_ll.h +++ b/components/hal/esp32/include/hal/mpu_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include diff --git a/components/hal/esp32/include/hal/sdio_slave_ll.h b/components/hal/esp32/include/hal/sdio_slave_ll.h index 5c4015f2e7..fa99989a82 100644 --- a/components/hal/esp32/include/hal/sdio_slave_ll.h +++ b/components/hal/esp32/include/hal/sdio_slave_ll.h @@ -16,7 +16,7 @@ #pragma once -#include "hal/sdio_slave_hal.h" +#include "hal/sdio_slave_types.h" #include "soc/slc_struct.h" #include "soc/slc_reg.h" #include "soc/host_struct.h" @@ -24,6 +24,10 @@ #include "soc/hinf_struct.h" #include "soc/lldesc.h" +#ifdef __cplusplus +extern "C" { +#endif + /// Get address of the only SLC registers for ESP32 #define sdio_slave_ll_get_slc(ID) (&SLC) /// Get address of the only HOST registers for ESP32 @@ -507,3 +511,7 @@ static inline void sdio_slave_ll_slvint_fetch_clear(slc_dev_t *slc, sdio_slave_l *out_slv_int = slv_int; slc->slc0_int_clr.val = slv_int; } + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/esp32/include/hal/spi_flash_encrypted_ll.h b/components/hal/esp32/include/hal/spi_flash_encrypted_ll.h index e6e7a47d8a..682be30815 100644 --- a/components/hal/esp32/include/hal/spi_flash_encrypted_ll.h +++ b/components/hal/esp32/include/hal/spi_flash_encrypted_ll.h @@ -1,16 +1,8 @@ -// Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /******************************************************************************* * NOTICE diff --git a/components/hal/esp32/include/hal/touch_sensor_hal.h b/components/hal/esp32/include/hal/touch_sensor_hal.h index 64c988f4e1..5cd1688df1 100644 --- a/components/hal/esp32/include/hal/touch_sensor_hal.h +++ b/components/hal/esp32/include/hal/touch_sensor_hal.h @@ -1,16 +1,8 @@ -// Copyright 2019 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /******************************************************************************* * NOTICE diff --git a/components/hal/esp32/include/hal/trace_ll.h b/components/hal/esp32/include/hal/trace_ll.h index da1130c193..a81fd83dac 100644 --- a/components/hal/esp32/include/hal/trace_ll.h +++ b/components/hal/esp32/include/hal/trace_ll.h @@ -1,21 +1,18 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once +#include #include "soc/dport_reg.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void trace_ll_mem_enable(int cpu, bool enable) { int reg[] = {DPORT_PRO_TRACEMEM_ENA_REG, DPORT_APP_TRACEMEM_ENA_REG}; @@ -26,3 +23,7 @@ static inline void trace_ll_set_mode(int mode) { DPORT_WRITE_PERI_REG(DPORT_TRACEMEM_MUX_MODE_REG, mode); } + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/esp32c2/include/hal/clk_gate_ll.h b/components/hal/esp32c2/include/hal/clk_gate_ll.h index fe9671fe72..aca5cd0569 100644 --- a/components/hal/esp32c2/include/hal/clk_gate_ll.h +++ b/components/hal/esp32c2/include/hal/clk_gate_ll.h @@ -115,7 +115,7 @@ static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool en } } -static uint32_t periph_ll_get_clk_en_reg(periph_module_t periph) +static inline uint32_t periph_ll_get_clk_en_reg(periph_module_t periph) { switch (periph) { case PERIPH_RNG_MODULE: @@ -140,7 +140,7 @@ static uint32_t periph_ll_get_clk_en_reg(periph_module_t periph) } } -static uint32_t periph_ll_get_rst_en_reg(periph_module_t periph) +static inline uint32_t periph_ll_get_rst_en_reg(periph_module_t periph) { switch (periph) { case PERIPH_RNG_MODULE: diff --git a/components/hal/esp32c2/include/hal/ecc_ll.h b/components/hal/esp32c2/include/hal/ecc_ll.h index 8a7c57a04a..90f7e405fb 100644 --- a/components/hal/esp32c2/include/hal/ecc_ll.h +++ b/components/hal/esp32c2/include/hal/ecc_ll.h @@ -8,6 +8,7 @@ #include #include #include "hal/assert.h" +#include "hal/ecc_types.h" #include "soc/ecc_mult_reg.h" #ifdef __cplusplus diff --git a/components/hal/esp32c2/include/hal/memprot_ll.h b/components/hal/esp32c2/include/hal/memprot_ll.h deleted file mode 100644 index a6b70c907f..0000000000 --- a/components/hal/esp32c2/include/hal/memprot_ll.h +++ /dev/null @@ -1,564 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include "soc/sensitive_reg.h" -#include "soc/ext_mem_defs.h" -#include "hal/assert.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* ****************************************************************************************************** - * *** GLOBALS *** - * NOTE: in this version, all the configurations apply only to WORLD_0 - */ - -#define IRAM_SRAM_START 0x4037C000 -#define DRAM_SRAM_START 0x3FC7C000 - -/* ICache size is fixed to 16KB on ESP32-C2 */ -#ifndef ICACHE_SIZE -#define ICACHE_SIZE 0x4000 -#endif - -#ifndef I_D_SRAM_SEGMENT_SIZE -#define I_D_SRAM_SEGMENT_SIZE 0x20000 -#endif - -#define I_D_SPLIT_LINE_SHIFT 0x9 -#define I_D_FAULT_ADDR_SHIFT 0x2 - -static inline void memprot_ll_set_iram0_dram0_split_line_lock(void) -{ - REG_WRITE(SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_0_REG, 1); -} - -static inline bool memprot_ll_get_iram0_dram0_split_line_lock(void) -{ - return REG_READ(SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_0_REG) == 1; -} - -static inline void* memprot_ll_get_split_addr_from_reg(uint32_t regval, uint32_t base) -{ - return (void*) - (base + ((regval & SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SRAM_SPLITADDR_M) - >> (SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SRAM_SPLITADDR_S - I_D_SPLIT_LINE_SHIFT))); -} - -/* ****************************************************************************************************** - * *** IRAM0 *** - */ - -//16kB (CACHE) -#define IRAM0_SRAM_LEVEL_0_LOW IRAM_SRAM_START //0x40370000 -#define IRAM0_SRAM_LEVEL_0_HIGH (IRAM0_SRAM_LEVEL_0_LOW + ICACHE_SIZE - 0x1) //0x4037FFFF - -//128kB (LEVEL 1) -#define IRAM0_SRAM_LEVEL_1_LOW (IRAM0_SRAM_LEVEL_0_HIGH + 0x1) //0x40380000 -#define IRAM0_SRAM_LEVEL_1_HIGH (IRAM0_SRAM_LEVEL_1_LOW + I_D_SRAM_SEGMENT_SIZE - 0x1) //0x4039FFFF - -//128kB (LEVEL 2) -#define IRAM0_SRAM_LEVEL_2_LOW (IRAM0_SRAM_LEVEL_1_HIGH + 0x1) //0x403A0000 -#define IRAM0_SRAM_LEVEL_2_HIGH (IRAM0_SRAM_LEVEL_2_LOW + I_D_SRAM_SEGMENT_SIZE - 0x1) //0x403BFFFF - -//128kB (LEVEL 3) -#define IRAM0_SRAM_LEVEL_3_LOW (IRAM0_SRAM_LEVEL_2_HIGH + 0x1) //0x403C0000 -#define IRAM0_SRAM_LEVEL_3_HIGH (IRAM0_SRAM_LEVEL_3_LOW + I_D_SRAM_SEGMENT_SIZE - 0x1) //0x403DFFFF - -//permission bits -#define SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_R 0x1 -#define SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_W 0x2 -#define SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_F 0x4 - -static inline uint32_t memprot_ll_iram0_get_intr_source_num(void) -{ - return ETS_CORE0_IRAM0_PMS_INTR_SOURCE; -} - - -/////////////////////////////////// -// IRAM0 - SPLIT LINES -/////////////////////////////////// - -static inline void memprot_ll_set_iram0_split_line(const void *line_addr, uint32_t sensitive_reg) -{ - uint32_t addr = (uint32_t)line_addr; - HAL_ASSERT(addr >= IRAM0_SRAM_LEVEL_1_LOW && addr <= IRAM0_SRAM_LEVEL_3_HIGH); - - uint32_t category[3] = {0}; - if (addr <= IRAM0_SRAM_LEVEL_1_HIGH) { - category[0] = 0x2; - category[1] = category[2] = 0x3; - } else if (addr >= IRAM0_SRAM_LEVEL_2_LOW && addr <= IRAM0_SRAM_LEVEL_2_HIGH) { - category[1] = 0x2; - category[2] = 0x3; - } else { - category[2] = 0x2; - } - - //NOTE: category & split line address bits are the same for all the areas - uint32_t category_bits = - (category[0] << SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SRAM_CATEGORY_0_S) | - (category[1] << SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SRAM_CATEGORY_1_S) | - (category[2] << SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SRAM_CATEGORY_2_S); - - uint32_t conf_addr = ((addr >> I_D_SPLIT_LINE_SHIFT) & SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SRAM_SPLITADDR_V) << SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SRAM_SPLITADDR_S; - - uint32_t reg_cfg = conf_addr | category_bits; - - REG_WRITE(sensitive_reg, reg_cfg); -} - -/* can be both IRAM0/DRAM0 address */ -static inline void memprot_ll_set_iram0_split_line_main_I_D(const void *line_addr) -{ - memprot_ll_set_iram0_split_line(line_addr, SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_1_REG); -} - -static inline void memprot_ll_set_iram0_split_line_I_0(const void *line_addr) -{ - memprot_ll_set_iram0_split_line(line_addr, SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_2_REG); -} - -static inline void memprot_ll_set_iram0_split_line_I_1(const void *line_addr) -{ - memprot_ll_set_iram0_split_line(line_addr, SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_3_REG); -} - -static inline void* memprot_ll_get_iram0_split_line_main_I_D(void) -{ - return memprot_ll_get_split_addr_from_reg(REG_READ(SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_1_REG), SOC_DIRAM_IRAM_LOW); -} - -static inline void* memprot_ll_get_iram0_split_line_I_0(void) -{ - return memprot_ll_get_split_addr_from_reg(REG_READ(SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_2_REG), SOC_DIRAM_IRAM_LOW); -} - -static inline void* memprot_ll_get_iram0_split_line_I_1(void) -{ - return memprot_ll_get_split_addr_from_reg(REG_READ(SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_3_REG), SOC_DIRAM_IRAM_LOW); -} - - -/////////////////////////////////// -// IRAM0 - PMS CONFIGURATION -/////////////////////////////////// - -// lock -static inline void memprot_ll_iram0_set_pms_lock(void) -{ - REG_WRITE(SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_0_REG, 1); -} - -static inline bool memprot_ll_iram0_get_pms_lock(void) -{ - return REG_READ(SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_0_REG) == 1; -} - -// permission settings -static inline uint32_t memprot_ll_iram0_set_permissions(bool r, bool w, bool x) -{ - uint32_t permissions = 0; - if ( r ) { - permissions |= SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_R; - } - if ( w ) { - permissions |= SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_W; - } - if ( x ) { - permissions |= SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_F; - } - - return permissions; -} - -static inline void memprot_ll_iram0_set_pms_area_0(bool r, bool w, bool x) -{ - REG_SET_FIELD(SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_2_REG, SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_0, memprot_ll_iram0_set_permissions(r, w, x)); -} - -static inline void memprot_ll_iram0_set_pms_area_1(bool r, bool w, bool x) -{ - REG_SET_FIELD(SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_2_REG, SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_1, memprot_ll_iram0_set_permissions(r, w, x)); -} - -static inline void memprot_ll_iram0_set_pms_area_2(bool r, bool w, bool x) -{ - REG_SET_FIELD(SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_2_REG, SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_2, memprot_ll_iram0_set_permissions(r, w, x)); -} - -static inline void memprot_ll_iram0_set_pms_area_3(bool r, bool w, bool x) -{ - REG_SET_FIELD(SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_2_REG, SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_3, memprot_ll_iram0_set_permissions(r, w, x)); -} - -static inline void memprot_ll_iram0_get_permissions(uint32_t perms, bool *r, bool *w, bool *x) -{ - *r = perms & SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_R; - *w = perms & SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_W; - *x = perms & SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_F; -} - -static inline void memprot_ll_iram0_get_pms_area_0(bool *r, bool *w, bool *x) -{ - uint32_t permissions = REG_GET_FIELD(SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_2_REG, SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_0); - memprot_ll_iram0_get_permissions( permissions, r, w, x); -} - -static inline void memprot_ll_iram0_get_pms_area_1(bool *r, bool *w, bool *x) -{ - uint32_t permissions = REG_GET_FIELD(SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_2_REG, SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_1); - memprot_ll_iram0_get_permissions( permissions, r, w, x); -} - -static inline void memprot_ll_iram0_get_pms_area_2(bool *r, bool *w, bool *x) -{ - uint32_t permissions = REG_GET_FIELD(SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_2_REG, SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_2); - memprot_ll_iram0_get_permissions( permissions, r, w, x); -} - -static inline void memprot_ll_iram0_get_pms_area_3(bool *r, bool *w, bool *x) -{ - uint32_t permissions = REG_GET_FIELD(SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_2_REG, SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_3); - memprot_ll_iram0_get_permissions( permissions, r, w, x); -} - - -/////////////////////////////////// -// IRAM0 - MONITOR -/////////////////////////////////// - -// lock -static inline void memprot_ll_iram0_set_monitor_lock(void) -{ - REG_WRITE(SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_0_REG, 1); -} - -static inline bool memprot_ll_iram0_get_monitor_lock(void) -{ - return REG_READ(SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_0_REG) == 1; -} - -// interrupt enable/clear -static inline void memprot_ll_iram0_set_monitor_en(bool enable) -{ - if ( enable ) { - REG_SET_BIT( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_1_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_EN ); - } else { - REG_CLR_BIT( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_1_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_EN ); - } -} - -static inline bool memprot_ll_iram0_get_monitor_en(void) -{ - return REG_GET_FIELD( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_1_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_EN ) == 1; -} - -static inline void memprot_ll_iram0_clear_monitor_intr(void) -{ - REG_SET_BIT( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_1_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_CLR ); -} - -static inline void memprot_ll_iram0_reset_clear_monitor_intr(void) -{ - REG_CLR_BIT( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_1_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_CLR ); -} - -static inline uint32_t memprot_ll_iram0_get_monitor_enable_register(void) -{ - return REG_READ(SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_1_REG); -} - -// // permission violation status -static inline uint32_t memprot_ll_iram0_get_monitor_status_intr(void) -{ - return REG_GET_FIELD( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_INTR ); -} - -static inline uint32_t memprot_ll_iram0_get_monitor_status_fault_wr(void) -{ - return REG_GET_FIELD( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_STATUS_WR ); -} - -static inline uint32_t memprot_ll_iram0_get_monitor_status_fault_loadstore(void) -{ - return REG_GET_FIELD( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_STATUS_LOADSTORE ); -} - -static inline uint32_t memprot_ll_iram0_get_monitor_status_fault_world(void) -{ - return REG_GET_FIELD( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_STATUS_WORLD ); -} - -static inline uint32_t memprot_ll_iram0_get_monitor_status_fault_addr(void) -{ - uint32_t addr = REG_GET_FIELD( SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_VIOLATE_STATUS_ADDR ); - return addr > 0 ? (addr << I_D_FAULT_ADDR_SHIFT) + IRAM0_ADDRESS_LOW : 0; -} - -static inline uint32_t memprot_ll_iram0_get_monitor_status_register(void) -{ - return REG_READ(SENSITIVE_CORE_0_IRAM0_PMS_MONITOR_2_REG); -} - - -/* ****************************************************************************************************** - * *** DRAM0 *** - */ - -//cache not available from DRAM (!) -#define DRAM0_SRAM_LEVEL_0_LOW DRAM_SRAM_START //0x3FC7C000 -#define DRAM0_SRAM_LEVEL_0_HIGH (DRAM0_SRAM_LEVEL_0_LOW + ICACHE_SIZE - 0x1) //0x3FC7FFFF - -//128kB -#define DRAM0_SRAM_LEVEL_1_LOW (DRAM0_SRAM_LEVEL_0_HIGH + 0x1) //0x3FC80000 -#define DRAM0_SRAM_LEVEL_1_HIGH (DRAM0_SRAM_LEVEL_1_LOW + I_D_SRAM_SEGMENT_SIZE - 0x1) //0x3FC9FFFF - -//128kB -#define DRAM0_SRAM_LEVEL_2_LOW (DRAM0_SRAM_LEVEL_1_HIGH + 0x1) //0x3FCA0000 -#define DRAM0_SRAM_LEVEL_2_HIGH (DRAM0_SRAM_LEVEL_2_LOW + I_D_SRAM_SEGMENT_SIZE - 0x1) //0x3FCBFFFF - -//128kB -#define DRAM0_SRAM_LEVEL_3_LOW (DRAM0_SRAM_LEVEL_2_HIGH + 0x1) //0x3FCC0000 -#define DRAM0_SRAM_LEVEL_3_HIGH (DRAM0_SRAM_LEVEL_3_LOW + I_D_SRAM_SEGMENT_SIZE - 0x1) //0x3FCDFFFF - -#define SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_W 0x2 -#define SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_R 0x1 - - -static inline uint32_t memprot_ll_dram0_get_intr_source_num(void) -{ - return ETS_CORE0_DRAM0_PMS_INTR_SOURCE; -} - - -/////////////////////////////////// -// DRAM0 - SPLIT LINES -/////////////////////////////////// - -static inline void memprot_ll_set_dram0_split_line(const void *line_addr, uint32_t sensitive_reg) -{ - uint32_t addr = (uint32_t)line_addr; - HAL_ASSERT(addr >= DRAM0_SRAM_LEVEL_1_LOW && addr <= DRAM0_SRAM_LEVEL_3_HIGH); - - uint32_t category[3] = {0}; - if (addr <= DRAM0_SRAM_LEVEL_1_HIGH) { - category[0] = 0x2; - category[1] = category[2] = 0x3; - } else if (addr >= DRAM0_SRAM_LEVEL_2_LOW && addr <= DRAM0_SRAM_LEVEL_2_HIGH) { - category[1] = 0x2; - category[2] = 0x3; - } else { - category[2] = 0x2; - } - - //NOTE: line address & category bits, shifts and masks are the same for all the areas - uint32_t category_bits = - (category[0] << SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SRAM_CATEGORY_0_S) | - (category[1] << SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SRAM_CATEGORY_1_S) | - (category[2] << SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SRAM_CATEGORY_2_S); - - uint32_t conf_addr = ((addr >> I_D_SPLIT_LINE_SHIFT) & SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SRAM_SPLITADDR_V) << SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SRAM_SPLITADDR_S; - - uint32_t reg_cfg = conf_addr | category_bits; - - REG_WRITE(sensitive_reg, reg_cfg); -} - -static inline void memprot_ll_set_dram0_split_line_D_0(const void *line_addr) -{ - memprot_ll_set_dram0_split_line(line_addr, SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_2_REG); -} - -static inline void memprot_ll_set_dram0_split_line_D_1(const void *line_addr) -{ - memprot_ll_set_dram0_split_line(line_addr, SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_3_REG); -} - -static inline void* memprot_ll_get_dram0_split_line_D_0(void) -{ - return memprot_ll_get_split_addr_from_reg(REG_READ(SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_2_REG), SOC_DIRAM_DRAM_LOW); -} - -static inline void* memprot_ll_get_dram0_split_line_D_1(void) -{ - return memprot_ll_get_split_addr_from_reg(REG_READ(SENSITIVE_CORE_X_IRAM0_DRAM0_DMA_SPLIT_LINE_CONSTRAIN_3_REG), SOC_DIRAM_DRAM_LOW); -} - - -/////////////////////////////////// -// DRAM0 - PMS CONFIGURATION -/////////////////////////////////// - -// lock -static inline void memprot_ll_dram0_set_pms_lock(void) -{ - REG_WRITE(SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_0_REG, 1); -} - -static inline bool memprot_ll_dram0_get_pms_lock(void) -{ - return REG_READ(SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_0_REG) == 1; -} - -// permission settings -static inline uint32_t memprot_ll_dram0_set_permissions(bool r, bool w) -{ - uint32_t permissions = 0; - if ( r ) { - permissions |= SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_R; - } - if ( w ) { - permissions |= SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_W; - } - - return permissions; -} - -static inline void memprot_ll_dram0_set_pms_area_0(bool r, bool w) -{ - REG_SET_FIELD(SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_1_REG, SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_0, memprot_ll_dram0_set_permissions(r, w)); -} - -static inline void memprot_ll_dram0_set_pms_area_1(bool r, bool w) -{ - REG_SET_FIELD(SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_1_REG, SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_1, memprot_ll_dram0_set_permissions(r, w)); -} - -static inline void memprot_ll_dram0_set_pms_area_2(bool r, bool w) -{ - REG_SET_FIELD(SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_1_REG, SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_2, memprot_ll_dram0_set_permissions(r, w)); -} - -static inline void memprot_ll_dram0_set_pms_area_3(bool r, bool w) -{ - REG_SET_FIELD(SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_1_REG, SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_3, memprot_ll_dram0_set_permissions(r, w)); -} - -static inline void memprot_ll_dram0_get_permissions(uint32_t perms, bool *r, bool *w ) -{ - *r = perms & SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_R; - *w = perms & SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_W; -} - -static inline void memprot_ll_dram0_get_pms_area_0(bool *r, bool *w) -{ - uint32_t permissions = REG_GET_FIELD(SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_1_REG, SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_0); - memprot_ll_dram0_get_permissions( permissions, r, w); -} - -static inline void memprot_ll_dram0_get_pms_area_1(bool *r, bool *w) -{ - uint32_t permissions = REG_GET_FIELD(SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_1_REG, SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_1); - memprot_ll_dram0_get_permissions( permissions, r, w); -} - -static inline void memprot_ll_dram0_get_pms_area_2(bool *r, bool *w) -{ - uint32_t permissions = REG_GET_FIELD(SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_1_REG, SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_2); - memprot_ll_dram0_get_permissions( permissions, r, w); -} - -static inline void memprot_ll_dram0_get_pms_area_3(bool *r, bool *w) -{ - uint32_t permissions = REG_GET_FIELD(SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_1_REG, SENSITIVE_CORE_X_DRAM0_PMS_CONSTRAIN_SRAM_WORLD_0_PMS_3); - memprot_ll_dram0_get_permissions( permissions, r, w); -} - -/////////////////////////////////// -// DRAM0 - MONITOR -/////////////////////////////////// - -// lock -static inline void memprot_ll_dram0_set_monitor_lock(void) -{ - REG_WRITE(SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_0_REG, 1); -} - -static inline bool memprot_ll_dram0_get_monitor_lock(void) -{ - return REG_READ(SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_0_REG) == 1; -} - -// interrupt enable/clear -static inline void memprot_ll_dram0_set_monitor_en(bool enable) -{ - if ( enable ) { - REG_SET_BIT( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_1_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_EN ); - } else { - REG_CLR_BIT( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_1_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_EN ); - } -} - -static inline bool memprot_ll_dram0_get_monitor_en(void) -{ - return REG_GET_BIT( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_1_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_EN ) == 1; -} - -static inline void memprot_ll_dram0_clear_monitor_intr(void) -{ - REG_SET_BIT( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_1_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_CLR ); -} - -static inline void memprot_ll_dram0_reset_clear_monitor_intr(void) -{ - REG_CLR_BIT( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_1_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_CLR ); -} - -static inline uint32_t memprot_ll_dram0_get_monitor_enable_register(void) -{ - return REG_READ(SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_1_REG); -} - -// permission violation status -static inline uint32_t memprot_ll_dram0_get_monitor_status_intr(void) -{ - return REG_GET_FIELD( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_INTR ); -} - -static inline uint32_t memprot_ll_dram0_get_monitor_status_fault_lock(void) -{ - return REG_GET_FIELD( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_STATUS_LOCK ); -} - -static inline uint32_t memprot_ll_dram0_get_monitor_status_fault_world(void) -{ - return REG_GET_FIELD( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_STATUS_WORLD ); -} - -static inline uint32_t memprot_ll_dram0_get_monitor_status_fault_addr(void) -{ - uint32_t addr = REG_GET_FIELD( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_STATUS_ADDR ); - return addr > 0 ? (addr << I_D_FAULT_ADDR_SHIFT) + DRAM0_ADDRESS_LOW : 0; -} - -static inline uint32_t memprot_ll_dram0_get_monitor_status_fault_wr(void) -{ - return REG_GET_FIELD( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_3_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_STATUS_WR ); -} - -static inline uint32_t memprot_ll_dram0_get_monitor_status_fault_byte_en(void) -{ - return REG_GET_FIELD( SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_2_REG, SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_VIOLATE_STATUS_BYTEEN ); -} - -static inline uint32_t memprot_ll_dram0_get_monitor_status_register_1(void) -{ - return REG_READ(SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_2_REG); -} - -static inline uint32_t memprot_ll_dram0_get_monitor_status_register_2(void) -{ - return REG_READ(SENSITIVE_CORE_0_DRAM0_PMS_MONITOR_3_REG); -} - -#ifdef __cplusplus -} -#endif diff --git a/components/hal/esp32c2/include/hal/regi2c_ctrl_ll.h b/components/hal/esp32c2/include/hal/regi2c_ctrl_ll.h index 3c222e38e4..7a3fee1a86 100644 --- a/components/hal/esp32c2/include/hal/regi2c_ctrl_ll.h +++ b/components/hal/esp32c2/include/hal/regi2c_ctrl_ll.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include "soc/soc.h" #include "soc/regi2c_defs.h" diff --git a/components/hal/esp32c3/include/hal/clk_gate_ll.h b/components/hal/esp32c3/include/hal/clk_gate_ll.h index 67ef4a883f..0f2c3c299a 100644 --- a/components/hal/esp32c3/include/hal/clk_gate_ll.h +++ b/components/hal/esp32c3/include/hal/clk_gate_ll.h @@ -159,7 +159,7 @@ static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool en } } -static uint32_t periph_ll_get_clk_en_reg(periph_module_t periph) +static inline uint32_t periph_ll_get_clk_en_reg(periph_module_t periph) { switch (periph) { case PERIPH_RNG_MODULE: @@ -187,7 +187,7 @@ static uint32_t periph_ll_get_clk_en_reg(periph_module_t periph) } } -static uint32_t periph_ll_get_rst_en_reg(periph_module_t periph) +static inline uint32_t periph_ll_get_rst_en_reg(periph_module_t periph) { switch (periph) { case PERIPH_RNG_MODULE: diff --git a/components/hal/esp32c3/include/hal/ds_ll.h b/components/hal/esp32c3/include/hal/ds_ll.h index fd98de367f..8817c3581d 100644 --- a/components/hal/esp32c3/include/hal/ds_ll.h +++ b/components/hal/esp32c3/include/hal/ds_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /******************************************************************************* * NOTICE @@ -25,6 +17,7 @@ #include "soc/hwcrypto_reg.h" #include "soc/soc_caps.h" +#include "hal/ds_types.h" #ifdef __cplusplus extern "C" { diff --git a/components/hal/esp32c3/include/hal/hmac_ll.h b/components/hal/esp32c3/include/hal/hmac_ll.h index 8e257a7d32..646dd14d76 100644 --- a/components/hal/esp32c3/include/hal/hmac_ll.h +++ b/components/hal/esp32c3/include/hal/hmac_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /******************************************************************************* * NOTICE @@ -24,7 +16,7 @@ #include "soc/system_reg.h" #include "soc/hwcrypto_reg.h" -#include "hal/hmac_hal.h" +#include "hal/hmac_types.h" #define SHA256_BLOCK_SZ 64 #define SHA256_DIGEST_SZ 32 diff --git a/components/hal/esp32c3/include/hal/memprot_ll.h b/components/hal/esp32c3/include/hal/memprot_ll.h index 61a20d0434..80ca7febf0 100644 --- a/components/hal/esp32c3/include/hal/memprot_ll.h +++ b/components/hal/esp32c3/include/hal/memprot_ll.h @@ -6,8 +6,10 @@ #pragma once +#include #include "soc/ext_mem_defs.h" #include "soc/memprot_defs.h" +#include "soc/periph_defs.h" #include "hal/memprot_types.h" #ifdef __cplusplus diff --git a/components/hal/esp32c3/include/hal/mpi_ll.h b/components/hal/esp32c3/include/hal/mpi_ll.h index da1697abfa..e480d37b96 100644 --- a/components/hal/esp32c3/include/hal/mpi_ll.h +++ b/components/hal/esp32c3/include/hal/mpi_ll.h @@ -8,6 +8,7 @@ #include #include #include "hal/assert.h" +#include "hal/mpi_types.h" #include "soc/hwcrypto_periph.h" #include "soc/system_reg.h" #include "soc/mpi_periph.h" diff --git a/components/hal/esp32c3/include/hal/mpu_ll.h b/components/hal/esp32c3/include/hal/mpu_ll.h index 77fa580cdb..245991b8dc 100644 --- a/components/hal/esp32c3/include/hal/mpu_ll.h +++ b/components/hal/esp32c3/include/hal/mpu_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include diff --git a/components/hal/esp32c3/include/hal/sha_ll.h b/components/hal/esp32c3/include/hal/sha_ll.h index a7bc493252..8f92ef950b 100644 --- a/components/hal/esp32c3/include/hal/sha_ll.h +++ b/components/hal/esp32c3/include/hal/sha_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include diff --git a/components/hal/esp32c3/include/hal/spimem_flash_ll.h b/components/hal/esp32c3/include/hal/spimem_flash_ll.h index cf75253aff..45eaddad7f 100644 --- a/components/hal/esp32c3/include/hal/spimem_flash_ll.h +++ b/components/hal/esp32c3/include/hal/spimem_flash_ll.h @@ -24,6 +24,7 @@ #include "hal/assert.h" #include "hal/spi_types.h" #include "hal/spi_flash_types.h" +#include "hal/misc.h" #ifdef __cplusplus extern "C" { diff --git a/components/hal/esp32c3/include/hal/uhci_ll.h b/components/hal/esp32c3/include/hal/uhci_ll.h index a766797ea0..ecf3b0f501 100644 --- a/components/hal/esp32c3/include/hal/uhci_ll.h +++ b/components/hal/esp32c3/include/hal/uhci_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ // The LL layer for UHCI register operations. // Note that most of the register operations in this layer are non-atomic operations. diff --git a/components/hal/esp32c3/rtc_cntl_hal.c b/components/hal/esp32c3/rtc_cntl_hal.c index 90b2e9d083..aa7f90a442 100644 --- a/components/hal/esp32c3/rtc_cntl_hal.c +++ b/components/hal/esp32c3/rtc_cntl_hal.c @@ -1,16 +1,8 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ // The HAL layer for RTC CNTL (common part) diff --git a/components/hal/esp32c6/include/hal/clk_gate_ll.h b/components/hal/esp32c6/include/hal/clk_gate_ll.h index 3a3a0ebc37..96aeecbe83 100644 --- a/components/hal/esp32c6/include/hal/clk_gate_ll.h +++ b/components/hal/esp32c6/include/hal/clk_gate_ll.h @@ -168,7 +168,7 @@ static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool en } } -static uint32_t periph_ll_get_clk_en_reg(periph_module_t periph) +static inline uint32_t periph_ll_get_clk_en_reg(periph_module_t periph) { switch (periph) { case PERIPH_SARADC_MODULE: @@ -236,7 +236,7 @@ static uint32_t periph_ll_get_clk_en_reg(periph_module_t periph) } } -static uint32_t periph_ll_get_rst_en_reg(periph_module_t periph) +static inline uint32_t periph_ll_get_rst_en_reg(periph_module_t periph) { switch (periph) { case PERIPH_SARADC_MODULE: diff --git a/components/hal/esp32c6/include/hal/ds_ll.h b/components/hal/esp32c6/include/hal/ds_ll.h index 49f0630c38..2f56cfe9cd 100644 --- a/components/hal/esp32c6/include/hal/ds_ll.h +++ b/components/hal/esp32c6/include/hal/ds_ll.h @@ -17,6 +17,8 @@ #include "soc/hwcrypto_reg.h" #include "soc/soc_caps.h" +#include "hal/ds_types.h" + #ifdef __cplusplus extern "C" { diff --git a/components/hal/esp32c6/include/hal/ecc_ll.h b/components/hal/esp32c6/include/hal/ecc_ll.h index 9df9655e5d..c363c32ec1 100644 --- a/components/hal/esp32c6/include/hal/ecc_ll.h +++ b/components/hal/esp32c6/include/hal/ecc_ll.h @@ -8,6 +8,7 @@ #include #include #include "hal/assert.h" +#include "hal/ecc_types.h" #include "soc/ecc_mult_reg.h" #ifdef __cplusplus diff --git a/components/hal/esp32c6/include/hal/hmac_ll.h b/components/hal/esp32c6/include/hal/hmac_ll.h index f4f95bd836..2911197fcc 100644 --- a/components/hal/esp32c6/include/hal/hmac_ll.h +++ b/components/hal/esp32c6/include/hal/hmac_ll.h @@ -16,7 +16,7 @@ #include "soc/system_reg.h" #include "soc/hwcrypto_reg.h" -#include "hal/hmac_hal.h" +#include "hal/hmac_types.h" #define SHA256_BLOCK_SZ 64 #define SHA256_DIGEST_SZ 32 diff --git a/components/hal/esp32c6/include/hal/lp_periph_clk_ctrl_ll.h b/components/hal/esp32c6/include/hal/lp_periph_clk_ctrl_ll.h index aa8d48d0af..18661243c9 100644 --- a/components/hal/esp32c6/include/hal/lp_periph_clk_ctrl_ll.h +++ b/components/hal/esp32c6/include/hal/lp_periph_clk_ctrl_ll.h @@ -17,7 +17,7 @@ extern "C" { #endif -static uint32_t lp_periph_ll_get_clk_en_mask(lp_periph_module_t lp_periph) +static inline uint32_t lp_periph_ll_get_clk_en_mask(lp_periph_module_t lp_periph) { switch (lp_periph) { case LP_PERIPH_I2C0_MODULE: @@ -30,7 +30,7 @@ static uint32_t lp_periph_ll_get_clk_en_mask(lp_periph_module_t lp_periph) } } -static uint32_t lp_periph_ll_get_rst_en_mask(lp_periph_module_t lp_periph) +static inline uint32_t lp_periph_ll_get_rst_en_mask(lp_periph_module_t lp_periph) { switch (lp_periph) { case LP_PERIPH_I2C0_MODULE: diff --git a/components/hal/esp32c6/include/hal/modem_lpcon_ll.h b/components/hal/esp32c6/include/hal/modem_lpcon_ll.h index 3374defb42..314650c097 100644 --- a/components/hal/esp32c6/include/hal/modem_lpcon_ll.h +++ b/components/hal/esp32c6/include/hal/modem_lpcon_ll.h @@ -9,6 +9,7 @@ #pragma once #include +#include #include "soc/soc.h" #include "hal/assert.h" #include "modem/modem_lpcon_struct.h" diff --git a/components/hal/esp32c6/include/hal/modem_syscon_ll.h b/components/hal/esp32c6/include/hal/modem_syscon_ll.h index 9fc2b50a3e..b3c8e9361d 100644 --- a/components/hal/esp32c6/include/hal/modem_syscon_ll.h +++ b/components/hal/esp32c6/include/hal/modem_syscon_ll.h @@ -9,6 +9,7 @@ #pragma once #include +#include #include "soc/soc.h" #include "hal/assert.h" #include "modem/modem_syscon_struct.h" diff --git a/components/hal/esp32c6/include/hal/mpi_ll.h b/components/hal/esp32c6/include/hal/mpi_ll.h index 8e8a433c75..fbcc4fd2f9 100644 --- a/components/hal/esp32c6/include/hal/mpi_ll.h +++ b/components/hal/esp32c6/include/hal/mpi_ll.h @@ -8,6 +8,7 @@ #include #include #include "hal/assert.h" +#include "hal/mpi_types.h" #include "soc/pcr_reg.h" #include "soc/rsa_reg.h" #include "soc/mpi_periph.h" diff --git a/components/hal/esp32c6/include/hal/sdio_slave_ll.h b/components/hal/esp32c6/include/hal/sdio_slave_ll.h index 29031b9475..5750657429 100644 --- a/components/hal/esp32c6/include/hal/sdio_slave_ll.h +++ b/components/hal/esp32c6/include/hal/sdio_slave_ll.h @@ -16,7 +16,7 @@ #pragma once -#include "hal/sdio_slave_hal.h" +#include "hal/sdio_slave_types.h" #include "soc/slc_struct.h" #include "soc/slc_reg.h" #include "soc/host_struct.h" @@ -24,6 +24,10 @@ #include "soc/hinf_struct.h" #include "soc/lldesc.h" +#ifdef __cplusplus +extern "C" { +#endif + /// Get address of the only SLC registers #define sdio_slave_ll_get_slc(ID) (&SLC) /// Get address of the only HOST registers @@ -507,3 +511,7 @@ static inline void sdio_slave_ll_slvint_fetch_clear(slc_dev_t *slc, sdio_slave_l *out_slv_int = slv_int; slc->slc0int_clr.val = slv_int; } + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/esp32c6/include/hal/spimem_flash_ll.h b/components/hal/esp32c6/include/hal/spimem_flash_ll.h index 71b1335202..1f27caf19e 100644 --- a/components/hal/esp32c6/include/hal/spimem_flash_ll.h +++ b/components/hal/esp32c6/include/hal/spimem_flash_ll.h @@ -22,6 +22,7 @@ #include "soc/spi_periph.h" #include "soc/spi_mem_struct.h" #include "hal/assert.h" +#include "hal/misc.h" #include "hal/spi_types.h" #include "hal/spi_flash_types.h" #include "soc/pcr_struct.h" diff --git a/components/hal/esp32c6/include/hal/twai_ll.h b/components/hal/esp32c6/include/hal/twai_ll.h index 6b3a9d8625..d3d8f3af0b 100644 --- a/components/hal/esp32c6/include/hal/twai_ll.h +++ b/components/hal/esp32c6/include/hal/twai_ll.h @@ -17,6 +17,7 @@ #include #include #include +#include "esp_assert.h" #include "hal/misc.h" #include "hal/assert.h" #include "hal/twai_types.h" @@ -82,7 +83,7 @@ typedef union { uint8_t bytes[13]; } __attribute__((packed)) twai_ll_frame_buffer_t; -_Static_assert(sizeof(twai_ll_frame_buffer_t) == 13, "TX/RX buffer type should be 13 bytes"); +ESP_STATIC_ASSERT(sizeof(twai_ll_frame_buffer_t) == 13, "TX/RX buffer type should be 13 bytes"); /* ---------------------------- Peripheral Control Register ----------------- */ diff --git a/components/hal/esp32h2/include/hal/clk_gate_ll.h b/components/hal/esp32h2/include/hal/clk_gate_ll.h index f1894080c0..f45fead764 100644 --- a/components/hal/esp32h2/include/hal/clk_gate_ll.h +++ b/components/hal/esp32h2/include/hal/clk_gate_ll.h @@ -198,7 +198,7 @@ static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool en } } -static uint32_t periph_ll_get_clk_en_reg(periph_module_t periph) +static inline uint32_t periph_ll_get_clk_en_reg(periph_module_t periph) {// ESP32H2-TODO: IDF-6400 switch (periph) { // case PERIPH_RNG_MODULE: @@ -274,7 +274,7 @@ static uint32_t periph_ll_get_clk_en_reg(periph_module_t periph) } } -static uint32_t periph_ll_get_rst_en_reg(periph_module_t periph) +static inline uint32_t periph_ll_get_rst_en_reg(periph_module_t periph) { // ESP32H2-TODO: IDF-6400 switch (periph) { diff --git a/components/hal/esp32h2/include/hal/ds_ll.h b/components/hal/esp32h2/include/hal/ds_ll.h index 49f0630c38..7a4a3fa353 100644 --- a/components/hal/esp32h2/include/hal/ds_ll.h +++ b/components/hal/esp32h2/include/hal/ds_ll.h @@ -17,6 +17,7 @@ #include "soc/hwcrypto_reg.h" #include "soc/soc_caps.h" +#include "hal/ds_types.h" #ifdef __cplusplus extern "C" { diff --git a/components/hal/esp32h2/include/hal/ecc_ll.h b/components/hal/esp32h2/include/hal/ecc_ll.h index 967d9857ef..eda0458db3 100644 --- a/components/hal/esp32h2/include/hal/ecc_ll.h +++ b/components/hal/esp32h2/include/hal/ecc_ll.h @@ -8,6 +8,7 @@ #include #include #include "hal/assert.h" +#include "hal/ecc_types.h" #include "soc/ecc_mult_reg.h" #ifdef __cplusplus diff --git a/components/hal/esp32h2/include/hal/hmac_ll.h b/components/hal/esp32h2/include/hal/hmac_ll.h index f4f95bd836..2911197fcc 100644 --- a/components/hal/esp32h2/include/hal/hmac_ll.h +++ b/components/hal/esp32h2/include/hal/hmac_ll.h @@ -16,7 +16,7 @@ #include "soc/system_reg.h" #include "soc/hwcrypto_reg.h" -#include "hal/hmac_hal.h" +#include "hal/hmac_types.h" #define SHA256_BLOCK_SZ 64 #define SHA256_DIGEST_SZ 32 diff --git a/components/hal/esp32h2/include/hal/lp_clkrst_ll.h b/components/hal/esp32h2/include/hal/lp_clkrst_ll.h index fcb46921ec..a91f01a857 100644 --- a/components/hal/esp32h2/include/hal/lp_clkrst_ll.h +++ b/components/hal/esp32h2/include/hal/lp_clkrst_ll.h @@ -8,6 +8,7 @@ #pragma once +#include #include #include "soc/soc.h" #include "soc/lp_clkrst_struct.h" diff --git a/components/hal/esp32h2/include/hal/lp_timer_ll.h b/components/hal/esp32h2/include/hal/lp_timer_ll.h index c57588c78f..8f71eabbc6 100644 --- a/components/hal/esp32h2/include/hal/lp_timer_ll.h +++ b/components/hal/esp32h2/include/hal/lp_timer_ll.h @@ -14,6 +14,7 @@ #include "soc/lp_timer_struct.h" #include "soc/lp_aon_reg.h" #include "hal/lp_timer_types.h" +#include "esp_attr.h" #ifdef __cplusplus extern "C" { diff --git a/components/hal/esp32h2/include/hal/modem_lpcon_ll.h b/components/hal/esp32h2/include/hal/modem_lpcon_ll.h index 33977bb12e..b465124d7b 100644 --- a/components/hal/esp32h2/include/hal/modem_lpcon_ll.h +++ b/components/hal/esp32h2/include/hal/modem_lpcon_ll.h @@ -9,6 +9,7 @@ #pragma once #include +#include #include "soc/soc.h" #include "hal/assert.h" #include "modem/modem_lpcon_struct.h" diff --git a/components/hal/esp32h2/include/hal/modem_syscon_ll.h b/components/hal/esp32h2/include/hal/modem_syscon_ll.h index c367c3b194..5d1329d30a 100644 --- a/components/hal/esp32h2/include/hal/modem_syscon_ll.h +++ b/components/hal/esp32h2/include/hal/modem_syscon_ll.h @@ -9,6 +9,7 @@ #pragma once #include +#include #include "soc/soc.h" #include "hal/assert.h" #include "modem/modem_syscon_struct.h" diff --git a/components/hal/esp32h2/include/hal/mpi_ll.h b/components/hal/esp32h2/include/hal/mpi_ll.h index 7ca607c140..790144c972 100644 --- a/components/hal/esp32h2/include/hal/mpi_ll.h +++ b/components/hal/esp32h2/include/hal/mpi_ll.h @@ -8,6 +8,7 @@ #include #include #include "hal/assert.h" +#include "hal/mpi_types.h" #include "soc/pcr_reg.h" #include "soc/rsa_reg.h" #include "soc/mpi_periph.h" diff --git a/components/hal/esp32h2/include/hal/mwdt_ll.h b/components/hal/esp32h2/include/hal/mwdt_ll.h index e25f377240..7e903cf138 100644 --- a/components/hal/esp32h2/include/hal/mwdt_ll.h +++ b/components/hal/esp32h2/include/hal/mwdt_ll.h @@ -27,19 +27,19 @@ extern "C" { #define MWDT_LL_DEFAULT_CLK_PRESCALER 24000 //Type check wdt_stage_action_t -_Static_assert(WDT_STAGE_ACTION_OFF == TIMG_WDT_STG_SEL_OFF, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_stage_action_t"); -_Static_assert(WDT_STAGE_ACTION_INT == TIMG_WDT_STG_SEL_INT, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_stage_action_t"); -_Static_assert(WDT_STAGE_ACTION_RESET_CPU == TIMG_WDT_STG_SEL_RESET_CPU, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_stage_action_t"); -_Static_assert(WDT_STAGE_ACTION_RESET_SYSTEM == TIMG_WDT_STG_SEL_RESET_SYSTEM, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_stage_action_t"); +ESP_STATIC_ASSERT(WDT_STAGE_ACTION_OFF == TIMG_WDT_STG_SEL_OFF, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_stage_action_t"); +ESP_STATIC_ASSERT(WDT_STAGE_ACTION_INT == TIMG_WDT_STG_SEL_INT, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_stage_action_t"); +ESP_STATIC_ASSERT(WDT_STAGE_ACTION_RESET_CPU == TIMG_WDT_STG_SEL_RESET_CPU, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_stage_action_t"); +ESP_STATIC_ASSERT(WDT_STAGE_ACTION_RESET_SYSTEM == TIMG_WDT_STG_SEL_RESET_SYSTEM, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_stage_action_t"); //Type check wdt_reset_sig_length_t -_Static_assert(WDT_RESET_SIG_LENGTH_100ns == TIMG_WDT_RESET_LENGTH_100_NS, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_reset_sig_length_t"); -_Static_assert(WDT_RESET_SIG_LENGTH_200ns == TIMG_WDT_RESET_LENGTH_200_NS, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_reset_sig_length_t"); -_Static_assert(WDT_RESET_SIG_LENGTH_300ns == TIMG_WDT_RESET_LENGTH_300_NS, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_reset_sig_length_t"); -_Static_assert(WDT_RESET_SIG_LENGTH_400ns == TIMG_WDT_RESET_LENGTH_400_NS, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_reset_sig_length_t"); -_Static_assert(WDT_RESET_SIG_LENGTH_500ns == TIMG_WDT_RESET_LENGTH_500_NS, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_reset_sig_length_t"); -_Static_assert(WDT_RESET_SIG_LENGTH_800ns == TIMG_WDT_RESET_LENGTH_800_NS, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_reset_sig_length_t"); -_Static_assert(WDT_RESET_SIG_LENGTH_1_6us == TIMG_WDT_RESET_LENGTH_1600_NS, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_reset_sig_length_t"); -_Static_assert(WDT_RESET_SIG_LENGTH_3_2us == TIMG_WDT_RESET_LENGTH_3200_NS, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_reset_sig_length_t"); +ESP_STATIC_ASSERT(WDT_RESET_SIG_LENGTH_100ns == TIMG_WDT_RESET_LENGTH_100_NS, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_reset_sig_length_t"); +ESP_STATIC_ASSERT(WDT_RESET_SIG_LENGTH_200ns == TIMG_WDT_RESET_LENGTH_200_NS, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_reset_sig_length_t"); +ESP_STATIC_ASSERT(WDT_RESET_SIG_LENGTH_300ns == TIMG_WDT_RESET_LENGTH_300_NS, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_reset_sig_length_t"); +ESP_STATIC_ASSERT(WDT_RESET_SIG_LENGTH_400ns == TIMG_WDT_RESET_LENGTH_400_NS, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_reset_sig_length_t"); +ESP_STATIC_ASSERT(WDT_RESET_SIG_LENGTH_500ns == TIMG_WDT_RESET_LENGTH_500_NS, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_reset_sig_length_t"); +ESP_STATIC_ASSERT(WDT_RESET_SIG_LENGTH_800ns == TIMG_WDT_RESET_LENGTH_800_NS, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_reset_sig_length_t"); +ESP_STATIC_ASSERT(WDT_RESET_SIG_LENGTH_1_6us == TIMG_WDT_RESET_LENGTH_1600_NS, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_reset_sig_length_t"); +ESP_STATIC_ASSERT(WDT_RESET_SIG_LENGTH_3_2us == TIMG_WDT_RESET_LENGTH_3200_NS, "Add mapping to LL watchdog timeout behavior, since it's no longer naturally compatible with wdt_reset_sig_length_t"); /** * @brief Enable the MWDT diff --git a/components/hal/esp32s2/include/hal/crypto_dma_ll.h b/components/hal/esp32s2/include/hal/crypto_dma_ll.h index 5c65c9249a..5520d807b9 100644 --- a/components/hal/esp32s2/include/hal/crypto_dma_ll.h +++ b/components/hal/esp32s2/include/hal/crypto_dma_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /******************************************************************************* * NOTICE @@ -23,7 +15,9 @@ extern "C" { #endif +#include #include "soc/hwcrypto_reg.h" +#include "soc/crypto_dma_reg.h" #include "soc/dport_reg.h" typedef enum { diff --git a/components/hal/esp32s2/include/hal/dac_ll.h b/components/hal/esp32s2/include/hal/dac_ll.h index e6b239dd12..dc4e85af24 100644 --- a/components/hal/esp32s2/include/hal/dac_ll.h +++ b/components/hal/esp32s2/include/hal/dac_ll.h @@ -13,6 +13,7 @@ #pragma once #include +#include #include "hal/misc.h" #include "soc/dac_periph.h" #include "hal/dac_types.h" diff --git a/components/hal/esp32s2/include/hal/dedic_gpio_ll.h b/components/hal/esp32s2/include/hal/dedic_gpio_ll.h index 8fcdd0e7a6..5f9e2b41a3 100644 --- a/components/hal/esp32s2/include/hal/dedic_gpio_ll.h +++ b/components/hal/esp32s2/include/hal/dedic_gpio_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #ifdef __cplusplus diff --git a/components/hal/esp32s2/include/hal/memprot_ll.h b/components/hal/esp32s2/include/hal/memprot_ll.h index da2ad85415..191a49e56b 100644 --- a/components/hal/esp32s2/include/hal/memprot_ll.h +++ b/components/hal/esp32s2/include/hal/memprot_ll.h @@ -10,6 +10,8 @@ #include "soc/memprot_defs.h" #include "hal/memprot_types.h" #include "soc/dport_reg.h" +#include "soc/dport_access.h" +#include "soc/periph_defs.h" #ifdef __cplusplus extern "C" { diff --git a/components/hal/esp32s2/include/hal/memprot_peri_ll.h b/components/hal/esp32s2/include/hal/memprot_peri_ll.h index f38bdee1f1..7afaaf2200 100644 --- a/components/hal/esp32s2/include/hal/memprot_peri_ll.h +++ b/components/hal/esp32s2/include/hal/memprot_peri_ll.h @@ -8,6 +8,8 @@ #include #include "soc/memprot_defs.h" +#include "soc/dport_access.h" +#include "soc/periph_defs.h" #include "hal/memprot_types.h" #ifdef __cplusplus diff --git a/components/hal/esp32s2/include/hal/mmu_ll.h b/components/hal/esp32s2/include/hal/mmu_ll.h index 6c067dd1ae..ddf3f2cf79 100644 --- a/components/hal/esp32s2/include/hal/mmu_ll.h +++ b/components/hal/esp32s2/include/hal/mmu_ll.h @@ -8,7 +8,8 @@ #pragma once -#include "stdint.h" +#include +#include #include "soc/extmem_reg.h" #include "soc/ext_mem_defs.h" #include "hal/assert.h" diff --git a/components/hal/esp32s2/include/hal/mpi_ll.h b/components/hal/esp32s2/include/hal/mpi_ll.h index 01f758ffb1..0a946b17be 100644 --- a/components/hal/esp32s2/include/hal/mpi_ll.h +++ b/components/hal/esp32s2/include/hal/mpi_ll.h @@ -8,6 +8,7 @@ #include #include #include "hal/assert.h" +#include "hal/mpi_types.h" #include "soc/hwcrypto_periph.h" #include "soc/dport_reg.h" #include "soc/mpi_periph.h" diff --git a/components/hal/esp32s2/include/hal/mpu_ll.h b/components/hal/esp32s2/include/hal/mpu_ll.h index 2ec955b48f..fa00a39954 100644 --- a/components/hal/esp32s2/include/hal/mpu_ll.h +++ b/components/hal/esp32s2/include/hal/mpu_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include diff --git a/components/hal/esp32s2/include/hal/sha_ll.h b/components/hal/esp32s2/include/hal/sha_ll.h index c8d8424c3c..c3de468df1 100644 --- a/components/hal/esp32s2/include/hal/sha_ll.h +++ b/components/hal/esp32s2/include/hal/sha_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include diff --git a/components/hal/esp32s2/include/hal/spi_flash_encrypted_ll.h b/components/hal/esp32s2/include/hal/spi_flash_encrypted_ll.h index dd4a5bd226..34d38742cf 100644 --- a/components/hal/esp32s2/include/hal/spi_flash_encrypted_ll.h +++ b/components/hal/esp32s2/include/hal/spi_flash_encrypted_ll.h @@ -1,16 +1,8 @@ -// Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /******************************************************************************* * NOTICE diff --git a/components/hal/esp32s2/include/hal/spimem_flash_ll.h b/components/hal/esp32s2/include/hal/spimem_flash_ll.h index ed2dc569e4..c07e5a0137 100644 --- a/components/hal/esp32s2/include/hal/spimem_flash_ll.h +++ b/components/hal/esp32s2/include/hal/spimem_flash_ll.h @@ -24,6 +24,7 @@ #include "hal/assert.h" #include "hal/spi_types.h" #include "hal/spi_flash_types.h" +#include "hal/misc.h" #ifdef __cplusplus extern "C" { diff --git a/components/hal/esp32s2/include/hal/trace_ll.h b/components/hal/esp32s2/include/hal/trace_ll.h index a9befdf87d..5b2031e708 100644 --- a/components/hal/esp32s2/include/hal/trace_ll.h +++ b/components/hal/esp32s2/include/hal/trace_ll.h @@ -1,23 +1,23 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include "esp_bit_defs.h" #include "soc/dport_reg.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void trace_ll_set_mem_block(int block) { DPORT_WRITE_PERI_REG(DPORT_PMS_OCCUPY_3_REG, BIT(block-4)); } + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/esp32s2/include/hal/usb_ll.h b/components/hal/esp32s2/include/hal/usb_ll.h index 2be637f55c..121c01d597 100644 --- a/components/hal/esp32s2/include/hal/usb_ll.h +++ b/components/hal/esp32s2/include/hal/usb_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include "soc/soc.h" @@ -18,6 +10,10 @@ #include "soc/gpio_sig_map.h" #include "soc/usb_periph.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void usb_ll_int_phy_enable(void) { USB_WRAP.otg_conf.pad_enable = 1; @@ -40,3 +36,7 @@ static inline void usb_ll_int_phy_pullup_conf(bool dp_pu, bool dp_pd, bool dm_pu conf.dm_pulldown = dm_pd; USB_WRAP.otg_conf = conf; } + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/esp32s3/include/hal/clk_gate_ll.h b/components/hal/esp32s3/include/hal/clk_gate_ll.h index d3bd68d085..38a0539aa8 100644 --- a/components/hal/esp32s3/include/hal/clk_gate_ll.h +++ b/components/hal/esp32s3/include/hal/clk_gate_ll.h @@ -196,7 +196,7 @@ static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool en } } -static uint32_t periph_ll_get_clk_en_reg(periph_module_t periph) +static inline uint32_t periph_ll_get_clk_en_reg(periph_module_t periph) { switch (periph) { case PERIPH_DEDIC_GPIO_MODULE: @@ -223,7 +223,7 @@ static uint32_t periph_ll_get_clk_en_reg(periph_module_t periph) } } -static uint32_t periph_ll_get_rst_en_reg(periph_module_t periph) +static inline uint32_t periph_ll_get_rst_en_reg(periph_module_t periph) { switch (periph) { case PERIPH_DEDIC_GPIO_MODULE: diff --git a/components/hal/esp32s3/include/hal/ds_ll.h b/components/hal/esp32s3/include/hal/ds_ll.h index f5ae99074c..928533a65e 100644 --- a/components/hal/esp32s3/include/hal/ds_ll.h +++ b/components/hal/esp32s3/include/hal/ds_ll.h @@ -12,6 +12,7 @@ #include "soc/hwcrypto_reg.h" #include "soc/soc_caps.h" +#include "hal/ds_types.h" #ifdef __cplusplus extern "C" { diff --git a/components/hal/esp32s3/include/hal/hmac_ll.h b/components/hal/esp32s3/include/hal/hmac_ll.h index 49967c3f20..ba9cecbaa7 100644 --- a/components/hal/esp32s3/include/hal/hmac_ll.h +++ b/components/hal/esp32s3/include/hal/hmac_ll.h @@ -14,6 +14,7 @@ #include /* For size_t type */ #include "soc/hwcrypto_reg.h" +#include "hal/hmac_types.h" #define SHA256_BLOCK_SZ 64 #define SHA256_DIGEST_SZ 32 diff --git a/components/hal/esp32s3/include/hal/memprot_ll.h b/components/hal/esp32s3/include/hal/memprot_ll.h index ccb99c77bd..49c9553bb2 100644 --- a/components/hal/esp32s3/include/hal/memprot_ll.h +++ b/components/hal/esp32s3/include/hal/memprot_ll.h @@ -6,10 +6,12 @@ #pragma once +#include #include "soc/ext_mem_defs.h" #include "soc/memprot_defs.h" #include "hal/memprot_types.h" #include "soc/sensitive_reg.h" +#include "soc/periph_defs.h" /* Uncomment to enable MPS debug assertions on false register writes. * It irregularly happens the PMS registers cannot be written which causes unpredictable malfunction of the Memprot feature @@ -27,15 +29,14 @@ extern "C" { //highest address of each Level slot in the SRAM's 3rd memory region (I/D access, 416kB) //quick resolver of split-address category bits -static const intptr_t sram_rg3_level_hlimits[] = { - 0x4037FFFF, //level 2 (32KB) - 0x4038FFFF, //level 3 (64KB) - 0x4039FFFF, //level 4 (64KB) - 0x403AFFFF, //level 5 (64KB) - 0x403BFFFF, //level 6 (64KB) - 0x403CFFFF, //level 7 (64KB) - 0x403DFFFF //level 8 (64KB) -}; +// 0x4037FFFF level 2 (32KB) +// 0x4038FFFF level 3 (64KB) +// 0x4039FFFF level 4 (64KB) +// 0x403AFFFF level 5 (64KB) +// 0x403BFFFF level 6 (64KB) +// 0x403CFFFF level 7 (64KB) +// 0x403DFFFF level 8 (64KB) +#define SRAM_RG3_LEVEL_HLIMITS(level) ((intptr_t[]) {0x4037FFFF,0x4038FFFF,0x4039FFFF,0x403AFFFF,0x403BFFFF,0x403CFFFF,0x403DFFFF} [(level)]) /* ****************************************************************************************************** * *** COMMON *** @@ -178,7 +179,7 @@ static inline void memprot_ll_prepare_iram0_split_line_regval(const uint32_t add //set category bits for given split line uint32_t cat[7] = {[0 ... 6]=MEMP_HAL_CORE_X_IRAM0_DRAM0_DMA_SRAM_CATEGORY_BITS_ABOVE_SA}; for (size_t x=0; x<7; x++) { - if (addr <= sram_rg3_level_hlimits[x]) { + if (addr <= SRAM_RG3_LEVEL_HLIMITS(x)) { cat[x] = MEMP_HAL_CORE_X_IRAM0_DRAM0_DMA_SRAM_CATEGORY_BITS_EQUAL_SA; break; } else { @@ -1252,7 +1253,7 @@ static inline void memprot_ll_prepare_dram0_split_line_regval(const uint32_t add //set category bits for given split line uint32_t cat[7] = {[0 ... 6]=MEMP_HAL_CORE_X_IRAM0_DRAM0_DMA_SRAM_CATEGORY_BITS_ABOVE_SA}; for (size_t x=0; x<7; x++) { - if (addr <= MAP_IRAM_TO_DRAM(sram_rg3_level_hlimits[x])) { + if (addr <= MAP_IRAM_TO_DRAM(SRAM_RG3_LEVEL_HLIMITS(x))) { cat[x] = MEMP_HAL_CORE_X_IRAM0_DRAM0_DMA_SRAM_CATEGORY_BITS_EQUAL_SA; break; } else { diff --git a/components/hal/esp32s3/include/hal/mpi_ll.h b/components/hal/esp32s3/include/hal/mpi_ll.h index 018ff06757..d6934b5353 100644 --- a/components/hal/esp32s3/include/hal/mpi_ll.h +++ b/components/hal/esp32s3/include/hal/mpi_ll.h @@ -8,6 +8,7 @@ #include #include #include "hal/assert.h" +#include "hal/mpi_types.h" #include "soc/hwcrypto_periph.h" #include "soc/dport_reg.h" #include "soc/mpi_periph.h" diff --git a/components/hal/esp32s3/include/hal/mpu_ll.h b/components/hal/esp32s3/include/hal/mpu_ll.h index 2ec955b48f..fa00a39954 100644 --- a/components/hal/esp32s3/include/hal/mpu_ll.h +++ b/components/hal/esp32s3/include/hal/mpu_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include diff --git a/components/hal/esp32s3/include/hal/regi2c_ctrl_ll.h b/components/hal/esp32s3/include/hal/regi2c_ctrl_ll.h index f194bedfc4..573b22c9a1 100644 --- a/components/hal/esp32s3/include/hal/regi2c_ctrl_ll.h +++ b/components/hal/esp32s3/include/hal/regi2c_ctrl_ll.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include "soc/soc.h" #include "soc/regi2c_defs.h" diff --git a/components/hal/esp32s3/include/hal/rwdt_ll.h b/components/hal/esp32s3/include/hal/rwdt_ll.h index f7a295a6bf..74deaaada3 100644 --- a/components/hal/esp32s3/include/hal/rwdt_ll.h +++ b/components/hal/esp32s3/include/hal/rwdt_ll.h @@ -16,6 +16,7 @@ extern "C" { #include #include #include "hal/wdt_types.h" +#include "hal/misc.h" #include "soc/rtc_cntl_periph.h" #include "soc/rtc_cntl_struct.h" #include "soc/efuse_reg.h" diff --git a/components/hal/esp32s3/include/hal/sha_ll.h b/components/hal/esp32s3/include/hal/sha_ll.h index fa660f040f..83216042ab 100644 --- a/components/hal/esp32s3/include/hal/sha_ll.h +++ b/components/hal/esp32s3/include/hal/sha_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include diff --git a/components/hal/esp32s3/include/hal/spi_flash_encrypted_ll.h b/components/hal/esp32s3/include/hal/spi_flash_encrypted_ll.h index 7dac0c41b5..cac478ee51 100644 --- a/components/hal/esp32s3/include/hal/spi_flash_encrypted_ll.h +++ b/components/hal/esp32s3/include/hal/spi_flash_encrypted_ll.h @@ -1,16 +1,8 @@ -// Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /******************************************************************************* * NOTICE diff --git a/components/hal/esp32s3/include/hal/spimem_flash_ll.h b/components/hal/esp32s3/include/hal/spimem_flash_ll.h index ddc49a9f4e..71af38fcba 100644 --- a/components/hal/esp32s3/include/hal/spimem_flash_ll.h +++ b/components/hal/esp32s3/include/hal/spimem_flash_ll.h @@ -24,6 +24,7 @@ #include "soc/spi_mem_struct.h" #include "hal/spi_types.h" #include "hal/spi_flash_types.h" +#include "hal/misc.h" #ifdef __cplusplus extern "C" { diff --git a/components/hal/esp32s3/include/hal/trace_ll.h b/components/hal/esp32s3/include/hal/trace_ll.h index ccf4e88553..df2afeacb9 100644 --- a/components/hal/esp32s3/include/hal/trace_ll.h +++ b/components/hal/esp32s3/include/hal/trace_ll.h @@ -10,6 +10,10 @@ #include "soc/dport_reg.h" #include "soc/tracemem_config.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void trace_ll_set_mem_block(int cpu, int block) { uint32_t block_bits = 0; @@ -21,3 +25,7 @@ static inline void trace_ll_set_mem_block(int cpu, int block) } DPORT_SET_PERI_REG_MASK(SENSITIVE_INTERNAL_SRAM_USAGE_2_REG, block_bits); } + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/esp32s3/include/hal/uhci_ll.h b/components/hal/esp32s3/include/hal/uhci_ll.h index 0ea4440853..d48cf86777 100644 --- a/components/hal/esp32s3/include/hal/uhci_ll.h +++ b/components/hal/esp32s3/include/hal/uhci_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ // The LL layer for UHCI register operations. // Note that most of the register operations in this layer are non-atomic operations. diff --git a/components/hal/esp32s3/include/hal/usb_ll.h b/components/hal/esp32s3/include/hal/usb_ll.h index 81950021d2..40eca13e61 100644 --- a/components/hal/esp32s3/include/hal/usb_ll.h +++ b/components/hal/esp32s3/include/hal/usb_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include "soc/soc.h" @@ -19,6 +11,10 @@ #include "soc/usb_periph.h" #include "soc/rtc_cntl_struct.h" +#ifdef __cplusplus +extern "C" { +#endif + static inline void usb_ll_int_phy_enable(void) { USB_WRAP.otg_conf.pad_enable = 1; @@ -51,3 +47,7 @@ static inline void usb_ll_int_phy_pullup_conf(bool dp_pu, bool dp_pd, bool dm_pu conf.dm_pulldown = dm_pd; USB_WRAP.otg_conf = conf; } + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/adc_types.h b/components/hal/include/hal/adc_types.h index 51f64927e0..b5bf184dea 100644 --- a/components/hal/include/hal/adc_types.h +++ b/components/hal/include/hal/adc_types.h @@ -12,6 +12,10 @@ #include "soc/clk_tree_defs.h" #include "esp_attr.h" +#ifdef __cplusplus +extern "C" { +#endif + /** * @brief ADC unit */ @@ -241,3 +245,7 @@ typedef struct { uint32_t div_a; /*! #include #include "esp_attr.h" +#include "soc/soc_caps.h" +#if SOC_ASSIST_DEBUG_SUPPORTED #include "hal/assist_debug_ll.h" +#endif #ifdef __cplusplus extern "C" { diff --git a/components/hal/include/hal/cache_hal.h b/components/hal/include/hal/cache_hal.h index 8881da6f68..8464c48f88 100644 --- a/components/hal/include/hal/cache_hal.h +++ b/components/hal/include/hal/cache_hal.h @@ -8,6 +8,7 @@ #pragma once #include +#include #include "hal/cache_types.h" #ifdef __cplusplus diff --git a/components/hal/include/hal/ds_hal.h b/components/hal/include/hal/ds_hal.h index 40d5c35893..bf9a18df5d 100644 --- a/components/hal/include/hal/ds_hal.h +++ b/components/hal/include/hal/ds_hal.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /******************************************************************************* * NOTICE @@ -20,34 +12,15 @@ #pragma once -#if CONFIG_IDF_TARGET_ESP32 -#error "ESP32 doesn't have a DS peripheral" -#endif - #include #include #include +#include "hal/ds_types.h" #ifdef __cplusplus extern "C" { #endif -/** - * The result when checking whether the key to decrypt the RSA parameters is ready. - */ -typedef enum { - DS_KEY_INPUT_OK = 0, /**< The decryption key is ready. */ - DS_NO_KEY_INPUT, /**< Dependent peripheral providing key hasn't been activated. */ - DS_OTHER_WRONG, /**< Dependent peripheral running but problem receiving the key. */ -} ds_key_check_t; - -typedef enum { - DS_SIGNATURE_OK = 0, /**< Signature is valid and can be read. */ - DS_SIGNATURE_PADDING_FAIL = 1, /**< Padding invalid, signature can be read if user wants it. */ - DS_SIGNATURE_MD_FAIL = 2, /**< Message digest check failed, signature invalid. */ - DS_SIGNATURE_PADDING_AND_MD_FAIL = 3, /**< Both padding and MD check failed. */ -} ds_signature_check_t; - /** * @brief Start the whole signing process after the input key is ready. * diff --git a/components/hal/include/hal/ds_types.h b/components/hal/include/hal/ds_types.h new file mode 100644 index 0000000000..f739a11b66 --- /dev/null +++ b/components/hal/include/hal/ds_types.h @@ -0,0 +1,30 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The result when checking whether the key to decrypt the RSA parameters is ready. + */ +typedef enum { + DS_KEY_INPUT_OK = 0, /**< The decryption key is ready. */ + DS_NO_KEY_INPUT, /**< Dependent peripheral providing key hasn't been activated. */ + DS_OTHER_WRONG, /**< Dependent peripheral running but problem receiving the key. */ +} ds_key_check_t; + +typedef enum { + DS_SIGNATURE_OK = 0, /**< Signature is valid and can be read. */ + DS_SIGNATURE_PADDING_FAIL = 1, /**< Padding invalid, signature can be read if user wants it. */ + DS_SIGNATURE_MD_FAIL = 2, /**< Message digest check failed, signature invalid. */ + DS_SIGNATURE_PADDING_AND_MD_FAIL = 3, /**< Both padding and MD check failed. */ +} ds_signature_check_t; + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/ecc_types.h b/components/hal/include/hal/ecc_types.h index 17ce834917..497fb5222c 100644 --- a/components/hal/include/hal/ecc_types.h +++ b/components/hal/include/hal/ecc_types.h @@ -5,6 +5,10 @@ */ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + typedef enum { ECC_MODE_POINT_MUL = 0x0, // (Rx, Ry) = K * (Px, Py) ECC_MODE_INVERSE_MUL, // R = K^(-1) * Py @@ -28,3 +32,7 @@ typedef enum { ECC_MOD_N, // Order of the curve ECC_MOD_P, // Prime modulus } ecc_mod_base_t; + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/emac_hal.h b/components/hal/include/hal/emac_hal.h index ef99c56732..80a00d9312 100644 --- a/components/hal/include/hal/emac_hal.h +++ b/components/hal/include/hal/emac_hal.h @@ -6,17 +6,22 @@ #pragma once -#ifdef __cplusplus -extern "C" { -#endif + #include #include #include "esp_assert.h" #include "esp_err.h" #include "hal/eth_types.h" +#include "soc/soc_caps.h" +#ifdef __cplusplus +extern "C" { +#endif +#if SOC_EMAC_SUPPORTED #include "hal/emac_ll.h" + + /** * @brief Indicate to ::emac_hal_receive_frame that receive frame buffer was allocated by ::emac_hal_alloc_recv_buf * @@ -377,6 +382,8 @@ static inline void emac_hal_clear_all_intr(emac_hal_context_t *hal) emac_ll_clear_all_pending_intr(hal->dma_regs); } +#endif // SOC_EMAC_SUPPORTED + #ifdef __cplusplus } #endif diff --git a/components/hal/include/hal/esp_flash_err.h b/components/hal/include/hal/esp_flash_err.h index 3da8b56de9..5e5214015d 100644 --- a/components/hal/include/hal/esp_flash_err.h +++ b/components/hal/include/hal/esp_flash_err.h @@ -1,16 +1,8 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once diff --git a/components/hal/include/hal/eth_types.h b/components/hal/include/hal/eth_types.h index d7d1f2ec4a..018d958f15 100644 --- a/components/hal/include/hal/eth_types.h +++ b/components/hal/include/hal/eth_types.h @@ -5,6 +5,10 @@ */ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + /** * @brief Ethernet interface * @@ -61,3 +65,7 @@ typedef enum { ETH_DMA_BURST_LEN_2, ETH_DMA_BURST_LEN_1, } eth_mac_dma_burst_len_t; + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/gdma_hal.h b/components/hal/include/hal/gdma_hal.h index 233f2e3b1c..4ed01d56a3 100644 --- a/components/hal/include/hal/gdma_hal.h +++ b/components/hal/include/hal/gdma_hal.h @@ -16,6 +16,10 @@ extern "C" { #endif +#include "soc/soc_caps.h" + +#if SOC_GDMA_SUPPORTED + #include "soc/gdma_struct.h" typedef struct { @@ -24,6 +28,8 @@ typedef struct { void gdma_hal_init(gdma_hal_context_t *hal, int group_id); +#endif + #ifdef __cplusplus } #endif diff --git a/components/hal/include/hal/hmac_hal.h b/components/hal/include/hal/hmac_hal.h index b5eb6c4196..1dcbd0e6fc 100644 --- a/components/hal/include/hal/hmac_hal.h +++ b/components/hal/include/hal/hmac_hal.h @@ -14,22 +14,12 @@ #include #include +#include "hal/hmac_types.h" #ifdef __cplusplus extern "C" { #endif -/** - * The HMAC peripheral can be configured to deliver its output to the user directly, or to deliver - * the output directly to another peripheral instead, e.g. the Digital Signature peripheral. - */ -typedef enum { - HMAC_OUTPUT_USER = 0, /**< Let user provide a message and read the HMAC result */ - HMAC_OUTPUT_DS = 1, /**< HMAC is provided to the DS peripheral to decrypt DS private key parameters */ - HMAC_OUTPUT_JTAG_ENABLE = 2, /**< HMAC is used to enable JTAG after soft-disabling it */ - HMAC_OUTPUT_ALL = 3 /**< HMAC is used for both as DS input for or enabling JTAG */ -} hmac_hal_output_t; - /** * @brief Make the peripheral ready for use. * diff --git a/components/hal/include/hal/hmac_types.h b/components/hal/include/hal/hmac_types.h new file mode 100644 index 0000000000..af309b3fe5 --- /dev/null +++ b/components/hal/include/hal/hmac_types.h @@ -0,0 +1,25 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The HMAC peripheral can be configured to deliver its output to the user directly, or to deliver + * the output directly to another peripheral instead, e.g. the Digital Signature peripheral. + */ +typedef enum { + HMAC_OUTPUT_USER = 0, /**< Let user provide a message and read the HMAC result */ + HMAC_OUTPUT_DS = 1, /**< HMAC is provided to the DS peripheral to decrypt DS private key parameters */ + HMAC_OUTPUT_JTAG_ENABLE = 2, /**< HMAC is used to enable JTAG after soft-disabling it */ + HMAC_OUTPUT_ALL = 3 /**< HMAC is used for both as DS input for or enabling JTAG */ +} hmac_hal_output_t; + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/i2s_hal.h b/components/hal/include/hal/i2s_hal.h index 7a76741f9f..d6ca077e36 100644 --- a/components/hal/include/hal/i2s_hal.h +++ b/components/hal/include/hal/i2s_hal.h @@ -16,13 +16,16 @@ #pragma once #include "soc/soc_caps.h" +#if SOC_I2S_SUPPORTED #include "hal/i2s_types.h" #include "hal/i2s_ll.h" +#endif #ifdef __cplusplus extern "C" { #endif +#if SOC_I2S_SUPPORTED /** * @brief General slot configuration information * @note It is a general purpose struct, not supposed to be used directly by user @@ -454,6 +457,8 @@ void i2s_hal_tdm_enable_rx_channel(i2s_hal_context_t *hal); #define i2s_hal_get_in_eof_des_addr(hal, addr) i2s_ll_rx_get_eof_des_addr((hal)->dev, addr) #endif +#endif // SOC_I2S_SUPPORTED + #ifdef __cplusplus } #endif diff --git a/components/hal/include/hal/ieee802154_common_ll.h b/components/hal/include/hal/ieee802154_common_ll.h index 45f077bb4a..cda2217caa 100644 --- a/components/hal/include/hal/ieee802154_common_ll.h +++ b/components/hal/include/hal/ieee802154_common_ll.h @@ -8,14 +8,20 @@ #include #include +#include "soc/soc_caps.h" + +#if SOC_IEEE802154_SUPPORTED #include "soc/ieee802154_reg.h" #include "soc/ieee802154_struct.h" #include "esp_attr.h" +#endif #ifdef __cplusplus extern "C" { #endif +#if SOC_IEEE802154_SUPPORTED + /** * @brief IEEE802154 opcode. */ @@ -449,6 +455,8 @@ static inline void ieee802154_ll_disable_coex(void) IEEE802154.pti.hw_ack_pti = 1; } +#endif + #ifdef __cplusplus } #endif diff --git a/components/hal/include/hal/ledc_hal.h b/components/hal/include/hal/ledc_hal.h index 1124e82a7b..cf912fdd8e 100644 --- a/components/hal/include/hal/ledc_hal.h +++ b/components/hal/include/hal/ledc_hal.h @@ -19,6 +19,10 @@ #include "hal/ledc_types.h" #include "soc/soc_caps.h" +#ifdef __cplusplus +extern "C" { +#endif + /** * Context that should be maintained by both the driver and the HAL */ @@ -434,3 +438,7 @@ void ledc_hal_clear_fade_end_intr_status(ledc_hal_context_t *hal, ledc_channel_t * @return None */ void ledc_hal_get_clk_cfg(ledc_hal_context_t *hal, ledc_timer_t timer_sel, ledc_clk_cfg_t *clk_cfg); + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/lp_timer_hal.h b/components/hal/include/hal/lp_timer_hal.h index b9e551c5dd..8ca557e676 100644 --- a/components/hal/include/hal/lp_timer_hal.h +++ b/components/hal/include/hal/lp_timer_hal.h @@ -9,13 +9,17 @@ #include #include #include +#include "soc/soc_caps.h" #include "soc/soc.h" +#if SOC_LP_TIMER_SUPPORTED #include "hal/lp_timer_types.h" +#endif #ifdef __cplusplus extern "C" { #endif +#if SOC_LP_TIMER_SUPPORTED /* * @brief set alarm target value * @@ -40,6 +44,8 @@ void lp_timer_hal_clear_alarm_intr_status(void); */ void lp_timer_hal_clear_overflow_intr_status(void); +#endif + #ifdef __cplusplus } #endif diff --git a/components/hal/include/hal/lp_timer_types.h b/components/hal/include/hal/lp_timer_types.h index ebb808ca50..f9fde84198 100644 --- a/components/hal/include/hal/lp_timer_types.h +++ b/components/hal/include/hal/lp_timer_types.h @@ -16,6 +16,7 @@ extern "C" { /** * @brief The structure of the counter value in lower power timer */ +#if SOC_LP_TIMER_SUPPORTED typedef struct { union { struct { @@ -26,6 +27,7 @@ typedef struct { uint64_t val; /*!< counter value */ }; } lp_timer_counter_value_t; +#endif #ifdef __cplusplus } diff --git a/components/hal/include/hal/memprot_types.h b/components/hal/include/hal/memprot_types.h index 0c0e7ee797..fe570142ae 100644 --- a/components/hal/include/hal/memprot_types.h +++ b/components/hal/include/hal/memprot_types.h @@ -7,12 +7,17 @@ #pragma once #include "soc/soc.h" +#include "soc/soc_caps.h" +#if SOC_MEMPROT_SUPPORTED #include "soc/memprot_defs.h" +#endif #ifdef __cplusplus extern "C" { #endif +#if SOC_MEMPROT_SUPPORTED + /** * @brief Memprot LL error codes * @@ -59,6 +64,8 @@ typedef enum { #define MEMP_HAL_CORE_X_IRAM0_DRAM0_DMA_SRAM_CATEGORY_BITS_EQUAL_SA 0x2 //0b10 #define MEMP_HAL_CORE_X_IRAM0_DRAM0_DMA_SRAM_CATEGORY_BITS_ABOVE_SA 0x3 //0b11 +#endif + #ifdef __cplusplus } #endif diff --git a/components/hal/include/hal/modem_clock_hal.h b/components/hal/include/hal/modem_clock_hal.h index 9912308f5e..4df1a2c452 100644 --- a/components/hal/include/hal/modem_clock_hal.h +++ b/components/hal/include/hal/modem_clock_hal.h @@ -8,15 +8,16 @@ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include "soc/soc_caps.h" +#if SOC_MODEM_CLOCK_IS_INDEPENDENT #include "hal/modem_syscon_ll.h" #include "hal/modem_lpcon_ll.h" #include "hal/modem_clock_types.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef struct { modem_syscon_dev_t *syscon_dev; modem_lpcon_dev_t *lpcon_dev; @@ -46,3 +47,5 @@ void modem_clock_hal_deselect_all_wifi_lpclk_source(modem_clock_hal_context_t *h #ifdef __cplusplus } #endif + +#endif // SOC_MODEM_CLOCK_IS_INDEPENDENT diff --git a/components/hal/include/hal/mpi_hal.h b/components/hal/include/hal/mpi_hal.h index c06779f20c..5a3c7002eb 100644 --- a/components/hal/include/hal/mpi_hal.h +++ b/components/hal/include/hal/mpi_hal.h @@ -13,10 +13,11 @@ #pragma once #include +#include #include #include "hal/mpi_types.h" +#include "sdkconfig.h" -#include "stdint.h" #ifdef __cplusplus extern "C" { diff --git a/components/hal/include/hal/mpi_types.h b/components/hal/include/hal/mpi_types.h index 25a5eeef20..c38fbe19c1 100644 --- a/components/hal/include/hal/mpi_types.h +++ b/components/hal/include/hal/mpi_types.h @@ -5,6 +5,11 @@ */ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + + typedef enum { MPI_MULT = 0x0, // (X * Y) MPI_MODMULT, // (X * Y) Mod M @@ -17,3 +22,7 @@ typedef enum { MPI_PARAM_Z, MPI_PARAM_M, } mpi_param_t; + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/mpu_hal.h b/components/hal/include/hal/mpu_hal.h index f1a7103fc7..c6559c0c24 100644 --- a/components/hal/include/hal/mpu_hal.h +++ b/components/hal/include/hal/mpu_hal.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include diff --git a/components/hal/include/hal/mpu_types.h b/components/hal/include/hal/mpu_types.h index cc7da62a93..22a838f0e6 100644 --- a/components/hal/include/hal/mpu_types.h +++ b/components/hal/include/hal/mpu_types.h @@ -1,21 +1,17 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include #include "soc/soc_caps.h" +#ifdef __cplusplus +extern "C" { +#endif + #if SOC_MPU_CONFIGURABLE_REGIONS_SUPPORTED typedef void** mpu_region_table_t; #endif @@ -32,3 +28,7 @@ typedef enum { MPU_REGION_X, // executable MPU_REGION_RWX // read-write-executable } mpu_access_t; + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/pau_hal.h b/components/hal/include/hal/pau_hal.h index 5aae8900f5..197fd63572 100644 --- a/components/hal/include/hal/pau_hal.h +++ b/components/hal/include/hal/pau_hal.h @@ -13,9 +13,11 @@ extern "C" { #endif #include "soc/soc_caps.h" +#if SOC_PAU_SUPPORTED #include "hal/pau_ll.h" #include "hal/pau_types.h" + typedef struct { pau_dev_t *dev; } pau_hal_context_t; @@ -109,6 +111,8 @@ void pau_hal_stop_regdma_extra_link(pau_hal_context_t *hal); void pau_hal_regdma_clock_configure(pau_hal_context_t *hal, bool enable); #endif +#endif + #ifdef __cplusplus } #endif diff --git a/components/hal/include/hal/pau_types.h b/components/hal/include/hal/pau_types.h index 19b4028f5a..df9f82f76a 100644 --- a/components/hal/include/hal/pau_types.h +++ b/components/hal/include/hal/pau_types.h @@ -8,9 +8,20 @@ #include "sdkconfig.h" #include "soc/soc_caps.h" +#ifdef __cplusplus +extern "C" { +#endif + +#if SOC_PAU_SUPPORTED #define PAU_REGDMA_LINK_NUM (SOC_PM_PAU_LINK_NUM) /** * @brief PAU REGDMA all link address buffer */ typedef void * pau_regdma_link_addr_t[PAU_REGDMA_LINK_NUM]; + +#endif + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/rtc_hal.h b/components/hal/include/hal/rtc_hal.h index 6848d559d8..182117e849 100644 --- a/components/hal/include/hal/rtc_hal.h +++ b/components/hal/include/hal/rtc_hal.h @@ -9,11 +9,18 @@ #include #include "soc/soc_caps.h" #include "hal/gpio_types.h" + +#if !SOC_LP_TIMER_SUPPORTED #include "hal/rtc_cntl_ll.h" +#endif #if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED #include "hal/rtc_io_ll.h" #endif +#ifdef __cplusplus +extern "C" { +#endif + typedef struct rtc_cntl_sleep_retent { #if SOC_PM_SUPPORT_CPU_PD void *cpu_pd_mem; /* Internal ram address for cpu retention */ @@ -87,3 +94,7 @@ void rtc_cntl_hal_disable_tagmem_retention(void *addr); #define rtc_hal_ulp_wakeup_enable() rtc_cntl_ll_ulp_wakeup_enable() #define rtc_hal_ulp_int_clear() rtc_cntl_ll_ulp_int_clear() + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/rtc_io_types.h b/components/hal/include/hal/rtc_io_types.h index 9f010aeff6..6480f23708 100644 --- a/components/hal/include/hal/rtc_io_types.h +++ b/components/hal/include/hal/rtc_io_types.h @@ -1,19 +1,15 @@ -// Copyright 2019 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + /** RTCIO output/input mode type. */ typedef enum { RTC_GPIO_MODE_INPUT_ONLY , /*!< Pad input */ @@ -23,3 +19,7 @@ typedef enum { RTC_GPIO_MODE_OUTPUT_OD, /*!< Pad open-drain output */ RTC_GPIO_MODE_INPUT_OUTPUT_OD, /*!< Pad input + open-drain output */ } rtc_gpio_mode_t; + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/sdio_slave_hal.h b/components/hal/include/hal/sdio_slave_hal.h index b30c53f671..a517f6b6d8 100644 --- a/components/hal/include/hal/sdio_slave_hal.h +++ b/components/hal/include/hal/sdio_slave_hal.h @@ -141,9 +141,18 @@ The HAL is used as below: #pragma once #include +#include +#include "soc/soc_caps.h" +#if SOC_SDIO_SLAVE_SUPPORTED #include "hal/sdio_slave_types.h" #include "hal/sdio_slave_ll.h" +#endif +#ifdef __cplusplus +extern "C" { +#endif + +#if SOC_SDIO_SLAVE_SUPPORTED /// Space used for each sending descriptor. Should initialize the sendbuf accoring to this size. #define SDIO_SLAVE_SEND_DESC_SIZE sizeof(sdio_slave_hal_send_desc_t) @@ -522,3 +531,9 @@ uint8_t sdio_slave_hal_host_get_reg(sdio_slave_context_t *hal, int pos); * @param reg Value to set. */ void sdio_slave_hal_host_set_reg(sdio_slave_context_t *hal, int pos, uint8_t reg); + +#endif // SOC_SDIO_SLAVE_SUPPORTED + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/sdio_slave_types.h b/components/hal/include/hal/sdio_slave_types.h index 56eaa2a334..6268d86212 100644 --- a/components/hal/include/hal/sdio_slave_types.h +++ b/components/hal/include/hal/sdio_slave_types.h @@ -8,6 +8,10 @@ #include "esp_bit_defs.h" +#ifdef __cplusplus +extern "C" { +#endif + /// Mask of interrupts sending to the host. typedef enum { SDIO_SLAVE_HOSTINT_BIT0 = BIT(0), ///< General purpose interrupt bit 0. @@ -42,3 +46,7 @@ typedef enum { SDIO_SLAVE_SEND_STREAM = 0, ///< Stream mode, all packets to send will be combined as one if possible SDIO_SLAVE_SEND_PACKET = 1, ///< Packet mode, one packets will be sent one after another (only increase packet_len if last packet sent). } sdio_slave_sending_mode_t; + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/sha_hal.h b/components/hal/include/hal/sha_hal.h index 775063a42d..ef44f7834d 100644 --- a/components/hal/include/hal/sha_hal.h +++ b/components/hal/include/hal/sha_hal.h @@ -1,16 +1,8 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /******************************************************************************* * NOTICE diff --git a/components/hal/include/hal/spi_flash_encrypt_hal.h b/components/hal/include/hal/spi_flash_encrypt_hal.h index adc22f7e02..e3da8c30d5 100644 --- a/components/hal/include/hal/spi_flash_encrypt_hal.h +++ b/components/hal/include/hal/spi_flash_encrypt_hal.h @@ -1,16 +1,8 @@ -// Copyright 2021 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /******************************************************************************* * NOTICE @@ -22,6 +14,10 @@ #include "hal/spi_flash_encrypted_ll.h" +#ifdef __cplusplus +extern "C" { +#endif + /** * @brief Enable the flash encryption */ @@ -60,3 +56,7 @@ void spi_flash_encryption_hal_destroy(void); * @param length Buffer size. */ bool spi_flash_encryption_hal_check(uint32_t address, uint32_t length); + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/spi_flash_hal.h b/components/hal/include/hal/spi_flash_hal.h index 2abf7820f1..99192071f3 100644 --- a/components/hal/include/hal/spi_flash_hal.h +++ b/components/hal/include/hal/spi_flash_hal.h @@ -19,6 +19,10 @@ #include "hal/spi_flash_types.h" #include "esp_assert.h" +#ifdef __cplusplus +extern "C" { +#endif + /* Hardware host-specific constants */ #define SPI_FLASH_HAL_MAX_WRITE_BYTES 64 #define SPI_FLASH_HAL_MAX_READ_BYTES 64 @@ -273,3 +277,7 @@ void spi_flash_hal_suspend(spi_flash_host_inst_t *host); * @return Always ESP_OK */ esp_err_t spi_flash_hal_setup_read_suspend(spi_flash_host_inst_t *host, const spi_flash_sus_cmd_conf *sus_conf); + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/spi_hal.h b/components/hal/include/hal/spi_hal.h index 81477b100c..e5d6b174b2 100644 --- a/components/hal/include/hal/spi_hal.h +++ b/components/hal/include/hal/spi_hal.h @@ -32,6 +32,10 @@ #include "soc/soc_caps.h" #include "hal/spi_types.h" +#ifdef __cplusplus +extern "C" { +#endif + /** * Input parameters to the ``spi_hal_cal_clock_conf`` to calculate the timing configuration */ @@ -264,3 +268,7 @@ void spi_hal_cal_timing(int source_freq_hz, int eff_clk, bool gpio_is_used, int * allowed. Left 0 if not known. */ int spi_hal_get_freq_limit(bool gpio_is_used, int input_delay_ns); + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/spi_slave_hal.h b/components/hal/include/hal/spi_slave_hal.h index 9d7ceec37e..1b6e2cf625 100644 --- a/components/hal/include/hal/spi_slave_hal.h +++ b/components/hal/include/hal/spi_slave_hal.h @@ -30,6 +30,10 @@ #include "soc/soc_caps.h" #include "hal/spi_ll.h" +#ifdef __cplusplus +extern "C" { +#endif + /** * Context that should be maintained by both the driver and the HAL. */ @@ -155,3 +159,7 @@ uint32_t spi_slave_hal_get_rcv_bitlen(spi_slave_hal_context_t *hal); */ bool spi_slave_hal_dma_need_reset(const spi_slave_hal_context_t *hal); #endif //#if CONFIG_IDF_TARGET_ESP32 + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/spi_slave_hd_hal.h b/components/hal/include/hal/spi_slave_hd_hal.h index d426f97e97..fe587fa250 100644 --- a/components/hal/include/hal/spi_slave_hd_hal.h +++ b/components/hal/include/hal/spi_slave_hd_hal.h @@ -48,6 +48,10 @@ #include "hal/spi_ll.h" #include "hal/spi_types.h" +#ifdef __cplusplus +extern "C" { +#endif + /** * @brief Type of dma descriptor with appended members * this structure inherits DMA descriptor, with a pointer to the transaction descriptor passed from users. @@ -306,3 +310,7 @@ esp_err_t spi_slave_hd_hal_txdma_append(spi_slave_hd_hal_context_t *hal, uint8_t * - ESP_ERR_INVALID_STATE: Function called in invalid state. */ esp_err_t spi_slave_hd_hal_rxdma_append(spi_slave_hd_hal_context_t *hal, uint8_t *data, size_t len, void *arg); + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/spi_types.h b/components/hal/include/hal/spi_types.h index e9db6e0ffd..7c2eebe6a6 100644 --- a/components/hal/include/hal/spi_types.h +++ b/components/hal/include/hal/spi_types.h @@ -13,6 +13,10 @@ #include "soc/soc_caps.h" #include "sdkconfig.h" +#ifdef __cplusplus +extern "C" { +#endif + /** * @brief Enum with the three SPI peripherals that are software-accessible in it */ @@ -88,3 +92,7 @@ typedef enum { #endif /** @endcond */ + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/systimer_types.h b/components/hal/include/hal/systimer_types.h index 3bbe0bdb23..8807ee629b 100644 --- a/components/hal/include/hal/systimer_types.h +++ b/components/hal/include/hal/systimer_types.h @@ -18,6 +18,7 @@ extern "C" { * @brief The structure of the counter value in systimer * */ +#if SOC_SYSTIMER_SUPPORTED typedef struct { union { struct { @@ -31,10 +32,13 @@ typedef struct { }; } systimer_counter_value_t; + /** @cond */ ESP_STATIC_ASSERT(sizeof(systimer_counter_value_t) == 8, "systimer_counter_value_t should occupy 8 bytes in memory"); /** @endcond */ +#endif + /** * @brief systimer alarm mode * diff --git a/components/hal/include/hal/touch_sensor_hal.h b/components/hal/include/hal/touch_sensor_hal.h index d2c28f88be..08da29daae 100644 --- a/components/hal/include/hal/touch_sensor_hal.h +++ b/components/hal/include/hal/touch_sensor_hal.h @@ -14,13 +14,16 @@ #pragma once +#if SOC_TOUCH_SENSOR_SUPPORTED #include "hal/touch_sensor_ll.h" #include "hal/touch_sensor_types.h" +#endif #ifdef __cplusplus extern "C" { #endif +#if SOC_TOUCH_SENSOR_SUPPORTED typedef struct { touch_high_volt_t refh; touch_low_volt_t refl; @@ -212,6 +215,8 @@ void touch_hal_deinit(void); */ void touch_hal_config(touch_pad_t touch_num); +#endif + #ifdef __cplusplus } #endif diff --git a/components/hal/include/hal/touch_sensor_types.h b/components/hal/include/hal/touch_sensor_types.h index 868e79118f..2c4daf78d9 100644 --- a/components/hal/include/hal/touch_sensor_types.h +++ b/components/hal/include/hal/touch_sensor_types.h @@ -7,11 +7,16 @@ #pragma once #include +#include #include "sdkconfig.h" #include "esp_attr.h" #include "esp_bit_defs.h" #include "soc/soc_caps.h" +#ifdef __cplusplus +extern "C" { +#endif + /** Touch pad channel */ typedef enum { TOUCH_PAD_NUM0 = 0, /*!< Touch pad channel 0 is GPIO4(ESP32) */ @@ -290,3 +295,7 @@ typedef struct { } touch_pad_sleep_channel_t; #endif // !CONFIG_IDF_TARGET_ESP32 + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/twai_hal.h b/components/hal/include/hal/twai_hal.h index 699687c20d..930b687cdc 100644 --- a/components/hal/include/hal/twai_hal.h +++ b/components/hal/include/hal/twai_hal.h @@ -15,13 +15,18 @@ #include #include #include "sdkconfig.h" +#include "soc/soc_caps.h" +#if SOC_TWAI_SUPPORTED #include "hal/twai_types.h" #include "hal/twai_ll.h" +#endif #ifdef __cplusplus extern "C" { #endif +#if SOC_TWAI_SUPPORTED + /* ------------------------- Defines and Typedefs --------------------------- */ #define TWAI_HAL_SET_BITS(var, flag) ((var) |= (flag)) @@ -377,6 +382,8 @@ static inline uint32_t twai_hal_get_reset_lost_rx_cnt(twai_hal_context_t *hal_ct } #endif //defined(CONFIG_TWAI_ERRATA_FIX_RX_FRAME_INVALID) || defined(CONFIG_TWAI_ERRATA_FIX_RX_FIFO_CORRUPT) +#endif + #ifdef __cplusplus } #endif diff --git a/components/hal/include/hal/uart_types.h b/components/hal/include/hal/uart_types.h index e5436fa197..cef1ca85fb 100644 --- a/components/hal/include/hal/uart_types.h +++ b/components/hal/include/hal/uart_types.h @@ -14,6 +14,7 @@ extern "C" { #include #include "soc/soc_caps.h" #include "soc/clk_tree_defs.h" +#include "esp_assert.h" /** * @brief UART port number, can be UART_NUM_0 ~ (UART_NUM_MAX -1). @@ -30,7 +31,7 @@ typedef enum { UART_NUM_MAX, /*!< UART port max */ } uart_port_t; -_Static_assert(UART_NUM_MAX == SOC_UART_NUM, "UART_NUM_MAX does not match SOC_UART_NUM"); +ESP_STATIC_ASSERT(UART_NUM_MAX == SOC_UART_NUM, "UART_NUM_MAX does not match SOC_UART_NUM"); /** * @brief UART mode selection diff --git a/components/hal/include/hal/uhci_types.h b/components/hal/include/hal/uhci_types.h index 7122e2a41a..9b0c1e2dea 100644 --- a/components/hal/include/hal/uhci_types.h +++ b/components/hal/include/hal/uhci_types.h @@ -1,16 +1,8 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ diff --git a/components/hal/include/hal/usb_dwc_hal.h b/components/hal/include/hal/usb_dwc_hal.h index d52e882cb9..3648b259e0 100644 --- a/components/hal/include/hal/usb_dwc_hal.h +++ b/components/hal/include/hal/usb_dwc_hal.h @@ -17,13 +17,16 @@ NOTE: Thread safety is the responsibility fo the HAL user. All USB Host HAL #include #include +#include "soc/soc_caps.h" +#if SOC_USB_OTG_SUPPORTED #include "soc/usb_dwc_struct.h" #include "hal/usb_dwc_ll.h" +#endif #include "hal/usb_types_private.h" #include "hal/assert.h" // ------------------------------------------------ Macros and Types --------------------------------------------------- - +#if SOC_USB_OTG_SUPPORTED // ------------------ Constants/Configs -------------------- #define USB_DWC_HAL_DMA_MEM_ALIGN 512 @@ -785,6 +788,8 @@ usb_dwc_hal_chan_t *usb_dwc_hal_get_chan_pending_intr(usb_dwc_hal_context_t *hal */ usb_dwc_hal_chan_event_t usb_dwc_hal_chan_decode_intr(usb_dwc_hal_chan_t *chan_obj); +#endif + #ifdef __cplusplus } #endif diff --git a/components/hal/include/hal/usb_dwc_ll.h b/components/hal/include/hal/usb_dwc_ll.h index 3bbaeca4c2..eb7231d2f7 100644 --- a/components/hal/include/hal/usb_dwc_ll.h +++ b/components/hal/include/hal/usb_dwc_ll.h @@ -12,7 +12,10 @@ extern "C" { #include #include +#include "soc/soc_caps.h" +#if SOC_USB_OTG_SUPPORTED #include "soc/usb_dwc_struct.h" +#endif #include "hal/usb_types_private.h" #include "hal/misc.h" @@ -95,6 +98,7 @@ extern "C" { #define USB_DWC_LL_INTR_CHAN_CHHLTD (1 << 1) #define USB_DWC_LL_INTR_CHAN_XFERCOMPL (1 << 0) +#if SOC_USB_OTG_SUPPORTED /* * QTD (Queue Transfer Descriptor) structure used in Scatter/Gather DMA mode. * Each QTD describes one transfer. Scatter gather mode will automatically split @@ -930,6 +934,8 @@ static inline void usb_dwc_ll_qtd_get_status(usb_dwc_ll_dma_qtd_t *qtd, int *rem qtd->buffer_status_val = 0; } +#endif + #ifdef __cplusplus } #endif diff --git a/components/hal/include/hal/usb_hal.h b/components/hal/include/hal/usb_hal.h index b79740932f..3d1e8034d2 100644 --- a/components/hal/include/hal/usb_hal.h +++ b/components/hal/include/hal/usb_hal.h @@ -1,20 +1,14 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/components/hal/include/hal/usb_phy_hal.h b/components/hal/include/hal/usb_phy_hal.h index fe77eb8744..f8d5a2688b 100644 --- a/components/hal/include/hal/usb_phy_hal.h +++ b/components/hal/include/hal/usb_phy_hal.h @@ -6,10 +6,13 @@ #pragma once +#include #include "usb_types_private.h" #include "usb_phy_types.h" #include "soc/soc_caps.h" +#if SOC_USB_OTG_SUPPORTED #include "soc/usb_wrap_struct.h" +#endif #if SOC_USB_SERIAL_JTAG_SUPPORTED #include "soc/usb_serial_jtag_struct.h" #endif @@ -18,9 +21,11 @@ extern "C" { #endif +#if SOC_USB_OTG_SUPPORTED /** * Context that should be maintained by both the driver and the HAL */ + typedef struct { usb_wrap_dev_t *wrap_dev; /**< Pointer to base address of USB Wrapper registers */ #if SOC_USB_SERIAL_JTAG_SUPPORTED @@ -28,6 +33,7 @@ typedef struct { #endif } usb_phy_hal_context_t; + /** * @brief Init the USB PHY hal. This function should be called first before other hal layer function is called * @@ -76,6 +82,8 @@ void usb_phy_hal_int_load_conf_dev(usb_phy_hal_context_t *hal, usb_priv_speed_t */ void usb_phy_hal_int_mimick_disconn(usb_phy_hal_context_t *hal, bool disconn); +#endif + #ifdef __cplusplus } #endif diff --git a/components/hal/include/hal/usb_types_private.h b/components/hal/include/hal/usb_types_private.h index 5cce6b66af..d3d358688d 100644 --- a/components/hal/include/hal/usb_types_private.h +++ b/components/hal/include/hal/usb_types_private.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /* Note: This header file contains USB2.0 related types and macros that can be used by code specific to the DWC_OTG diff --git a/components/hal/include/hal/xt_wdt_hal.h b/components/hal/include/hal/xt_wdt_hal.h index bd08f2a989..4b999d930a 100644 --- a/components/hal/include/hal/xt_wdt_hal.h +++ b/components/hal/include/hal/xt_wdt_hal.h @@ -8,19 +8,26 @@ #include #include +#include "soc/soc_caps.h" +#if SOC_XT_WDT_SUPPORTED #include "hal/xt_wdt_ll.h" +#endif #ifdef __cplusplus extern "C" { #endif + +#if SOC_XT_WDT_SUPPORTED + typedef struct { rtc_cntl_dev_t *dev; /* Pointer to the RTC register struct */ } xt_wdt_hal_context_t; /* HAL context struct */ + typedef struct { - uint32_t timeout; /* Watchdog timer timeout in RTC_CLK cycles*/ + uint32_t timeout; /* Watchdog timer timeout in RTC_CLK cycles */ } xt_wdt_hal_config_t; /* HAL config parameter struct */ /* ---------------------------- Init and Config ----------------------------- */ @@ -56,6 +63,8 @@ void xt_wdt_hal_enable(xt_wdt_hal_context_t *hal, bool enable); */ uint32_t xt_wdt_hal_enable_backup_clk(xt_wdt_hal_context_t *hal, uint32_t rtc_clk_frequency_khz); +#endif + #ifdef __cplusplus } #endif diff --git a/components/hal/mpu_hal.c b/components/hal/mpu_hal.c index bebcb7c057..c03fe80b11 100644 --- a/components/hal/mpu_hal.c +++ b/components/hal/mpu_hal.c @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include #include diff --git a/components/hal/platform_port/include/hal/misc.h b/components/hal/platform_port/include/hal/misc.h index 766d0c5fbe..c6e50ad8c3 100644 --- a/components/hal/platform_port/include/hal/misc.h +++ b/components/hal/platform_port/include/hal/misc.h @@ -7,6 +7,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + #define HAL_SWAP16(d) __builtin_bswap16((d)) #define HAL_SWAP32(d) __builtin_bswap32((d)) #define HAL_SWAP64(d) __builtin_bswap64((d)) @@ -83,3 +87,7 @@ __attribute__((always_inline)) static inline void *hal_memset(void *dst_mem, int asm("" : "+r"(dst_mem)); return memset(dst_mem, value, len); } + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/sha_hal.c b/components/hal/sha_hal.c index 7a4f94d834..68c06b70dd 100644 --- a/components/hal/sha_hal.c +++ b/components/hal/sha_hal.c @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ // The HAL layer for SHA diff --git a/components/hal/spi_flash_encrypt_hal_iram.c b/components/hal/spi_flash_encrypt_hal_iram.c index 9dca065602..2636e699f5 100644 --- a/components/hal/spi_flash_encrypt_hal_iram.c +++ b/components/hal/spi_flash_encrypt_hal_iram.c @@ -1,16 +1,8 @@ -// Copyright 2021 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ // This part is put in iram. diff --git a/components/hal/spi_flash_hal_gpspi.c b/components/hal/spi_flash_hal_gpspi.c index 3393cd2196..1ad7a3320e 100644 --- a/components/hal/spi_flash_hal_gpspi.c +++ b/components/hal/spi_flash_hal_gpspi.c @@ -1,16 +1,8 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ // HAL for // - GPSPI (SP2, SPI3) on ESP32-S2 and later diff --git a/components/hal/touch_sensor_hal.c b/components/hal/touch_sensor_hal.c index 2fe670eaf5..c145b479fc 100644 --- a/components/hal/touch_sensor_hal.c +++ b/components/hal/touch_sensor_hal.c @@ -1,16 +1,8 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ // The HAL layer for Touch Sensor (common part) diff --git a/components/hal/uart_hal_iram.c b/components/hal/uart_hal_iram.c index 447bf631ee..786384b70b 100644 --- a/components/hal/uart_hal_iram.c +++ b/components/hal/uart_hal_iram.c @@ -1,16 +1,8 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ // The HAL layer for UART (IRAM part) #include "hal/uart_hal.h" diff --git a/components/hal/usb_hal.c b/components/hal/usb_hal.c index 359f50d68a..fe960f2766 100644 --- a/components/hal/usb_hal.c +++ b/components/hal/usb_hal.c @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// 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. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include "hal/usb_ll.h" diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 6d66b8db94..a5d3a6177b 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -593,57 +593,13 @@ components/freertos/FreeRTOS-Kernel-SMP/queue.c components/freertos/FreeRTOS-Kernel-SMP/stream_buffer.c components/freertos/FreeRTOS-Kernel-SMP/tasks.c components/freertos/FreeRTOS-Kernel-SMP/timers.c -components/hal/aes_hal.c -components/hal/ds_hal.c -components/hal/esp32/include/hal/aes_ll.h -components/hal/esp32/include/hal/mpu_ll.h -components/hal/esp32/include/hal/spi_flash_encrypted_ll.h -components/hal/esp32/include/hal/touch_sensor_hal.h -components/hal/esp32/include/hal/trace_ll.h components/hal/esp32c3/hmac_hal.c -components/hal/esp32c3/include/hal/ds_ll.h components/hal/esp32c3/include/hal/hmac_hal.h -components/hal/esp32c3/include/hal/hmac_ll.h -components/hal/esp32c3/include/hal/mpu_ll.h -components/hal/esp32c3/include/hal/sha_ll.h -components/hal/esp32c3/include/hal/uhci_ll.h -components/hal/esp32c3/rtc_cntl_hal.c -components/hal/esp32s2/include/hal/crypto_dma_ll.h -components/hal/esp32s2/include/hal/dedic_gpio_ll.h -components/hal/esp32s2/include/hal/mpu_ll.h -components/hal/esp32s2/include/hal/sha_ll.h -components/hal/esp32s2/include/hal/spi_flash_encrypted_ll.h -components/hal/esp32s2/include/hal/trace_ll.h -components/hal/esp32s2/include/hal/usb_ll.h -components/hal/esp32s3/include/hal/mpu_ll.h -components/hal/esp32s3/include/hal/sha_ll.h -components/hal/esp32s3/include/hal/spi_flash_encrypted_ll.h -components/hal/esp32s3/include/hal/uhci_ll.h -components/hal/esp32s3/include/hal/usb_ll.h -components/hal/include/hal/aes_hal.h -components/hal/include/hal/aes_types.h components/hal/include/hal/dac_types.h -components/hal/include/hal/ds_hal.h -components/hal/include/hal/esp_flash_err.h -components/hal/include/hal/mpu_hal.h -components/hal/include/hal/mpu_types.h -components/hal/include/hal/rtc_io_types.h components/hal/include/hal/sdio_slave_ll.h -components/hal/include/hal/sha_hal.h -components/hal/include/hal/spi_flash_encrypt_hal.h -components/hal/include/hal/uhci_types.h -components/hal/include/hal/usb_hal.h -components/hal/include/hal/usb_types_private.h -components/hal/mpu_hal.c -components/hal/sha_hal.c -components/hal/spi_flash_encrypt_hal_iram.c -components/hal/spi_flash_hal_gpspi.c components/hal/spi_slave_hal.c components/hal/spi_slave_hal_iram.c components/hal/test/test_mpu.c -components/hal/touch_sensor_hal.c -components/hal/uart_hal_iram.c -components/hal/usb_hal.c components/heap/include/heap_memory_layout.h components/heap/test/test_aligned_alloc_caps.c components/heap/test/test_allocator_timings.c diff --git a/tools/ci/check_public_headers_exceptions.txt b/tools/ci/check_public_headers_exceptions.txt index cc3291d247..cbc80670db 100644 --- a/tools/ci/check_public_headers_exceptions.txt +++ b/tools/ci/check_public_headers_exceptions.txt @@ -17,8 +17,6 @@ components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/include/freertos/ components/log/include/esp_log_internal.h -components/hal/ - components/esp_rom/include/esp32s2/rom/rsa_pss.h components/esp_common/include/esp_private/