mirror of
https://github.com/limine-bootloader/limine
synced 2024-12-13 18:17:17 +03:00
e1f6ac8860
* Initial aarch64 port * Enable chainload on aarch64 No changes necessary since it's all UEFI anyway. * Add specification for Limine protocol for aarch64 * PROTOCOL: Specify state of information in DT /chosen node * common: Add spinup code for aarch64 * common: Port elf and term to aarch64 * common: Port vmm to aarch64 Also prepare to drop VMM_FLAG_PRESENT on x86. * protos: Port limine boot protocol to aarch64 Also drop VMM_FLAG_PRESENT since we never unmap pages anyway. * test: Add DTB request * PROTOCOL: Port SMP request to aarch64 * cpu: Add cache maintenance functions for aarch64 * protos/limine, sys: Port SMP to aarch64 Also move common asm macros into a header file. * test: Start up APs * vmm: Unify get_next_level and implement large page splitting * protos/limine: Map framebuffer using correct caching mode on AArch64 * CI: Fix GCC build for aarch64 * entry, menu: Replace uses of naked attribute with separate asm file GCC does not understand the naked attribute on aarch64, and didn't understand it for x86 in older versions.
104 lines
2.6 KiB
C
104 lines
2.6 KiB
C
#ifndef __LIB__BLIB_H__
|
|
#define __LIB__BLIB_H__
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <stdnoreturn.h>
|
|
#include <fs/file.h>
|
|
#include <lib/part.h>
|
|
#include <lib/libc.h>
|
|
#if uefi == 1
|
|
# include <efi.h>
|
|
#endif
|
|
|
|
#if uefi == 1
|
|
extern EFI_SYSTEM_TABLE *gST;
|
|
extern EFI_BOOT_SERVICES *gBS;
|
|
extern EFI_RUNTIME_SERVICES *gRT;
|
|
extern EFI_HANDLE efi_image_handle;
|
|
extern EFI_MEMORY_DESCRIPTOR *efi_mmap;
|
|
extern UINTN efi_mmap_size, efi_desc_size;
|
|
extern UINT32 efi_desc_ver;
|
|
|
|
extern bool efi_boot_services_exited;
|
|
bool efi_exit_boot_services(void);
|
|
#endif
|
|
|
|
extern const char bsd_2_clause[];
|
|
|
|
extern struct volume *boot_volume;
|
|
|
|
#if bios == 1
|
|
extern bool stage3_loaded;
|
|
#endif
|
|
|
|
extern bool quiet, serial, editor_enabled;
|
|
|
|
bool parse_resolution(size_t *width, size_t *height, size_t *bpp, const char *buf);
|
|
|
|
uint32_t get_crc32(void *_stream, size_t len);
|
|
|
|
uint32_t oct2bin(uint8_t *str, uint32_t max);
|
|
uint32_t hex2bin(uint8_t *str, uint32_t size);
|
|
|
|
uint64_t sqrt(uint64_t a_nInput);
|
|
size_t get_trailing_zeros(uint64_t val);
|
|
|
|
int digit_to_int(char c);
|
|
uint8_t bcd_to_int(uint8_t val);
|
|
uint8_t int_to_bcd(uint8_t val);
|
|
|
|
noreturn void panic(bool allow_menu, const char *fmt, ...);
|
|
|
|
int pit_sleep_and_quit_on_keypress(int seconds);
|
|
|
|
uint64_t strtoui(const char *s, const char **end, int base);
|
|
|
|
#if defined (__i386__)
|
|
void memcpy32to64(uint64_t, uint64_t, uint64_t);
|
|
#elif defined (__x86_64__) || defined (__aarch64__)
|
|
# define memcpy32to64(X, Y, Z) memcpy((void *)(uintptr_t)(X), (void *)(uintptr_t)(Y), Z)
|
|
#else
|
|
#error Unknown architecture
|
|
#endif
|
|
|
|
#define DIV_ROUNDUP(a, b) (((a) + ((b) - 1)) / (b))
|
|
|
|
#define ALIGN_UP(x, a) ({ \
|
|
typeof(x) value = x; \
|
|
typeof(a) align = a; \
|
|
value = DIV_ROUNDUP(value, align) * align; \
|
|
value; \
|
|
})
|
|
|
|
#define ALIGN_DOWN(x, a) ({ \
|
|
typeof(x) value = x; \
|
|
typeof(a) align = a; \
|
|
value = (value / align) * align; \
|
|
value; \
|
|
})
|
|
|
|
#define SIZEOF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
|
|
|
|
typedef char symbol[];
|
|
|
|
noreturn void stage3_common(void);
|
|
|
|
#if defined (__x86_64__) || defined (__i386__)
|
|
noreturn void common_spinup(void *fnptr, int args, ...);
|
|
#elif defined (__aarch64__)
|
|
noreturn void enter_in_current_el(uint64_t entry, uint64_t sp, uint64_t sctlr,
|
|
uint64_t target_x0);
|
|
|
|
noreturn void enter_in_el1(uint64_t entry, uint64_t sp, uint64_t sctlr,
|
|
uint64_t mair, uint64_t tcr, uint64_t ttbr0,
|
|
uint64_t ttbr1, uint64_t target_x0);
|
|
#else
|
|
#error Unknown architecture
|
|
#endif
|
|
|
|
#define no_unwind __attribute__((section(".no_unwind")))
|
|
|
|
#endif
|