2020-01-22 07:02:12 +03:00
|
|
|
#ifndef __LIB__BLIB_H__
|
|
|
|
#define __LIB__BLIB_H__
|
|
|
|
|
|
|
|
#include <stddef.h>
|
2020-01-25 04:05:19 +03:00
|
|
|
#include <stdint.h>
|
2020-10-17 07:23:11 +03:00
|
|
|
#include <stdbool.h>
|
2021-02-25 13:28:14 +03:00
|
|
|
#include <fs/file.h>
|
2021-03-02 12:23:43 +03:00
|
|
|
#include <lib/part.h>
|
2021-08-16 19:02:28 +03:00
|
|
|
#include <lib/libc.h>
|
2021-07-15 11:03:47 +03:00
|
|
|
#if uefi == 1
|
2021-03-02 12:23:43 +03:00
|
|
|
# include <efi.h>
|
|
|
|
#endif
|
|
|
|
|
2021-07-15 11:03:47 +03:00
|
|
|
#if uefi == 1
|
2021-03-02 12:23:43 +03:00
|
|
|
extern EFI_SYSTEM_TABLE *gST;
|
|
|
|
extern EFI_BOOT_SERVICES *gBS;
|
|
|
|
extern EFI_RUNTIME_SERVICES *gRT;
|
2021-03-05 06:20:58 +03:00
|
|
|
extern EFI_HANDLE efi_image_handle;
|
2021-04-29 00:41:34 +03:00
|
|
|
extern EFI_MEMORY_DESCRIPTOR *efi_mmap;
|
2021-08-25 23:03:00 +03:00
|
|
|
extern UINTN efi_mmap_size, efi_desc_size;
|
|
|
|
extern UINT32 efi_desc_ver;
|
2021-03-05 06:20:58 +03:00
|
|
|
|
|
|
|
extern bool efi_boot_services_exited;
|
|
|
|
bool efi_exit_boot_services(void);
|
2021-03-02 12:23:43 +03:00
|
|
|
#endif
|
2020-10-01 03:12:13 +03:00
|
|
|
|
2021-08-22 19:29:18 +03:00
|
|
|
void copyright_notice(void);
|
|
|
|
|
2021-03-11 02:23:44 +03:00
|
|
|
extern struct volume *boot_volume;
|
2020-10-01 03:12:13 +03:00
|
|
|
|
2021-07-15 11:03:47 +03:00
|
|
|
#if bios == 1
|
2021-02-22 08:14:27 +03:00
|
|
|
extern bool stage3_loaded;
|
2021-03-11 02:23:44 +03:00
|
|
|
#endif
|
2020-12-29 03:01:38 +03:00
|
|
|
|
2021-05-11 07:46:42 +03:00
|
|
|
extern bool verbose;
|
|
|
|
|
2021-08-16 19:02:28 +03:00
|
|
|
bool parse_resolution(size_t *width, size_t *height, size_t *bpp, const char *buf);
|
2020-11-09 14:31:47 +03:00
|
|
|
|
2021-09-02 00:01:03 +03:00
|
|
|
uint32_t get_crc32(void *_stream, size_t len);
|
|
|
|
|
2020-09-30 18:29:07 +03:00
|
|
|
uint64_t sqrt(uint64_t a_nInput);
|
2021-07-17 09:19:03 +03:00
|
|
|
size_t get_trailing_zeros(uint64_t val);
|
2020-09-30 18:29:07 +03:00
|
|
|
|
2020-11-02 11:20:34 +03:00
|
|
|
int digit_to_int(char c);
|
2020-04-30 22:19:12 +03:00
|
|
|
uint8_t bcd_to_int(uint8_t val);
|
|
|
|
|
2020-05-10 01:48:58 +03:00
|
|
|
__attribute__((noreturn)) void panic(const char *fmt, ...);
|
2020-04-13 09:21:25 +03:00
|
|
|
|
2021-03-04 15:48:31 +03:00
|
|
|
int pit_sleep_and_quit_on_keypress(int seconds);
|
2020-01-22 07:02:12 +03:00
|
|
|
|
2020-11-05 14:50:42 +03:00
|
|
|
uint64_t strtoui(const char *s, const char **end, int base);
|
2020-01-22 07:02:12 +03:00
|
|
|
|
2021-08-16 19:02:28 +03:00
|
|
|
#if defined (__i386__)
|
|
|
|
void memcpy32to64(uint64_t, uint64_t, uint64_t);
|
|
|
|
#elif defined (__x86_64__)
|
|
|
|
# define memcpy32to64(X, Y, Z) memcpy((void *)(uintptr_t)(X), (void *)(uintptr_t)(Y), Z)
|
|
|
|
#endif
|
|
|
|
|
2020-01-22 07:02:12 +03:00
|
|
|
#define DIV_ROUNDUP(a, b) (((a) + ((b) - 1)) / (b))
|
|
|
|
|
2020-09-17 13:06:35 +03:00
|
|
|
#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; \
|
|
|
|
})
|
2020-01-22 07:02:12 +03:00
|
|
|
|
2020-05-01 18:19:29 +03:00
|
|
|
#define SIZEOF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
|
|
|
|
|
2021-02-25 03:24:54 +03:00
|
|
|
typedef char symbol[];
|
2020-09-17 13:06:35 +03:00
|
|
|
|
2021-07-06 00:28:04 +03:00
|
|
|
__attribute__((noreturn)) void common_spinup(void *fnptr, int args, ...);
|
2021-03-07 02:52:25 +03:00
|
|
|
|
2020-01-22 07:02:12 +03:00
|
|
|
#endif
|