diff options
author | Benji Dial <benji6283@gmail.com> | 2021-01-24 12:00:11 -0500 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2021-01-24 12:00:11 -0500 |
commit | bce944d1498eaa3b6940ee234c863b3548a66b37 (patch) | |
tree | ea40c087ab4f0f236aee8d158cf68550f5209f72 /src/user/include/knob | |
parent | ca731aa747214919df7b3dfe3478dbe787ce5b68 (diff) | |
download | portland-os-bce944d1498eaa3b6940ee234c863b3548a66b37.tar.gz |
graphics!
Diffstat (limited to 'src/user/include/knob')
-rw-r--r-- | src/user/include/knob/block.h | 5 | ||||
-rw-r--r-- | src/user/include/knob/env.h | 9 | ||||
-rw-r--r-- | src/user/include/knob/format.h | 27 | ||||
-rw-r--r-- | src/user/include/knob/ipc.h | 16 | ||||
-rw-r--r-- | src/user/include/knob/key.h | 8 | ||||
-rw-r--r-- | src/user/include/knob/panic.h | 9 | ||||
-rw-r--r-- | src/user/include/knob/task.h | 7 | ||||
-rw-r--r-- | src/user/include/knob/user.h | 22 |
8 files changed, 64 insertions, 39 deletions
diff --git a/src/user/include/knob/block.h b/src/user/include/knob/block.h index 56d3740..f77709d 100644 --- a/src/user/include/knob/block.h +++ b/src/user/include/knob/block.h @@ -13,4 +13,9 @@ uint32_t strcpy(char *to, const char *from); //allocates new memory char *strdup(const char *from); +//without null-terminator +uint32_t strlen(const char *str) __attribute__ ((pure)); + +bool strequ(const char *a, const char *b) __attribute__ ((pure)); + #endif
\ No newline at end of file diff --git a/src/user/include/knob/env.h b/src/user/include/knob/env.h deleted file mode 100644 index 6d750ae..0000000 --- a/src/user/include/knob/env.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef KNOB_ENV_H -#define KNOB_ENV_H - -#include <stdint.h> - -//not implemented yet -extern uint32_t current_drive; - -#endif
\ No newline at end of file diff --git a/src/user/include/knob/format.h b/src/user/include/knob/format.h index d55036c..fed31c7 100644 --- a/src/user/include/knob/format.h +++ b/src/user/include/knob/format.h @@ -1,12 +1,29 @@ #ifndef KNOB_FORMAT_H #define KNOB_FORMAT_H -#include <stdbool.h> +#include <knob/heap.h> + #include <stdint.h> +#include <stdarg.h> + +//allocates new memory +char *format_v(const char *fmt, va_list args); + +//allocates new memory +char *format(const char *fmt, ...); + +void syslogf_v(const char *fmt, va_list args); + +void syslogf(const char *fmt, ...); + +//reads a unsigned decimal terminated by either null or whitespace +//returns length of string plus length of whitespace +//returns 0 on failure +uint32_t try_swtou(const char *from, uint32_t *i_out); -bool try_sntoi(const char *s, uint32_t n, uint32_t *out); -void itosz(uint32_t i, char *out) __attribute__ ((access (write_only, 2))); -void itosz_h8(uint8_t i, char *out) __attribute__ ((access (write_only, 2))); -void itosz_h32(uint32_t i, char *out) __attribute__ ((access (write_only, 2))); +//reads a hexadecimal terminated by either null or whitespace +//returns length of string plus length of whitespace +//returns 0 on failure +uint32_t try_swtoh(const char *from, uint32_t *i_out); #endif
\ No newline at end of file diff --git a/src/user/include/knob/ipc.h b/src/user/include/knob/ipc.h new file mode 100644 index 0000000..3eab562 --- /dev/null +++ b/src/user/include/knob/ipc.h @@ -0,0 +1,16 @@ +#ifndef KNOB_IPC_H +#define KNOB_IPC_H + +#include <pland/syscall.h> + +//blocking, returns early if other process is dead. +//return value is number of bytes written. +uint32_t try_send_ipc(_task_handle_t to, void *buffer, uint32_t size); + +//blocking, returns early if other process is dead. +//return value is number of bytes read. +uint32_t try_read_ipc(_task_handle_t from, void *buffer, uint32_t size); + +void flush_ipc(_task_handle_t from); + +#endif
\ No newline at end of file diff --git a/src/user/include/knob/key.h b/src/user/include/knob/key.h new file mode 100644 index 0000000..90509fc --- /dev/null +++ b/src/user/include/knob/key.h @@ -0,0 +1,8 @@ +#ifndef KNOB_KEY_H +#define KNOB_KEY_H + +#include <keypack.h> + +char key_to_char(struct key_packet kp) __attribute__ ((pure)); + +#endif
\ No newline at end of file diff --git a/src/user/include/knob/panic.h b/src/user/include/knob/panic.h new file mode 100644 index 0000000..1dd33a0 --- /dev/null +++ b/src/user/include/knob/panic.h @@ -0,0 +1,9 @@ +#ifndef KNOB_PANIC_H +#define KNOB_PANIC_H + +#include <stdint.h> + +#define PANIC(msg) panic(__FILE__, __LINE__, msg) +void panic(const char *filename, uint32_t line, const char *message) __attribute__ ((noreturn)); + +#endif
\ No newline at end of file diff --git a/src/user/include/knob/task.h b/src/user/include/knob/task.h index 6539a00..cd51c37 100644 --- a/src/user/include/knob/task.h +++ b/src/user/include/knob/task.h @@ -1,11 +1,12 @@ #ifndef KNOB_TASK_H #define KNOB_TASK_H +#include <pland/syscall.h> + #include <stdint.h> #include <stdbool.h> -uint32_t run_command(const char *path); -bool try_run_command_blocking(const char *path); -void yield_task(); +uint32_t run_command(const char *path, _task_handle_t stdio_task); +bool try_run_command_blocking(const char *path, _task_handle_t stdio_task); #endif
\ No newline at end of file diff --git a/src/user/include/knob/user.h b/src/user/include/knob/user.h deleted file mode 100644 index fb11c9b..0000000 --- a/src/user/include/knob/user.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef KNOB_USER_H -#define KNOB_USER_H - -#include <stdint.h> -#include <pland/syscall.h> - -struct history; - -char key_to_char(_key_code_t key) __attribute__ ((const)); - -void tell_user_sz(const char *sz); - -//return value and max_length don't include null terminator -//returns the real length of the string -uint32_t ask_user_line_sz(char *sz, uint32_t max_length); - -struct history *new_history(uint32_t max_entries); -void del_history(struct history *hs); - -uint32_t ask_user_line_sz_with_history(char *sz, uint32_t max_length, struct history *hs); - -#endif
\ No newline at end of file |