From d30ad28f038a0698220e62504de3df18dd4b0207 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 15 Dec 2022 14:45:15 -0500 Subject: [PATCH] canboot: Introduce a new canboot.h header file Move canboot specific definitions in board/misc.h to new canboot.h header file. This makes it a little easier to identify differences between canboot code and low-level upstream klipper code. Signed-off-by: Kevin O'Connor --- src/bootentry.c | 2 +- src/canboot.h | 19 +++++++++++++++++++ src/deployer.c | 2 ++ src/flashcmd.c | 1 + src/generic/armcm_canboot.c | 2 +- src/generic/armcm_reset.c | 1 + src/generic/armcm_timer.c | 2 +- src/generic/misc.h | 12 ------------ src/rp2040/armcm_canboot.c | 1 + src/rp2040/timer.c | 1 + src/sched.c | 1 + src/sched.h | 1 - src/stm32/stm32f0_timer.c | 1 + 13 files changed, 30 insertions(+), 16 deletions(-) create mode 100644 src/canboot.h diff --git a/src/bootentry.c b/src/bootentry.c index e83ee96..e216a39 100644 --- a/src/bootentry.c +++ b/src/bootentry.c @@ -10,8 +10,8 @@ #include "board/gpio.h" // gpio_in_setup #include "board/misc.h" // set_bootup_code #include "bootentry.h" // bootentry_check +#include "canboot.h" // udelay #include "ctr.h" // DECL_CTR -#include "sched.h" // udelay // Generated by buildcommands.py DECL_CTR("DECL_BUTTON " __stringify(CONFIG_BUTTON_PIN)); diff --git a/src/canboot.h b/src/canboot.h new file mode 100644 index 0000000..a9e8d30 --- /dev/null +++ b/src/canboot.h @@ -0,0 +1,19 @@ +#ifndef __CANBOOT_H +#define __CANBOOT_H + +#include // uint32_t + +#define CANBOOT_SIGNATURE 0x21746f6f426e6143 // CanBoot! +#define REQUEST_CANBOOT 0x5984E3FA6CA1589B +#define REQUEST_START_APP 0x7b06ec45a9a8243d + +uint64_t get_bootup_code(void); +void set_bootup_code(uint64_t code); +void application_read_flash(uint32_t address, uint32_t *dest); +int application_check_valid(void); +void application_jump(void); + +void udelay(uint32_t usecs); +void timer_setup(void); + +#endif // canboot.h diff --git a/src/deployer.c b/src/deployer.c index 0388df5..78b201f 100644 --- a/src/deployer.c +++ b/src/deployer.c @@ -9,6 +9,8 @@ #include "board/armcm_reset.h" // try_request_canboot #include "board/flash.h" // flash_write_block #include "board/io.h" // readb +#include "board/misc.h" // timer_read_time +#include "canboot.h" // timer_setup #include "deployer.h" // deployer_is_active #include "sched.h" // sched_check_periodic diff --git a/src/flashcmd.c b/src/flashcmd.c index 9ca9615..5aff334 100644 --- a/src/flashcmd.c +++ b/src/flashcmd.c @@ -9,6 +9,7 @@ #include "board/flash.h" // flash_write_block #include "board/misc.h" // application_jump #include "byteorder.h" // cpu_to_le32 +#include "canboot.h" // application_jump #include "command.h" // command_respond_ack #include "flashcmd.h" // flashcmd_is_in_transfer #include "sched.h" // DECL_TASK diff --git a/src/generic/armcm_canboot.c b/src/generic/armcm_canboot.c index 6a8256c..513a500 100644 --- a/src/generic/armcm_canboot.c +++ b/src/generic/armcm_canboot.c @@ -9,7 +9,7 @@ #include "autoconf.h" // CONFIG_MCU #include "board/internal.h" // SysTick #include "board/irq.h" // irq_disable -#include "board/misc.h" // get_bootup_code +#include "canboot.h" // get_bootup_code #include "command.h" // DECL_CONSTANT_STR // Export MCU type diff --git a/src/generic/armcm_reset.c b/src/generic/armcm_reset.c index 0457e21..0fef20e 100644 --- a/src/generic/armcm_reset.c +++ b/src/generic/armcm_reset.c @@ -9,6 +9,7 @@ #include "board/internal.h" // NVIC_SystemReset #include "board/irq.h" // irq_disable #include "board/misc.h" // try_request_canboot +#include "canboot.h" // REQUEST_CANBOOT void try_request_canboot(void) diff --git a/src/generic/armcm_timer.c b/src/generic/armcm_timer.c index ede09eb..297a729 100644 --- a/src/generic/armcm_timer.c +++ b/src/generic/armcm_timer.c @@ -9,7 +9,7 @@ #include "board/internal.h" // SysTick #include "board/irq.h" // irq_disable #include "board/misc.h" // timer_from_us - +#include "canboot.h" // timer_setup // Return the number of clock ticks for a given number of microseconds uint32_t diff --git a/src/generic/misc.h b/src/generic/misc.h index 97d9591..fe0804e 100644 --- a/src/generic/misc.h +++ b/src/generic/misc.h @@ -8,18 +8,6 @@ struct command_encoder; void console_sendf(const struct command_encoder *ce, va_list args); void *console_receive_buffer(void); -#define CANBOOT_SIGNATURE 0x21746f6f426e6143 // CanBoot! -#define REQUEST_CANBOOT 0x5984E3FA6CA1589B -#define REQUEST_START_APP 0x7b06ec45a9a8243d - -uint64_t get_bootup_code(void); -void set_bootup_code(uint64_t code); -void application_read_flash(uint32_t address, uint32_t *dest); -int application_check_valid(void); -void application_jump(void); - -void timer_setup(void); - uint32_t timer_from_us(uint32_t us); uint8_t timer_is_before(uint32_t time1, uint32_t time2); uint32_t timer_read_time(void); diff --git a/src/rp2040/armcm_canboot.c b/src/rp2040/armcm_canboot.c index 8f271a4..0d34cae 100644 --- a/src/rp2040/armcm_canboot.c +++ b/src/rp2040/armcm_canboot.c @@ -10,6 +10,7 @@ #include "board/internal.h" // SysTick #include "board/irq.h" // irq_disable #include "board/misc.h" // get_bootup_code +#include "canboot.h" // get_bootup_code #include "command.h" // DECL_CONSTANT_STR // Export MCU type diff --git a/src/rp2040/timer.c b/src/rp2040/timer.c index c803f3e..6d7033a 100644 --- a/src/rp2040/timer.c +++ b/src/rp2040/timer.c @@ -8,6 +8,7 @@ #include "board/armcm_boot.h" // armcm_enable_irq #include "board/irq.h" // irq_disable #include "board/misc.h" // timer_read_time +#include "canboot.h" // timer_setup #include "hardware/structs/resets.h" // RESETS_RESET_UART0_BITS #include "hardware/structs/timer.h" // RESETS_RESET_UART0_BITS #include "internal.h" // enable_pclock diff --git a/src/sched.c b/src/sched.c index 4487042..45196a0 100644 --- a/src/sched.c +++ b/src/sched.c @@ -7,6 +7,7 @@ #include "board/io.h" // readb #include "board/misc.h" // jump_to_application #include "bootentry.h" // bootentry_check +#include "canboot.h" // timer_setup #include "deployer.h" // deployer_is_active #include "sched.h" // sched_check_periodic diff --git a/src/sched.h b/src/sched.h index d929256..06afe63 100644 --- a/src/sched.h +++ b/src/sched.h @@ -17,7 +17,6 @@ struct task_wake { }; // sched.c -void udelay(uint32_t usecs); void sched_wake_tasks(void); void sched_wake_task(struct task_wake *w); uint8_t sched_check_wake(struct task_wake *w); diff --git a/src/stm32/stm32f0_timer.c b/src/stm32/stm32f0_timer.c index 61a1726..afbd84c 100644 --- a/src/stm32/stm32f0_timer.c +++ b/src/stm32/stm32f0_timer.c @@ -9,6 +9,7 @@ #include "board/io.h" // readl #include "board/irq.h" // irq_disable #include "board/misc.h" // timer_read_time +#include "canboot.h" // timer_setup /****************************************************************