From f8b5ed5d6cfa69a52ebb9d1ebcf8c005b899264d Mon Sep 17 00:00:00 2001 From: Jakob Hasse Date: Mon, 23 May 2022 16:23:07 +0800 Subject: [PATCH] refactor (soc, esp_rom)!: removed target-specific ROM dependencies --- components/esp_rom/include/esp32/rom/lldesc.h | 45 +++--------------- .../esp_rom/include/esp32c2/rom/lldesc.h | 27 +---------- .../esp_rom/include/esp32c3/rom/lldesc.h | 45 +++--------------- .../esp_rom/include/esp32h2/rom/lldesc.h | 45 +++--------------- .../esp_rom/include/esp32s2/rom/lldesc.h | 45 +++--------------- .../esp_rom/include/esp32s3/rom/lldesc.h | 46 +++---------------- components/esp_rom/include/esp_rom_lldesc.h | 45 ++++++++++++++++++ .../esp32c3/include/soc/Kconfig.soc_caps.in | 4 ++ .../soc/esp32c3/include/soc/memprot_defs.h | 4 +- components/soc/esp32c3/include/soc/soc_caps.h | 1 + components/soc/include/soc/lldesc.h | 15 +----- tools/ci/check_copyright_ignore.txt | 5 -- 12 files changed, 84 insertions(+), 243 deletions(-) create mode 100644 components/esp_rom/include/esp_rom_lldesc.h diff --git a/components/esp_rom/include/esp32/rom/lldesc.h b/components/esp_rom/include/esp32/rom/lldesc.h index ae5b4160ba..725a610982 100644 --- a/components/esp_rom/include/esp32/rom/lldesc.h +++ b/components/esp_rom/include/esp32/rom/lldesc.h @@ -1,16 +1,8 @@ -// Copyright 2010-2016 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: 2010-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ROM_LLDESC_H_ #define _ROM_LLDESC_H_ @@ -18,6 +10,7 @@ #include #include "sys/queue.h" +#include "esp_rom_lldesc.h" #ifdef __cplusplus extern "C" { @@ -51,32 +44,6 @@ extern "C" { #define LLDESC_RX_AMPDU_ENTRY_MBLK_NUM 4 #define LLDESC_RX_AMPDU_LEN_MLBK_NUM 8 #endif /* !ESP_MAC_5 */ -/* - * SLC2 DMA Desc struct, aka lldesc_t - * - * -------------------------------------------------------------- - * | own | EoF | sub_sof | 5'b0 | length [11:0] | size [11:0] | - * -------------------------------------------------------------- - * | buf_ptr [31:0] | - * -------------------------------------------------------------- - * | next_desc_ptr [31:0] | - * -------------------------------------------------------------- - */ - -/* this bitfield is start from the LSB!!! */ -typedef struct lldesc_s { - volatile uint32_t size :12, - length:12, - offset: 5, /* h/w reserved 5bit, s/w use it as offset in buffer */ - sosf : 1, /* start of sub-frame */ - eof : 1, /* end of frame */ - owner : 1; /* hw or sw */ - volatile uint8_t *buf; /* point to buffer data */ - union{ - volatile uint32_t empty; - STAILQ_ENTRY(lldesc_s) qe; /* pointing to the next desc */ - }; -} lldesc_t; typedef struct tx_ampdu_entry_s{ uint32_t sub_len :12, diff --git a/components/esp_rom/include/esp32c2/rom/lldesc.h b/components/esp_rom/include/esp32c2/rom/lldesc.h index dc80d6705f..721e536acf 100644 --- a/components/esp_rom/include/esp32c2/rom/lldesc.h +++ b/components/esp_rom/include/esp32c2/rom/lldesc.h @@ -10,6 +10,7 @@ #include #include "sys/queue.h" +#include "esp_rom_lldesc.h" #ifdef __cplusplus extern "C" { @@ -43,32 +44,6 @@ extern "C" { #define LLDESC_RX_AMPDU_ENTRY_MBLK_NUM 4 #define LLDESC_RX_AMPDU_LEN_MLBK_NUM 8 #endif /* !ESP_MAC_5 */ -/* - * SLC2 DMA Desc struct, aka lldesc_t - * - * -------------------------------------------------------------- - * | own | EoF | sub_sof | 5'b0 | length [11:0] | size [11:0] | - * -------------------------------------------------------------- - * | buf_ptr [31:0] | - * -------------------------------------------------------------- - * | next_desc_ptr [31:0] | - * -------------------------------------------------------------- - */ - -/* this bitfield is start from the LSB!!! */ -typedef struct lldesc_s { - volatile uint32_t size : 12, - length: 12, - offset: 5, /* h/w reserved 5bit, s/w use it as offset in buffer */ - sosf : 1, /* start of sub-frame */ - eof : 1, /* end of frame */ - owner : 1; /* hw or sw */ - volatile const uint8_t *buf; /* point to buffer data */ - union { - volatile uint32_t empty; - STAILQ_ENTRY(lldesc_s) qe; /* pointing to the next desc */ - }; -} lldesc_t; typedef struct tx_ampdu_entry_s { uint32_t sub_len : 12, diff --git a/components/esp_rom/include/esp32c3/rom/lldesc.h b/components/esp_rom/include/esp32c3/rom/lldesc.h index d4c5d92a30..721e536acf 100644 --- a/components/esp_rom/include/esp32c3/rom/lldesc.h +++ b/components/esp_rom/include/esp32c3/rom/lldesc.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-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ROM_LLDESC_H_ #define _ROM_LLDESC_H_ @@ -18,6 +10,7 @@ #include #include "sys/queue.h" +#include "esp_rom_lldesc.h" #ifdef __cplusplus extern "C" { @@ -51,32 +44,6 @@ extern "C" { #define LLDESC_RX_AMPDU_ENTRY_MBLK_NUM 4 #define LLDESC_RX_AMPDU_LEN_MLBK_NUM 8 #endif /* !ESP_MAC_5 */ -/* - * SLC2 DMA Desc struct, aka lldesc_t - * - * -------------------------------------------------------------- - * | own | EoF | sub_sof | 5'b0 | length [11:0] | size [11:0] | - * -------------------------------------------------------------- - * | buf_ptr [31:0] | - * -------------------------------------------------------------- - * | next_desc_ptr [31:0] | - * -------------------------------------------------------------- - */ - -/* this bitfield is start from the LSB!!! */ -typedef struct lldesc_s { - volatile uint32_t size : 12, - length: 12, - offset: 5, /* h/w reserved 5bit, s/w use it as offset in buffer */ - sosf : 1, /* start of sub-frame */ - eof : 1, /* end of frame */ - owner : 1; /* hw or sw */ - volatile const uint8_t *buf; /* point to buffer data */ - union { - volatile uint32_t empty; - STAILQ_ENTRY(lldesc_s) qe; /* pointing to the next desc */ - }; -} lldesc_t; typedef struct tx_ampdu_entry_s { uint32_t sub_len : 12, diff --git a/components/esp_rom/include/esp32h2/rom/lldesc.h b/components/esp_rom/include/esp32h2/rom/lldesc.h index d4c5d92a30..721e536acf 100644 --- a/components/esp_rom/include/esp32h2/rom/lldesc.h +++ b/components/esp_rom/include/esp32h2/rom/lldesc.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-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ROM_LLDESC_H_ #define _ROM_LLDESC_H_ @@ -18,6 +10,7 @@ #include #include "sys/queue.h" +#include "esp_rom_lldesc.h" #ifdef __cplusplus extern "C" { @@ -51,32 +44,6 @@ extern "C" { #define LLDESC_RX_AMPDU_ENTRY_MBLK_NUM 4 #define LLDESC_RX_AMPDU_LEN_MLBK_NUM 8 #endif /* !ESP_MAC_5 */ -/* - * SLC2 DMA Desc struct, aka lldesc_t - * - * -------------------------------------------------------------- - * | own | EoF | sub_sof | 5'b0 | length [11:0] | size [11:0] | - * -------------------------------------------------------------- - * | buf_ptr [31:0] | - * -------------------------------------------------------------- - * | next_desc_ptr [31:0] | - * -------------------------------------------------------------- - */ - -/* this bitfield is start from the LSB!!! */ -typedef struct lldesc_s { - volatile uint32_t size : 12, - length: 12, - offset: 5, /* h/w reserved 5bit, s/w use it as offset in buffer */ - sosf : 1, /* start of sub-frame */ - eof : 1, /* end of frame */ - owner : 1; /* hw or sw */ - volatile const uint8_t *buf; /* point to buffer data */ - union { - volatile uint32_t empty; - STAILQ_ENTRY(lldesc_s) qe; /* pointing to the next desc */ - }; -} lldesc_t; typedef struct tx_ampdu_entry_s { uint32_t sub_len : 12, diff --git a/components/esp_rom/include/esp32s2/rom/lldesc.h b/components/esp_rom/include/esp32s2/rom/lldesc.h index a11be3767f..725a610982 100644 --- a/components/esp_rom/include/esp32s2/rom/lldesc.h +++ b/components/esp_rom/include/esp32s2/rom/lldesc.h @@ -1,16 +1,8 @@ -// Copyright 2010-2016 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: 2010-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ROM_LLDESC_H_ #define _ROM_LLDESC_H_ @@ -18,6 +10,7 @@ #include #include "sys/queue.h" +#include "esp_rom_lldesc.h" #ifdef __cplusplus extern "C" { @@ -51,32 +44,6 @@ extern "C" { #define LLDESC_RX_AMPDU_ENTRY_MBLK_NUM 4 #define LLDESC_RX_AMPDU_LEN_MLBK_NUM 8 #endif /* !ESP_MAC_5 */ -/* - * SLC2 DMA Desc struct, aka lldesc_t - * - * -------------------------------------------------------------- - * | own | EoF | sub_sof | 5'b0 | length [11:0] | size [11:0] | - * -------------------------------------------------------------- - * | buf_ptr [31:0] | - * -------------------------------------------------------------- - * | next_desc_ptr [31:0] | - * -------------------------------------------------------------- - */ - -/* this bitfield is start from the LSB!!! */ -typedef struct lldesc_s { - volatile uint32_t size :12, - length:12, - offset: 5, /* h/w reserved 5bit, s/w use it as offset in buffer */ - sosf : 1, /* start of sub-frame */ - eof : 1, /* end of frame */ - owner : 1; /* hw or sw */ - volatile const uint8_t *buf; /* point to buffer data */ - union{ - volatile uint32_t empty; - STAILQ_ENTRY(lldesc_s) qe; /* pointing to the next desc */ - }; -} lldesc_t; typedef struct tx_ampdu_entry_s{ uint32_t sub_len :12, diff --git a/components/esp_rom/include/esp32s3/rom/lldesc.h b/components/esp_rom/include/esp32s3/rom/lldesc.h index ebd02016bb..edc3780e04 100644 --- a/components/esp_rom/include/esp32s3/rom/lldesc.h +++ b/components/esp_rom/include/esp32s3/rom/lldesc.h @@ -1,21 +1,14 @@ -// Copyright 2010-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: 2010-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include #include "sys/queue.h" +#include "esp_rom_lldesc.h" #ifdef __cplusplus extern "C" { @@ -49,33 +42,6 @@ extern "C" { #define LLDESC_RX_AMPDU_ENTRY_MBLK_NUM 4 #define LLDESC_RX_AMPDU_LEN_MLBK_NUM 8 #endif /* !ESP_MAC_5 */ -/* - * SLC2 DMA Desc struct, aka lldesc_t - * - * -------------------------------------------------------------- - * | own | EoF | sub_sof | 5'b0 | length [11:0] | size [11:0] | - * -------------------------------------------------------------- - * | buf_ptr [31:0] | - * -------------------------------------------------------------- - * | next_desc_ptr [31:0] | - * -------------------------------------------------------------- - */ - -/* this bitfield is start from the LSB!!! */ -typedef struct lldesc_s { - volatile uint32_t size : 12, - length: 12, - offset: 5, /* h/w reserved 5bit, s/w use it as offset in buffer */ - sosf : 1, /* start of sub-frame */ - eof : 1, /* end of frame */ - owner : 1; /* hw or sw */ - volatile uint8_t *buf; /* point to buffer data */ - union { - volatile uint32_t empty; - STAILQ_ENTRY(lldesc_s) qe; /* pointing to the next desc */ - }; -} lldesc_t; - typedef struct tx_ampdu_entry_s { uint32_t sub_len : 12, dili_num : 7, diff --git a/components/esp_rom/include/esp_rom_lldesc.h b/components/esp_rom/include/esp_rom_lldesc.h new file mode 100644 index 0000000000..ab6df59fcc --- /dev/null +++ b/components/esp_rom/include/esp_rom_lldesc.h @@ -0,0 +1,45 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include +#include "sys/queue.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * SLC2 DMA Desc struct, aka lldesc_t + * + * -------------------------------------------------------------- + * | own | EoF | sub_sof | 5'b0 | length [11:0] | size [11:0] | + * -------------------------------------------------------------- + * | buf_ptr [31:0] | + * -------------------------------------------------------------- + * | next_desc_ptr [31:0] | + * -------------------------------------------------------------- + */ + +/* this bitfield is start from the LSB!!! */ +typedef struct lldesc_s { + volatile uint32_t size : 12, + length: 12, + offset: 5, /* h/w reserved 5bit, s/w use it as offset in buffer */ + sosf : 1, /* start of sub-frame */ + eof : 1, /* end of frame */ + owner : 1; /* hw or sw */ + volatile const uint8_t *buf; /* point to buffer data */ + union { + volatile uint32_t empty; + STAILQ_ENTRY(lldesc_s) qe; /* pointing to the next desc */ + }; +} lldesc_t; + +#ifdef __cplusplus +} +#endif diff --git a/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in index 8835561b61..2f3a1d8fec 100644 --- a/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in @@ -203,6 +203,10 @@ config SOC_SHARED_IDCACHE_SUPPORTED bool default y +config SOC_CACHE_MEMORY_IBANK_SIZE + hex + default 0x4000 + config SOC_CPU_CORES_NUM int default 1 diff --git a/components/soc/esp32c3/include/soc/memprot_defs.h b/components/soc/esp32c3/include/soc/memprot_defs.h index fe4f20e3bd..78bf5cdb0e 100644 --- a/components/soc/esp32c3/include/soc/memprot_defs.h +++ b/components/soc/esp32c3/include/soc/memprot_defs.h @@ -7,8 +7,8 @@ #pragma once #include "soc/soc.h" +#include "soc/soc_caps.h" #include "soc/sensitive_reg.h" -#include "esp32c3/rom/cache.h" #ifdef __cplusplus extern "C" { @@ -39,7 +39,7 @@ typedef union { //16kB (ICACHE) #define IRAM0_SRAM_LEVEL_0_LOW SOC_IRAM_LOW //0x40370000 -#define IRAM0_SRAM_LEVEL_0_HIGH (IRAM0_SRAM_LEVEL_0_LOW + CACHE_MEMORY_IBANK_SIZE - 0x1) //0x4037FFFF +#define IRAM0_SRAM_LEVEL_0_HIGH (IRAM0_SRAM_LEVEL_0_LOW + SOC_CACHE_MEMORY_IBANK_SIZE - 0x1) //0x4037FFFF //128kB (LEVEL 1) #define IRAM0_SRAM_LEVEL_1_LOW (IRAM0_SRAM_LEVEL_0_HIGH + 0x1) //0x40380000 diff --git a/components/soc/esp32c3/include/soc/soc_caps.h b/components/soc/esp32c3/include/soc/soc_caps.h index c92c664a50..d3729d35e9 100644 --- a/components/soc/esp32c3/include/soc/soc_caps.h +++ b/components/soc/esp32c3/include/soc/soc_caps.h @@ -100,6 +100,7 @@ /*-------------------------- CACHE CAPS --------------------------------------*/ #define SOC_SHARED_IDCACHE_SUPPORTED 1 //Shared Cache for both instructions and data +#define SOC_CACHE_MEMORY_IBANK_SIZE 0x4000 // has to be same as the definition in ROM component /*-------------------------- CPU CAPS ----------------------------------------*/ #define SOC_CPU_CORES_NUM (1U) diff --git a/components/soc/include/soc/lldesc.h b/components/soc/include/soc/lldesc.h index 4e6692620b..8975154bb4 100644 --- a/components/soc/include/soc/lldesc.h +++ b/components/soc/include/soc/lldesc.h @@ -7,20 +7,7 @@ #pragma once #include #include "sdkconfig.h" - -#if CONFIG_IDF_TARGET_ESP32 -#include "esp32/rom/lldesc.h" -#elif CONFIG_IDF_TARGET_ESP32S2 -#include "esp32s2/rom/lldesc.h" -#elif CONFIG_IDF_TARGET_ESP32S3 -#include "esp32s3/rom/lldesc.h" -#elif CONFIG_IDF_TARGET_ESP32C3 -#include "esp32c3/rom/lldesc.h" -#elif CONFIG_IDF_TARGET_ESP32H2 -#include "esp32h2/rom/lldesc.h" -#elif CONFIG_IDF_TARGET_ESP32C2 -#include "esp32c2/rom/lldesc.h" -#endif +#include "esp_rom_lldesc.h" //the size field has 12 bits, but 0 not for 4096. //to avoid possible problem when the size is not word-aligned, we only use 4096-4 per desc. diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 5496dcddb3..5d13ed71df 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -523,7 +523,6 @@ components/esp_rom/include/esp32/rom/bigint.h components/esp_rom/include/esp32/rom/crc.h components/esp_rom/include/esp32/rom/efuse.h components/esp_rom/include/esp32/rom/libc_stubs.h -components/esp_rom/include/esp32/rom/lldesc.h components/esp_rom/include/esp32/rom/md5_hash.h components/esp_rom/include/esp32/rom/miniz.h components/esp_rom/include/esp32/rom/rsa_pss.h @@ -543,7 +542,6 @@ components/esp_rom/include/esp32c3/rom/ets_sys.h components/esp_rom/include/esp32c3/rom/gpio.h components/esp_rom/include/esp32c3/rom/hmac.h components/esp_rom/include/esp32c3/rom/libc_stubs.h -components/esp_rom/include/esp32c3/rom/lldesc.h components/esp_rom/include/esp32c3/rom/md5_hash.h components/esp_rom/include/esp32c3/rom/miniz.h components/esp_rom/include/esp32c3/rom/rom_layout.h @@ -562,7 +560,6 @@ components/esp_rom/include/esp32h2/rom/esp_flash.h components/esp_rom/include/esp32h2/rom/ets_sys.h components/esp_rom/include/esp32h2/rom/hmac.h components/esp_rom/include/esp32h2/rom/libc_stubs.h -components/esp_rom/include/esp32h2/rom/lldesc.h components/esp_rom/include/esp32h2/rom/md5_hash.h components/esp_rom/include/esp32h2/rom/miniz.h components/esp_rom/include/esp32h2/rom/rsa_pss.h @@ -578,7 +575,6 @@ components/esp_rom/include/esp32s2/rom/ets_sys.h components/esp_rom/include/esp32s2/rom/gpio.h components/esp_rom/include/esp32s2/rom/hmac.h components/esp_rom/include/esp32s2/rom/libc_stubs.h -components/esp_rom/include/esp32s2/rom/lldesc.h components/esp_rom/include/esp32s2/rom/md5_hash.h components/esp_rom/include/esp32s2/rom/miniz.h components/esp_rom/include/esp32s2/rom/opi_flash.h @@ -605,7 +601,6 @@ components/esp_rom/include/esp32s3/rom/ets_sys.h components/esp_rom/include/esp32s3/rom/gpio.h components/esp_rom/include/esp32s3/rom/hmac.h components/esp_rom/include/esp32s3/rom/libc_stubs.h -components/esp_rom/include/esp32s3/rom/lldesc.h components/esp_rom/include/esp32s3/rom/md5_hash.h components/esp_rom/include/esp32s3/rom/miniz.h components/esp_rom/include/esp32s3/rom/opi_flash.h