Skip to content

Commit

Permalink
Fix warnings and clang-tidy checks
Browse files Browse the repository at this point in the history
  • Loading branch information
robotman2412 committed Aug 22, 2024
1 parent b2ad9e4 commit f3de96d
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 28 deletions.
1 change: 1 addition & 0 deletions kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ include_directories(
${cpu_include}
${port_include}
)
include_directories(SYSTEM ${port_system_include})

# Add libraries.
add_subdirectory(../common/badgelib badgelib)
Expand Down
9 changes: 5 additions & 4 deletions kernel/port/esp32c6/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ MEMORY

PHDRS
{
codeseg PT_LOAD;
rodataseg PT_LOAD;
dataseg PT_LOAD;
codeseg PT_LOAD;
rodataseg PT_LOAD;
ramcodeseg PT_LOAD;
dataseg PT_LOAD;
}

SECTIONS
Expand Down Expand Up @@ -110,7 +111,7 @@ PROVIDE(CLINT_U = 0x20001C00);
. = ALIGN(__section_alignment);
*(.ramtext) *(.ramtext.*)
. = ALIGN(__section_alignment);
} >sram :dataseg
} >sram :ramcodeseg
.data : AT(LOADADDR(.ramtext) + SIZEOF(.ramtext)) {
. = ALIGN(__section_alignment);
*(.data) *(.data.*)
Expand Down
2 changes: 1 addition & 1 deletion kernel/port/esp32c6/src/hal/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void spi_controller_init(
// Clock configuration.
clkconfig_spi2(bitrate, true, false);

irq_ch_set_isr(ETS_GSPI2_INTR_SOURCE, spi_isr);
irq_ch_set_isr(ETS_GSPI2_INTR_SOURCE, (isr_t)spi_isr);
irq_ch_enable(ETS_GSPI2_INTR_SOURCE);
GPSPI2.dma_int_ena.trans_done = true;

Expand Down
2 changes: 1 addition & 1 deletion kernel/port/esp32c6/src/interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void riscv_interrupt_handler() {
for (int i = 0; i < ETS_MAX_INTR_SOURCE / 32; i++) {
uint32_t pending = INTMTX.status[i];
uint32_t lsb_pos = __builtin_clz(pending);
int irq = i * 32 + lsb_pos;
uint32_t irq = i * 32 + lsb_pos;
if (irq_ch_is_enabled(irq)) {
// Jump to ISR.
if (isr_table[mcause]) {
Expand Down
5 changes: 1 addition & 4 deletions kernel/port/esp32c6/src/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void port_early_init() {
// Full hardware initialization.
void port_init() {
extern void esp_i2c_isr();
irq_ch_set_isr(ETS_I2C_EXT0_INTR_SOURCE, esp_i2c_isr);
irq_ch_set_isr(ETS_I2C_EXT0_INTR_SOURCE, (isr_t)esp_i2c_isr);
irq_ch_enable(ETS_I2C_EXT0_INTR_SOURCE);
}

Expand Down Expand Up @@ -102,9 +102,6 @@ static void peri_poweroff() {

RAMFUNC static void trigger_restart() {
Cache_Disable_ICache();

// Reset the CPU.
void software_reset_cpu();
software_reset_cpu(0);
}

Expand Down
9 changes: 5 additions & 4 deletions kernel/port/esp32p4/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ MEMORY

PHDRS
{
codeseg PT_LOAD;
rodataseg PT_LOAD;
dataseg PT_LOAD;
codeseg PT_LOAD;
ramcodeseg PT_LOAD;
rodataseg PT_LOAD;
dataseg PT_LOAD;
}

SECTIONS
Expand Down Expand Up @@ -113,7 +114,7 @@ PROVIDE(CLIC_CTL = 0x20801000);
. = ALIGN(__section_alignment);
*(.ramtext) *(.ramtext.*)
. = ALIGN(__section_alignment);
} >sram :dataseg
} >sram :ramcodeseg
.data : AT(LOADADDR(.ramtext) + SIZEOF(.ramtext)) {
. = ALIGN(__section_alignment);
*(.data) *(.data.*)
Expand Down
6 changes: 3 additions & 3 deletions kernel/port/esp32p4/src/interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ void riscv_interrupt_handler() {
uint32_t lsb_mask = 1 << lsb_pos;
uint32_t prev = atomic_fetch_or(&claim_mask[i], lsb_mask);
if (!(prev & lsb_mask)) {
int irq = i * 32 + lsb_pos;
uint32_t irq = i * 32 + lsb_pos;
if (!isr_table[irq]) {
logkf(LOG_FATAL, "Unhandled interrupt #%{d}", irq);
logkf(LOG_FATAL, "Unhandled interrupt #%{u32;d}", irq);
panic_abort();
} else {
isr_table[irq](irq);
isr_table[irq]((int)irq);
}
atomic_fetch_and(&claim_mask[i], lsb_mask);
}
Expand Down
1 change: 1 addition & 0 deletions kernel/port/esp32p4/src/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ static void appcpu_stub() {
}

// APP CPU startup stub: Part 2 edition.
static void appcpu_stub_2() __attribute__((unused));
static void appcpu_stub_2() {
isr_ctx_t kctx = {0};
kctx.flags |= ISR_CTX_FLAG_KERNEL | ISR_CTX_FLAG_USE_SP;
Expand Down
2 changes: 2 additions & 0 deletions kernel/port/esp_common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ set(port_src ${port_src}
)
set(port_include ${port_include}
${CMAKE_CURRENT_LIST_DIR}/include/
)
set(port_system_include ${port_system_include}
${CMAKE_CURRENT_LIST_DIR}/esp-idf/components/soc/${CONFIG_TARGET}/include/
${CMAKE_CURRENT_LIST_DIR}/esp-idf/components/soc/include/
${CMAKE_CURRENT_LIST_DIR}/esp-idf/components/hal/${CONFIG_TARGET}/include/
Expand Down
5 changes: 0 additions & 5 deletions kernel/port/esp_common/src/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@

#include "hal/gpio.h"

// NOLINTBEGIN
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#define STDLIB_H
#define _STDLIB_H
#define __STDLIB_H
#include "hal/gpio_ll.h"
#include "soc/gpio_sig_map.h"
#pragma GCC diagnostic pop
// NOLINTEND

#include "soc/io_mux_struct.h"

Expand Down
8 changes: 2 additions & 6 deletions kernel/port/esp_common/src/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@
#include "interrupt.h"
#include "scheduler/scheduler.h"

#include <config.h>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
// NOLINTBEGIN
#define STDLIB_H
#define _STDLIB_H
#define __STDLIB_H
// NOLINTEND
#include "esp_rom_gpio.h"
#include "hal/clk_tree_ll.h"
#include "hal/gpio_hal.h"
Expand All @@ -24,7 +21,6 @@
#include "soc/gpio_sig_map.h"
#pragma GCC diagnostic pop

#include <config.h>
// NOLINTNEXTLINE
static int __DECLARE_RCC_ATOMIC_ENV __attribute__((unused));

Expand Down
2 changes: 2 additions & 0 deletions kernel/port/esp_common/src/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
#include "scheduler/isr.h"
#include "smp.h"

// NOLINTBEGIN
#define __DECLARE_RCC_RC_ATOMIC_ENV 0
#define __DECLARE_RCC_ATOMIC_ENV 0
// NOLINTEND

#include <config.h>
#include <soc/lp_wdt_struct.h>
Expand Down

0 comments on commit f3de96d

Please sign in to comment.