rulimine/stage23/lib/blib.h

56 lines
1.1 KiB
C

#ifndef __LIB__BLIB_H__
#define __LIB__BLIB_H__
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <fs/file.h>
extern uint8_t boot_drive;
extern int boot_partition;
extern bool booted_from_pxe;
extern bool booted_from_cd;
extern bool stage3_loaded;
bool parse_resolution(int *width, int *height, int *bpp, const char *buf);
uint64_t sqrt(uint64_t a_nInput);
int digit_to_int(char c);
uint8_t bcd_to_int(uint8_t val);
__attribute__((noreturn)) void panic(const char *fmt, ...);
int pit_sleep_and_quit_on_keypress(uint32_t pit_ticks);
uint64_t strtoui(const char *s, const char **end, int base);
#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[];
enum {
BOOT_FROM_HDD,
BOOT_FROM_PXE,
BOOT_FROM_CD
};
#endif