diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-28 09:30:38 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-28 09:30:38 +0100 |
| commit | 7df7ed6d026c5e1f3b8111e3536af3771301c177 (patch) | |
| tree | f87916ee645aec06971a84dc1e9e5f1267fbe755 /lib/boot.h | |
| parent | 176cf8f237745d658185a2fba8fff1401c1c2b5f (diff) | |
feat! firmware breaking changes on the API.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'lib/boot.h')
| -rw-r--r-- | lib/boot.h | 214 |
1 files changed, 0 insertions, 214 deletions
diff --git a/lib/boot.h b/lib/boot.h deleted file mode 100644 index 0badfc0..0000000 --- a/lib/boot.h +++ /dev/null @@ -1,214 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2024, Amlal El Mahrouss, licensed under Apache 2.0. - -------------------------------------------- */ - -#pragma once - -/// -/// @file boot.h -/// @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; - -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 __INTPTR_TYPE__ intptr_t; - -typedef __INT64_TYPE__ int64_t; -typedef __INT32_TYPE__ int32_t; -typedef __INT16_TYPE__ int16_t; -typedef char int8_t; - -typedef void* voidptr_t; -typedef char* addr_t; -typedef const char* caddr_t; - -typedef __UINTPTR_TYPE__ ptrtype_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 - -#ifndef null -#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 - -#define boolean char - -#define no __no -#define yes __yes - -#ifndef __cplusplus -#define bool boolean -#define false no -#define true yes -#endif //!_cplusplus - -#define NB_RESTART 0 -#define NB_SHUTDOWN 1 - -#ifndef asm -#define asm __asm -#endif // ifndef asm - -#define __COPYRIGHT(s) /* unused */ - -#ifdef __COMPILE_RISCV__ -#define NB_BOOT_ADDR (0x80020000) -#define NB_BOOT_ADDR_STR "0x80020000" -#define NB_FRAMEBUFFER_ADDR 0x40000000L -#define NB_UART_BASE 0x10000000 -#define NB_FLASH_BASE_ADDR 0x08000000 - -#define cb_sync_synchronize() __sync_synchronize() -#elif defined(__COMPILE_POWERPC__) -#define NB_UART_BASE 0x10000000 -#define NB_BOOT_ADDR 0x1030000 -#define NB_BOOT_ADDR_STR "0x1030000" -#define NB_FRAMEBUFFER_ADDR 0x40000000L -#define NB_FLASH_BASE_ADDR 0x08000000 - -#define cb_sync_synchronize() __sync_synchronize() -#elif defined(__COMPILE_ARM64__) - -#define NB_UART_BASE 0x09000000 -#define NB_BOOT_ADDR 0x1030000 -#define NB_BOOT_ADDR_STR "0x1030000" -#define NB_FRAMEBUFFER_ADDR 0x40000000L -#define NB_FLASH_BASE_ADDR 0x08000000 - -static inline void __sync_synchronize(void) { - /// leave it as is. -} - -#define cb_sync_synchronize() __sync_synchronize() -#endif // ifndef __COMPILE_POWERPC__ - -#define NB_BAUDRATE_TABLE \ - { 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 } - -#define NB_STRING(s) #s - -#define NB_BOOT_MAG_0 'C' -#define NB_BOOT_MAG_1 'B' - -#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(); - - - -/// @brief Binary64 representation (IEE 7554) in a C structure -typedef union { - struct { - char __sign; - int32_t __mantissa; - int16_t __exponent; - }; - - 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); - -/// @brief update the power status of the machine. -void cb_update_power_status(boolean restart); - -/// @brief puts a string in serial -/// @param text -/// @return -size_t cb_put_string(const ascii_char_t* _Nonnull text); - -/// @brief gets a char from serial -/// @param -/// @return -utf_char_t cb_get_char(void); - -/// @brief puts a char in serial -/// @param ch -void cb_put_char(utf_char_t ch); - -/// @brief Hangs the firmware. -/// @param void no args. -void cb_restart_machine(void); - -/// @brief Flushs the TLB. -/// @param void no args. -void cb_flush_tlb(void); - -/// @brief Print current kernel name. -/// @param -void cb_print_name(void); - -/// @brief String length getter -/// @param str the string. -/// @return -size_t strlen(_Nonnull caddr_t str); - -/// @brief Compare two strings. -/// @param src source string -/// @param cmp string to compare. -/// @return -size_t strcmp(_Nonnull caddr_t src, _Nonnull caddr_t cmp); - -typedef void (*cb_proc_t)(); - -/// \brief ASCII character. -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) -}; - -// EOF. |
