// © 2021 Raptor Engineering, LLC // // Released under the terms of the GPL v3 // See the LICENSE file for full details #if (WITH_ZEPHYR) #include #endif #if (WITH_ZEPHYR) #define KESTREL_SERVICE_THREAD_PRIORITY K_PRIO_PREEMPT(CONFIG_NUM_PREEMPT_PRIORITIES - 1) #endif #if (WITH_ZEPHYR) #define SW0_NODE DT_ALIAS(sw0) #if DT_NODE_HAS_STATUS(SW0_NODE, okay) #define KESTREL_HOST_POWER_BUTTON_GPIO DT_GPIO_LABEL(SW0_NODE, gpios) #define KESTREL_HOST_POWER_BUTTON_PIN DT_GPIO_PIN(SW0_NODE, gpios) #else #error "No power button defined in device tree" #endif #define SW1_NODE DT_ALIAS(sw1) #if DT_NODE_HAS_STATUS(SW1_NODE, okay) #define KESTREL_HOST_RESET_BUTTON_GPIO DT_GPIO_LABEL(SW1_NODE, gpios) #define KESTREL_HOST_RESET_BUTTON_PIN DT_GPIO_PIN(SW1_NODE, gpios) #else #error "No reset button defined in device tree" #endif #endif #define HOST_POWER_STATUS_OFFLINE 0 #define HOST_POWER_STATUS_POWERING_ON 1 #define HOST_POWER_STATUS_RUNNING 2 #define HOST_POWER_STATUS_POWERING_OFF 3 struct firmware_buffer_region { uint8_t *buffer_address; unsigned long long buffer_length; uintptr_t current_write_offset; unsigned long long valid_bytes; uint8_t locked; uint8_t overflow; }; extern struct firmware_buffer_region main_firmware_buffer; extern uint8_t kestrel_basic_init_complete; extern uint8_t host_background_service_task_active; extern uint8_t host_console_service_task_requested; extern uint8_t host_power_status; #if (WITH_ZEPHYR) extern k_tid_t kestrel_service_thread_id; extern k_tid_t kestrel_console_thread_id; extern const struct shell *host_console_service_task_shell; #endif int kestrel_init(void); int power_on_host(void); void power_off_chassis(void); void print_chassis_status(void); int write_flash_buffer_to_flash(void); int primary_service_event_loop(void); #if (WITH_ZEPHYR) int attach_to_host_console(const struct shell *shell); int host_console_event_loop(const struct shell *shell); #else int attach_to_host_console(); #endif