Merge pull request #1 from Leonmmcoset/codex/style-autofix-24604680449-1

style: auto-format C/C++ sources with clang-format
This commit is contained in:
LeonMMcoset
2026-04-18 20:31:49 +08:00
committed by GitHub
92 changed files with 1078 additions and 1536 deletions

View File

@@ -3,12 +3,13 @@ static int ush_cmd_ansi(void) {
ush_writeln("\x1B[1;36mansi color demo\x1B[0m"); ush_writeln("\x1B[1;36mansi color demo\x1B[0m");
ush_writeln(" \x1B[30mblack\x1B[0m \x1B[31mred\x1B[0m \x1B[32mgreen\x1B[0m \x1B[33myellow\x1B[0m"); ush_writeln(" \x1B[30mblack\x1B[0m \x1B[31mred\x1B[0m \x1B[32mgreen\x1B[0m \x1B[33myellow\x1B[0m");
ush_writeln(" \x1B[34mblue\x1B[0m \x1B[35mmagenta\x1B[0m \x1B[36mcyan\x1B[0m \x1B[37mwhite\x1B[0m"); ush_writeln(" \x1B[34mblue\x1B[0m \x1B[35mmagenta\x1B[0m \x1B[36mcyan\x1B[0m \x1B[37mwhite\x1B[0m");
ush_writeln(" \x1B[90mbright-black\x1B[0m \x1B[91mbright-red\x1B[0m \x1B[92mbright-green\x1B[0m \x1B[93mbright-yellow\x1B[0m"); ush_writeln(" \x1B[90mbright-black\x1B[0m \x1B[91mbright-red\x1B[0m \x1B[92mbright-green\x1B[0m "
ush_writeln(" \x1B[94mbright-blue\x1B[0m \x1B[95mbright-magenta\x1B[0m \x1B[96mbright-cyan\x1B[0m \x1B[97mbright-white\x1B[0m"); "\x1B[93mbright-yellow\x1B[0m");
ush_writeln(" \x1B[94mbright-blue\x1B[0m \x1B[95mbright-magenta\x1B[0m \x1B[96mbright-cyan\x1B[0m "
"\x1B[97mbright-white\x1B[0m");
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -50,4 +51,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -3,8 +3,10 @@ static int ush_cmd_ansi(void) {
ush_writeln("\x1B[1;36mansi color demo\x1B[0m"); ush_writeln("\x1B[1;36mansi color demo\x1B[0m");
ush_writeln(" \x1B[30mblack\x1B[0m \x1B[31mred\x1B[0m \x1B[32mgreen\x1B[0m \x1B[33myellow\x1B[0m"); ush_writeln(" \x1B[30mblack\x1B[0m \x1B[31mred\x1B[0m \x1B[32mgreen\x1B[0m \x1B[33myellow\x1B[0m");
ush_writeln(" \x1B[34mblue\x1B[0m \x1B[35mmagenta\x1B[0m \x1B[36mcyan\x1B[0m \x1B[37mwhite\x1B[0m"); ush_writeln(" \x1B[34mblue\x1B[0m \x1B[35mmagenta\x1B[0m \x1B[36mcyan\x1B[0m \x1B[37mwhite\x1B[0m");
ush_writeln(" \x1B[90mbright-black\x1B[0m \x1B[91mbright-red\x1B[0m \x1B[92mbright-green\x1B[0m \x1B[93mbright-yellow\x1B[0m"); ush_writeln(" \x1B[90mbright-black\x1B[0m \x1B[91mbright-red\x1B[0m \x1B[92mbright-green\x1B[0m "
ush_writeln(" \x1B[94mbright-blue\x1B[0m \x1B[95mbright-magenta\x1B[0m \x1B[96mbright-cyan\x1B[0m \x1B[97mbright-white\x1B[0m"); "\x1B[93mbright-yellow\x1B[0m");
ush_writeln(" \x1B[94mbright-blue\x1B[0m \x1B[95mbright-magenta\x1B[0m \x1B[96mbright-cyan\x1B[0m "
"\x1B[97mbright-white\x1B[0m");
return 1; return 1;
} }
@@ -107,7 +109,8 @@ static int ush_cmd_ansitest(void) {
ush_write_char('\n'); ush_write_char('\n');
ush_writeln("truecolor demo:"); ush_writeln("truecolor demo:");
ush_writeln(" \x1B[38;2;255;64;64mRGB(255,64,64)\x1B[0m \x1B[38;2;64;255;64mRGB(64,255,64)\x1B[0m \x1B[38;2;64;128;255mRGB(64,128,255)\x1B[0m"); ush_writeln(" \x1B[38;2;255;64;64mRGB(255,64,64)\x1B[0m \x1B[38;2;64;255;64mRGB(64,255,64)\x1B[0m "
"\x1B[38;2;64;128;255mRGB(64,128,255)\x1B[0m");
ush_writeln("cursor control demo:"); ush_writeln("cursor control demo:");
ush_write(" 0123456789"); ush_write(" 0123456789");
@@ -131,7 +134,6 @@ static int ush_cmd_ansitest(void) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -173,4 +175,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -44,7 +44,6 @@ static int ush_cmd_append(const ush_state *sh, const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -88,4 +87,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -61,7 +61,6 @@ static int ush_cmd_cat(const ush_state *sh, const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -105,4 +104,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -21,7 +21,6 @@ static int ush_cmd_cd(ush_state *sh, const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -65,4 +64,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -4,7 +4,6 @@ static int ush_cmd_clear(void) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -46,4 +45,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -526,17 +526,12 @@ int ush_split_first_and_rest(const char *arg, char *out_first, u64 out_first_siz
return 1; return 1;
} }
int ush_split_two_args(const char *arg, int ush_split_two_args(const char *arg, char *out_first, u64 out_first_size, char *out_second, u64 out_second_size) {
char *out_first,
u64 out_first_size,
char *out_second,
u64 out_second_size) {
u64 i = 0ULL; u64 i = 0ULL;
u64 p = 0ULL; u64 p = 0ULL;
if (arg == (const char *)0 || if (arg == (const char *)0 || out_first == (char *)0 || out_first_size == 0ULL || out_second == (char *)0 ||
out_first == (char *)0 || out_first_size == 0ULL || out_second_size == 0ULL) {
out_second == (char *)0 || out_second_size == 0ULL) {
return 0; return 0;
} }

View File

@@ -90,11 +90,7 @@ int ush_path_is_under_system(const char *path);
int ush_path_is_under_temp(const char *path); int ush_path_is_under_temp(const char *path);
int ush_split_first_and_rest(const char *arg, char *out_first, u64 out_first_size, const char **out_rest); int ush_split_first_and_rest(const char *arg, char *out_first, u64 out_first_size, const char **out_rest);
int ush_split_two_args(const char *arg, int ush_split_two_args(const char *arg, char *out_first, u64 out_first_size, char *out_second, u64 out_second_size);
char *out_first,
u64 out_first_size,
char *out_second,
u64 out_second_size);
int ush_command_ctx_read(ush_cmd_ctx *out_ctx); int ush_command_ctx_read(ush_cmd_ctx *out_ctx);
int ush_command_ret_write(const ush_cmd_ret *ret); int ush_command_ret_write(const ush_cmd_ret *ret);

View File

@@ -39,9 +39,7 @@ static int ush_copy_file(const char *src_path, const char *dst_path) {
{ {
u64 written_total = 0ULL; u64 written_total = 0ULL;
while (written_total < got) { while (written_total < got) {
u64 written = cleonos_sys_fd_write(dst_fd, u64 written = cleonos_sys_fd_write(dst_fd, copy_buf + written_total, got - written_total);
copy_buf + written_total,
got - written_total);
if (written == (u64)-1 || written == 0ULL) { if (written == (u64)-1 || written == 0ULL) {
(void)cleonos_sys_fd_close(dst_fd); (void)cleonos_sys_fd_close(dst_fd);
(void)cleonos_sys_fd_close(src_fd); (void)cleonos_sys_fd_close(src_fd);
@@ -88,7 +86,6 @@ static int ush_cmd_cp(const ush_state *sh, const char *arg) {
return ush_copy_file(src_path, dst_path); return ush_copy_file(src_path, dst_path);
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -132,4 +129,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -18,11 +18,7 @@ static int ush_cut_parse_delim(const char *token, char *out_delim) {
return 1; return 1;
} }
static int ush_cut_parse_args(const char *arg, static int ush_cut_parse_args(const char *arg, char *out_delim, u64 *out_field, char *out_file, u64 out_file_size) {
char *out_delim,
u64 *out_field,
char *out_file,
u64 out_file_size) {
char token[USH_PATH_MAX]; char token[USH_PATH_MAX];
char value[USH_PATH_MAX]; char value[USH_PATH_MAX];
const char *cursor = arg; const char *cursor = arg;
@@ -223,7 +219,6 @@ static int ush_cmd_cut(const ush_state *sh, const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;

View File

@@ -34,7 +34,6 @@ static int ush_cmd_dmesg(const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -78,4 +77,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -61,7 +61,6 @@ static int ush_cmd_exec(const ush_state *sh, const char *arg) {
return 0; return 0;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -105,4 +104,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -20,7 +20,6 @@ static int ush_cmd_exit(ush_state *sh, const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -64,4 +63,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -166,7 +166,6 @@ static int ush_cmd_fastfetch(const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -210,4 +209,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -52,8 +52,7 @@ static int ush_fg_pick_latest_job(u64 *out_pid) {
continue; continue;
} }
if (snap.state != CLEONOS_PROC_STATE_PENDING && if (snap.state != CLEONOS_PROC_STATE_PENDING && snap.state != CLEONOS_PROC_STATE_RUNNING &&
snap.state != CLEONOS_PROC_STATE_RUNNING &&
snap.state != CLEONOS_PROC_STATE_STOPPED) { snap.state != CLEONOS_PROC_STATE_STOPPED) {
continue; continue;
} }

View File

@@ -11,7 +11,6 @@ static int ush_cmd_fsstat(void) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -53,4 +52,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -203,7 +203,6 @@ static int ush_cmd_grep(const ush_state *sh, const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -247,4 +246,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -165,7 +165,6 @@ static int ush_cmd_head(const ush_state *sh, const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;

View File

@@ -45,7 +45,6 @@ static int ush_cmd_help(void) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;

View File

@@ -9,7 +9,6 @@ static int ush_cmd_kbdstat(void) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -51,4 +50,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -167,8 +167,7 @@ static int ush_cmd_kdbg(const char *arg) {
if (ush_streq(subcmd, "bt") != 0) { if (ush_streq(subcmd, "bt") != 0) {
if (ush_kdbg_next_token(&cursor, tok0, (u64)sizeof(tok0)) == 0 || if (ush_kdbg_next_token(&cursor, tok0, (u64)sizeof(tok0)) == 0 ||
ush_kdbg_next_token(&cursor, tok1, (u64)sizeof(tok1)) == 0 || ush_kdbg_next_token(&cursor, tok1, (u64)sizeof(tok1)) == 0 || ush_kdbg_has_more_tokens(cursor) != 0) {
ush_kdbg_has_more_tokens(cursor) != 0) {
ush_kdbg_usage(); ush_kdbg_usage();
return 0; return 0;
} }

View File

@@ -125,19 +125,13 @@ static void ush_ls_print_one(const char *name, u64 type, u64 size, int long_mode
clio_write_char('\n'); clio_write_char('\n');
} }
static int ush_ls_parse_args(const char *arg, static int ush_ls_parse_args(const char *arg, int *out_long_mode, int *out_recursive, char *out_target,
int *out_long_mode,
int *out_recursive,
char *out_target,
u64 out_target_size) { u64 out_target_size) {
char token[USH_PATH_MAX]; char token[USH_PATH_MAX];
u64 i = 0ULL; u64 i = 0ULL;
int path_set = 0; int path_set = 0;
if (out_long_mode == (int *)0 || if (out_long_mode == (int *)0 || out_recursive == (int *)0 || out_target == (char *)0 || out_target_size == 0ULL) {
out_recursive == (int *)0 ||
out_target == (char *)0 ||
out_target_size == 0ULL) {
return 0; return 0;
} }
@@ -196,11 +190,7 @@ static int ush_ls_parse_args(const char *arg,
return 1; return 1;
} }
static int ush_ls_dir(const char *path, static int ush_ls_dir(const char *path, int long_mode, int recursive, int print_header, u64 depth) {
int long_mode,
int recursive,
int print_header,
u64 depth) {
u64 count; u64 count;
u64 i; u64 i;
@@ -309,7 +299,6 @@ static int ush_cmd_ls(const ush_state *sh, const char *arg) {
return ush_ls_dir(path, long_mode, recursive, recursive, 0ULL); return ush_ls_dir(path, long_mode, recursive, recursive, 0ULL);
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -353,4 +342,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -8,7 +8,6 @@ static int ush_cmd_memstat(void) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -50,4 +49,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -25,7 +25,6 @@ static int ush_cmd_mkdir(const ush_state *sh, const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -69,4 +68,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -82,7 +82,6 @@ static int ush_cmd_mv(const ush_state *sh, const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -126,4 +125,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -4,7 +4,6 @@ static int ush_cmd_pid(void) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -46,4 +45,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -4,7 +4,6 @@ static int ush_cmd_pwd(const ush_state *sh) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -46,4 +45,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -5,7 +5,6 @@ static int ush_cmd_restart(void) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -47,4 +46,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -25,7 +25,6 @@ static int ush_cmd_rm(const ush_state *sh, const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -69,4 +68,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -22,7 +22,6 @@ static u64 ush_pipeline_stdin_len = 0ULL;
static char ush_pipeline_capture_a[USH_PIPE_CAPTURE_MAX + 1U]; static char ush_pipeline_capture_a[USH_PIPE_CAPTURE_MAX + 1U];
static char ush_pipeline_capture_b[USH_PIPE_CAPTURE_MAX + 1U]; static char ush_pipeline_capture_b[USH_PIPE_CAPTURE_MAX + 1U];
static int ush_path_is_under_temp(const char *path) { static int ush_path_is_under_temp(const char *path) {
if (path == (const char *)0) { if (path == (const char *)0) {
return 0; return 0;
@@ -71,17 +70,13 @@ static int ush_split_first_and_rest(const char *arg, char *out_first, u64 out_fi
return 1; return 1;
} }
static int ush_split_two_args(const char *arg, static int ush_split_two_args(const char *arg, char *out_first, u64 out_first_size, char *out_second,
char *out_first,
u64 out_first_size,
char *out_second,
u64 out_second_size) { u64 out_second_size) {
u64 i = 0ULL; u64 i = 0ULL;
u64 p = 0ULL; u64 p = 0ULL;
if (arg == (const char *)0 || if (arg == (const char *)0 || out_first == (char *)0 || out_first_size == 0ULL || out_second == (char *)0 ||
out_first == (char *)0 || out_first_size == 0ULL || out_second_size == 0ULL) {
out_second == (char *)0 || out_second_size == 0ULL) {
return 0; return 0;
} }
@@ -278,19 +273,13 @@ static void ush_ls_print_one(const char *name, u64 type, u64 size, int long_mode
ush_write_char('\n'); ush_write_char('\n');
} }
static int ush_ls_parse_args(const char *arg, static int ush_ls_parse_args(const char *arg, int *out_long_mode, int *out_recursive, char *out_target,
int *out_long_mode,
int *out_recursive,
char *out_target,
u64 out_target_size) { u64 out_target_size) {
char token[USH_PATH_MAX]; char token[USH_PATH_MAX];
u64 i = 0ULL; u64 i = 0ULL;
int path_set = 0; int path_set = 0;
if (out_long_mode == (int *)0 || if (out_long_mode == (int *)0 || out_recursive == (int *)0 || out_target == (char *)0 || out_target_size == 0ULL) {
out_recursive == (int *)0 ||
out_target == (char *)0 ||
out_target_size == 0ULL) {
return 0; return 0;
} }
@@ -349,11 +338,7 @@ static int ush_ls_parse_args(const char *arg,
return 1; return 1;
} }
static int ush_ls_dir(const char *path, static int ush_ls_dir(const char *path, int long_mode, int recursive, int print_header, u64 depth) {
int long_mode,
int recursive,
int print_header,
u64 depth) {
u64 count; u64 count;
u64 i; u64 i;
@@ -756,19 +741,14 @@ static int ush_text_parse_optional_file(const char *arg, char *out_file, u64 out
return 1; return 1;
} }
static int ush_text_load_input(const ush_state *sh, static int ush_text_load_input(const ush_state *sh, const char *cmd, const char *file_arg, const char **out_input,
const char *cmd,
const char *file_arg,
const char **out_input,
u64 *out_input_len) { u64 *out_input_len) {
static char file_buf[USH_COPY_MAX + 1U]; static char file_buf[USH_COPY_MAX + 1U];
char path[USH_PATH_MAX]; char path[USH_PATH_MAX];
u64 size; u64 size;
u64 got; u64 got;
if (sh == (const ush_state *)0 || if (sh == (const ush_state *)0 || cmd == (const char *)0 || out_input == (const char **)0 ||
cmd == (const char *)0 ||
out_input == (const char **)0 ||
out_input_len == (u64 *)0) { out_input_len == (u64 *)0) {
return 0; return 0;
} }
@@ -1126,11 +1106,7 @@ static int ush_cut_parse_delim(const char *token, char *out_delim) {
return 1; return 1;
} }
static int ush_cut_parse_args(const char *arg, static int ush_cut_parse_args(const char *arg, char *out_delim, u64 *out_field, char *out_file, u64 out_file_size) {
char *out_delim,
u64 *out_field,
char *out_file,
u64 out_file_size) {
char token[USH_PATH_MAX]; char token[USH_PATH_MAX];
char value[USH_PATH_MAX]; char value[USH_PATH_MAX];
const char *cursor = arg; const char *cursor = arg;
@@ -1711,8 +1687,10 @@ static int ush_cmd_ansi(void) {
ush_writeln("\x1B[1;36mansi color demo\x1B[0m"); ush_writeln("\x1B[1;36mansi color demo\x1B[0m");
ush_writeln(" \x1B[30mblack\x1B[0m \x1B[31mred\x1B[0m \x1B[32mgreen\x1B[0m \x1B[33myellow\x1B[0m"); ush_writeln(" \x1B[30mblack\x1B[0m \x1B[31mred\x1B[0m \x1B[32mgreen\x1B[0m \x1B[33myellow\x1B[0m");
ush_writeln(" \x1B[34mblue\x1B[0m \x1B[35mmagenta\x1B[0m \x1B[36mcyan\x1B[0m \x1B[37mwhite\x1B[0m"); ush_writeln(" \x1B[34mblue\x1B[0m \x1B[35mmagenta\x1B[0m \x1B[36mcyan\x1B[0m \x1B[37mwhite\x1B[0m");
ush_writeln(" \x1B[90mbright-black\x1B[0m \x1B[91mbright-red\x1B[0m \x1B[92mbright-green\x1B[0m \x1B[93mbright-yellow\x1B[0m"); ush_writeln(" \x1B[90mbright-black\x1B[0m \x1B[91mbright-red\x1B[0m \x1B[92mbright-green\x1B[0m "
ush_writeln(" \x1B[94mbright-blue\x1B[0m \x1B[95mbright-magenta\x1B[0m \x1B[96mbright-cyan\x1B[0m \x1B[97mbright-white\x1B[0m"); "\x1B[93mbright-yellow\x1B[0m");
ush_writeln(" \x1B[94mbright-blue\x1B[0m \x1B[95mbright-magenta\x1B[0m \x1B[96mbright-cyan\x1B[0m "
"\x1B[97mbright-white\x1B[0m");
return 1; return 1;
} }
@@ -1815,7 +1793,8 @@ static int ush_cmd_ansitest(void) {
ush_write_char('\n'); ush_write_char('\n');
ush_writeln("truecolor demo:"); ush_writeln("truecolor demo:");
ush_writeln(" \x1B[38;2;255;64;64mRGB(255,64,64)\x1B[0m \x1B[38;2;64;255;64mRGB(64,255,64)\x1B[0m \x1B[38;2;64;128;255mRGB(64,128,255)\x1B[0m"); ush_writeln(" \x1B[38;2;255;64;64mRGB(255,64,64)\x1B[0m \x1B[38;2;64;255;64mRGB(64,255,64)\x1B[0m "
"\x1B[38;2;64;128;255mRGB(64,128,255)\x1B[0m");
ush_writeln("cursor control demo:"); ush_writeln("cursor control demo:");
ush_write(" 0123456789"); ush_write(" 0123456789");
@@ -2456,12 +2435,8 @@ static void ush_report_external_not_found(const char *cmd) {
ush_writeln(cmd); ush_writeln(cmd);
} }
static int ush_execute_single_command(ush_state *sh, static int ush_execute_single_command(ush_state *sh, const char *cmd, const char *arg, int allow_external,
const char *cmd, int *out_known, int *out_success) {
const char *arg,
int allow_external,
int *out_known,
int *out_success) {
int known = 1; int known = 1;
int success = 0; int success = 0;
@@ -2708,16 +2683,14 @@ static int ush_pipeline_parse_stage(ush_pipeline_stage *stage, const char *segme
return 1; return 1;
} }
static int ush_pipeline_parse(const char *line, static int ush_pipeline_parse(const char *line, ush_pipeline_stage *stages, u64 max_stages, u64 *out_stage_count) {
ush_pipeline_stage *stages,
u64 max_stages,
u64 *out_stage_count) {
char segment[USH_LINE_MAX]; char segment[USH_LINE_MAX];
u64 i = 0ULL; u64 i = 0ULL;
u64 seg_pos = 0ULL; u64 seg_pos = 0ULL;
u64 stage_count = 0ULL; u64 stage_count = 0ULL;
if (line == (const char *)0 || stages == (ush_pipeline_stage *)0 || max_stages == 0ULL || out_stage_count == (u64 *)0) { if (line == (const char *)0 || stages == (ush_pipeline_stage *)0 || max_stages == 0ULL ||
out_stage_count == (u64 *)0) {
return 0; return 0;
} }
@@ -2888,10 +2861,7 @@ static int ush_pipeline_open_redirect_fd(const ush_state *sh, const ush_pipeline
return 1; return 1;
} }
static int ush_execute_pipeline(ush_state *sh, static int ush_execute_pipeline(ush_state *sh, const char *line, int *out_known, int *out_success) {
const char *line,
int *out_known,
int *out_success) {
ush_pipeline_stage stages[USH_PIPELINE_MAX_STAGES]; ush_pipeline_stage stages[USH_PIPELINE_MAX_STAGES];
u64 stage_count = 0ULL; u64 stage_count = 0ULL;
u64 i; u64 i;
@@ -2950,8 +2920,7 @@ static int ush_execute_pipeline(ush_state *sh,
if (i + 1ULL < stage_count) { if (i + 1ULL < stage_count) {
stage_pipe_out = (pipe_output_toggle_external == 0) ? USH_PIPE_TMP_A : USH_PIPE_TMP_B; stage_pipe_out = (pipe_output_toggle_external == 0) ? USH_PIPE_TMP_A : USH_PIPE_TMP_B;
if (ush_pipeline_open_write_fd(stage_pipe_out, if (ush_pipeline_open_write_fd(stage_pipe_out, CLEONOS_O_WRONLY | CLEONOS_O_CREAT | CLEONOS_O_TRUNC,
CLEONOS_O_WRONLY | CLEONOS_O_CREAT | CLEONOS_O_TRUNC,
&opened_out_fd) == 0) { &opened_out_fd) == 0) {
ush_writeln("pipe: failed to open temp stream"); ush_writeln("pipe: failed to open temp stream");
@@ -2977,13 +2946,8 @@ static int ush_execute_pipeline(ush_state *sh,
stage_stdout_fd = opened_out_fd; stage_stdout_fd = opened_out_fd;
} }
stage_known = ush_try_exec_external_with_fds(sh, stage_known = ush_try_exec_external_with_fds(sh, stages[i].cmd, stages[i].arg, stage_stdin_fd,
stages[i].cmd, stage_stdout_fd, CLEONOS_FD_INHERIT, &stage_success);
stages[i].arg,
stage_stdin_fd,
stage_stdout_fd,
CLEONOS_FD_INHERIT,
&stage_success);
if (opened_in_fd != (u64)-1) { if (opened_in_fd != (u64)-1) {
(void)cleonos_sys_fd_close(opened_in_fd); (void)cleonos_sys_fd_close(opened_in_fd);
@@ -3040,9 +3004,7 @@ static int ush_execute_pipeline(ush_state *sh,
} }
if (pipe_input_path != (const char *)0) { if (pipe_input_path != (const char *)0) {
if (ush_pipeline_read_path_into_buffer(pipe_input_path, if (ush_pipeline_read_path_into_buffer(pipe_input_path, pipe_input_buffer, (u64)USH_PIPE_CAPTURE_MAX + 1ULL,
pipe_input_buffer,
(u64)USH_PIPE_CAPTURE_MAX + 1ULL,
&pipe_input_len) == 0) { &pipe_input_len) == 0) {
ush_writeln("pipe: failed to read stage input"); ush_writeln("pipe: failed to read stage input");
success = 0; success = 0;
@@ -3057,8 +3019,7 @@ static int ush_execute_pipeline(ush_state *sh,
if (i + 1ULL < stage_count) { if (i + 1ULL < stage_count) {
stage_pipe_out = (pipe_output_toggle == 0) ? USH_PIPE_TMP_A : USH_PIPE_TMP_B; stage_pipe_out = (pipe_output_toggle == 0) ? USH_PIPE_TMP_A : USH_PIPE_TMP_B;
if (ush_pipeline_open_write_fd(stage_pipe_out, if (ush_pipeline_open_write_fd(stage_pipe_out, CLEONOS_O_WRONLY | CLEONOS_O_CREAT | CLEONOS_O_TRUNC,
CLEONOS_O_WRONLY | CLEONOS_O_CREAT | CLEONOS_O_TRUNC,
&stage_fd) == 0) { &stage_fd) == 0) {
ush_writeln("pipe: failed to open temp stream"); ush_writeln("pipe: failed to open temp stream");
success = 0; success = 0;
@@ -3097,8 +3058,8 @@ static int ush_execute_pipeline(ush_state *sh,
if (i + 1ULL < stage_count) { if (i + 1ULL < stage_count) {
pipe_input_path = stage_pipe_out; pipe_input_path = stage_pipe_out;
pipe_input_buffer = (pipe_input_buffer == ush_pipeline_capture_a) ? ush_pipeline_capture_b pipe_input_buffer =
: ush_pipeline_capture_a; (pipe_input_buffer == ush_pipeline_capture_a) ? ush_pipeline_capture_b : ush_pipeline_capture_a;
pipe_output_toggle = (pipe_output_toggle == 0) ? 1 : 0; pipe_output_toggle = (pipe_output_toggle == 0) ? 1 : 0;
} }
} }
@@ -3165,6 +3126,3 @@ void ush_execute_line(ush_state *sh, const char *line) {
sh->cmd_unknown++; sh->cmd_unknown++;
} }
} }

View File

@@ -137,13 +137,8 @@ int ush_command_ret_read(ush_cmd_ret *out_ret) {
return (got == (u64)sizeof(*out_ret)) ? 1 : 0; return (got == (u64)sizeof(*out_ret)) ? 1 : 0;
} }
int ush_try_exec_external_with_fds(ush_state *sh, int ush_try_exec_external_with_fds(ush_state *sh, const char *cmd, const char *arg, u64 stdin_fd, u64 stdout_fd,
const char *cmd, u64 stderr_fd, int *out_success) {
const char *arg,
u64 stdin_fd,
u64 stdout_fd,
u64 stderr_fd,
int *out_success) {
const char *canonical; const char *canonical;
char path[USH_PATH_MAX]; char path[USH_PATH_MAX];
char env_line[USH_PATH_MAX + USH_CMD_MAX + 96ULL]; char env_line[USH_PATH_MAX + USH_CMD_MAX + 96ULL];
@@ -230,11 +225,6 @@ int ush_try_exec_external_with_fds(ush_state *sh,
} }
int ush_try_exec_external(ush_state *sh, const char *cmd, const char *arg, int *out_success) { int ush_try_exec_external(ush_state *sh, const char *cmd, const char *arg, int *out_success) {
return ush_try_exec_external_with_fds(sh, return ush_try_exec_external_with_fds(sh, cmd, arg, CLEONOS_FD_INHERIT, CLEONOS_FD_INHERIT, CLEONOS_FD_INHERIT,
cmd,
arg,
CLEONOS_FD_INHERIT,
CLEONOS_FD_INHERIT,
CLEONOS_FD_INHERIT,
out_success); out_success);
} }

View File

@@ -712,4 +712,3 @@ void ush_read_line(ush_state *sh, char *out_line, u64 out_size) {
} }
} }
} }

View File

@@ -112,13 +112,7 @@ void ush_command_ret_reset(void);
int ush_command_ret_write(const ush_cmd_ret *ret); int ush_command_ret_write(const ush_cmd_ret *ret);
int ush_command_ret_read(ush_cmd_ret *out_ret); int ush_command_ret_read(ush_cmd_ret *out_ret);
int ush_try_exec_external(ush_state *sh, const char *cmd, const char *arg, int *out_success); int ush_try_exec_external(ush_state *sh, const char *cmd, const char *arg, int *out_success);
int ush_try_exec_external_with_fds(ush_state *sh, int ush_try_exec_external_with_fds(ush_state *sh, const char *cmd, const char *arg, u64 stdin_fd, u64 stdout_fd,
const char *cmd, u64 stderr_fd, int *out_success);
const char *arg,
u64 stdin_fd,
u64 stdout_fd,
u64 stderr_fd,
int *out_success);
#endif #endif

View File

@@ -194,7 +194,8 @@ int ush_path_is_under_system(const char *path) {
return 0; return 0;
} }
if (path[0] != '/' || path[1] != 's' || path[2] != 'y' || path[3] != 's' || path[4] != 't' || path[5] != 'e' || path[6] != 'm') { if (path[0] != '/' || path[1] != 's' || path[2] != 'y' || path[3] != 's' || path[4] != 't' || path[5] != 'e' ||
path[6] != 'm') {
return 0; return 0;
} }

View File

@@ -7,8 +7,7 @@ int cleonos_app_main(void) {
ush_init_state(&sh); ush_init_state(&sh);
ush_writeln("\x1B[92m[USER][SHELL]\x1B[0m interactive framework online"); ush_writeln("\x1B[92m[USER][SHELL]\x1B[0m interactive framework online");
if (ush_run_script_file(&sh, "/shell/init.cmd") == 0 && if (ush_run_script_file(&sh, "/shell/init.cmd") == 0 && ush_run_script_file(&sh, "/shell/INIT.CMD") == 0 &&
ush_run_script_file(&sh, "/shell/INIT.CMD") == 0 &&
ush_run_script_file(&sh, "/SHELL/INIT.CMD") == 0) { ush_run_script_file(&sh, "/SHELL/INIT.CMD") == 0) {
ush_writeln("\x1B[33m[USER][SHELL]\x1B[0m init script not found, continue interactive mode"); ush_writeln("\x1B[33m[USER][SHELL]\x1B[0m init script not found, continue interactive mode");
} }

View File

@@ -10,7 +10,6 @@ static int ush_cmd_shstat(const ush_state *sh) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -52,4 +51,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -5,7 +5,6 @@ static int ush_cmd_shutdown(void) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -47,4 +46,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -18,7 +18,6 @@ static int ush_cmd_sleep(const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -62,4 +61,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -28,7 +28,8 @@ static int ush_sort_parse_args(const char *arg, char *out_file, u64 out_file_siz
return 1; return 1;
} }
static int ush_sort_load_input(const ush_state *sh, const char *file_arg, char *out_buf, u64 out_buf_size, u64 *out_len) { static int ush_sort_load_input(const ush_state *sh, const char *file_arg, char *out_buf, u64 out_buf_size,
u64 *out_len) {
char path[USH_PATH_MAX]; char path[USH_PATH_MAX];
u64 size; u64 size;
u64 got; u64 got;
@@ -221,7 +222,6 @@ static int ush_cmd_sort(const ush_state *sh, const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;

View File

@@ -48,7 +48,6 @@ static int ush_cmd_spawn(const ush_state *sh, const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -92,4 +91,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -1,8 +1,7 @@
#include <stdio.h> #include <stdio.h>
int cleonos_app_main(void) { int cleonos_app_main(void) {
static const char banner[] = static const char banner[] = "spin: busy loop started (test Alt+Ctrl+C force stop)\n";
"spin: busy loop started (test Alt+Ctrl+C force stop)\n";
volatile unsigned long long noise = 0xC1E0C1E0ULL; volatile unsigned long long noise = 0xC1E0C1E0ULL;
(void)fputs(banner, 1); (void)fputs(banner, 1);

View File

@@ -74,7 +74,6 @@ static int ush_cmd_stats(const ush_state *sh) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -116,4 +115,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -12,79 +12,152 @@ typedef struct ush_sysstat_entry {
static const char *ush_sysstat_name_for_id(u64 id) { static const char *ush_sysstat_name_for_id(u64 id) {
switch (id) { switch (id) {
case CLEONOS_SYSCALL_LOG_WRITE: return "LOG_WRITE"; case CLEONOS_SYSCALL_LOG_WRITE:
case CLEONOS_SYSCALL_TIMER_TICKS: return "TIMER_TICKS"; return "LOG_WRITE";
case CLEONOS_SYSCALL_TASK_COUNT: return "TASK_COUNT"; case CLEONOS_SYSCALL_TIMER_TICKS:
case CLEONOS_SYSCALL_CUR_TASK: return "CUR_TASK"; return "TIMER_TICKS";
case CLEONOS_SYSCALL_SERVICE_COUNT: return "SERVICE_COUNT"; case CLEONOS_SYSCALL_TASK_COUNT:
case CLEONOS_SYSCALL_SERVICE_READY_COUNT: return "SERVICE_READY"; return "TASK_COUNT";
case CLEONOS_SYSCALL_CONTEXT_SWITCHES: return "CONTEXT_SWITCH"; case CLEONOS_SYSCALL_CUR_TASK:
case CLEONOS_SYSCALL_KELF_COUNT: return "KELF_COUNT"; return "CUR_TASK";
case CLEONOS_SYSCALL_KELF_RUNS: return "KELF_RUNS"; case CLEONOS_SYSCALL_SERVICE_COUNT:
case CLEONOS_SYSCALL_FS_NODE_COUNT: return "FS_NODE_COUNT"; return "SERVICE_COUNT";
case CLEONOS_SYSCALL_FS_CHILD_COUNT: return "FS_CHILD_COUNT"; case CLEONOS_SYSCALL_SERVICE_READY_COUNT:
case CLEONOS_SYSCALL_FS_GET_CHILD_NAME: return "FS_CHILD_NAME"; return "SERVICE_READY";
case CLEONOS_SYSCALL_FS_READ: return "FS_READ"; case CLEONOS_SYSCALL_CONTEXT_SWITCHES:
case CLEONOS_SYSCALL_EXEC_PATH: return "EXEC_PATH"; return "CONTEXT_SWITCH";
case CLEONOS_SYSCALL_EXEC_REQUESTS: return "EXEC_REQUESTS"; case CLEONOS_SYSCALL_KELF_COUNT:
case CLEONOS_SYSCALL_EXEC_SUCCESS: return "EXEC_SUCCESS"; return "KELF_COUNT";
case CLEONOS_SYSCALL_USER_SHELL_READY: return "USER_SHELL_READY"; case CLEONOS_SYSCALL_KELF_RUNS:
case CLEONOS_SYSCALL_USER_EXEC_REQUESTED: return "USER_EXEC_REQ"; return "KELF_RUNS";
case CLEONOS_SYSCALL_USER_LAUNCH_TRIES: return "USER_LAUNCH_TRY"; case CLEONOS_SYSCALL_FS_NODE_COUNT:
case CLEONOS_SYSCALL_USER_LAUNCH_OK: return "USER_LAUNCH_OK"; return "FS_NODE_COUNT";
case CLEONOS_SYSCALL_USER_LAUNCH_FAIL: return "USER_LAUNCH_FAIL"; case CLEONOS_SYSCALL_FS_CHILD_COUNT:
case CLEONOS_SYSCALL_TTY_COUNT: return "TTY_COUNT"; return "FS_CHILD_COUNT";
case CLEONOS_SYSCALL_TTY_ACTIVE: return "TTY_ACTIVE"; case CLEONOS_SYSCALL_FS_GET_CHILD_NAME:
case CLEONOS_SYSCALL_TTY_SWITCH: return "TTY_SWITCH"; return "FS_CHILD_NAME";
case CLEONOS_SYSCALL_TTY_WRITE: return "TTY_WRITE"; case CLEONOS_SYSCALL_FS_READ:
case CLEONOS_SYSCALL_TTY_WRITE_CHAR: return "TTY_WRITE_CHAR"; return "FS_READ";
case CLEONOS_SYSCALL_KBD_GET_CHAR: return "KBD_GET_CHAR"; case CLEONOS_SYSCALL_EXEC_PATH:
case CLEONOS_SYSCALL_FS_STAT_TYPE: return "FS_STAT_TYPE"; return "EXEC_PATH";
case CLEONOS_SYSCALL_FS_STAT_SIZE: return "FS_STAT_SIZE"; case CLEONOS_SYSCALL_EXEC_REQUESTS:
case CLEONOS_SYSCALL_FS_MKDIR: return "FS_MKDIR"; return "EXEC_REQUESTS";
case CLEONOS_SYSCALL_FS_WRITE: return "FS_WRITE"; case CLEONOS_SYSCALL_EXEC_SUCCESS:
case CLEONOS_SYSCALL_FS_APPEND: return "FS_APPEND"; return "EXEC_SUCCESS";
case CLEONOS_SYSCALL_FS_REMOVE: return "FS_REMOVE"; case CLEONOS_SYSCALL_USER_SHELL_READY:
case CLEONOS_SYSCALL_LOG_JOURNAL_COUNT: return "LOG_JCOUNT"; return "USER_SHELL_READY";
case CLEONOS_SYSCALL_LOG_JOURNAL_READ: return "LOG_JREAD"; case CLEONOS_SYSCALL_USER_EXEC_REQUESTED:
case CLEONOS_SYSCALL_KBD_BUFFERED: return "KBD_BUFFERED"; return "USER_EXEC_REQ";
case CLEONOS_SYSCALL_KBD_PUSHED: return "KBD_PUSHED"; case CLEONOS_SYSCALL_USER_LAUNCH_TRIES:
case CLEONOS_SYSCALL_KBD_POPPED: return "KBD_POPPED"; return "USER_LAUNCH_TRY";
case CLEONOS_SYSCALL_KBD_DROPPED: return "KBD_DROPPED"; case CLEONOS_SYSCALL_USER_LAUNCH_OK:
case CLEONOS_SYSCALL_KBD_HOTKEY_SWITCHES: return "KBD_HOTKEYS"; return "USER_LAUNCH_OK";
case CLEONOS_SYSCALL_GETPID: return "GETPID"; case CLEONOS_SYSCALL_USER_LAUNCH_FAIL:
case CLEONOS_SYSCALL_SPAWN_PATH: return "SPAWN_PATH"; return "USER_LAUNCH_FAIL";
case CLEONOS_SYSCALL_WAITPID: return "WAITPID"; case CLEONOS_SYSCALL_TTY_COUNT:
case CLEONOS_SYSCALL_EXIT: return "EXIT"; return "TTY_COUNT";
case CLEONOS_SYSCALL_SLEEP_TICKS: return "SLEEP_TICKS"; case CLEONOS_SYSCALL_TTY_ACTIVE:
case CLEONOS_SYSCALL_YIELD: return "YIELD"; return "TTY_ACTIVE";
case CLEONOS_SYSCALL_SHUTDOWN: return "SHUTDOWN"; case CLEONOS_SYSCALL_TTY_SWITCH:
case CLEONOS_SYSCALL_RESTART: return "RESTART"; return "TTY_SWITCH";
case CLEONOS_SYSCALL_AUDIO_AVAILABLE: return "AUDIO_AVAIL"; case CLEONOS_SYSCALL_TTY_WRITE:
case CLEONOS_SYSCALL_AUDIO_PLAY_TONE: return "AUDIO_TONE"; return "TTY_WRITE";
case CLEONOS_SYSCALL_AUDIO_STOP: return "AUDIO_STOP"; case CLEONOS_SYSCALL_TTY_WRITE_CHAR:
case CLEONOS_SYSCALL_EXEC_PATHV: return "EXEC_PATHV"; return "TTY_WRITE_CHAR";
case CLEONOS_SYSCALL_SPAWN_PATHV: return "SPAWN_PATHV"; case CLEONOS_SYSCALL_KBD_GET_CHAR:
case CLEONOS_SYSCALL_PROC_ARGC: return "PROC_ARGC"; return "KBD_GET_CHAR";
case CLEONOS_SYSCALL_PROC_ARGV: return "PROC_ARGV"; case CLEONOS_SYSCALL_FS_STAT_TYPE:
case CLEONOS_SYSCALL_PROC_ENVC: return "PROC_ENVC"; return "FS_STAT_TYPE";
case CLEONOS_SYSCALL_PROC_ENV: return "PROC_ENV"; case CLEONOS_SYSCALL_FS_STAT_SIZE:
case CLEONOS_SYSCALL_PROC_LAST_SIGNAL: return "PROC_LAST_SIG"; return "FS_STAT_SIZE";
case CLEONOS_SYSCALL_PROC_FAULT_VECTOR: return "PROC_FAULT_VEC"; case CLEONOS_SYSCALL_FS_MKDIR:
case CLEONOS_SYSCALL_PROC_FAULT_ERROR: return "PROC_FAULT_ERR"; return "FS_MKDIR";
case CLEONOS_SYSCALL_PROC_FAULT_RIP: return "PROC_FAULT_RIP"; case CLEONOS_SYSCALL_FS_WRITE:
case CLEONOS_SYSCALL_PROC_COUNT: return "PROC_COUNT"; return "FS_WRITE";
case CLEONOS_SYSCALL_PROC_PID_AT: return "PROC_PID_AT"; case CLEONOS_SYSCALL_FS_APPEND:
case CLEONOS_SYSCALL_PROC_SNAPSHOT: return "PROC_SNAPSHOT"; return "FS_APPEND";
case CLEONOS_SYSCALL_PROC_KILL: return "PROC_KILL"; case CLEONOS_SYSCALL_FS_REMOVE:
case CLEONOS_SYSCALL_KDBG_SYM: return "KDBG_SYM"; return "FS_REMOVE";
case CLEONOS_SYSCALL_KDBG_BT: return "KDBG_BT"; case CLEONOS_SYSCALL_LOG_JOURNAL_COUNT:
case CLEONOS_SYSCALL_KDBG_REGS: return "KDBG_REGS"; return "LOG_JCOUNT";
case CLEONOS_SYSCALL_STATS_TOTAL: return "STATS_TOTAL"; case CLEONOS_SYSCALL_LOG_JOURNAL_READ:
case CLEONOS_SYSCALL_STATS_ID_COUNT: return "STATS_ID_COUNT"; return "LOG_JREAD";
case CLEONOS_SYSCALL_STATS_RECENT_WINDOW: return "STATS_RECENT_WIN"; case CLEONOS_SYSCALL_KBD_BUFFERED:
case CLEONOS_SYSCALL_STATS_RECENT_ID: return "STATS_RECENT_ID"; return "KBD_BUFFERED";
default: return "UNKNOWN"; case CLEONOS_SYSCALL_KBD_PUSHED:
return "KBD_PUSHED";
case CLEONOS_SYSCALL_KBD_POPPED:
return "KBD_POPPED";
case CLEONOS_SYSCALL_KBD_DROPPED:
return "KBD_DROPPED";
case CLEONOS_SYSCALL_KBD_HOTKEY_SWITCHES:
return "KBD_HOTKEYS";
case CLEONOS_SYSCALL_GETPID:
return "GETPID";
case CLEONOS_SYSCALL_SPAWN_PATH:
return "SPAWN_PATH";
case CLEONOS_SYSCALL_WAITPID:
return "WAITPID";
case CLEONOS_SYSCALL_EXIT:
return "EXIT";
case CLEONOS_SYSCALL_SLEEP_TICKS:
return "SLEEP_TICKS";
case CLEONOS_SYSCALL_YIELD:
return "YIELD";
case CLEONOS_SYSCALL_SHUTDOWN:
return "SHUTDOWN";
case CLEONOS_SYSCALL_RESTART:
return "RESTART";
case CLEONOS_SYSCALL_AUDIO_AVAILABLE:
return "AUDIO_AVAIL";
case CLEONOS_SYSCALL_AUDIO_PLAY_TONE:
return "AUDIO_TONE";
case CLEONOS_SYSCALL_AUDIO_STOP:
return "AUDIO_STOP";
case CLEONOS_SYSCALL_EXEC_PATHV:
return "EXEC_PATHV";
case CLEONOS_SYSCALL_SPAWN_PATHV:
return "SPAWN_PATHV";
case CLEONOS_SYSCALL_PROC_ARGC:
return "PROC_ARGC";
case CLEONOS_SYSCALL_PROC_ARGV:
return "PROC_ARGV";
case CLEONOS_SYSCALL_PROC_ENVC:
return "PROC_ENVC";
case CLEONOS_SYSCALL_PROC_ENV:
return "PROC_ENV";
case CLEONOS_SYSCALL_PROC_LAST_SIGNAL:
return "PROC_LAST_SIG";
case CLEONOS_SYSCALL_PROC_FAULT_VECTOR:
return "PROC_FAULT_VEC";
case CLEONOS_SYSCALL_PROC_FAULT_ERROR:
return "PROC_FAULT_ERR";
case CLEONOS_SYSCALL_PROC_FAULT_RIP:
return "PROC_FAULT_RIP";
case CLEONOS_SYSCALL_PROC_COUNT:
return "PROC_COUNT";
case CLEONOS_SYSCALL_PROC_PID_AT:
return "PROC_PID_AT";
case CLEONOS_SYSCALL_PROC_SNAPSHOT:
return "PROC_SNAPSHOT";
case CLEONOS_SYSCALL_PROC_KILL:
return "PROC_KILL";
case CLEONOS_SYSCALL_KDBG_SYM:
return "KDBG_SYM";
case CLEONOS_SYSCALL_KDBG_BT:
return "KDBG_BT";
case CLEONOS_SYSCALL_KDBG_REGS:
return "KDBG_REGS";
case CLEONOS_SYSCALL_STATS_TOTAL:
return "STATS_TOTAL";
case CLEONOS_SYSCALL_STATS_ID_COUNT:
return "STATS_ID_COUNT";
case CLEONOS_SYSCALL_STATS_RECENT_WINDOW:
return "STATS_RECENT_WIN";
case CLEONOS_SYSCALL_STATS_RECENT_ID:
return "STATS_RECENT_ID";
default:
return "UNKNOWN";
} }
} }
@@ -141,7 +214,8 @@ static int ush_sysstat_parse_args(const char *arg, int *out_show_all, u64 *out_l
} }
if (ush_streq(token, "-n") != 0 || ush_streq(token, "--top") != 0) { if (ush_streq(token, "-n") != 0 || ush_streq(token, "--top") != 0) {
if (ush_sysstat_next_token(&cursor, token, (u64)sizeof(token)) == 0 || ush_parse_u64_dec(token, &limit) == 0) { if (ush_sysstat_next_token(&cursor, token, (u64)sizeof(token)) == 0 ||
ush_parse_u64_dec(token, &limit) == 0) {
return 0; return 0;
} }
continue; continue;

View File

@@ -198,7 +198,6 @@ static int ush_cmd_tail(const ush_state *sh, const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;

View File

@@ -8,7 +8,6 @@ static int ush_cmd_taskstat(void) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -50,4 +49,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -117,8 +117,7 @@ static void ush_top_render_frame(u64 frame_index, u64 delay_ticks) {
continue; continue;
} }
if (snap.state != CLEONOS_PROC_STATE_PENDING && if (snap.state != CLEONOS_PROC_STATE_PENDING && snap.state != CLEONOS_PROC_STATE_RUNNING &&
snap.state != CLEONOS_PROC_STATE_RUNNING &&
snap.state != CLEONOS_PROC_STATE_STOPPED) { snap.state != CLEONOS_PROC_STATE_STOPPED) {
continue; continue;
} }

View File

@@ -26,7 +26,6 @@ static int ush_cmd_touch(const ush_state *sh, const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -70,4 +69,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -33,7 +33,6 @@ static int ush_cmd_tty(const char *arg) {
} }
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -77,4 +76,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -169,7 +169,6 @@ static int ush_cmd_uniq(const ush_state *sh, const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;

View File

@@ -13,7 +13,6 @@ static int ush_cmd_userstat(void) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -55,4 +54,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -37,7 +37,6 @@ static int ush_cmd_wait(const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -81,4 +80,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -20,9 +20,7 @@ static unsigned int ush_wav_le16(const unsigned char *ptr) {
} }
static unsigned int ush_wav_le32(const unsigned char *ptr) { static unsigned int ush_wav_le32(const unsigned char *ptr) {
return (unsigned int)ptr[0] | return (unsigned int)ptr[0] | ((unsigned int)ptr[1] << 8U) | ((unsigned int)ptr[2] << 16U) |
((unsigned int)ptr[1] << 8U) |
((unsigned int)ptr[2] << 16U) |
((unsigned int)ptr[3] << 24U); ((unsigned int)ptr[3] << 24U);
} }
@@ -31,9 +29,7 @@ static int ush_wav_tag_eq(const unsigned char *tag, const char *lit4) {
return 0; return 0;
} }
return (tag[0] == (unsigned char)lit4[0] && return (tag[0] == (unsigned char)lit4[0] && tag[1] == (unsigned char)lit4[1] && tag[2] == (unsigned char)lit4[2] &&
tag[1] == (unsigned char)lit4[1] &&
tag[2] == (unsigned char)lit4[2] &&
tag[3] == (unsigned char)lit4[3]) tag[3] == (unsigned char)lit4[3])
? 1 ? 1
: 0; : 0;
@@ -278,11 +274,7 @@ static u64 ush_wav_frame_deviation(const ush_wav_info *info, const unsigned char
return 0ULL; return 0ULL;
} }
static int ush_wavplay_parse_args(const char *arg, static int ush_wavplay_parse_args(const char *arg, char *out_path, u64 out_path_size, u64 *out_steps, u64 *out_ticks,
char *out_path,
u64 out_path_size,
u64 *out_steps,
u64 *out_ticks,
int *out_stop) { int *out_stop) {
char first[USH_PATH_MAX]; char first[USH_PATH_MAX];
char second[32]; char second[32];

View File

@@ -163,7 +163,6 @@ static int ush_cmd_wc(const ush_state *sh, const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;

View File

@@ -44,7 +44,6 @@ static int ush_cmd_write(const ush_state *sh, const char *arg) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -88,4 +87,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -4,7 +4,6 @@ static int ush_cmd_yield(void) {
return 1; return 1;
} }
int cleonos_app_main(void) { int cleonos_app_main(void) {
ush_cmd_ctx ctx; ush_cmd_ctx ctx;
ush_cmd_ret ret; ush_cmd_ret ret;
@@ -46,4 +45,3 @@ int cleonos_app_main(void) {
return (success != 0) ? 0 : 1; return (success != 0) ? 0 : 1;
} }

View File

@@ -24,7 +24,7 @@ typedef unsigned long long usize;
#define CLEONOS_O_CREAT 0x0040ULL #define CLEONOS_O_CREAT 0x0040ULL
#define CLEONOS_O_TRUNC 0x0200ULL #define CLEONOS_O_TRUNC 0x0200ULL
#define CLEONOS_O_APPEND 0x0400ULL #define CLEONOS_O_APPEND 0x0400ULL
#define CLEONOS_FD_INHERIT ((u64)-1) #define CLEONOS_FD_INHERIT ((u64) - 1)
typedef struct cleonos_proc_snapshot { typedef struct cleonos_proc_snapshot {
u64 pid; u64 pid;
@@ -140,12 +140,8 @@ u64 cleonos_sys_fs_get_child_name(const char *dir_path, u64 index, char *out_nam
u64 cleonos_sys_fs_read(const char *path, char *out_buffer, u64 buffer_size); u64 cleonos_sys_fs_read(const char *path, char *out_buffer, u64 buffer_size);
u64 cleonos_sys_exec_path(const char *path); u64 cleonos_sys_exec_path(const char *path);
u64 cleonos_sys_exec_pathv(const char *path, const char *argv_line, const char *env_line); u64 cleonos_sys_exec_pathv(const char *path, const char *argv_line, const char *env_line);
u64 cleonos_sys_exec_pathv_io(const char *path, u64 cleonos_sys_exec_pathv_io(const char *path, const char *argv_line, const char *env_line, u64 stdin_fd,
const char *argv_line, u64 stdout_fd, u64 stderr_fd);
const char *env_line,
u64 stdin_fd,
u64 stdout_fd,
u64 stderr_fd);
u64 cleonos_sys_exec_request_count(void); u64 cleonos_sys_exec_request_count(void);
u64 cleonos_sys_exec_success_count(void); u64 cleonos_sys_exec_success_count(void);
u64 cleonos_sys_user_shell_ready(void); u64 cleonos_sys_user_shell_ready(void);

View File

@@ -126,10 +126,7 @@ static int clio_sink_emit(struct clio_sink *sink, const char *text, clio_size_t
return 1; return 1;
} }
static clio_size_t clio_u64_to_base(unsigned long long value, static clio_size_t clio_u64_to_base(unsigned long long value, unsigned int base, int uppercase, char *out,
unsigned int base,
int uppercase,
char *out,
clio_size_t out_size) { clio_size_t out_size) {
char tmp[64]; char tmp[64];
clio_size_t pos = 0UL; clio_size_t pos = 0UL;

View File

@@ -3,12 +3,7 @@
u64 cleonos_syscall(u64 id, u64 arg0, u64 arg1, u64 arg2) { u64 cleonos_syscall(u64 id, u64 arg0, u64 arg1, u64 arg2) {
u64 ret; u64 ret;
__asm__ volatile( __asm__ volatile("int $0x80" : "=a"(ret) : "a"(id), "b"(arg0), "c"(arg1), "d"(arg2) : "memory");
"int $0x80"
: "=a"(ret)
: "a"(id), "b"(arg0), "c"(arg1), "d"(arg2)
: "memory"
);
return ret; return ret;
} }
@@ -76,12 +71,8 @@ struct cleonos_exec_pathv_io_req {
u64 stderr_fd; u64 stderr_fd;
}; };
u64 cleonos_sys_exec_pathv_io(const char *path, u64 cleonos_sys_exec_pathv_io(const char *path, const char *argv_line, const char *env_line, u64 stdin_fd,
const char *argv_line, u64 stdout_fd, u64 stderr_fd) {
const char *env_line,
u64 stdin_fd,
u64 stdout_fd,
u64 stderr_fd) {
struct cleonos_exec_pathv_io_req req; struct cleonos_exec_pathv_io_req req;
req.env_line_ptr = (u64)env_line; req.env_line_ptr = (u64)env_line;
@@ -231,7 +222,6 @@ u64 cleonos_sys_restart(void) {
return cleonos_syscall(CLEONOS_SYSCALL_RESTART, 0ULL, 0ULL, 0ULL); return cleonos_syscall(CLEONOS_SYSCALL_RESTART, 0ULL, 0ULL, 0ULL);
} }
u64 cleonos_sys_audio_available(void) { u64 cleonos_sys_audio_available(void) {
return cleonos_syscall(CLEONOS_SYSCALL_AUDIO_AVAILABLE, 0ULL, 0ULL, 0ULL); return cleonos_syscall(CLEONOS_SYSCALL_AUDIO_AVAILABLE, 0ULL, 0ULL, 0ULL);
} }

View File

@@ -40,8 +40,7 @@ void clks_serial_write_char(char ch) {
#define CLKS_PL011_FR (*(volatile u32 *)(CLKS_PL011_BASE + 0x18)) #define CLKS_PL011_FR (*(volatile u32 *)(CLKS_PL011_BASE + 0x18))
#define CLKS_PL011_TXFF (1U << 5) #define CLKS_PL011_TXFF (1U << 5)
void clks_serial_init(void) { void clks_serial_init(void) {}
}
void clks_serial_write_char(char ch) { void clks_serial_write_char(char ch) {
while ((CLKS_PL011_FR & CLKS_PL011_TXFF) != 0) { while ((CLKS_PL011_FR & CLKS_PL011_TXFF) != 0) {

View File

@@ -8,50 +8,28 @@ struct clks_glyph8x8 {
}; };
static const struct clks_glyph8x8 clks_font_table[] = { static const struct clks_glyph8x8 clks_font_table[] = {
{' ', {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {' ', {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {'[', {0x1E, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1E, 0x00}},
{'[', {0x1E, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1E, 0x00}}, {']', {0x78, 0x08, 0x08, 0x08, 0x08, 0x08, 0x78, 0x00}}, {':', {0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00}},
{']', {0x78, 0x08, 0x08, 0x08, 0x08, 0x08, 0x78, 0x00}}, {'.', {0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00}}, {'-', {0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00}},
{':', {0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00}}, {'/', {0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00}}, {'_', {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00}},
{'.', {0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00}}, {'?', {0x3C, 0x42, 0x02, 0x0C, 0x10, 0x00, 0x10, 0x00}}, {'0', {0x3C, 0x42, 0x46, 0x4A, 0x52, 0x62, 0x3C, 0x00}},
{'-', {0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00}}, {'1', {0x18, 0x28, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00}}, {'2', {0x3C, 0x42, 0x02, 0x0C, 0x30, 0x40, 0x7E, 0x00}},
{'/', {0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00}}, {'3', {0x3C, 0x42, 0x02, 0x1C, 0x02, 0x42, 0x3C, 0x00}}, {'4', {0x0C, 0x14, 0x24, 0x44, 0x7E, 0x04, 0x04, 0x00}},
{'_', {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00}}, {'5', {0x7E, 0x40, 0x7C, 0x02, 0x02, 0x42, 0x3C, 0x00}}, {'6', {0x1C, 0x20, 0x40, 0x7C, 0x42, 0x42, 0x3C, 0x00}},
{'?', {0x3C, 0x42, 0x02, 0x0C, 0x10, 0x00, 0x10, 0x00}}, {'7', {0x7E, 0x02, 0x04, 0x08, 0x10, 0x20, 0x20, 0x00}}, {'8', {0x3C, 0x42, 0x42, 0x3C, 0x42, 0x42, 0x3C, 0x00}},
{'0', {0x3C, 0x42, 0x46, 0x4A, 0x52, 0x62, 0x3C, 0x00}}, {'9', {0x3C, 0x42, 0x42, 0x3E, 0x02, 0x04, 0x38, 0x00}}, {'A', {0x18, 0x24, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x00}},
{'1', {0x18, 0x28, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00}}, {'B', {0x7C, 0x42, 0x42, 0x7C, 0x42, 0x42, 0x7C, 0x00}}, {'C', {0x3C, 0x42, 0x40, 0x40, 0x40, 0x42, 0x3C, 0x00}},
{'2', {0x3C, 0x42, 0x02, 0x0C, 0x30, 0x40, 0x7E, 0x00}}, {'D', {0x78, 0x44, 0x42, 0x42, 0x42, 0x44, 0x78, 0x00}}, {'E', {0x7E, 0x40, 0x40, 0x7C, 0x40, 0x40, 0x7E, 0x00}},
{'3', {0x3C, 0x42, 0x02, 0x1C, 0x02, 0x42, 0x3C, 0x00}}, {'F', {0x7E, 0x40, 0x40, 0x7C, 0x40, 0x40, 0x40, 0x00}}, {'G', {0x3C, 0x42, 0x40, 0x4E, 0x42, 0x42, 0x3C, 0x00}},
{'4', {0x0C, 0x14, 0x24, 0x44, 0x7E, 0x04, 0x04, 0x00}}, {'H', {0x42, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x00}}, {'I', {0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00}},
{'5', {0x7E, 0x40, 0x7C, 0x02, 0x02, 0x42, 0x3C, 0x00}}, {'J', {0x1E, 0x04, 0x04, 0x04, 0x44, 0x44, 0x38, 0x00}}, {'K', {0x42, 0x44, 0x48, 0x70, 0x48, 0x44, 0x42, 0x00}},
{'6', {0x1C, 0x20, 0x40, 0x7C, 0x42, 0x42, 0x3C, 0x00}}, {'L', {0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x00}}, {'M', {0x42, 0x66, 0x5A, 0x5A, 0x42, 0x42, 0x42, 0x00}},
{'7', {0x7E, 0x02, 0x04, 0x08, 0x10, 0x20, 0x20, 0x00}}, {'N', {0x42, 0x62, 0x52, 0x4A, 0x46, 0x42, 0x42, 0x00}}, {'O', {0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00}},
{'8', {0x3C, 0x42, 0x42, 0x3C, 0x42, 0x42, 0x3C, 0x00}}, {'P', {0x7C, 0x42, 0x42, 0x7C, 0x40, 0x40, 0x40, 0x00}}, {'Q', {0x3C, 0x42, 0x42, 0x42, 0x4A, 0x44, 0x3A, 0x00}},
{'9', {0x3C, 0x42, 0x42, 0x3E, 0x02, 0x04, 0x38, 0x00}}, {'R', {0x7C, 0x42, 0x42, 0x7C, 0x48, 0x44, 0x42, 0x00}}, {'S', {0x3C, 0x42, 0x40, 0x3C, 0x02, 0x42, 0x3C, 0x00}},
{'A', {0x18, 0x24, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x00}}, {'T', {0x7F, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00}}, {'U', {0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00}},
{'B', {0x7C, 0x42, 0x42, 0x7C, 0x42, 0x42, 0x7C, 0x00}}, {'V', {0x42, 0x42, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00}}, {'W', {0x42, 0x42, 0x42, 0x5A, 0x5A, 0x66, 0x42, 0x00}},
{'C', {0x3C, 0x42, 0x40, 0x40, 0x40, 0x42, 0x3C, 0x00}}, {'X', {0x42, 0x42, 0x24, 0x18, 0x24, 0x42, 0x42, 0x00}}, {'Y', {0x42, 0x42, 0x24, 0x18, 0x08, 0x08, 0x08, 0x00}},
{'D', {0x78, 0x44, 0x42, 0x42, 0x42, 0x44, 0x78, 0x00}},
{'E', {0x7E, 0x40, 0x40, 0x7C, 0x40, 0x40, 0x7E, 0x00}},
{'F', {0x7E, 0x40, 0x40, 0x7C, 0x40, 0x40, 0x40, 0x00}},
{'G', {0x3C, 0x42, 0x40, 0x4E, 0x42, 0x42, 0x3C, 0x00}},
{'H', {0x42, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x00}},
{'I', {0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00}},
{'J', {0x1E, 0x04, 0x04, 0x04, 0x44, 0x44, 0x38, 0x00}},
{'K', {0x42, 0x44, 0x48, 0x70, 0x48, 0x44, 0x42, 0x00}},
{'L', {0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x00}},
{'M', {0x42, 0x66, 0x5A, 0x5A, 0x42, 0x42, 0x42, 0x00}},
{'N', {0x42, 0x62, 0x52, 0x4A, 0x46, 0x42, 0x42, 0x00}},
{'O', {0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00}},
{'P', {0x7C, 0x42, 0x42, 0x7C, 0x40, 0x40, 0x40, 0x00}},
{'Q', {0x3C, 0x42, 0x42, 0x42, 0x4A, 0x44, 0x3A, 0x00}},
{'R', {0x7C, 0x42, 0x42, 0x7C, 0x48, 0x44, 0x42, 0x00}},
{'S', {0x3C, 0x42, 0x40, 0x3C, 0x02, 0x42, 0x3C, 0x00}},
{'T', {0x7F, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00}},
{'U', {0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00}},
{'V', {0x42, 0x42, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00}},
{'W', {0x42, 0x42, 0x42, 0x5A, 0x5A, 0x66, 0x42, 0x00}},
{'X', {0x42, 0x42, 0x24, 0x18, 0x24, 0x42, 0x42, 0x00}},
{'Y', {0x42, 0x42, 0x24, 0x18, 0x08, 0x08, 0x08, 0x00}},
{'Z', {0x7E, 0x02, 0x04, 0x18, 0x20, 0x40, 0x7E, 0x00}}, {'Z', {0x7E, 0x02, 0x04, 0x18, 0x20, 0x40, 0x7E, 0x00}},
}; };

View File

@@ -181,11 +181,8 @@ void clks_fb_scroll_up(u32 pixel_rows, u32 fill_rgb) {
row_bytes = (usize)clks_fb.info.pitch; row_bytes = (usize)clks_fb.info.pitch;
move_bytes = (usize)(clks_fb.info.height - pixel_rows) * row_bytes; move_bytes = (usize)(clks_fb.info.height - pixel_rows) * row_bytes;
clks_memmove( clks_memmove((void *)clks_fb.address, (const void *)(clks_fb.address + ((usize)pixel_rows * row_bytes)),
(void *)clks_fb.address, move_bytes);
(const void *)(clks_fb.address + ((usize)pixel_rows * row_bytes)),
move_bytes
);
for (y = clks_fb.info.height - pixel_rows; y < clks_fb.info.height; y++) { for (y = clks_fb.info.height - pixel_rows; y < clks_fb.info.height; y++) {
volatile u32 *row_ptr = (volatile u32 *)(clks_fb.address + ((usize)y * row_bytes)); volatile u32 *row_ptr = (volatile u32 *)(clks_fb.address + ((usize)y * row_bytes));
@@ -265,9 +262,8 @@ void clks_fb_draw_char_styled(u32 x, u32 y, char ch, u32 fg_rgb, u32 bg_rgb, u32
for (row = 0U; row < draw_rows; row++) { for (row = 0U; row < draw_rows; row++) {
const u8 *row_bits = glyph + ((usize)row * (usize)row_stride); const u8 *row_bits = glyph + ((usize)row * (usize)row_stride);
volatile u32 *dst_row = (volatile u32 *)( volatile u32 *dst_row =
clks_fb.address + ((usize)(y + row) * (usize)clks_fb.info.pitch) + ((usize)x * 4U) (volatile u32 *)(clks_fb.address + ((usize)(y + row) * (usize)clks_fb.info.pitch) + ((usize)x * 4U));
);
for (col = 0U; col < draw_cols; col++) { for (col = 0U; col < draw_cols; col++) {
u8 bits = row_bits[col >> 3U]; u8 bits = row_bits[col >> 3U];
@@ -317,4 +313,3 @@ u32 clks_fb_cell_width(void) {
u32 clks_fb_cell_height(void) { u32 clks_fb_cell_height(void) {
return clks_fb.glyph_height == 0U ? 8U : clks_fb.glyph_height; return clks_fb.glyph_height == 0U ? 8U : clks_fb.glyph_height;
} }

View File

@@ -35,55 +35,31 @@ struct clks_psf_seed_glyph {
u8 rows[CLKS_PSF1_GLYPH_BYTES]; u8 rows[CLKS_PSF1_GLYPH_BYTES];
}; };
static const u8 clks_psf_unknown[CLKS_PSF1_GLYPH_BYTES] = { static const u8 clks_psf_unknown[CLKS_PSF1_GLYPH_BYTES] = {0x3C, 0x42, 0x02, 0x0C, 0x10, 0x00, 0x10, 0x00};
0x3C, 0x42, 0x02, 0x0C, 0x10, 0x00, 0x10, 0x00
};
static const struct clks_psf_seed_glyph clks_psf_seed_table[] = { static const struct clks_psf_seed_glyph clks_psf_seed_table[] = {
{' ', {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {' ', {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, {'[', {0x1E, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1E, 0x00}},
{'[', {0x1E, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1E, 0x00}}, {']', {0x78, 0x08, 0x08, 0x08, 0x08, 0x08, 0x78, 0x00}}, {':', {0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00}},
{']', {0x78, 0x08, 0x08, 0x08, 0x08, 0x08, 0x78, 0x00}}, {'.', {0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00}}, {'-', {0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00}},
{':', {0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00}}, {'/', {0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00}}, {'_', {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00}},
{'.', {0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00}}, {'?', {0x3C, 0x42, 0x02, 0x0C, 0x10, 0x00, 0x10, 0x00}}, {'0', {0x3C, 0x42, 0x46, 0x4A, 0x52, 0x62, 0x3C, 0x00}},
{'-', {0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00}}, {'1', {0x18, 0x28, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00}}, {'2', {0x3C, 0x42, 0x02, 0x0C, 0x30, 0x40, 0x7E, 0x00}},
{'/', {0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00}}, {'3', {0x3C, 0x42, 0x02, 0x1C, 0x02, 0x42, 0x3C, 0x00}}, {'4', {0x0C, 0x14, 0x24, 0x44, 0x7E, 0x04, 0x04, 0x00}},
{'_', {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00}}, {'5', {0x7E, 0x40, 0x7C, 0x02, 0x02, 0x42, 0x3C, 0x00}}, {'6', {0x1C, 0x20, 0x40, 0x7C, 0x42, 0x42, 0x3C, 0x00}},
{'?', {0x3C, 0x42, 0x02, 0x0C, 0x10, 0x00, 0x10, 0x00}}, {'7', {0x7E, 0x02, 0x04, 0x08, 0x10, 0x20, 0x20, 0x00}}, {'8', {0x3C, 0x42, 0x42, 0x3C, 0x42, 0x42, 0x3C, 0x00}},
{'0', {0x3C, 0x42, 0x46, 0x4A, 0x52, 0x62, 0x3C, 0x00}}, {'9', {0x3C, 0x42, 0x42, 0x3E, 0x02, 0x04, 0x38, 0x00}}, {'A', {0x18, 0x24, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x00}},
{'1', {0x18, 0x28, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00}}, {'B', {0x7C, 0x42, 0x42, 0x7C, 0x42, 0x42, 0x7C, 0x00}}, {'C', {0x3C, 0x42, 0x40, 0x40, 0x40, 0x42, 0x3C, 0x00}},
{'2', {0x3C, 0x42, 0x02, 0x0C, 0x30, 0x40, 0x7E, 0x00}}, {'D', {0x78, 0x44, 0x42, 0x42, 0x42, 0x44, 0x78, 0x00}}, {'E', {0x7E, 0x40, 0x40, 0x7C, 0x40, 0x40, 0x7E, 0x00}},
{'3', {0x3C, 0x42, 0x02, 0x1C, 0x02, 0x42, 0x3C, 0x00}}, {'F', {0x7E, 0x40, 0x40, 0x7C, 0x40, 0x40, 0x40, 0x00}}, {'G', {0x3C, 0x42, 0x40, 0x4E, 0x42, 0x42, 0x3C, 0x00}},
{'4', {0x0C, 0x14, 0x24, 0x44, 0x7E, 0x04, 0x04, 0x00}}, {'H', {0x42, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x00}}, {'I', {0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00}},
{'5', {0x7E, 0x40, 0x7C, 0x02, 0x02, 0x42, 0x3C, 0x00}}, {'J', {0x1E, 0x04, 0x04, 0x04, 0x44, 0x44, 0x38, 0x00}}, {'K', {0x42, 0x44, 0x48, 0x70, 0x48, 0x44, 0x42, 0x00}},
{'6', {0x1C, 0x20, 0x40, 0x7C, 0x42, 0x42, 0x3C, 0x00}}, {'L', {0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x00}}, {'M', {0x42, 0x66, 0x5A, 0x5A, 0x42, 0x42, 0x42, 0x00}},
{'7', {0x7E, 0x02, 0x04, 0x08, 0x10, 0x20, 0x20, 0x00}}, {'N', {0x42, 0x62, 0x52, 0x4A, 0x46, 0x42, 0x42, 0x00}}, {'O', {0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00}},
{'8', {0x3C, 0x42, 0x42, 0x3C, 0x42, 0x42, 0x3C, 0x00}}, {'P', {0x7C, 0x42, 0x42, 0x7C, 0x40, 0x40, 0x40, 0x00}}, {'Q', {0x3C, 0x42, 0x42, 0x42, 0x4A, 0x44, 0x3A, 0x00}},
{'9', {0x3C, 0x42, 0x42, 0x3E, 0x02, 0x04, 0x38, 0x00}}, {'R', {0x7C, 0x42, 0x42, 0x7C, 0x48, 0x44, 0x42, 0x00}}, {'S', {0x3C, 0x42, 0x40, 0x3C, 0x02, 0x42, 0x3C, 0x00}},
{'A', {0x18, 0x24, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x00}}, {'T', {0x7F, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00}}, {'U', {0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00}},
{'B', {0x7C, 0x42, 0x42, 0x7C, 0x42, 0x42, 0x7C, 0x00}}, {'V', {0x42, 0x42, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00}}, {'W', {0x42, 0x42, 0x42, 0x5A, 0x5A, 0x66, 0x42, 0x00}},
{'C', {0x3C, 0x42, 0x40, 0x40, 0x40, 0x42, 0x3C, 0x00}}, {'X', {0x42, 0x42, 0x24, 0x18, 0x24, 0x42, 0x42, 0x00}}, {'Y', {0x42, 0x42, 0x24, 0x18, 0x08, 0x08, 0x08, 0x00}},
{'D', {0x78, 0x44, 0x42, 0x42, 0x42, 0x44, 0x78, 0x00}},
{'E', {0x7E, 0x40, 0x40, 0x7C, 0x40, 0x40, 0x7E, 0x00}},
{'F', {0x7E, 0x40, 0x40, 0x7C, 0x40, 0x40, 0x40, 0x00}},
{'G', {0x3C, 0x42, 0x40, 0x4E, 0x42, 0x42, 0x3C, 0x00}},
{'H', {0x42, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x00}},
{'I', {0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00}},
{'J', {0x1E, 0x04, 0x04, 0x04, 0x44, 0x44, 0x38, 0x00}},
{'K', {0x42, 0x44, 0x48, 0x70, 0x48, 0x44, 0x42, 0x00}},
{'L', {0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x00}},
{'M', {0x42, 0x66, 0x5A, 0x5A, 0x42, 0x42, 0x42, 0x00}},
{'N', {0x42, 0x62, 0x52, 0x4A, 0x46, 0x42, 0x42, 0x00}},
{'O', {0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00}},
{'P', {0x7C, 0x42, 0x42, 0x7C, 0x40, 0x40, 0x40, 0x00}},
{'Q', {0x3C, 0x42, 0x42, 0x42, 0x4A, 0x44, 0x3A, 0x00}},
{'R', {0x7C, 0x42, 0x42, 0x7C, 0x48, 0x44, 0x42, 0x00}},
{'S', {0x3C, 0x42, 0x40, 0x3C, 0x02, 0x42, 0x3C, 0x00}},
{'T', {0x7F, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00}},
{'U', {0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00}},
{'V', {0x42, 0x42, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00}},
{'W', {0x42, 0x42, 0x42, 0x5A, 0x5A, 0x66, 0x42, 0x00}},
{'X', {0x42, 0x42, 0x24, 0x18, 0x24, 0x42, 0x42, 0x00}},
{'Y', {0x42, 0x42, 0x24, 0x18, 0x08, 0x08, 0x08, 0x00}},
{'Z', {0x7E, 0x02, 0x04, 0x18, 0x20, 0x40, 0x7E, 0x00}}, {'Z', {0x7E, 0x02, 0x04, 0x18, 0x20, 0x40, 0x7E, 0x00}},
}; };
@@ -226,7 +202,8 @@ const struct clks_psf_font *clks_psf_default_font(void) {
if (clks_psf_default_ready == CLKS_FALSE) { if (clks_psf_default_ready == CLKS_FALSE) {
clks_psf_seed_default_blob(); clks_psf_seed_default_blob();
if (clks_psf_parse_psf1(clks_psf_default_blob, sizeof(clks_psf_default_blob), &clks_psf_default) == CLKS_FALSE) { if (clks_psf_parse_psf1(clks_psf_default_blob, sizeof(clks_psf_default_blob), &clks_psf_default) ==
CLKS_FALSE) {
clks_psf_default.width = 8U; clks_psf_default.width = 8U;
clks_psf_default.height = 8U; clks_psf_default.height = 8U;
clks_psf_default.glyph_count = 1U; clks_psf_default.glyph_count = 1U;
@@ -270,11 +247,7 @@ clks_bool clks_psf_parse_font(const void *blob, u64 blob_size, struct clks_psf_f
bytes = (const u8 *)blob; bytes = (const u8 *)blob;
if (blob_size >= 4ULL) { if (blob_size >= 4ULL) {
magic32 = magic32 = ((u32)bytes[0]) | (((u32)bytes[1]) << 8U) | (((u32)bytes[2]) << 16U) | (((u32)bytes[3]) << 24U);
((u32)bytes[0]) |
(((u32)bytes[1]) << 8U) |
(((u32)bytes[2]) << 16U) |
(((u32)bytes[3]) << 24U);
if (magic32 == CLKS_PSF2_MAGIC) { if (magic32 == CLKS_PSF2_MAGIC) {
return clks_psf_parse_psf2(bytes, (usize)blob_size, out_font); return clks_psf_parse_psf2(bytes, (usize)blob_size, out_font);

View File

@@ -36,13 +36,8 @@ struct clks_exec_proc_snapshot {
void clks_exec_init(void); void clks_exec_init(void);
clks_bool clks_exec_run_path(const char *path, u64 *out_status); clks_bool clks_exec_run_path(const char *path, u64 *out_status);
clks_bool clks_exec_run_pathv(const char *path, const char *argv_line, const char *env_line, u64 *out_status); clks_bool clks_exec_run_pathv(const char *path, const char *argv_line, const char *env_line, u64 *out_status);
clks_bool clks_exec_run_pathv_io(const char *path, clks_bool clks_exec_run_pathv_io(const char *path, const char *argv_line, const char *env_line, u64 stdin_fd,
const char *argv_line, u64 stdout_fd, u64 stderr_fd, u64 *out_status);
const char *env_line,
u64 stdin_fd,
u64 stdout_fd,
u64 stderr_fd,
u64 *out_status);
clks_bool clks_exec_spawn_path(const char *path, u64 *out_pid); clks_bool clks_exec_spawn_path(const char *path, u64 *out_pid);
clks_bool clks_exec_spawn_pathv(const char *path, const char *argv_line, const char *env_line, u64 *out_pid); clks_bool clks_exec_spawn_pathv(const char *path, const char *argv_line, const char *env_line, u64 *out_pid);
u64 clks_exec_wait_pid(u64 pid, u64 *out_status); u64 clks_exec_wait_pid(u64 pid, u64 *out_status);
@@ -71,12 +66,7 @@ clks_bool clks_exec_proc_snapshot(u64 pid, struct clks_exec_proc_snapshot *out_s
u64 clks_exec_proc_kill(u64 pid, u64 signal); u64 clks_exec_proc_kill(u64 pid, u64 signal);
u64 clks_exec_force_stop_tty_running_process(u32 tty_index, u64 *out_pid); u64 clks_exec_force_stop_tty_running_process(u32 tty_index, u64 *out_pid);
clks_bool clks_exec_try_unwind_signaled_process(u64 interrupted_rip, u64 *io_rip, u64 *io_rdi, u64 *io_rsi); clks_bool clks_exec_try_unwind_signaled_process(u64 interrupted_rip, u64 *io_rip, u64 *io_rdi, u64 *io_rsi);
clks_bool clks_exec_handle_exception(u64 vector, clks_bool clks_exec_handle_exception(u64 vector, u64 error_code, u64 rip, u64 *io_rip, u64 *io_rdi, u64 *io_rsi);
u64 error_code,
u64 rip,
u64 *io_rip,
u64 *io_rdi,
u64 *io_rsi);
u64 clks_exec_sleep_ticks(u64 ticks); u64 clks_exec_sleep_ticks(u64 ticks);
u64 clks_exec_yield(void); u64 clks_exec_yield(void);
void clks_exec_tick(u64 tick); void clks_exec_tick(u64 tick);

View File

@@ -29,4 +29,3 @@ u64 clks_keyboard_push_count(void);
u64 clks_keyboard_pop_count(void); u64 clks_keyboard_pop_count(void);
#endif #endif

View File

@@ -16,36 +16,16 @@
{ 0xf9562b2d5c95a6c8ULL, 0x6a7b384944536bdcULL, (N) } { 0xf9562b2d5c95a6c8ULL, 0x6a7b384944536bdcULL, (N) }
#define LIMINE_FRAMEBUFFER_REQUEST \ #define LIMINE_FRAMEBUFFER_REQUEST \
{ \ { LIMINE_COMMON_MAGIC, LIMINE_REQUEST_MAGIC, 0x9d5827dcd881dd75ULL, 0xa3148604f6fab11bULL }
LIMINE_COMMON_MAGIC, \
LIMINE_REQUEST_MAGIC, \
0x9d5827dcd881dd75ULL, \
0xa3148604f6fab11bULL \
}
#define LIMINE_MEMMAP_REQUEST \ #define LIMINE_MEMMAP_REQUEST \
{ \ { LIMINE_COMMON_MAGIC, LIMINE_REQUEST_MAGIC, 0x67cf3d9d378a806fULL, 0xe304acdfc50c3c62ULL }
LIMINE_COMMON_MAGIC, \
LIMINE_REQUEST_MAGIC, \
0x67cf3d9d378a806fULL, \
0xe304acdfc50c3c62ULL \
}
#define LIMINE_EXECUTABLE_FILE_REQUEST \ #define LIMINE_EXECUTABLE_FILE_REQUEST \
{ \ { LIMINE_COMMON_MAGIC, LIMINE_REQUEST_MAGIC, 0xad97e90e83f1ed67ULL, 0x31eb5d1c5ff23b69ULL }
LIMINE_COMMON_MAGIC, \
LIMINE_REQUEST_MAGIC, \
0xad97e90e83f1ed67ULL, \
0x31eb5d1c5ff23b69ULL \
}
#define LIMINE_MODULE_REQUEST \ #define LIMINE_MODULE_REQUEST \
{ \ { LIMINE_COMMON_MAGIC, LIMINE_REQUEST_MAGIC, 0x3e7e279702be32afULL, 0xca1c4f3bd1280ceeULL }
LIMINE_COMMON_MAGIC, \
LIMINE_REQUEST_MAGIC, \
0x3e7e279702be32afULL, \
0xca1c4f3bd1280ceeULL \
}
#define LIMINE_MEMMAP_USABLE 0ULL #define LIMINE_MEMMAP_USABLE 0ULL
#define LIMINE_MEMMAP_RESERVED 1ULL #define LIMINE_MEMMAP_RESERVED 1ULL

View File

@@ -5,11 +5,6 @@
#include <clks/types.h> #include <clks/types.h>
CLKS_NORETURN void clks_panic(const char *reason); CLKS_NORETURN void clks_panic(const char *reason);
CLKS_NORETURN void clks_panic_exception(const char *name, CLKS_NORETURN void clks_panic_exception(const char *name, u64 vector, u64 error_code, u64 rip, u64 rbp, u64 rsp);
u64 vector,
u64 error_code,
u64 rip,
u64 rbp,
u64 rsp);
#endif #endif

View File

@@ -7,12 +7,7 @@
typedef void (*clks_task_entry_fn)(u64 tick); typedef void (*clks_task_entry_fn)(u64 tick);
enum clks_task_state { enum clks_task_state { CLKS_TASK_UNUSED = 0, CLKS_TASK_READY = 1, CLKS_TASK_RUNNING = 2, CLKS_TASK_BLOCKED = 3 };
CLKS_TASK_UNUSED = 0,
CLKS_TASK_READY = 1,
CLKS_TASK_RUNNING = 2,
CLKS_TASK_BLOCKED = 3
};
struct clks_task_descriptor { struct clks_task_descriptor {
u32 id; u32 id;

View File

@@ -13,10 +13,7 @@ typedef signed long long i64;
typedef u64 usize; typedef u64 usize;
typedef enum clks_bool { typedef enum clks_bool { CLKS_FALSE = 0, CLKS_TRUE = 1 } clks_bool;
CLKS_FALSE = 0,
CLKS_TRUE = 1
} clks_bool;
#define CLKS_NULL ((void *)0) #define CLKS_NULL ((void *)0)

View File

@@ -207,8 +207,8 @@ static void clks_desktop_draw_static_scene(const struct clks_mouse_state *mouse)
} }
if (clks_desktop.height > clks_desktop.topbar_h) { if (clks_desktop.height > clks_desktop.topbar_h) {
clks_fb_fill_rect(0U, clks_desktop.topbar_h, clks_desktop.dock_w, clks_fb_fill_rect(0U, clks_desktop.topbar_h, clks_desktop.dock_w, clks_desktop.height - clks_desktop.topbar_h,
clks_desktop.height - clks_desktop.topbar_h, CLKS_DESKTOP_DOCK_COLOR); CLKS_DESKTOP_DOCK_COLOR);
} }
clks_fb_fill_rect(clks_desktop.win_x, clks_desktop.win_y, clks_desktop.win_w, clks_desktop.win_h, clks_fb_fill_rect(clks_desktop.win_x, clks_desktop.win_y, clks_desktop.win_w, clks_desktop.win_h,
@@ -217,8 +217,8 @@ static void clks_desktop_draw_static_scene(const struct clks_mouse_state *mouse)
CLKS_DESKTOP_TITLE_COLOR); CLKS_DESKTOP_TITLE_COLOR);
clks_desktop_draw_text(12U, 6U, "CLeonOS Desktop TTY2", CLKS_DESKTOP_TEXT_FG, CLKS_DESKTOP_TOPBAR_COLOR); clks_desktop_draw_text(12U, 6U, "CLeonOS Desktop TTY2", CLKS_DESKTOP_TEXT_FG, CLKS_DESKTOP_TOPBAR_COLOR);
clks_desktop_draw_text(clks_desktop.win_x + 12U, clks_desktop.win_y + 6U, "Mouse Input Ready", clks_desktop_draw_text(clks_desktop.win_x + 12U, clks_desktop.win_y + 6U, "Mouse Input Ready", CLKS_DESKTOP_TEXT_FG,
CLKS_DESKTOP_TEXT_FG, CLKS_DESKTOP_TITLE_COLOR); CLKS_DESKTOP_TITLE_COLOR);
clks_desktop_draw_text(clks_desktop.win_x + 16U, clks_desktop.win_y + clks_desktop.win_title_h + 16U, clks_desktop_draw_text(clks_desktop.win_x + 16U, clks_desktop.win_y + clks_desktop.win_title_h + 16U,
"Stage25: Alt+F2 desktop, Alt+F1 shell", CLKS_DESKTOP_TEXT_FG, CLKS_DESKTOP_WINDOW_COLOR); "Stage25: Alt+F2 desktop, Alt+F1 shell", CLKS_DESKTOP_TEXT_FG, CLKS_DESKTOP_WINDOW_COLOR);

View File

@@ -48,10 +48,9 @@ static clks_bool clks_driver_has_elf_suffix(const char *name) {
return CLKS_FALSE; return CLKS_FALSE;
} }
return (name[len - 4U] == '.' && return (name[len - 4U] == '.' && name[len - 3U] == 'e' && name[len - 2U] == 'l' && name[len - 1U] == 'f')
name[len - 3U] == 'e' && ? CLKS_TRUE
name[len - 2U] == 'l' && : CLKS_FALSE;
name[len - 1U] == 'f') ? CLKS_TRUE : CLKS_FALSE;
} }
static clks_bool clks_driver_build_path(const char *child_name, char *out_path, usize out_size) { static clks_bool clks_driver_build_path(const char *child_name, char *out_path, usize out_size) {
@@ -75,12 +74,8 @@ static clks_bool clks_driver_build_path(const char *child_name, char *out_path,
return CLKS_TRUE; return CLKS_TRUE;
} }
static clks_bool clks_driver_push(const char *name, static clks_bool clks_driver_push(const char *name, enum clks_driver_kind kind, enum clks_driver_state state,
enum clks_driver_kind kind, clks_bool from_elf, u64 image_size, u64 elf_entry) {
enum clks_driver_state state,
clks_bool from_elf,
u64 image_size,
u64 elf_entry) {
struct clks_driver_info *slot; struct clks_driver_info *slot;
if (clks_driver_table_count >= CLKS_DRIVER_MAX) { if (clks_driver_table_count >= CLKS_DRIVER_MAX) {
@@ -110,10 +105,12 @@ static void clks_driver_register_builtins(void) {
clks_driver_push("serial", CLKS_DRIVER_KIND_BUILTIN_CHAR, CLKS_DRIVER_STATE_READY, CLKS_FALSE, 0ULL, 0ULL); clks_driver_push("serial", CLKS_DRIVER_KIND_BUILTIN_CHAR, CLKS_DRIVER_STATE_READY, CLKS_FALSE, 0ULL, 0ULL);
if (clks_fb_ready() == CLKS_TRUE) { if (clks_fb_ready() == CLKS_TRUE) {
clks_driver_push("framebuffer", CLKS_DRIVER_KIND_BUILTIN_VIDEO, CLKS_DRIVER_STATE_READY, CLKS_FALSE, 0ULL, 0ULL); clks_driver_push("framebuffer", CLKS_DRIVER_KIND_BUILTIN_VIDEO, CLKS_DRIVER_STATE_READY, CLKS_FALSE, 0ULL,
0ULL);
clks_driver_push("tty", CLKS_DRIVER_KIND_BUILTIN_TTY, CLKS_DRIVER_STATE_READY, CLKS_FALSE, 0ULL, 0ULL); clks_driver_push("tty", CLKS_DRIVER_KIND_BUILTIN_TTY, CLKS_DRIVER_STATE_READY, CLKS_FALSE, 0ULL, 0ULL);
} else { } else {
clks_driver_push("framebuffer", CLKS_DRIVER_KIND_BUILTIN_VIDEO, CLKS_DRIVER_STATE_FAILED, CLKS_FALSE, 0ULL, 0ULL); clks_driver_push("framebuffer", CLKS_DRIVER_KIND_BUILTIN_VIDEO, CLKS_DRIVER_STATE_FAILED, CLKS_FALSE, 0ULL,
0ULL);
clks_driver_push("tty", CLKS_DRIVER_KIND_BUILTIN_TTY, CLKS_DRIVER_STATE_FAILED, CLKS_FALSE, 0ULL, 0ULL); clks_driver_push("tty", CLKS_DRIVER_KIND_BUILTIN_TTY, CLKS_DRIVER_STATE_FAILED, CLKS_FALSE, 0ULL, 0ULL);
} }

View File

@@ -46,10 +46,8 @@ struct clks_elf64_phdr {
}; };
static clks_bool clks_elf64_header_ok(const struct clks_elf64_ehdr *eh) { static clks_bool clks_elf64_header_ok(const struct clks_elf64_ehdr *eh) {
if (eh->e_ident[0] != CLKS_ELF64_MAGIC_0 || if (eh->e_ident[0] != CLKS_ELF64_MAGIC_0 || eh->e_ident[1] != CLKS_ELF64_MAGIC_1 ||
eh->e_ident[1] != CLKS_ELF64_MAGIC_1 || eh->e_ident[2] != CLKS_ELF64_MAGIC_2 || eh->e_ident[3] != CLKS_ELF64_MAGIC_3) {
eh->e_ident[2] != CLKS_ELF64_MAGIC_2 ||
eh->e_ident[3] != CLKS_ELF64_MAGIC_3) {
return CLKS_FALSE; return CLKS_FALSE;
} }

View File

@@ -34,7 +34,7 @@ typedef u64 (*clks_exec_entry_fn)(void);
#define CLKS_EXEC_O_CREAT 0x0040ULL #define CLKS_EXEC_O_CREAT 0x0040ULL
#define CLKS_EXEC_O_TRUNC 0x0200ULL #define CLKS_EXEC_O_TRUNC 0x0200ULL
#define CLKS_EXEC_O_APPEND 0x0400ULL #define CLKS_EXEC_O_APPEND 0x0400ULL
#define CLKS_EXEC_FD_INHERIT ((u64)-1) #define CLKS_EXEC_FD_INHERIT ((u64) - 1)
#define CLKS_EXEC_DYNLIB_MAX 32U #define CLKS_EXEC_DYNLIB_MAX 32U
#ifndef CLKS_CFG_EXEC_SERIAL_LOG #ifndef CLKS_CFG_EXEC_SERIAL_LOG
@@ -446,8 +446,7 @@ static void clks_exec_dynlib_release_owner(u64 owner_pid) {
} }
for (i = 0U; i < CLKS_EXEC_DYNLIB_MAX; i++) { for (i = 0U; i < CLKS_EXEC_DYNLIB_MAX; i++) {
if (clks_exec_dynlib_table[i].used == CLKS_TRUE && if (clks_exec_dynlib_table[i].used == CLKS_TRUE && clks_exec_dynlib_table[i].owner_pid == owner_pid) {
clks_exec_dynlib_table[i].owner_pid == owner_pid) {
clks_exec_dynlib_slot_reset(&clks_exec_dynlib_table[i]); clks_exec_dynlib_slot_reset(&clks_exec_dynlib_table[i]);
} }
} }
@@ -458,10 +457,8 @@ static clks_bool clks_exec_dynlib_elf_header_ok(const struct clks_exec_elf64_ehd
return CLKS_FALSE; return CLKS_FALSE;
} }
if (eh->e_ident[0] != CLKS_EXEC_ELF64_MAGIC_0 || if (eh->e_ident[0] != CLKS_EXEC_ELF64_MAGIC_0 || eh->e_ident[1] != CLKS_EXEC_ELF64_MAGIC_1 ||
eh->e_ident[1] != CLKS_EXEC_ELF64_MAGIC_1 || eh->e_ident[2] != CLKS_EXEC_ELF64_MAGIC_2 || eh->e_ident[3] != CLKS_EXEC_ELF64_MAGIC_3) {
eh->e_ident[2] != CLKS_EXEC_ELF64_MAGIC_2 ||
eh->e_ident[3] != CLKS_EXEC_ELF64_MAGIC_3) {
return CLKS_FALSE; return CLKS_FALSE;
} }
@@ -480,9 +477,7 @@ static clks_bool clks_exec_dynlib_elf_header_ok(const struct clks_exec_elf64_ehd
return CLKS_TRUE; return CLKS_TRUE;
} }
static clks_bool clks_exec_dynlib_symbol_name_ptr(const char *strtab, static clks_bool clks_exec_dynlib_symbol_name_ptr(const char *strtab, u64 strtab_size, u32 st_name,
u64 strtab_size,
u32 st_name,
const char **out_name) { const char **out_name) {
u64 i; u64 i;
@@ -504,8 +499,7 @@ static clks_bool clks_exec_dynlib_symbol_name_ptr(const char *strtab,
return CLKS_FALSE; return CLKS_FALSE;
} }
static clks_bool clks_exec_dynlib_resolve_symbol(const struct clks_exec_dynlib_slot *slot, static clks_bool clks_exec_dynlib_resolve_symbol(const struct clks_exec_dynlib_slot *slot, const char *symbol,
const char *symbol,
u64 *out_addr) { u64 *out_addr) {
const struct clks_exec_elf64_ehdr *eh; const struct clks_exec_elf64_ehdr *eh;
const struct clks_exec_elf64_shdr *shdrs; const struct clks_exec_elf64_shdr *shdrs;
@@ -619,9 +613,7 @@ static void clks_exec_clear_items(char items[][CLKS_EXEC_ITEM_MAX], u32 max_coun
} }
} }
static u32 clks_exec_parse_whitespace_items(const char *line, static u32 clks_exec_parse_whitespace_items(const char *line, char items[][CLKS_EXEC_ITEM_MAX], u32 max_count) {
char items[][CLKS_EXEC_ITEM_MAX],
u32 max_count) {
u32 count = 0U; u32 count = 0U;
usize i = 0U; usize i = 0U;
@@ -644,11 +636,7 @@ static u32 clks_exec_parse_whitespace_items(const char *line,
break; break;
} }
while (line[i] != '\0' && while (line[i] != '\0' && line[i] != ' ' && line[i] != '\t' && line[i] != '\r' && line[i] != '\n') {
line[i] != ' ' &&
line[i] != '\t' &&
line[i] != '\r' &&
line[i] != '\n') {
if (p + 1U < CLKS_EXEC_ITEM_MAX) { if (p + 1U < CLKS_EXEC_ITEM_MAX) {
items[count][p++] = line[i]; items[count][p++] = line[i];
} }
@@ -663,9 +651,7 @@ static u32 clks_exec_parse_whitespace_items(const char *line,
return count; return count;
} }
static u32 clks_exec_parse_env_items(const char *line, static u32 clks_exec_parse_env_items(const char *line, char items[][CLKS_EXEC_ITEM_MAX], u32 max_count) {
char items[][CLKS_EXEC_ITEM_MAX],
u32 max_count) {
u32 count = 0U; u32 count = 0U;
usize i = 0U; usize i = 0U;
@@ -734,9 +720,7 @@ static u64 clks_exec_signal_from_vector(u64 vector) {
} }
static u64 clks_exec_encode_signal_status(u64 signal, u64 vector, u64 error_code) { static u64 clks_exec_encode_signal_status(u64 signal, u64 vector, u64 error_code) {
return CLKS_EXEC_STATUS_SIGNAL_FLAG | return CLKS_EXEC_STATUS_SIGNAL_FLAG | (signal & 0xFFULL) | ((vector & 0xFFULL) << 8) |
(signal & 0xFFULL) |
((vector & 0xFFULL) << 8) |
((error_code & 0xFFFFULL) << 16); ((error_code & 0xFFFFULL) << 16);
} }
@@ -877,11 +861,8 @@ static void clks_exec_fd_init_defaults(struct clks_exec_proc_record *proc) {
} }
static clks_bool clks_exec_fd_copy_from_parent(struct clks_exec_proc_record *child, static clks_bool clks_exec_fd_copy_from_parent(struct clks_exec_proc_record *child,
const struct clks_exec_proc_record *parent, const struct clks_exec_proc_record *parent, u64 parent_fd, u64 child_fd,
u64 parent_fd, clks_bool require_read, clks_bool require_write) {
u64 child_fd,
clks_bool require_read,
clks_bool require_write) {
const struct clks_exec_fd_entry *src; const struct clks_exec_fd_entry *src;
if (child == CLKS_NULL || parent == CLKS_NULL || parent_fd >= CLKS_EXEC_FD_MAX || child_fd >= CLKS_EXEC_FD_MAX) { if (child == CLKS_NULL || parent == CLKS_NULL || parent_fd >= CLKS_EXEC_FD_MAX || child_fd >= CLKS_EXEC_FD_MAX) {
@@ -907,10 +888,8 @@ static clks_bool clks_exec_fd_copy_from_parent(struct clks_exec_proc_record *chi
} }
static clks_bool clks_exec_fd_apply_stdio_overrides(struct clks_exec_proc_record *child, static clks_bool clks_exec_fd_apply_stdio_overrides(struct clks_exec_proc_record *child,
const struct clks_exec_proc_record *parent, const struct clks_exec_proc_record *parent, u64 stdin_fd,
u64 stdin_fd, u64 stdout_fd, u64 stderr_fd) {
u64 stdout_fd,
u64 stderr_fd) {
if (child == CLKS_NULL) { if (child == CLKS_NULL) {
return CLKS_FALSE; return CLKS_FALSE;
} }
@@ -1069,11 +1048,8 @@ static u64 clks_exec_fd_file_write(struct clks_exec_fd_entry *entry, const void
return size; return size;
} }
static struct clks_exec_proc_record *clks_exec_prepare_proc_record(i32 slot, static struct clks_exec_proc_record *clks_exec_prepare_proc_record(i32 slot, u64 pid, const char *path,
u64 pid, const char *argv_line, const char *env_line,
const char *path,
const char *argv_line,
const char *env_line,
enum clks_exec_proc_state state) { enum clks_exec_proc_state state) {
struct clks_exec_proc_record *proc; struct clks_exec_proc_record *proc;
@@ -1114,8 +1090,7 @@ static struct clks_exec_proc_record *clks_exec_prepare_proc_record(i32 slot,
} }
if (proc->argv_line[0] != '\0' && proc->argc < CLKS_EXEC_MAX_ARGS) { if (proc->argv_line[0] != '\0' && proc->argc < CLKS_EXEC_MAX_ARGS) {
proc->argc += clks_exec_parse_whitespace_items(proc->argv_line, proc->argc += clks_exec_parse_whitespace_items(proc->argv_line, &proc->argv_items[proc->argc],
&proc->argv_items[proc->argc],
(u32)(CLKS_EXEC_MAX_ARGS - proc->argc)); (u32)(CLKS_EXEC_MAX_ARGS - proc->argc));
} }
@@ -1421,8 +1396,7 @@ static clks_bool clks_exec_dispatch_pending_once(void) {
} }
for (i = 0U; i < CLKS_EXEC_MAX_PROCS; i++) { for (i = 0U; i < CLKS_EXEC_MAX_PROCS; i++) {
if (clks_exec_proc_table[i].used == CLKS_TRUE && if (clks_exec_proc_table[i].used == CLKS_TRUE && clks_exec_proc_table[i].state == CLKS_EXEC_PROC_PENDING) {
clks_exec_proc_table[i].state == CLKS_EXEC_PROC_PENDING) {
u64 ignored_status = (u64)-1; u64 ignored_status = (u64)-1;
clks_exec_pending_dispatch_active = CLKS_TRUE; clks_exec_pending_dispatch_active = CLKS_TRUE;
@@ -1435,13 +1409,8 @@ static clks_bool clks_exec_dispatch_pending_once(void) {
return CLKS_FALSE; return CLKS_FALSE;
} }
static clks_bool clks_exec_run_path_internal(const char *path, static clks_bool clks_exec_run_path_internal(const char *path, const char *argv_line, const char *env_line,
const char *argv_line, u64 stdin_fd, u64 stdout_fd, u64 stderr_fd, u64 *out_status,
const char *env_line,
u64 stdin_fd,
u64 stdout_fd,
u64 stderr_fd,
u64 *out_status,
u64 *out_pid) { u64 *out_pid) {
i32 slot; i32 slot;
u64 pid; u64 pid;
@@ -1522,35 +1491,19 @@ void clks_exec_init(void) {
} }
clks_bool clks_exec_run_path(const char *path, u64 *out_status) { clks_bool clks_exec_run_path(const char *path, u64 *out_status) {
return clks_exec_run_path_internal(path, return clks_exec_run_path_internal(path, CLKS_NULL, CLKS_NULL, CLKS_EXEC_FD_INHERIT, CLKS_EXEC_FD_INHERIT,
CLKS_NULL, CLKS_EXEC_FD_INHERIT, out_status, CLKS_NULL);
CLKS_NULL,
CLKS_EXEC_FD_INHERIT,
CLKS_EXEC_FD_INHERIT,
CLKS_EXEC_FD_INHERIT,
out_status,
CLKS_NULL);
} }
clks_bool clks_exec_run_pathv(const char *path, const char *argv_line, const char *env_line, u64 *out_status) { clks_bool clks_exec_run_pathv(const char *path, const char *argv_line, const char *env_line, u64 *out_status) {
return clks_exec_run_path_internal(path, return clks_exec_run_path_internal(path, argv_line, env_line, CLKS_EXEC_FD_INHERIT, CLKS_EXEC_FD_INHERIT,
argv_line, CLKS_EXEC_FD_INHERIT, out_status, CLKS_NULL);
env_line,
CLKS_EXEC_FD_INHERIT,
CLKS_EXEC_FD_INHERIT,
CLKS_EXEC_FD_INHERIT,
out_status,
CLKS_NULL);
} }
clks_bool clks_exec_run_pathv_io(const char *path, clks_bool clks_exec_run_pathv_io(const char *path, const char *argv_line, const char *env_line, u64 stdin_fd,
const char *argv_line, u64 stdout_fd, u64 stderr_fd, u64 *out_status) {
const char *env_line, return clks_exec_run_path_internal(path, argv_line, env_line, stdin_fd, stdout_fd, stderr_fd, out_status,
u64 stdin_fd, CLKS_NULL);
u64 stdout_fd,
u64 stderr_fd,
u64 *out_status) {
return clks_exec_run_path_internal(path, argv_line, env_line, stdin_fd, stdout_fd, stderr_fd, out_status, CLKS_NULL);
} }
clks_bool clks_exec_spawn_pathv(const char *path, const char *argv_line, const char *env_line, u64 *out_pid) { clks_bool clks_exec_spawn_pathv(const char *path, const char *argv_line, const char *env_line, u64 *out_pid) {
@@ -1622,8 +1575,7 @@ u64 clks_exec_wait_pid(u64 pid, u64 *out_status) {
clks_exec_pending_dispatch_active = CLKS_FALSE; clks_exec_pending_dispatch_active = CLKS_FALSE;
} }
if (proc->state == CLKS_EXEC_PROC_PENDING || if (proc->state == CLKS_EXEC_PROC_PENDING || proc->state == CLKS_EXEC_PROC_RUNNING ||
proc->state == CLKS_EXEC_PROC_RUNNING ||
proc->state == CLKS_EXEC_PROC_STOPPED) { proc->state == CLKS_EXEC_PROC_STOPPED) {
return 0ULL; return 0ULL;
} }
@@ -1695,8 +1647,7 @@ u64 clks_exec_fd_open(const char *path, u64 flags, u64 mode) {
return (u64)fd_slot; return (u64)fd_slot;
} }
if (clks_exec_path_is_dev_null(path) == CLKS_TRUE || if (clks_exec_path_is_dev_null(path) == CLKS_TRUE || clks_exec_path_is_dev_zero(path) == CLKS_TRUE ||
clks_exec_path_is_dev_zero(path) == CLKS_TRUE ||
clks_exec_path_is_dev_random(path) == CLKS_TRUE) { clks_exec_path_is_dev_random(path) == CLKS_TRUE) {
struct clks_exec_fd_entry *entry = &proc->fds[(u32)fd_slot]; struct clks_exec_fd_entry *entry = &proc->fds[(u32)fd_slot];
@@ -1849,8 +1800,7 @@ u64 clks_exec_fd_write(u64 fd, const void *buffer, u64 size) {
return size; return size;
} }
if (entry->kind == CLKS_EXEC_FD_KIND_DEV_NULL || if (entry->kind == CLKS_EXEC_FD_KIND_DEV_NULL || entry->kind == CLKS_EXEC_FD_KIND_DEV_ZERO ||
entry->kind == CLKS_EXEC_FD_KIND_DEV_ZERO ||
entry->kind == CLKS_EXEC_FD_KIND_DEV_RANDOM) { entry->kind == CLKS_EXEC_FD_KIND_DEV_RANDOM) {
entry->offset += size; entry->offset += size;
return size; return size;
@@ -2159,9 +2109,7 @@ static u64 clks_exec_proc_runtime_ticks(const struct clks_exec_proc_record *proc
runtime = proc->runtime_ticks_accum; runtime = proc->runtime_ticks_accum;
if (proc->state == CLKS_EXEC_PROC_RUNNING && if (proc->state == CLKS_EXEC_PROC_RUNNING && proc->run_started_tick != 0ULL && now_tick > proc->run_started_tick) {
proc->run_started_tick != 0ULL &&
now_tick > proc->run_started_tick) {
runtime += (now_tick - proc->run_started_tick); runtime += (now_tick - proc->run_started_tick);
} }
@@ -2374,9 +2322,7 @@ u64 clks_exec_force_stop_tty_running_process(u32 tty_index, u64 *out_pid) {
if (slot >= 0) { if (slot >= 0) {
const struct clks_exec_proc_record *proc = &clks_exec_proc_table[(u32)slot]; const struct clks_exec_proc_record *proc = &clks_exec_proc_table[(u32)slot];
if (proc->used == CLKS_TRUE && if (proc->used == CLKS_TRUE && proc->state == CLKS_EXEC_PROC_RUNNING && proc->tty_index == tty_index &&
proc->state == CLKS_EXEC_PROC_RUNNING &&
proc->tty_index == tty_index &&
clks_exec_path_is_user_program(proc->path) == CLKS_TRUE) { clks_exec_path_is_user_program(proc->path) == CLKS_TRUE) {
u64 ret = clks_exec_proc_kill(current_pid, CLKS_EXEC_SIGNAL_STOP); u64 ret = clks_exec_proc_kill(current_pid, CLKS_EXEC_SIGNAL_STOP);
@@ -2392,8 +2338,7 @@ u64 clks_exec_force_stop_tty_running_process(u32 tty_index, u64 *out_pid) {
for (i = 0U; i < CLKS_EXEC_MAX_PROCS; i++) { for (i = 0U; i < CLKS_EXEC_MAX_PROCS; i++) {
u64 ret; u64 ret;
if (clks_exec_proc_table[i].used != CLKS_TRUE || if (clks_exec_proc_table[i].used != CLKS_TRUE || clks_exec_proc_table[i].state != CLKS_EXEC_PROC_RUNNING ||
clks_exec_proc_table[i].state != CLKS_EXEC_PROC_RUNNING ||
clks_exec_proc_table[i].tty_index != tty_index || clks_exec_proc_table[i].tty_index != tty_index ||
clks_exec_path_is_user_program(clks_exec_proc_table[i].path) == CLKS_FALSE) { clks_exec_path_is_user_program(clks_exec_proc_table[i].path) == CLKS_FALSE) {
continue; continue;
@@ -2413,10 +2358,7 @@ u64 clks_exec_force_stop_tty_running_process(u32 tty_index, u64 *out_pid) {
return 0ULL; return 0ULL;
} }
clks_bool clks_exec_try_unwind_signaled_process(u64 interrupted_rip, clks_bool clks_exec_try_unwind_signaled_process(u64 interrupted_rip, u64 *io_rip, u64 *io_rdi, u64 *io_rsi) {
u64 *io_rip,
u64 *io_rdi,
u64 *io_rsi) {
i32 depth_index; i32 depth_index;
if (io_rip == CLKS_NULL || io_rdi == CLKS_NULL || io_rsi == CLKS_NULL) { if (io_rip == CLKS_NULL || io_rdi == CLKS_NULL || io_rsi == CLKS_NULL) {
@@ -2456,12 +2398,7 @@ clks_bool clks_exec_try_unwind_signaled_process(u64 interrupted_rip,
#endif #endif
} }
clks_bool clks_exec_handle_exception(u64 vector, clks_bool clks_exec_handle_exception(u64 vector, u64 error_code, u64 rip, u64 *io_rip, u64 *io_rdi, u64 *io_rsi) {
u64 error_code,
u64 rip,
u64 *io_rip,
u64 *io_rdi,
u64 *io_rsi) {
i32 depth_index; i32 depth_index;
struct clks_exec_proc_record *proc; struct clks_exec_proc_record *proc;
u64 signal; u64 signal;
@@ -2589,4 +2526,3 @@ clks_bool clks_exec_current_path_is_user(void) {
proc = &clks_exec_proc_table[(u32)slot]; proc = &clks_exec_proc_table[(u32)slot];
return clks_exec_path_is_user_program(proc->path); return clks_exec_path_is_user_program(proc->path);
} }

View File

@@ -103,10 +103,7 @@ static clks_bool clks_fs_internal_in_temp_tree(const char *internal_path) {
return CLKS_FALSE; return CLKS_FALSE;
} }
if (internal_path[0] != 't' || if (internal_path[0] != 't' || internal_path[1] != 'e' || internal_path[2] != 'm' || internal_path[3] != 'p') {
internal_path[1] != 'e' ||
internal_path[2] != 'm' ||
internal_path[3] != 'p') {
return CLKS_FALSE; return CLKS_FALSE;
} }
@@ -248,11 +245,8 @@ static i32 clks_fs_alloc_slot(void) {
return (i32)(clks_fs_nodes_used - 1U); return (i32)(clks_fs_nodes_used - 1U);
} }
static i32 clks_fs_create_or_update_node(const char *internal_path, static i32 clks_fs_create_or_update_node(const char *internal_path, enum clks_fs_node_type type, u16 parent,
enum clks_fs_node_type type, const void *data, u64 size) {
u16 parent,
const void *data,
u64 size) {
i32 existing; i32 existing;
i32 slot; i32 slot;
usize path_len; usize path_len;
@@ -433,11 +427,8 @@ static clks_bool clks_fs_ramdisk_visit(const struct clks_ramdisk_entry *entry, v
return CLKS_FALSE; return CLKS_FALSE;
} }
if (clks_fs_create_or_update_node(entry->path, if (clks_fs_create_or_update_node(entry->path, CLKS_FS_NODE_FILE, (u16)parent_index, entry->data, entry->size) <
CLKS_FS_NODE_FILE, 0) {
(u16)parent_index,
entry->data,
entry->size) < 0) {
return CLKS_FALSE; return CLKS_FALSE;
} }
@@ -448,9 +439,7 @@ static clks_bool clks_fs_ramdisk_visit(const struct clks_ramdisk_entry *entry, v
return CLKS_TRUE; return CLKS_TRUE;
} }
static clks_bool clks_fs_build_file_payload(const void *data, static clks_bool clks_fs_build_file_payload(const void *data, u64 size, const void **out_data,
u64 size,
const void **out_data,
clks_bool *out_heap_owned) { clks_bool *out_heap_owned) {
void *payload; void *payload;
@@ -764,13 +753,7 @@ clks_bool clks_fs_write_all(const char *path, const void *data, u64 size) {
clks_fs_node_release_heap_data((u16)node_index); clks_fs_node_release_heap_data((u16)node_index);
} }
node_index = clks_fs_create_or_update_node( node_index = clks_fs_create_or_update_node(internal, CLKS_FS_NODE_FILE, (u16)parent_index, payload_data, size);
internal,
CLKS_FS_NODE_FILE,
(u16)parent_index,
payload_data,
size
);
if (node_index < 0) { if (node_index < 0) {
if (payload_heap_owned == CLKS_TRUE) { if (payload_heap_owned == CLKS_TRUE) {

View File

@@ -125,8 +125,7 @@ static struct clks_idt_entry clks_idt[CLKS_IDT_ENTRY_COUNT];
static u16 clks_idt_code_selector = 0x08U; static u16 clks_idt_code_selector = 0x08U;
static u64 clks_timer_ticks = 0; static u64 clks_timer_ticks = 0;
static const char *clks_exception_names[32] = { static const char *clks_exception_names[32] = {"DE DIVIDE ERROR",
"DE DIVIDE ERROR",
"DB DEBUG", "DB DEBUG",
"NMI", "NMI",
"BP BREAKPOINT", "BP BREAKPOINT",
@@ -157,8 +156,7 @@ static const char *clks_exception_names[32] = {
"HV HYPERVISOR", "HV HYPERVISOR",
"VC VMM COMM", "VC VMM COMM",
"SX SECURITY", "SX SECURITY",
"RESERVED" "RESERVED"};
};
static inline void clks_outb(u16 port, u8 value) { static inline void clks_outb(u16 port, u8 value) {
__asm__ volatile("outb %0, %1" : : "a"(value), "Nd"(port)); __asm__ volatile("outb %0, %1" : : "a"(value), "Nd"(port));
@@ -234,7 +232,6 @@ static void clks_load_idt(void) {
__asm__ volatile("lidt %0" : : "m"(idtr)); __asm__ volatile("lidt %0" : : "m"(idtr));
} }
static clks_bool clks_ps2_has_output(void) { static clks_bool clks_ps2_has_output(void) {
return (clks_inb(CLKS_PS2_STATUS_PORT) & 0x01U) != 0U ? CLKS_TRUE : CLKS_FALSE; return (clks_inb(CLKS_PS2_STATUS_PORT) & 0x01U) != 0U ? CLKS_TRUE : CLKS_FALSE;
} }
@@ -251,20 +248,12 @@ void clks_interrupt_dispatch(struct clks_interrupt_frame *frame) {
} }
if (vector < 32U) { if (vector < 32U) {
if (clks_exec_handle_exception(vector, if (clks_exec_handle_exception(vector, frame->error_code, frame->rip, &frame->rip, &frame->rdi, &frame->rsi) ==
frame->error_code, CLKS_TRUE) {
frame->rip,
&frame->rip,
&frame->rdi,
&frame->rsi) == CLKS_TRUE) {
return; return;
} }
clks_panic_exception(clks_exception_names[vector], clks_panic_exception(clks_exception_names[vector], vector, frame->error_code, frame->rip, frame->rbp,
vector,
frame->error_code,
frame->rip,
frame->rbp,
frame->rsp); frame->rsp);
} }

View File

@@ -69,10 +69,7 @@ static void clks_kelf_copy_name(char *dst, usize dst_size, const char *src) {
dst[i] = '\0'; dst[i] = '\0';
} }
static clks_bool clks_kelf_load_runtime_image(const void *image, static clks_bool clks_kelf_load_runtime_image(const void *image, u64 size, void **out_runtime, u64 *out_runtime_size,
u64 size,
void **out_runtime,
u64 *out_runtime_size,
clks_kelf_entry_fn *out_entry) { clks_kelf_entry_fn *out_entry) {
const struct clks_elf64_ehdr *eh; const struct clks_elf64_ehdr *eh;
u64 min_vaddr = 0xffffffffffffffffULL; u64 min_vaddr = 0xffffffffffffffffULL;
@@ -143,9 +140,7 @@ static clks_bool clks_kelf_load_runtime_image(const void *image,
continue; continue;
} }
clks_memcpy(runtime + (usize)(ph->p_vaddr - min_vaddr), clks_memcpy(runtime + (usize)(ph->p_vaddr - min_vaddr), (const u8 *)image + ph->p_offset, (usize)ph->p_filesz);
(const u8 *)image + ph->p_offset,
(usize)ph->p_filesz);
} }
if (eh->e_entry < min_vaddr || eh->e_entry >= max_vaddr) { if (eh->e_entry < min_vaddr || eh->e_entry >= max_vaddr) {
@@ -253,4 +248,3 @@ u64 clks_kelf_count(void) {
u64 clks_kelf_total_runs(void) { u64 clks_kelf_total_runs(void) {
return clks_kelf_total_runs_count; return clks_kelf_total_runs_count;
} }

View File

@@ -43,26 +43,20 @@
#endif #endif
static const char clks_kbd_map[128] = { static const char clks_kbd_map[128] = {
[2] = '1', [3] = '2', [4] = '3', [5] = '4', [6] = '5', [7] = '6', [8] = '7', [9] = '8', [2] = '1', [3] = '2', [4] = '3', [5] = '4', [6] = '5', [7] = '6', [8] = '7', [9] = '8', [10] = '9',
[10] = '9', [11] = '0', [12] = '-', [13] = '=', [14] = '\b', [15] = '\t', [11] = '0', [12] = '-', [13] = '=', [14] = '\b', [15] = '\t', [16] = 'q', [17] = 'w', [18] = 'e', [19] = 'r',
[16] = 'q', [17] = 'w', [18] = 'e', [19] = 'r', [20] = 't', [21] = 'y', [22] = 'u', [23] = 'i', [20] = 't', [21] = 'y', [22] = 'u', [23] = 'i', [24] = 'o', [25] = 'p', [26] = '[', [27] = ']', [28] = '\n',
[24] = 'o', [25] = 'p', [26] = '[', [27] = ']', [28] = '\n', [30] = 'a', [31] = 's', [32] = 'd', [33] = 'f', [34] = 'g', [35] = 'h', [36] = 'j', [37] = 'k', [38] = 'l',
[30] = 'a', [31] = 's', [32] = 'd', [33] = 'f', [34] = 'g', [35] = 'h', [36] = 'j', [37] = 'k', [39] = ';', [40] = '\'', [41] = '`', [43] = '\\', [44] = 'z', [45] = 'x', [46] = 'c', [47] = 'v', [48] = 'b',
[38] = 'l', [39] = ';', [40] = '\'', [41] = '`', [43] = '\\', [49] = 'n', [50] = 'm', [51] = ',', [52] = '.', [53] = '/', [57] = ' '};
[44] = 'z', [45] = 'x', [46] = 'c', [47] = 'v', [48] = 'b', [49] = 'n', [50] = 'm',
[51] = ',', [52] = '.', [53] = '/', [57] = ' '
};
static const char clks_kbd_shift_map[128] = { static const char clks_kbd_shift_map[128] = {
[2] = '!', [3] = '@', [4] = '#', [5] = '$', [6] = '%', [7] = '^', [8] = '&', [9] = '*', [2] = '!', [3] = '@', [4] = '#', [5] = '$', [6] = '%', [7] = '^', [8] = '&', [9] = '*', [10] = '(',
[10] = '(', [11] = ')', [12] = '_', [13] = '+', [14] = '\b', [15] = '\t', [11] = ')', [12] = '_', [13] = '+', [14] = '\b', [15] = '\t', [16] = 'Q', [17] = 'W', [18] = 'E', [19] = 'R',
[16] = 'Q', [17] = 'W', [18] = 'E', [19] = 'R', [20] = 'T', [21] = 'Y', [22] = 'U', [23] = 'I', [20] = 'T', [21] = 'Y', [22] = 'U', [23] = 'I', [24] = 'O', [25] = 'P', [26] = '{', [27] = '}', [28] = '\n',
[24] = 'O', [25] = 'P', [26] = '{', [27] = '}', [28] = '\n', [30] = 'A', [31] = 'S', [32] = 'D', [33] = 'F', [34] = 'G', [35] = 'H', [36] = 'J', [37] = 'K', [38] = 'L',
[30] = 'A', [31] = 'S', [32] = 'D', [33] = 'F', [34] = 'G', [35] = 'H', [36] = 'J', [37] = 'K', [39] = ':', [40] = '"', [41] = '~', [43] = '|', [44] = 'Z', [45] = 'X', [46] = 'C', [47] = 'V', [48] = 'B',
[38] = 'L', [39] = ':', [40] = '"', [41] = '~', [43] = '|', [49] = 'N', [50] = 'M', [51] = '<', [52] = '>', [53] = '?', [57] = ' '};
[44] = 'Z', [45] = 'X', [46] = 'C', [47] = 'V', [48] = 'B', [49] = 'N', [50] = 'M',
[51] = '<', [52] = '>', [53] = '?', [57] = ' '
};
static char clks_kbd_input_queue[CLKS_KBD_TTY_MAX][CLKS_KBD_INPUT_CAP]; static char clks_kbd_input_queue[CLKS_KBD_TTY_MAX][CLKS_KBD_INPUT_CAP];
static u16 clks_kbd_input_head[CLKS_KBD_TTY_MAX]; static u16 clks_kbd_input_head[CLKS_KBD_TTY_MAX];
@@ -172,9 +166,8 @@ static clks_bool clks_keyboard_should_pump_shell_now(void) {
} }
static char clks_keyboard_translate_scancode(u8 code) { static char clks_keyboard_translate_scancode(u8 code) {
clks_bool shift_active = (clks_kbd_lshift_down == CLKS_TRUE || clks_kbd_rshift_down == CLKS_TRUE) clks_bool shift_active =
? CLKS_TRUE (clks_kbd_lshift_down == CLKS_TRUE || clks_kbd_rshift_down == CLKS_TRUE) ? CLKS_TRUE : CLKS_FALSE;
: CLKS_FALSE;
if (shift_active == CLKS_TRUE) { if (shift_active == CLKS_TRUE) {
return clks_kbd_shift_map[code]; return clks_kbd_shift_map[code];
@@ -383,9 +376,7 @@ void clks_keyboard_handle_scancode(u8 scancode) {
return; return;
} }
if (CLKS_CFG_KBD_TTY_SWITCH_HOTKEY != 0 && if (CLKS_CFG_KBD_TTY_SWITCH_HOTKEY != 0 && clks_kbd_alt_down == CLKS_TRUE && code >= CLKS_SC_F1 &&
clks_kbd_alt_down == CLKS_TRUE &&
code >= CLKS_SC_F1 &&
code <= CLKS_SC_F4) { code <= CLKS_SC_F4) {
u32 target = (u32)(code - CLKS_SC_F1); u32 target = (u32)(code - CLKS_SC_F1);
u32 before = clks_tty_active(); u32 before = clks_tty_active();
@@ -471,4 +462,3 @@ u64 clks_keyboard_push_count(void) {
u64 clks_keyboard_pop_count(void) { u64 clks_keyboard_pop_count(void) {
return clks_kbd_pop_count; return clks_kbd_pop_count;
} }

View File

@@ -1,42 +1,42 @@
#include <clks/boot.h> #include <clks/boot.h>
#include <clks/compiler.h> #include <clks/compiler.h>
CLKS_USED static volatile u64 limine_requests_start[] CLKS_USED static volatile u64 limine_requests_start[] __attribute__((section(".limine_requests_start"))) =
__attribute__((section(".limine_requests_start"))) = LIMINE_REQUESTS_START_MARKER; LIMINE_REQUESTS_START_MARKER;
CLKS_USED static volatile u64 limine_base_revision[] CLKS_USED static volatile u64 limine_base_revision[] __attribute__((section(".limine_requests"))) =
__attribute__((section(".limine_requests"))) = LIMINE_BASE_REVISION(3); LIMINE_BASE_REVISION(3);
CLKS_USED static volatile struct limine_framebuffer_request limine_framebuffer_request CLKS_USED static volatile struct limine_framebuffer_request limine_framebuffer_request
__attribute__((section(".limine_requests"))) = { __attribute__((section(".limine_requests"))) = {
.id = LIMINE_FRAMEBUFFER_REQUEST, .id = LIMINE_FRAMEBUFFER_REQUEST,
.revision = 0, .revision = 0,
.response = CLKS_NULL, .response = CLKS_NULL,
}; };
CLKS_USED static volatile struct limine_memmap_request limine_memmap_request CLKS_USED static volatile struct limine_memmap_request limine_memmap_request
__attribute__((section(".limine_requests"))) = { __attribute__((section(".limine_requests"))) = {
.id = LIMINE_MEMMAP_REQUEST, .id = LIMINE_MEMMAP_REQUEST,
.revision = 0, .revision = 0,
.response = CLKS_NULL, .response = CLKS_NULL,
}; };
CLKS_USED static volatile struct limine_executable_file_request limine_executable_file_request CLKS_USED static volatile struct limine_executable_file_request limine_executable_file_request
__attribute__((section(".limine_requests"))) = { __attribute__((section(".limine_requests"))) = {
.id = LIMINE_EXECUTABLE_FILE_REQUEST, .id = LIMINE_EXECUTABLE_FILE_REQUEST,
.revision = 0, .revision = 0,
.response = CLKS_NULL, .response = CLKS_NULL,
}; };
CLKS_USED static volatile struct limine_module_request limine_module_request CLKS_USED static volatile struct limine_module_request limine_module_request
__attribute__((section(".limine_requests"))) = { __attribute__((section(".limine_requests"))) = {
.id = LIMINE_MODULE_REQUEST, .id = LIMINE_MODULE_REQUEST,
.revision = 0, .revision = 0,
.response = CLKS_NULL, .response = CLKS_NULL,
}; };
CLKS_USED static volatile u64 limine_requests_end[] CLKS_USED static volatile u64 limine_requests_end[] __attribute__((section(".limine_requests_end"))) =
__attribute__((section(".limine_requests_end"))) = LIMINE_REQUESTS_END_MARKER; LIMINE_REQUESTS_END_MARKER;
clks_bool clks_boot_base_revision_supported(void) { clks_bool clks_boot_base_revision_supported(void) {
return (limine_base_revision[2] == 0) ? CLKS_TRUE : CLKS_FALSE; return (limine_base_revision[2] == 0) ? CLKS_TRUE : CLKS_FALSE;

View File

@@ -106,14 +106,8 @@ static const char *clks_log_level_ansi(enum clks_log_level level) {
static const char *clks_log_tag_ansi(const char *tag) { static const char *clks_log_tag_ansi(const char *tag) {
static const char *palette[] = { static const char *palette[] = {
"\x1B[38;5;81m", "\x1B[38;5;81m", "\x1B[38;5;117m", "\x1B[38;5;159m", "\x1B[38;5;45m",
"\x1B[38;5;117m", "\x1B[38;5;75m", "\x1B[38;5;141m", "\x1B[38;5;214m", "\x1B[38;5;168m",
"\x1B[38;5;159m",
"\x1B[38;5;45m",
"\x1B[38;5;75m",
"\x1B[38;5;141m",
"\x1B[38;5;214m",
"\x1B[38;5;168m",
}; };
u32 hash = 5381U; u32 hash = 5381U;
usize i = 0U; usize i = 0U;

View File

@@ -193,8 +193,7 @@ void clks_mouse_init(void) {
return; return;
} }
if (clks_mouse_write_cmd(CLKS_PS2_CMD_READ_CFG) == CLKS_FALSE || if (clks_mouse_write_cmd(CLKS_PS2_CMD_READ_CFG) == CLKS_FALSE || clks_mouse_read_data(&config) == CLKS_FALSE) {
clks_mouse_read_data(&config) == CLKS_FALSE) {
clks_log(CLKS_LOG_WARN, "MOUSE", "PS2 READ CFG FAILED"); clks_log(CLKS_LOG_WARN, "MOUSE", "PS2 READ CFG FAILED");
return; return;
} }
@@ -202,8 +201,7 @@ void clks_mouse_init(void) {
config |= 0x02U; config |= 0x02U;
config &= (u8)~0x20U; config &= (u8)~0x20U;
if (clks_mouse_write_cmd(CLKS_PS2_CMD_WRITE_CFG) == CLKS_FALSE || if (clks_mouse_write_cmd(CLKS_PS2_CMD_WRITE_CFG) == CLKS_FALSE || clks_mouse_write_data(config) == CLKS_FALSE) {
clks_mouse_write_data(config) == CLKS_FALSE) {
clks_log(CLKS_LOG_WARN, "MOUSE", "PS2 WRITE CFG FAILED"); clks_log(CLKS_LOG_WARN, "MOUSE", "PS2 WRITE CFG FAILED");
return; return;
} }
@@ -214,8 +212,7 @@ void clks_mouse_init(void) {
return; return;
} }
if (clks_mouse_send_device_cmd(CLKS_PS2_MOUSE_CMD_ENABLE_STREAM, &ack) == CLKS_FALSE || if (clks_mouse_send_device_cmd(CLKS_PS2_MOUSE_CMD_ENABLE_STREAM, &ack) == CLKS_FALSE || ack != CLKS_PS2_MOUSE_ACK) {
ack != CLKS_PS2_MOUSE_ACK) {
clks_log(CLKS_LOG_WARN, "MOUSE", "PS2 ENABLE STREAM FAILED"); clks_log(CLKS_LOG_WARN, "MOUSE", "PS2 ENABLE STREAM FAILED");
return; return;
} }

View File

@@ -225,13 +225,8 @@ static u8 clks_panic_hex_value(char ch) {
return (u8)(10 + (ch - 'A')); return (u8)(10 + (ch - 'A'));
} }
static clks_bool clks_panic_parse_symbol_line(const char *line, static clks_bool clks_panic_parse_symbol_line(const char *line, usize len, u64 *out_addr, const char **out_name,
usize len, usize *out_name_len, const char **out_source, usize *out_source_len) {
u64 *out_addr,
const char **out_name,
usize *out_name_len,
const char **out_source,
usize *out_source_len) {
usize i = 0U; usize i = 0U;
u64 addr = 0ULL; u64 addr = 0ULL;
u32 digits = 0U; u32 digits = 0U;
@@ -328,12 +323,8 @@ static clks_bool clks_panic_symbols_ready(void) {
return CLKS_TRUE; return CLKS_TRUE;
} }
static clks_bool clks_panic_lookup_symbol(u64 addr, static clks_bool clks_panic_lookup_symbol(u64 addr, const char **out_name, usize *out_name_len, u64 *out_base,
const char **out_name, const char **out_source, usize *out_source_len) {
usize *out_name_len,
u64 *out_base,
const char **out_source,
usize *out_source_len) {
const char *data; const char *data;
const char *end; const char *end;
const char *line; const char *line;
@@ -381,12 +372,7 @@ static clks_bool clks_panic_lookup_symbol(u64 addr,
data++; data++;
} }
if (clks_panic_parse_symbol_line(line, if (clks_panic_parse_symbol_line(line, line_len, &line_addr, &line_name, &line_name_len, &line_source,
line_len,
&line_addr,
&line_name,
&line_name_len,
&line_source,
&line_source_len) == CLKS_FALSE) { &line_source_len) == CLKS_FALSE) {
continue; continue;
} }
@@ -632,12 +618,7 @@ CLKS_NORETURN void clks_panic(const char *reason) {
clks_panic_halt_loop(); clks_panic_halt_loop();
} }
CLKS_NORETURN void clks_panic_exception(const char *name, CLKS_NORETURN void clks_panic_exception(const char *name, u64 vector, u64 error_code, u64 rip, u64 rbp, u64 rsp) {
u64 vector,
u64 error_code,
u64 rip,
u64 rbp,
u64 rsp) {
struct clks_panic_console console; struct clks_panic_console console;
char hex_buf[19]; char hex_buf[19];

View File

@@ -70,24 +70,18 @@ void clks_service_init(void) {
heap_stats = clks_heap_get_stats(); heap_stats = clks_heap_get_stats();
clks_service_register(CLKS_SERVICE_LOG, "log", CLKS_SERVICE_STATE_READY); clks_service_register(CLKS_SERVICE_LOG, "log", CLKS_SERVICE_STATE_READY);
clks_service_register(CLKS_SERVICE_MEM, clks_service_register(CLKS_SERVICE_MEM, "memory",
"memory",
(heap_stats.total_bytes > 0U) ? CLKS_SERVICE_STATE_READY : CLKS_SERVICE_STATE_DEGRADED); (heap_stats.total_bytes > 0U) ? CLKS_SERVICE_STATE_READY : CLKS_SERVICE_STATE_DEGRADED);
clks_service_register(CLKS_SERVICE_FS, clks_service_register(CLKS_SERVICE_FS, "filesystem",
"filesystem",
(clks_fs_is_ready() == CLKS_TRUE) ? CLKS_SERVICE_STATE_READY : CLKS_SERVICE_STATE_DEGRADED); (clks_fs_is_ready() == CLKS_TRUE) ? CLKS_SERVICE_STATE_READY : CLKS_SERVICE_STATE_DEGRADED);
clks_service_register(CLKS_SERVICE_DRIVER, clks_service_register(CLKS_SERVICE_DRIVER, "driver",
"driver",
(clks_driver_count() > 0ULL) ? CLKS_SERVICE_STATE_READY : CLKS_SERVICE_STATE_DEGRADED); (clks_driver_count() > 0ULL) ? CLKS_SERVICE_STATE_READY : CLKS_SERVICE_STATE_DEGRADED);
clks_service_register(CLKS_SERVICE_SCHED, clks_service_register(CLKS_SERVICE_SCHED, "scheduler", CLKS_SERVICE_STATE_READY);
"scheduler", clks_service_register(CLKS_SERVICE_KELF, "kelf",
CLKS_SERVICE_STATE_READY);
clks_service_register(CLKS_SERVICE_KELF,
"kelf",
(clks_kelf_count() > 0ULL) ? CLKS_SERVICE_STATE_READY : CLKS_SERVICE_STATE_DEGRADED); (clks_kelf_count() > 0ULL) ? CLKS_SERVICE_STATE_READY : CLKS_SERVICE_STATE_DEGRADED);
clks_service_register(CLKS_SERVICE_USER, clks_service_register(CLKS_SERVICE_USER, "userland",
"userland", (clks_userland_shell_ready() == CLKS_TRUE) ? CLKS_SERVICE_STATE_READY
(clks_userland_shell_ready() == CLKS_TRUE) ? CLKS_SERVICE_STATE_READY : CLKS_SERVICE_STATE_DEGRADED); : CLKS_SERVICE_STATE_DEGRADED);
clks_log(CLKS_LOG_INFO, "SRV", "KERNEL SERVICES ONLINE"); clks_log(CLKS_LOG_INFO, "SRV", "KERNEL SERVICES ONLINE");
clks_log_hex(CLKS_LOG_INFO, "SRV", "COUNT", clks_service_count()); clks_log_hex(CLKS_LOG_INFO, "SRV", "COUNT", clks_service_count());

View File

@@ -173,35 +173,24 @@ static void clks_shell_history_push(const char *line) {
return; return;
} }
if (clks_shell_history_count > 0U && if (clks_shell_history_count > 0U && clks_strcmp(clks_shell_history[clks_shell_history_count - 1U], line) == 0) {
clks_strcmp(clks_shell_history[clks_shell_history_count - 1U], line) == 0) {
clks_shell_history_cancel_nav(); clks_shell_history_cancel_nav();
return; return;
} }
if (clks_shell_history_count < CLKS_SHELL_HISTORY_MAX) { if (clks_shell_history_count < CLKS_SHELL_HISTORY_MAX) {
clks_shell_copy_line( clks_shell_copy_line(clks_shell_history[clks_shell_history_count],
clks_shell_history[clks_shell_history_count], sizeof(clks_shell_history[clks_shell_history_count]), line);
sizeof(clks_shell_history[clks_shell_history_count]),
line
);
clks_shell_history_count++; clks_shell_history_count++;
} else { } else {
u32 i; u32 i;
for (i = 1U; i < CLKS_SHELL_HISTORY_MAX; i++) { for (i = 1U; i < CLKS_SHELL_HISTORY_MAX; i++) {
clks_memcpy( clks_memcpy(clks_shell_history[i - 1U], clks_shell_history[i], CLKS_SHELL_LINE_MAX);
clks_shell_history[i - 1U],
clks_shell_history[i],
CLKS_SHELL_LINE_MAX
);
} }
clks_shell_copy_line( clks_shell_copy_line(clks_shell_history[CLKS_SHELL_HISTORY_MAX - 1U],
clks_shell_history[CLKS_SHELL_HISTORY_MAX - 1U], sizeof(clks_shell_history[CLKS_SHELL_HISTORY_MAX - 1U]), line);
sizeof(clks_shell_history[CLKS_SHELL_HISTORY_MAX - 1U]),
line
);
} }
clks_shell_history_cancel_nav(); clks_shell_history_cancel_nav();
@@ -287,10 +276,7 @@ static void clks_shell_trim(char *line) {
} }
} }
static void clks_shell_split_line(const char *line, static void clks_shell_split_line(const char *line, char *out_cmd, usize out_cmd_size, char *out_arg,
char *out_cmd,
usize out_cmd_size,
char *out_arg,
usize out_arg_size) { usize out_arg_size) {
usize i = 0U; usize i = 0U;
usize cmd_pos = 0U; usize cmd_pos = 0U;
@@ -407,7 +393,8 @@ static clks_bool clks_shell_resolve_exec_path(const char *arg, char *out_path, u
return CLKS_TRUE; return CLKS_TRUE;
} }
static clks_bool clks_shell_path_push_component(char *path, usize path_size, usize *io_len, const char *component, usize comp_len) { static clks_bool clks_shell_path_push_component(char *path, usize path_size, usize *io_len, const char *component,
usize comp_len) {
if (path == CLKS_NULL || io_len == CLKS_NULL || component == CLKS_NULL || comp_len == 0U) { if (path == CLKS_NULL || io_len == CLKS_NULL || component == CLKS_NULL || comp_len == 0U) {
return CLKS_FALSE; return CLKS_FALSE;
} }
@@ -528,9 +515,7 @@ static clks_bool clks_shell_resolve_path(const char *arg, char *out_path, usize
return clks_shell_path_parse_into(arg, out_path, out_size, &len); return clks_shell_path_parse_into(arg, out_path, out_size, &len);
} }
static clks_bool clks_shell_split_first_and_rest(const char *arg, static clks_bool clks_shell_split_first_and_rest(const char *arg, char *out_first, usize out_first_size,
char *out_first,
usize out_first_size,
const char **out_rest) { const char **out_rest) {
usize i = 0U; usize i = 0U;
usize p = 0U; usize p = 0U;
@@ -567,17 +552,13 @@ static clks_bool clks_shell_split_first_and_rest(const char *arg,
return CLKS_TRUE; return CLKS_TRUE;
} }
static clks_bool clks_shell_split_two_args(const char *arg, static clks_bool clks_shell_split_two_args(const char *arg, char *out_first, usize out_first_size, char *out_second,
char *out_first,
usize out_first_size,
char *out_second,
usize out_second_size) { usize out_second_size) {
usize i = 0U; usize i = 0U;
usize p = 0U; usize p = 0U;
if (arg == CLKS_NULL || if (arg == CLKS_NULL || out_first == CLKS_NULL || out_first_size == 0U || out_second == CLKS_NULL ||
out_first == CLKS_NULL || out_first_size == 0U || out_second_size == 0U) {
out_second == CLKS_NULL || out_second_size == 0U) {
return CLKS_FALSE; return CLKS_FALSE;
} }
@@ -1018,7 +999,8 @@ static clks_bool clks_shell_cmd_mv(const char *arg) {
return CLKS_FALSE; return CLKS_FALSE;
} }
if (clks_shell_path_is_under_temp(src_path) == CLKS_FALSE || clks_shell_path_is_under_temp(dst_path) == CLKS_FALSE) { if (clks_shell_path_is_under_temp(src_path) == CLKS_FALSE ||
clks_shell_path_is_under_temp(dst_path) == CLKS_FALSE) {
clks_shell_writeln("mv: source and destination must be under /temp"); clks_shell_writeln("mv: source and destination must be under /temp");
return CLKS_FALSE; return CLKS_FALSE;
} }
@@ -1563,4 +1545,3 @@ void clks_shell_tick(u64 tick) {
clks_shell_drain_input(CLKS_SHELL_INPUT_BUDGET); clks_shell_drain_input(CLKS_SHELL_INPUT_BUDGET);
clks_shell_process_pending_command(); clks_shell_process_pending_command();
} }

View File

@@ -103,7 +103,6 @@ static inline void clks_syscall_outw(u16 port, u16 value) {
} }
#endif #endif
static clks_bool clks_syscall_copy_user_string(u64 src_addr, char *dst, usize dst_size) { static clks_bool clks_syscall_copy_user_string(u64 src_addr, char *dst, usize dst_size) {
const char *src = (const char *)src_addr; const char *src = (const char *)src_addr;
usize i = 0U; usize i = 0U;
@@ -497,13 +496,8 @@ static u8 clks_syscall_hex_value(char ch) {
return (u8)(10 + (ch - 'A')); return (u8)(10 + (ch - 'A'));
} }
static clks_bool clks_syscall_parse_symbol_line(const char *line, static clks_bool clks_syscall_parse_symbol_line(const char *line, usize len, u64 *out_addr, const char **out_name,
usize len, usize *out_name_len, const char **out_source, usize *out_source_len) {
u64 *out_addr,
const char **out_name,
usize *out_name_len,
const char **out_source,
usize *out_source_len) {
usize i = 0U; usize i = 0U;
u64 addr = 0ULL; u64 addr = 0ULL;
u32 digits = 0U; u32 digits = 0U;
@@ -600,12 +594,8 @@ static clks_bool clks_syscall_symbols_ready(void) {
return CLKS_TRUE; return CLKS_TRUE;
} }
static clks_bool clks_syscall_lookup_symbol(u64 addr, static clks_bool clks_syscall_lookup_symbol(u64 addr, const char **out_name, usize *out_name_len, u64 *out_base,
const char **out_name, const char **out_source, usize *out_source_len) {
usize *out_name_len,
u64 *out_base,
const char **out_source,
usize *out_source_len) {
const char *data; const char *data;
const char *end; const char *end;
const char *line; const char *line;
@@ -653,12 +643,7 @@ static clks_bool clks_syscall_lookup_symbol(u64 addr,
data++; data++;
} }
if (clks_syscall_parse_symbol_line(line, if (clks_syscall_parse_symbol_line(line, line_len, &line_addr, &line_name, &line_name_len, &line_source,
line_len,
&line_addr,
&line_name,
&line_name_len,
&line_source,
&line_source_len) == CLKS_FALSE) { &line_source_len) == CLKS_FALSE) {
continue; continue;
} }
@@ -904,10 +889,8 @@ static u64 clks_syscall_kdbg_bt(u64 arg0) {
current_rbp = next_rbp; current_rbp = next_rbp;
} }
} else { } else {
pos = clks_syscall_procfs_append_text(text, pos = clks_syscall_procfs_append_text(
sizeof(text), text, sizeof(text), pos, "NOTE: stack walk skipped (rbp not in current kernel stack window)\n");
pos,
"NOTE: stack walk skipped (rbp not in current kernel stack window)\n");
} }
} }
#else #else
@@ -941,8 +924,7 @@ static clks_bool clks_syscall_procfs_snapshot_for_path(const char *path, struct
return CLKS_FALSE; return CLKS_FALSE;
} }
static usize clks_syscall_procfs_render_snapshot(char *out, static usize clks_syscall_procfs_render_snapshot(char *out, usize out_size,
usize out_size,
const struct clks_exec_proc_snapshot *snap) { const struct clks_exec_proc_snapshot *snap) {
usize pos = 0U; usize pos = 0U;
@@ -1048,10 +1030,7 @@ static usize clks_syscall_procfs_render_list(char *out, usize out_size) {
return pos; return pos;
} }
static clks_bool clks_syscall_procfs_render_file(const char *path, static clks_bool clks_syscall_procfs_render_file(const char *path, char *out, usize out_size, usize *out_len) {
char *out,
usize out_size,
usize *out_len) {
struct clks_exec_proc_snapshot snap; struct clks_exec_proc_snapshot snap;
if (out_len != CLKS_NULL) { if (out_len != CLKS_NULL) {
@@ -1093,8 +1072,7 @@ static u64 clks_syscall_fs_child_count(u64 arg0) {
return (u64)-1; return (u64)-1;
} }
if (CLKS_CFG_PROCFS != 0 && if (CLKS_CFG_PROCFS != 0 && clks_syscall_fs_is_root(path) == CLKS_TRUE &&
clks_syscall_fs_is_root(path) == CLKS_TRUE &&
clks_syscall_fs_has_real_proc_dir() == CLKS_FALSE) { clks_syscall_fs_has_real_proc_dir() == CLKS_FALSE) {
return base_count + 1ULL; return base_count + 1ULL;
} }
@@ -1148,8 +1126,7 @@ static u64 clks_syscall_fs_get_child_name(u64 arg0, u64 arg1, u64 arg2) {
} }
} }
if (CLKS_CFG_PROCFS != 0 && if (CLKS_CFG_PROCFS != 0 && clks_syscall_fs_is_root(path) == CLKS_TRUE &&
clks_syscall_fs_is_root(path) == CLKS_TRUE &&
clks_syscall_fs_has_real_proc_dir() == CLKS_FALSE) { clks_syscall_fs_has_real_proc_dir() == CLKS_FALSE) {
if (arg1 == 0ULL) { if (arg1 == 0ULL) {
clks_memset((void *)arg2, 0, CLKS_SYSCALL_NAME_MAX); clks_memset((void *)arg2, 0, CLKS_SYSCALL_NAME_MAX);
@@ -1186,8 +1163,7 @@ static u64 clks_syscall_fs_read(u64 arg0, u64 arg1, u64 arg2) {
} }
if (CLKS_CFG_PROCFS != 0 && if (CLKS_CFG_PROCFS != 0 &&
(clks_syscall_procfs_is_list(path) == CLKS_TRUE || (clks_syscall_procfs_is_list(path) == CLKS_TRUE || clks_syscall_procfs_is_self(path) == CLKS_TRUE ||
clks_syscall_procfs_is_self(path) == CLKS_TRUE ||
clks_syscall_procfs_parse_pid(path, &file_size) == CLKS_TRUE)) { clks_syscall_procfs_parse_pid(path, &file_size) == CLKS_TRUE)) {
char proc_text[CLKS_SYSCALL_PROCFS_TEXT_MAX]; char proc_text[CLKS_SYSCALL_PROCFS_TEXT_MAX];
usize proc_len = 0U; usize proc_len = 0U;
@@ -1282,7 +1258,8 @@ static u64 clks_syscall_exec_pathv_io(u64 arg0, u64 arg1, u64 arg2) {
return (u64)-1; return (u64)-1;
} }
if (clks_exec_run_pathv_io(path, argv_line, env_line, req.stdin_fd, req.stdout_fd, req.stderr_fd, &status) == CLKS_FALSE) { if (clks_exec_run_pathv_io(path, argv_line, env_line, req.stdin_fd, req.stdout_fd, req.stderr_fd, &status) ==
CLKS_FALSE) {
return (u64)-1; return (u64)-1;
} }
@@ -1462,7 +1439,6 @@ static u64 clks_syscall_restart(void) {
return 1ULL; return 1ULL;
} }
static u64 clks_syscall_audio_available(void) { static u64 clks_syscall_audio_available(void) {
return (clks_audio_available() == CLKS_TRUE) ? 1ULL : 0ULL; return (clks_audio_available() == CLKS_TRUE) ? 1ULL : 0ULL;
} }
@@ -1736,9 +1712,7 @@ static u64 clks_syscall_stats_recent_id(u64 id) {
static void clks_syscall_trace_user_program(u64 id) { static void clks_syscall_trace_user_program(u64 id) {
clks_bool user_program_running = clks_bool user_program_running =
(clks_exec_is_running() == CLKS_TRUE && clks_exec_current_path_is_user() == CLKS_TRUE) (clks_exec_is_running() == CLKS_TRUE && clks_exec_current_path_is_user() == CLKS_TRUE) ? CLKS_TRUE : CLKS_FALSE;
? CLKS_TRUE
: CLKS_FALSE;
if (user_program_running == CLKS_FALSE) { if (user_program_running == CLKS_FALSE) {
if (clks_syscall_user_trace_active == CLKS_TRUE) { if (clks_syscall_user_trace_active == CLKS_TRUE) {
@@ -1977,12 +1951,7 @@ u64 clks_syscall_dispatch(void *frame_ptr) {
u64 clks_syscall_invoke_kernel(u64 id, u64 arg0, u64 arg1, u64 arg2) { u64 clks_syscall_invoke_kernel(u64 id, u64 arg0, u64 arg1, u64 arg2) {
u64 ret; u64 ret;
__asm__ volatile( __asm__ volatile("int $0x80" : "=a"(ret) : "a"(id), "b"(arg0), "c"(arg1), "d"(arg2) : "memory");
"int $0x80"
: "=a"(ret)
: "a"(id), "b"(arg0), "c"(arg1), "d"(arg2)
: "memory"
);
return ret; return ret;
} }

View File

@@ -69,12 +69,9 @@ static clks_bool clks_tty_scrollback_is_active(u32 tty_index);
static void clks_tty_redraw_active(void); static void clks_tty_redraw_active(void);
static u32 clks_tty_ansi_palette(u32 index) { static u32 clks_tty_ansi_palette(u32 index) {
static const u32 palette[16] = { static const u32 palette[16] = {0x00000000U, 0x00CD3131U, 0x000DBC79U, 0x00E5E510U, 0x002472C8U, 0x00BC3FBCU,
0x00000000U, 0x00CD3131U, 0x000DBC79U, 0x00E5E510U, 0x0011A8CDU, 0x00E5E5E5U, 0x00666666U, 0x00F14C4CU, 0x0023D18BU, 0x00F5F543U,
0x002472C8U, 0x00BC3FBCU, 0x0011A8CDU, 0x00E5E5E5U, 0x003B8EEAU, 0x00D670D6U, 0x0029B8DBU, 0x00FFFFFFU};
0x00666666U, 0x00F14C4CU, 0x0023D18BU, 0x00F5F543U,
0x003B8EEAU, 0x00D670D6U, 0x0029B8DBU, 0x00FFFFFFU
};
if (index < 16U) { if (index < 16U) {
return palette[index]; return palette[index];
@@ -88,25 +85,12 @@ static void clks_tty_reset_blink_timer(void) {
} }
static void clks_tty_draw_cell_with_colors(u32 row, u32 col, char ch, u32 fg, u32 bg, u8 style) { static void clks_tty_draw_cell_with_colors(u32 row, u32 col, char ch, u32 fg, u32 bg, u8 style) {
clks_fb_draw_char_styled( clks_fb_draw_char_styled(col * clks_tty_cell_width, row * clks_tty_cell_height, ch, fg, bg, (u32)style);
col * clks_tty_cell_width,
row * clks_tty_cell_height,
ch,
fg,
bg,
(u32)style
);
} }
static void clks_tty_draw_cell(u32 tty_index, u32 row, u32 col) { static void clks_tty_draw_cell(u32 tty_index, u32 row, u32 col) {
clks_tty_draw_cell_with_colors( clks_tty_draw_cell_with_colors(row, col, clks_tty_cells[tty_index][row][col], clks_tty_cell_fg[tty_index][row][col],
row, clks_tty_cell_bg[tty_index][row][col], clks_tty_cell_style[tty_index][row][col]);
col,
clks_tty_cells[tty_index][row][col],
clks_tty_cell_fg[tty_index][row][col],
clks_tty_cell_bg[tty_index][row][col],
clks_tty_cell_style[tty_index][row][col]
);
} }
static void clks_tty_dirty_reset(void) { static void clks_tty_dirty_reset(void) {
@@ -189,21 +173,11 @@ static void clks_tty_scrollback_push_row(u32 tty_index, u32 row) {
u32 slot = clks_tty_scrollback_head[tty_index]; u32 slot = clks_tty_scrollback_head[tty_index];
clks_memcpy(clks_tty_scrollback_cells[tty_index][slot], clks_tty_cells[tty_index][row], clks_tty_cols); clks_memcpy(clks_tty_scrollback_cells[tty_index][slot], clks_tty_cells[tty_index][row], clks_tty_cols);
clks_memcpy( clks_memcpy(clks_tty_scrollback_fg[tty_index][slot], clks_tty_cell_fg[tty_index][row],
clks_tty_scrollback_fg[tty_index][slot], (usize)clks_tty_cols * sizeof(u32));
clks_tty_cell_fg[tty_index][row], clks_memcpy(clks_tty_scrollback_bg[tty_index][slot], clks_tty_cell_bg[tty_index][row],
(usize)clks_tty_cols * sizeof(u32) (usize)clks_tty_cols * sizeof(u32));
); clks_memcpy(clks_tty_scrollback_style[tty_index][slot], clks_tty_cell_style[tty_index][row], clks_tty_cols);
clks_memcpy(
clks_tty_scrollback_bg[tty_index][slot],
clks_tty_cell_bg[tty_index][row],
(usize)clks_tty_cols * sizeof(u32)
);
clks_memcpy(
clks_tty_scrollback_style[tty_index][slot],
clks_tty_cell_style[tty_index][row],
clks_tty_cols
);
clks_tty_scrollback_head[tty_index] = (slot + 1U) % CLKS_TTY_SCROLLBACK_LINES; clks_tty_scrollback_head[tty_index] = (slot + 1U) % CLKS_TTY_SCROLLBACK_LINES;
@@ -338,14 +312,8 @@ static void clks_tty_draw_status_bar(void) {
for (col = 0U; col < clks_tty_cols; col++) { for (col = 0U; col < clks_tty_cols; col++) {
char ch = (col < CLKS_TTY_MAX_COLS) ? line[col] : ' '; char ch = (col < CLKS_TTY_MAX_COLS) ? line[col] : ' ';
clks_tty_draw_cell_with_colors( clks_tty_draw_cell_with_colors(status_row, col, ch, CLKS_TTY_STATUS_FG, CLKS_TTY_STATUS_BG,
status_row, CLKS_TTY_STATUS_STYLE);
col,
ch,
CLKS_TTY_STATUS_FG,
CLKS_TTY_STATUS_BG,
CLKS_TTY_STATUS_STYLE
);
} }
} }
@@ -470,14 +438,10 @@ static void clks_tty_redraw_active(void) {
u32 phys = clks_tty_scrollback_logical_to_physical(tty_index, doc_index); u32 phys = clks_tty_scrollback_logical_to_physical(tty_index, doc_index);
for (col = 0; col < clks_tty_cols; col++) { for (col = 0; col < clks_tty_cols; col++) {
clks_tty_draw_cell_with_colors( clks_tty_draw_cell_with_colors(row, col, clks_tty_scrollback_cells[tty_index][phys][col],
row,
col,
clks_tty_scrollback_cells[tty_index][phys][col],
clks_tty_scrollback_fg[tty_index][phys][col], clks_tty_scrollback_fg[tty_index][phys][col],
clks_tty_scrollback_bg[tty_index][phys][col], clks_tty_scrollback_bg[tty_index][phys][col],
clks_tty_scrollback_style[tty_index][phys][col] clks_tty_scrollback_style[tty_index][phys][col]);
);
} }
continue; continue;
@@ -492,13 +456,8 @@ static void clks_tty_redraw_active(void) {
for (col = 0; col < clks_tty_cols; col++) { for (col = 0; col < clks_tty_cols; col++) {
clks_tty_draw_cell_with_colors( clks_tty_draw_cell_with_colors(
row, row, col, clks_tty_cells[tty_index][src_row][col], clks_tty_cell_fg[tty_index][src_row][col],
col, clks_tty_cell_bg[tty_index][src_row][col], clks_tty_cell_style[tty_index][src_row][col]);
clks_tty_cells[tty_index][src_row][col],
clks_tty_cell_fg[tty_index][src_row][col],
clks_tty_cell_bg[tty_index][src_row][col],
clks_tty_cell_style[tty_index][src_row][col]
);
} }
} }
} }
@@ -516,21 +475,11 @@ static void clks_tty_scroll_up(u32 tty_index) {
for (row = 1; row < clks_tty_content_rows(); row++) { for (row = 1; row < clks_tty_content_rows(); row++) {
clks_memcpy(clks_tty_cells[tty_index][row - 1U], clks_tty_cells[tty_index][row], clks_tty_cols); clks_memcpy(clks_tty_cells[tty_index][row - 1U], clks_tty_cells[tty_index][row], clks_tty_cols);
clks_memcpy( clks_memcpy(clks_tty_cell_fg[tty_index][row - 1U], clks_tty_cell_fg[tty_index][row],
clks_tty_cell_fg[tty_index][row - 1U], (usize)clks_tty_cols * sizeof(u32));
clks_tty_cell_fg[tty_index][row], clks_memcpy(clks_tty_cell_bg[tty_index][row - 1U], clks_tty_cell_bg[tty_index][row],
(usize)clks_tty_cols * sizeof(u32) (usize)clks_tty_cols * sizeof(u32));
); clks_memcpy(clks_tty_cell_style[tty_index][row - 1U], clks_tty_cell_style[tty_index][row], clks_tty_cols);
clks_memcpy(
clks_tty_cell_bg[tty_index][row - 1U],
clks_tty_cell_bg[tty_index][row],
(usize)clks_tty_cols * sizeof(u32)
);
clks_memcpy(
clks_tty_cell_style[tty_index][row - 1U],
clks_tty_cell_style[tty_index][row],
clks_tty_cols
);
} }
clks_tty_fill_row(tty_index, clks_tty_content_rows() - 1U, ' '); clks_tty_fill_row(tty_index, clks_tty_content_rows() - 1U, ' ');
@@ -1462,7 +1411,6 @@ void clks_tty_scrollback_page_down(void) {
} }
} }
u32 clks_tty_active(void) { u32 clks_tty_active(void) {
return clks_tty_active_index; return clks_tty_active_index;
} }
@@ -1474,4 +1422,3 @@ u32 clks_tty_count(void) {
clks_bool clks_tty_ready(void) { clks_bool clks_tty_ready(void) {
return clks_tty_is_ready; return clks_tty_is_ready;
} }

View File

@@ -136,8 +136,7 @@ clks_bool clks_userland_init(void) {
} }
void clks_userland_tick(u64 tick) { void clks_userland_tick(u64 tick) {
if (clks_user_shell_exec_enabled == CLKS_FALSE || if (clks_user_shell_exec_enabled == CLKS_FALSE || clks_user_shell_ready == CLKS_FALSE ||
clks_user_shell_ready == CLKS_FALSE ||
clks_user_shell_exec_requested_flag == CLKS_TRUE) { clks_user_shell_exec_requested_flag == CLKS_TRUE) {
return; return;
} }