summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2021-03-11 22:00:22 -0500
committerBenji Dial <benji6283@gmail.com>2021-03-11 22:00:22 -0500
commit5fcf57739e68a8b5053e03778aaee0eed445babd (patch)
treee7a8bab18668d112e58b1b48190195035c71fa8a /src/kernel
parent0f2398d1f622cce37925f52d978d92e6cce1c7a9 (diff)
downloadportland-os-5fcf57739e68a8b5053e03778aaee0eed445babd.tar.gz
settings editor, and lots of changes in service of that
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/main.c2
-rw-r--r--src/kernel/settings.c8
-rw-r--r--src/kernel/settings.h1
-rw-r--r--src/kernel/window.c8
4 files changed, 18 insertions, 1 deletions
diff --git a/src/kernel/main.c b/src/kernel/main.c
index 9699029..951e37f 100644
--- a/src/kernel/main.c
+++ b/src/kernel/main.c
@@ -47,6 +47,8 @@ void main() {
init_idt();
init_win();
+ close_settings();
+
logf(LOG_INFO, "Kernel initialization done.");
logf(LOG_INFO, "Available kernel memory: %dk", kernel_pages_left * 4);
logf(LOG_INFO, "Available user memory: %dk", user_pages_left * 4);
diff --git a/src/kernel/settings.c b/src/kernel/settings.c
index 699196b..419341a 100644
--- a/src/kernel/settings.c
+++ b/src/kernel/settings.c
@@ -36,6 +36,11 @@ struct main_entry {
static file_id_t fid;
static uint32_t main_end;
+void close_settings() {
+ drives->free_file(drives, fid);
+ fid = 0;
+}
+
void init_settings() {
fid = drives->get_file(drives, SETTINGS_FILE);
if (!fid)
@@ -47,6 +52,9 @@ void init_settings() {
}
bool try_find_setting(const char *name, struct main_entry *entry_out) {
+ if (!fid)
+ PANIC("setting requested after settings file closed");
+
uint16_t name_len = 0;
while (name[name_len])
if (++name_len == 256)
diff --git a/src/kernel/settings.h b/src/kernel/settings.h
index f25d4df..ec5e9f5 100644
--- a/src/kernel/settings.h
+++ b/src/kernel/settings.h
@@ -7,6 +7,7 @@
#include <stdint.h>
void init_settings();
+void close_settings();
//lengths do not include null terminator. if setting value is too long, it is cropped.
bool try_get_sz_setting(const char *name, char *out, uint32_t max_len, uint32_t *len_out);
diff --git a/src/kernel/window.c b/src/kernel/window.c
index 4b01bc4..69babe4 100644
--- a/src/kernel/window.c
+++ b/src/kernel/window.c
@@ -330,9 +330,15 @@ got_window:
}
static void del_no_paint(struct window *w) {
+ if ((w < windows) || (w >= windows + MAX_WINDOWS) || (((void *)w - (void *)windows) % sizeof(struct window))) {
+ logf(LOG_WARN, "Refusing to delete bad window pointer 0x%h", w);
+ return;
+ }
+
if (w == top_window) {
top_window = w->below;
- send_action(top_window, (struct window_action){.action_type = FOCUS_ENTER});
+ if (top_window)
+ send_action(top_window, (struct window_action){.action_type = FOCUS_ENTER});
}
if (w == bottom_window)
bottom_window = w->above;