diff options
Diffstat (limited to 'src/user')
-rw-r--r-- | src/user/highway/highway.c | 4 | ||||
-rw-r--r-- | src/user/include/knob/task.h | 4 | ||||
-rw-r--r-- | src/user/include/pland/syscall.h | 12 | ||||
-rw-r--r-- | src/user/init/init.c | 2 | ||||
-rw-r--r-- | src/user/knob/task.c | 11 |
5 files changed, 24 insertions, 9 deletions
diff --git a/src/user/highway/highway.c b/src/user/highway/highway.c index 8dc0080..7e78472 100644 --- a/src/user/highway/highway.c +++ b/src/user/highway/highway.c @@ -18,9 +18,7 @@ void main() { ask_user_line_sz(line_buf, 1023); if (blockequ(line_buf, "exit", 5)) return; - if (try_run_command(path_buf)) - yield_task(); - else + if (!try_run_command_blocking(path_buf)) tell_user_sz("An error occured trying to run that command.\n"); } }
\ No newline at end of file diff --git a/src/user/include/knob/task.h b/src/user/include/knob/task.h index ea5df62..6539a00 100644 --- a/src/user/include/knob/task.h +++ b/src/user/include/knob/task.h @@ -1,9 +1,11 @@ #ifndef KNOB_TASK_H #define KNOB_TASK_H +#include <stdint.h> #include <stdbool.h> -bool try_run_command(const char *path); +uint32_t run_command(const char *path); +bool try_run_command_blocking(const char *path); void yield_task(); #endif
\ No newline at end of file diff --git a/src/user/include/pland/syscall.h b/src/user/include/pland/syscall.h index c597e2b..75383fc 100644 --- a/src/user/include/pland/syscall.h +++ b/src/user/include/pland/syscall.h @@ -8,6 +8,7 @@ typedef uint32_t _file_handle_t; typedef uint32_t _task_handle_t; typedef uint32_t _drive_number_t; typedef uint32_t _pages_t; +typedef uint32_t _process_handle_t; typedef enum { _KEY_BACKSPACE = '\b', @@ -43,7 +44,8 @@ enum _scn { _SCN_LOG_STRING, _SCN_GET_KEY, _SCN_ALLOCATE_RAM, - _SCN_MEMORY_INFO + _SCN_MEMORY_INFO, + _SCN_WAIT_FOR_TASK }; static inline uint32_t _sc0(enum _scn eax) { @@ -124,8 +126,8 @@ static inline uint32_t _file_size(_file_handle_t handle) { return _sc1(_SCN_FILE_SIZE, handle); } -static inline bool _start_task(_drive_number_t drive_number, const char *path, const char *pass) { - return (bool)_sc3(_SCN_START_TASK, drive_number, (uint32_t)path, (uint32_t)pass); +static inline _process_handle_t _start_task(_drive_number_t drive_number, const char *path, const char *pass) { + return _sc3(_SCN_START_TASK, drive_number, (uint32_t)path, (uint32_t)pass); } static inline void _log_string(const char *sz) { @@ -160,4 +162,8 @@ static inline _pages_t _this_process_memory_left() { return _sc1(_SCN_MEMORY_INFO, 0x4); } +static inline void _wait_for_task(_process_handle_t handle) { + _sc1(_SCN_WAIT_FOR_TASK, handle); +} + #endif
\ No newline at end of file diff --git a/src/user/init/init.c b/src/user/init/init.c index 390b731..e878603 100644 --- a/src/user/init/init.c +++ b/src/user/init/init.c @@ -7,7 +7,7 @@ void start(const char *cmd) { tell_user_sz(cmd); tell_user_sz(": "); tell_user_sz( - try_run_command(cmd) + run_command(cmd) ? "Succeded.\n" : "Failed.\n" ); diff --git a/src/user/knob/task.c b/src/user/knob/task.c index 598bee2..df5d38f 100644 --- a/src/user/knob/task.c +++ b/src/user/knob/task.c @@ -4,7 +4,7 @@ #include <knob/heap.h> #include <knob/block.h> -bool try_run_command(const char *path) { +_task_handle_t run_command(const char *path) { uint8_t dn; path = remove_prefix(path, &dn); @@ -22,6 +22,15 @@ bool try_run_command(const char *path) { return _start_task(dn, path, ""); } +bool try_run_command_blocking(const char *path) { + _task_handle_t handle = run_command(path); + if (!handle) + return false; + _wait_for_task(handle); + _yield_task(); + return true; +} + void yield_task() { _yield_task(); }
\ No newline at end of file |