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-09-30 18:29:07 +03:00
|
|
|
uint64_t sqrt(uint64_t a_nInput);
|
|
|
|
|
2020-04-30 22:19:12 +03:00
|
|
|
uint8_t bcd_to_int(uint8_t val);
|
|
|
|
|
2020-04-30 14:03:04 +03:00
|
|
|
int cpuid(uint32_t leaf, uint32_t subleaf,
|
|
|
|
uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx);
|
|
|
|
|
2020-05-10 01:48:58 +03:00
|
|
|
__attribute__((noreturn)) void panic(const char *fmt, ...);
|
2020-04-13 09:21:25 +03:00
|
|
|
|
2020-04-25 21:33:26 +03:00
|
|
|
int pit_sleep_and_quit_on_keypress(uint32_t pit_ticks);
|
2020-01-22 07:02:12 +03:00
|
|
|
|
2020-01-25 06:49:11 +03:00
|
|
|
#define GETCHAR_CURSOR_LEFT (-10)
|
|
|
|
#define GETCHAR_CURSOR_RIGHT (-11)
|
|
|
|
#define GETCHAR_CURSOR_UP (-12)
|
|
|
|
#define GETCHAR_CURSOR_DOWN (-13)
|
|
|
|
|
|
|
|
int getchar(void);
|
2020-01-25 05:06:56 +03:00
|
|
|
void gets(const char *orig_str, char *buf, size_t limit);
|
2020-01-22 09:13:19 +03:00
|
|
|
uint64_t strtoui(const char *s);
|
2020-09-24 22:48:49 +03:00
|
|
|
uint64_t strtoui16(const char *s);
|
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]))
|
|
|
|
|
2020-09-17 13:06:35 +03:00
|
|
|
typedef void *symbol[];
|
|
|
|
|
2020-01-22 07:02:12 +03:00
|
|
|
#endif
|