Integrate uACPI
This commit is contained in:
@ -10,6 +10,43 @@
|
||||
#include "vfs/vfs.h"
|
||||
#include "baseimg/baseimg.h"
|
||||
#include "storedev/storedev.h"
|
||||
#include "util/util.h"
|
||||
|
||||
const char *human_size(uint64_t bytes, char *buf, size_t bufsize) {
|
||||
static const char *units[] = { "B", "KiB", "MiB", "GiB", "TiB", "PiB" };
|
||||
int unit = 0;
|
||||
|
||||
// Scale down until value fits nicely
|
||||
uint64_t rem = 0;
|
||||
while (bytes >= 1024 && unit < (int)(sizeof(units)/sizeof(units[0])) - 1) {
|
||||
rem = bytes % 1024;
|
||||
bytes /= 1024;
|
||||
unit++;
|
||||
}
|
||||
|
||||
if (unit == 0) {
|
||||
// Just bytes
|
||||
ksnprintf(buf, bufsize, "%llu %s", (unsigned long long)bytes, units[unit]);
|
||||
} else {
|
||||
// Show one decimal place without using floats
|
||||
// Multiply remainder by 10 to get first decimal digit
|
||||
uint64_t frac = (rem * 10 + 512) / 1024; // rounded
|
||||
if (frac == 10) { // handle carry, e.g. 1023.9 -> 1024.0
|
||||
bytes++;
|
||||
frac = 0;
|
||||
}
|
||||
|
||||
if (frac > 0) ksnprintf(buf, bufsize, "%llu.%llu %s", (unsigned long long)bytes, (unsigned long long)frac, units[unit]);
|
||||
else ksnprintf(buf, bufsize, "%llu %s", (unsigned long long)bytes, units[unit]);
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
void log_bootinfo(void) {
|
||||
char buf[100];
|
||||
LOG("kmain", "Memory total = %s\n", human_size(BOOT_INFO.memmap_total, buf, sizeof(buf)));
|
||||
}
|
||||
|
||||
static volatile LIMINE_BASE_REVISION(2);
|
||||
|
||||
@ -20,10 +57,12 @@ void kmain(void) {
|
||||
|
||||
bootinfo_init();
|
||||
term_init();
|
||||
log_bootinfo();
|
||||
hal_init();
|
||||
pmm_init();
|
||||
paging_init();
|
||||
dlmalloc_check();
|
||||
hal_init_withmalloc();
|
||||
storedev_init();
|
||||
baseimg_init();
|
||||
vfs_init();
|
||||
|
Reference in New Issue
Block a user