rulimine/stage23/lib/blib.h

56 lines
1.1 KiB
C
Raw Normal View History

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>
#include <stdbool.h>
#include <fs/file.h>
2020-10-01 03:12:13 +03:00
extern uint8_t boot_drive;
2020-12-09 15:02:05 +03:00
extern int boot_partition;
2020-10-01 03:12:13 +03:00
extern bool booted_from_pxe;
2021-02-21 05:45:24 +03:00
extern bool booted_from_cd;
2021-02-22 08:14:27 +03:00
extern bool stage3_loaded;
bool parse_resolution(int *width, int *height, int *bpp, const char *buf);
2020-09-30 18:29:07 +03:00
uint64_t sqrt(uint64_t a_nInput);
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
int pit_sleep_and_quit_on_keypress(uint32_t pit_ticks);
2020-01-22 07:02:12 +03:00
uint64_t strtoui(const char *s, const char **end, int base);
2020-01-22 07:02:12 +03:00
#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; \
})
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[];
enum {
BOOT_FROM_HDD,
BOOT_FROM_PXE,
BOOT_FROM_CD
};
2020-01-22 07:02:12 +03:00
#endif