From 5ec6ba7ee09ae09715a09c6194ce0dba00ed80aa Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 8 Dec 2025 02:59:01 -0500 Subject: [PATCH 1/3] chore: new `nullptr_t` (for pre-C23 targets), auto_type, and asm macro definition. Signed-off-by: Amlal El Mahrouss --- lib/boot.h | 53 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/lib/boot.h b/lib/boot.h index 00242f0..e81a671 100644 --- a/lib/boot.h +++ b/lib/boot.h @@ -11,6 +11,13 @@ /// @brief NeBoot types, data structures, and standard library. /// +#ifdef __unix__ +#undef __unix__ +#define __unix__ 7 +#endif // !__unix__ + +#define __mpboot__ __unix__ + typedef __UINTPTR_TYPE__ uintptr_t; typedef __UINT32_TYPE__ phys_addr_t; @@ -21,13 +28,6 @@ typedef unsigned uint32_t; typedef unsigned short uint16_t; typedef unsigned char uint8_t; -#ifdef __unix__ -#undef __unix__ -#define __unix__ 7 -#endif // !__unix__ - -#define __mpboot__ __unix__ - typedef __INTPTR_TYPE__ intptr_t; typedef __INT64_TYPE__ int64_t; @@ -52,6 +52,16 @@ typedef ptrtype_t size_t; #define null ((voidptr_t) 0) #endif // ifndef null +/// C23 introduces `nullptr`: https://en.cppreference.com/w/c/language/nullptr.html +#if __STDC_VERSION__ < 202311L +#define nullptr ((struct nullptr_*)null) + +struct nullptr_ { char __nullv; }; +typedef struct nullptr_* nullptr_t; +#endif + +#define auto_type void* + #define __no 0 #define __yes 1 @@ -69,6 +79,10 @@ typedef ptrtype_t size_t; #define NB_RESTART 0 #define NB_SHUTDOWN 1 +#ifndef asm +#define asm __asm +#endif // ifndef asm + #define __COPYRIGHT(s) /* unused */ #ifdef __COMPILE_RISCV__ @@ -93,7 +107,7 @@ typedef ptrtype_t size_t; #define NB_BOOT_ADDR 0x1030000 #define NB_BOOT_ADDR_STR "0x1030000" #define NB_FRAMEBUFFER_ADDR 0x40000000L -#define NB_FLASH_BASE_ADDR 0x60000000 +#define NB_FLASH_BASE_ADDR 0x08000000 static inline void __sync_synchronize(void) { /// leave it as is. @@ -116,20 +130,25 @@ static inline void __sync_synchronize(void) { volatile cb_proc_t proc_##offset = (volatile cb_proc_t)(struct->offset); \ proc_##offset(); -/// @brief floating point representation (IEE 7554) in a C structure + + +/// @brief Binary64 representation (IEE 7554) in a C structure typedef union { struct { - char sign; - int32_t mantissa; - int16_t exponent; + char __sign; + int32_t __mantissa; + int16_t __exponent; }; - float f; -} float_t; + float __fv; +} __attribute__((packed)) binary64_t; /// \brief UTF-32 character typedef uint32_t utf_char_t; +/// \brief ASCII character +typedef char ascii_char_t; + /// @brief panic the entire system. /// @param reason why text. void cb_panic(const char* reason); @@ -140,7 +159,7 @@ void cb_update_power_status(boolean restart); /// @brief puts a string in serial /// @param text /// @return -size_t cb_put_string(const char* text); +size_t cb_put_string(const ascii_char_t* _Nonnull text); /// @brief gets a char from serial /// @param @@ -166,13 +185,13 @@ void cb_print_name(void); /// @brief String length getter /// @param str the string. /// @return -size_t strlen(caddr_t str); +size_t strlen(_Nonnull caddr_t str); /// @brief Compare two strings. /// @param src source string /// @param cmp string to compare. /// @return -size_t strcmp(caddr_t src, caddr_t cmp); +size_t strcmp(_Nonnull caddr_t src, _Nonnull caddr_t cmp); typedef void (*cb_proc_t)(); From 2661a95d686375737aa88a41808c3cc49ae12ec5 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 8 Dec 2025 03:01:29 -0500 Subject: [PATCH 2/3] chore: update CI. Signed-off-by: Amlal El Mahrouss --- .github/workflows/arm64.yml | 6 +++--- .github/workflows/rv64.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/arm64.yml b/.github/workflows/arm64.yml index 80c4d8b..493efa2 100644 --- a/.github/workflows/arm64.yml +++ b/.github/workflows/arm64.yml @@ -1,10 +1,10 @@ -name: FW CI (ARM64) +name: FW CI (ARM64, develop) on: push: - branches: [ "stable" ] + branches: [ "develop" ] pull_request: - branches: [ "stable" ] + branches: [ "develop" ] jobs: build: diff --git a/.github/workflows/rv64.yml b/.github/workflows/rv64.yml index 23fef58..d9aaffb 100644 --- a/.github/workflows/rv64.yml +++ b/.github/workflows/rv64.yml @@ -1,10 +1,10 @@ -name: FW CI (RV64) +name: FW CI (RV64, develop) on: push: - branches: [ "stable" ] + branches: [ "develop" ] pull_request: - branches: [ "stable" ] + branches: [ "develop" ] jobs: build: From e6ff3efb7e2f44f5fb2463435e3f45300d7223a6 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 8 Dec 2025 03:02:46 -0500 Subject: [PATCH 3/3] chore: define `_Nonnull` when not available. Signed-off-by: Amlal El Mahrouss --- lib/boot.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/boot.h b/lib/boot.h index e81a671..0badfc0 100644 --- a/lib/boot.h +++ b/lib/boot.h @@ -126,6 +126,10 @@ static inline void __sync_synchronize(void) { #define NB_BOOT_VER 0x101 +#ifndef _Nonnull +#define _Nonnull +#endif // ifndef _Nonnull + #define NB_BOOT_CALL(struct, offset) \ volatile cb_proc_t proc_##offset = (volatile cb_proc_t)(struct->offset); \ proc_##offset();