From 5481848e27fdd4fc859def9841a0283665531a46 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 13 Sep 2020 17:12:29 -0400 Subject: fixed some paging bugs, added fault handlers and new programs --- src/user/knob/entry.asm | 1 - src/user/knob/format.c | 14 ++++++++++++++ src/user/knob/user.c | 14 +++++++++----- 3 files changed, 23 insertions(+), 6 deletions(-) (limited to 'src/user/knob') diff --git a/src/user/knob/entry.asm b/src/user/knob/entry.asm index 18faf7f..acf6f5f 100644 --- a/src/user/knob/entry.asm +++ b/src/user/knob/entry.asm @@ -12,7 +12,6 @@ _entry: mov esp, stack push edx - ;TODO: heap stuff? ;TODO: determine current_disk ;any further needed initialization diff --git a/src/user/knob/format.c b/src/user/knob/format.c index 087f6fd..645fb73 100644 --- a/src/user/knob/format.c +++ b/src/user/knob/format.c @@ -28,4 +28,18 @@ void itosz(uint32_t i, char *out) { } } *out = '\0'; +} + +const char *const hex_digits = "0123456789abcdef"; + +void itosz_h8(uint8_t i, char *out) { + out[0] = hex_digits[i >> 4]; + out[1] = hex_digits[i & 0xf]; + out[2] = '\0'; +} + +void itosz_h32(uint32_t i, char *out) { + for (uint8_t digit = 0; digit < 8; ++digit) + out[digit] = hex_digits[(i >> (28 - digit * 4)) & 0xf]; + out[8] = '\0'; } \ No newline at end of file diff --git a/src/user/knob/user.c b/src/user/knob/user.c index 4ef3321..c84977c 100644 --- a/src/user/knob/user.c +++ b/src/user/knob/user.c @@ -165,16 +165,20 @@ uint32_t ask_user_line_sz(char *sz, uint32_t max_length) { goto replace; if (key & 0x80) goto replace;//TODO + if (key == '\b') { + if (i) { + --i; + _log_string("\b"); + } + goto replace; + } log_buf[0] = key; _log_string(log_buf); - if (key == '\b') - i -= i ? 2 : 1; - else if (key == '\n') + if (key == '\n') break; - else - sz[i] = key; + sz[i] = key; } sz[i] = '\0'; -- cgit v1.2.3