summaryrefslogtreecommitdiff
path: root/src/user/knob
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2020-09-13 03:19:57 -0400
committerBenji Dial <benji6283@gmail.com>2020-09-13 03:19:57 -0400
commit1e4a254674f668839e5de273916024c16814b045 (patch)
tree6774f4d4398a29c4aafb4120070975d864ffcde4 /src/user/knob
parentb8284137d4e0eec11c78bc14047243fce6a51373 (diff)
downloadportland-os-1e4a254674f668839e5de273916024c16814b045.tar.gz
(basic, not much tested) keyboard, better panic
Diffstat (limited to 'src/user/knob')
-rw-r--r--src/user/knob/block.c17
-rw-r--r--src/user/knob/entry.asm1
-rw-r--r--src/user/knob/quit.c25
-rw-r--r--src/user/knob/task.c16
-rw-r--r--src/user/knob/user.c116
5 files changed, 116 insertions, 59 deletions
diff --git a/src/user/knob/block.c b/src/user/knob/block.c
new file mode 100644
index 0000000..e890fa1
--- /dev/null
+++ b/src/user/knob/block.c
@@ -0,0 +1,17 @@
+#include <stdint.h>
+#include <stdbool.h>
+
+//unsophisticated, should copy by dwords where available
+void blockcpy(void *to, const void *from, uint32_t size) {
+ for (uint32_t i = 0; i < size; ++i)
+ *(uint8_t *)(to++) = *(const uint8_t *)(from++);
+}
+
+//unsophisticated, should check by dwords wheere available
+__attribute__ ((__pure__))
+bool blockequ(void *a, void *b, uint32_t size) {
+ for (uint32_t i = 0; i < size; ++i)
+ if (*(uint8_t *)(a++) != *(uint8_t *)(b++))
+ return false;
+ return true;
+} \ No newline at end of file
diff --git a/src/user/knob/entry.asm b/src/user/knob/entry.asm
index ae024c4..18faf7f 100644
--- a/src/user/knob/entry.asm
+++ b/src/user/knob/entry.asm
@@ -10,6 +10,7 @@ extern current_disk
section .text
_entry:
mov esp, stack
+ push edx
;TODO: heap stuff?
;TODO: determine current_disk
diff --git a/src/user/knob/quit.c b/src/user/knob/quit.c
index a2ef5aa..7c20bdd 100644
--- a/src/user/knob/quit.c
+++ b/src/user/knob/quit.c
@@ -1,29 +1,6 @@
#include <pland/syscall.h>
-#include <knob/heap.h>
-
-struct quit_list_node {
- struct quit_list_node *prev;
- void (*f)();
-};
-
-static struct quit_list_node head = {
- .f = &_exit_task
-};
-
-static struct quit_list_node *last = &head;
-
-void on_quit(void (*run_f)()) {
- struct quit_list_node *new = get_block(sizeof(struct quit_list_node));
- new->prev = last;
- new->f = run_f;
- last = new;
-}
__attribute__ ((noreturn))
void quit() {
- struct quit_list_node *node = last;
- while (1) {
- node->f();
- node = node->prev;
- }
+ _exit_task();
} \ No newline at end of file
diff --git a/src/user/knob/task.c b/src/user/knob/task.c
index aa18eab..598bee2 100644
--- a/src/user/knob/task.c
+++ b/src/user/knob/task.c
@@ -1,11 +1,25 @@
#include <stdbool.h>
#include <pland/syscall.h>
#include <knob/file.h>
+#include <knob/heap.h>
+#include <knob/block.h>
bool try_run_command(const char *path) {
uint8_t dn;
path = remove_prefix(path, &dn);
- return _start_task(dn, path);
+
+ for (const char *ptr = path; *ptr; ++ptr)
+ if (*ptr == ' ') {
+ char *new_path = get_block(ptr - path + 1);
+ blockcpy(new_path, path, ptr - path);
+ new_path[ptr - path] = '\0';
+
+ bool succeded = _start_task(dn, new_path, ptr + 1);
+ free_block(new_path);
+ return succeded;
+ }
+
+ return _start_task(dn, path, "");
}
void yield_task() {
diff --git a/src/user/knob/user.c b/src/user/knob/user.c
index fb39851..4ef3321 100644
--- a/src/user/knob/user.c
+++ b/src/user/knob/user.c
@@ -19,9 +19,25 @@ static const uint8_t caps_and_shift[] = {
0x7e, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
- 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x00
-
- //TODO: higher
+ 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x00,
+
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static const uint8_t caps_no_shift[] = {
@@ -41,9 +57,25 @@ static const uint8_t caps_no_shift[] = {
0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
- 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x00
-
- //TODO: higher
+ 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x00,
+
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static const uint8_t shifted[] = {
@@ -63,28 +95,39 @@ static const uint8_t shifted[] = {
0x7e, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
- 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x00
-
- //TODO: higher
+ 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x00,
+
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static char get_key_char() {
_key_code_t key;
while (!(key = _get_key()))
_yield_task();
- return (char)(
- (key & (_KEY_ALT | _KEY_CTRL | _KEY_META))
- ? 0
- : (key & _KEY_CAPS)
- ? (key & _KEY_SHIFT)
- ? caps_and_shift[key & 0xff]
- : caps_no_shift[key & 0xff]
- : (key & _KEY_SHIFT)
- ? shifted[key & 0xff]
- : (key & 0x80)
- ? 0
- : (key & 0x7f)
- );
+ return
+ key & _KEY_CAPS
+ ? key & _KEY_SHIFT
+ ? caps_and_shift[key & 0xff]
+ : caps_no_shift[key & 0xff]
+ : key & _KEY_SHIFT
+ ? shifted[key & 0xff]
+ : key & 0xff;
}
void tell_user_sz(const char *sz) {
@@ -115,18 +158,23 @@ uint32_t ask_user_line_sz(char *sz, uint32_t max_length) {
uint32_t i;
for (i = 0; i != max_length; ++i) {
- char key = get_key_char();
- if (key) {
- log_buf[0] = key;
- _log_string(log_buf);
-
- if (key == '\b')
- i -= i ? 2 : 1;
- else if (key == '\n')
- break;
- else
- sz[i] = key;
- }
+ char key;
+ replace:
+ key = get_key_char();
+ if (!key)
+ goto replace;
+ if (key & 0x80)
+ goto replace;//TODO
+
+ log_buf[0] = key;
+ _log_string(log_buf);
+
+ if (key == '\b')
+ i -= i ? 2 : 1;
+ else if (key == '\n')
+ break;
+ else
+ sz[i] = key;
}
sz[i] = '\0';