Floating point numbers work, _start.S fix stack alignment, fix debug info

This commit is contained in:
2026-03-07 19:56:59 +01:00
parent 55d9b1fcd5
commit bf99bedfc5
5 changed files with 35 additions and 7 deletions

View File

@@ -11,6 +11,7 @@
#include <kb.h>
#include <liballoc.h>
#include <path.h>
#include <printf.h>
#include <process.h>
#include <stddef.h>
#include <str_status.h>
@@ -24,6 +25,26 @@ bool interp_is_running (void) { return run; }
void interp_shutdown (void) { run = false; }
static void human_size (double size, double* out, char** str) {
if (size >= 1024.0f && size < 1024.0f * 1024.0f) {
*out = (double)size / 1024.0f;
*str = "KiB";
} else if (size >= 1024.0f * 1024.0f && size < 1024.0f * 1024.0f * 1024.0f) {
*out = (double)size / (1024.0f * 1024.0f);
*str = "MiB";
} else if (size >= 1024.0f * 1024.0f * 1024.0f && size < 1024.0f * 1024.0f * 1024.0f * 1024.0f) {
*out = (double)size / (1024.0f * 1024.0f * 1024.0f);
*str = "GiB";
} else if (size >= 1024.0f * 1024.0f * 1024.0f * 1024.0f &&
size < 1024.0f * 1024.0f * 1024.0f * 1024.0f * 1024.0f) {
*out = (double)size / (1024.0f * 1024.0f * 1024.0f * 1024.0f);
*str = "TiB";
} else {
*out = 0.0f;
*str = "???";
}
}
static void echo (struct context* context, char** strings, size_t strings_count) {
for (size_t i = 0; i < strings_count; i++)
cprintf (context, "%s ", strings[i]);
@@ -192,8 +213,16 @@ static void ls (struct context* context, const char* path_string) {
read_dir_entry (path, &entry, entry_num);
describe (entry.path, &desc);
cprintf (context, "%c %-40s %-40zu\n", (desc.type == FS_DIR ? 'D' : 'F'), entry.path,
desc.size);
char* hs_string;
double hs;
human_size ((double)desc.size, &hs, &hs_string);
char size_buf[64];
snprintf (size_buf, sizeof (size_buf), "%.2f %s", hs, hs_string);
char type = (desc.type == FS_DIR ? 'D' : 'F');
cprintf (context, "%c %-40s %-40s\n", type, entry.path, size_buf);
}
volume_close ();