diff options
| author | Amlal <amlal@nekernel.org> | 2025-04-25 13:28:08 +0200 |
|---|---|---|
| committer | Amlal <amlal@nekernel.org> | 2025-04-25 13:28:08 +0200 |
| commit | 1c8414d3348c55fcf132839a04fdedec5efaacbe (patch) | |
| tree | 5c7386fae0504a798801e0b34b588f4177ba67c1 /lib/boot.h | |
| parent | d7e35959ebb6b1dd892a99f23c2a7f23c0f99041 (diff) | |
dev: refactor codebase.
Signed-off-by: Amlal <amlal@nekernel.org>
Diffstat (limited to 'lib/boot.h')
| -rw-r--r-- | lib/boot.h | 109 |
1 files changed, 52 insertions, 57 deletions
@@ -1,6 +1,6 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ @@ -12,101 +12,98 @@ /// typedef __UINTPTR_TYPE__ uintptr_t; -typedef __UINT32_TYPE__ phys_addr_t; +typedef __UINT32_TYPE__ phys_addr_t; typedef unsigned long ulong_t; typedef unsigned long long int uint64_t; -typedef unsigned uint32_t; -typedef unsigned short uint16_t; -typedef unsigned char uint8_t; +typedef unsigned uint32_t; +typedef unsigned short uint16_t; +typedef unsigned char uint8_t; #ifdef __unix__ #undef __unix__ #define __unix__ 7 -#endif // !__unix__ +#endif // !__unix__ #define __mpboot__ __unix__ typedef __INTPTR_TYPE__ intptr_t; typedef __INT64_TYPE__ int64_t; -typedef int int32_t; -typedef short int16_t; -typedef char int8_t; +typedef int int32_t; +typedef short int16_t; +typedef char int8_t; -typedef void* voidptr_t; -typedef char* addr_t; +typedef void* voidptr_t; +typedef char* addr_t; typedef const char* caddr_t; typedef __UINTPTR_TYPE__ ptrtype_t; -typedef ptrtype_t size_t; +typedef ptrtype_t size_t; #define array_size(arr) (sizeof(arr[0]) / sizeof(arr)) #ifndef nil -#define nil ((voidptr_t)0) -#endif // ifndef nil +#define nil ((voidptr_t) 0) +#endif // ifndef nil #ifndef null -#define null ((voidptr_t)0) -#endif // ifndef null +#define null ((voidptr_t) 0) +#endif // ifndef null -#define __no 0 +#define __no 0 #define __yes 1 #define boolean char -#define no __no +#define no __no #define yes __yes #ifndef __cplusplus #define bool boolean #define false no #define true yes -#endif //!_cplusplus +#endif //!_cplusplus -#define CB_RESTART 0 +#define CB_RESTART 0 #define CB_SHUTDOWN 1 #define __COPYRIGHT(s) /* unused */ #ifdef __COMPILE_RISCV__ -#define CB_BOOT_ADDR (0x80020000) -#define CB_BOOT_ADDR_STR "0x80020000" +#define CB_BOOT_ADDR (0x80020000) +#define CB_BOOT_ADDR_STR "0x80020000" #define CB_FRAMEBUFFER_ADDR 0x40000000L -#define CB_UART_BASE 0x10000000 -#define CB_FLASH_BASE_ADDR 0x08000000 +#define CB_UART_BASE 0x10000000 +#define CB_FLASH_BASE_ADDR 0x08000000 #define cb_sync_synchronize() __sync_synchronize() #elif defined(__COMPILE_POWERPC__) -#define CB_UART_BASE 0x10000000 -#define CB_BOOT_ADDR 0x1030000 -#define CB_BOOT_ADDR_STR "0x1030000" +#define CB_UART_BASE 0x10000000 +#define CB_BOOT_ADDR 0x1030000 +#define CB_BOOT_ADDR_STR "0x1030000" #define CB_FRAMEBUFFER_ADDR 0x40000000L -#define CB_FLASH_BASE_ADDR 0x08000000 +#define CB_FLASH_BASE_ADDR 0x08000000 #define cb_sync_synchronize() __sync_synchronize() #elif defined(__COMPILE_ARM64__) -#define CB_UART_BASE 0x09000000 -#define CB_BOOT_ADDR 0x1030000 -#define CB_BOOT_ADDR_STR "0x1030000" +#define CB_UART_BASE 0x09000000 +#define CB_BOOT_ADDR 0x1030000 +#define CB_BOOT_ADDR_STR "0x1030000" #define CB_FRAMEBUFFER_ADDR 0x40000000L -#define CB_FLASH_BASE_ADDR 0x08000000 +#define CB_FLASH_BASE_ADDR 0x08000000 -static inline void __sync_synchronize(void) -{ - /// leave it as is. +static inline void __sync_synchronize(void) { + /// leave it as is. } #define cb_sync_synchronize() __sync_synchronize() -#endif // ifndef __COMPILE_POWERPC__ +#endif // ifndef __COMPILE_POWERPC__ -#define CB_BAUDRATE_TABLE \ - { \ - 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 \ - } +#define CB_BAUDRATE_TABLE \ + { 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 } #define CB_STRING(s) #s @@ -115,20 +112,19 @@ static inline void __sync_synchronize(void) #define CB_BOOT_VER 0x101 -#define CB_BOOT_CALL(struct, offset) \ - volatile cb_proc_t proc_##offset = (volatile cb_proc_t)(struct->offset); \ - proc_##offset(); +#define CB_BOOT_CALL(struct, offset) \ + volatile cb_proc_t proc_##offset = (volatile cb_proc_t)(struct->offset); \ + proc_##offset(); /// @brief floating point representation (IEE 7554) in a C structure typedef union { - struct - { - char sign; - int32_t mantissa; - int16_t exponent; - }; - - float f; + struct { + char sign; + int32_t mantissa; + int16_t exponent; + }; + + float f; } float_t; /// \brief UTF-32 character @@ -185,12 +181,11 @@ typedef char ascii_char_t; /// @brief Linear Executable Header /// @author Amlal EL Mahrouss (Amlal EL Mahrouss) -struct __attribute__((aligned(4))) cb_boot_header -{ - const ascii_char_t h_mag[2]; // magic number - const ascii_char_t h_name[10]; // operating system name - const uint32_t h_revision; // firmware revision - const uint64_t h_start_address; // start address (master/slave(s) thread) +struct __attribute__((aligned(4))) cb_boot_header { + const ascii_char_t h_mag[2]; // magic number + const ascii_char_t h_name[10]; // operating system name + const uint32_t h_revision; // firmware revision + const uint64_t h_start_address; // start address (master/slave(s) thread) }; // EOF. |
