rulimine/stage2/lib/blib.h

44 lines
927 B
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>
2020-10-01 03:12:13 +03:00
extern uint8_t boot_drive;
2020-10-01 03:12:13 +03:00
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]))
typedef void *symbol[];
2020-01-22 07:02:12 +03:00
#endif