mirror of
https://github.com/Leonmmcoset/cleonos.git
synced 2026-04-21 10:40:00 +00:00
Stage 12
This commit is contained in:
@@ -22,6 +22,11 @@ typedef unsigned long long usize;
|
|||||||
#define CLEONOS_SYSCALL_EXEC_PATH 13ULL
|
#define CLEONOS_SYSCALL_EXEC_PATH 13ULL
|
||||||
#define CLEONOS_SYSCALL_EXEC_REQUESTS 14ULL
|
#define CLEONOS_SYSCALL_EXEC_REQUESTS 14ULL
|
||||||
#define CLEONOS_SYSCALL_EXEC_SUCCESS 15ULL
|
#define CLEONOS_SYSCALL_EXEC_SUCCESS 15ULL
|
||||||
|
#define CLEONOS_SYSCALL_USER_SHELL_READY 16ULL
|
||||||
|
#define CLEONOS_SYSCALL_USER_EXEC_REQUESTED 17ULL
|
||||||
|
#define CLEONOS_SYSCALL_USER_LAUNCH_TRIES 18ULL
|
||||||
|
#define CLEONOS_SYSCALL_USER_LAUNCH_OK 19ULL
|
||||||
|
#define CLEONOS_SYSCALL_USER_LAUNCH_FAIL 20ULL
|
||||||
|
|
||||||
u64 cleonos_syscall(u64 id, u64 arg0, u64 arg1, u64 arg2);
|
u64 cleonos_syscall(u64 id, u64 arg0, u64 arg1, u64 arg2);
|
||||||
u64 cleonos_sys_log_write(const char *message, u64 length);
|
u64 cleonos_sys_log_write(const char *message, u64 length);
|
||||||
@@ -34,5 +39,10 @@ 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_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_exec_requested(void);
|
||||||
|
u64 cleonos_sys_user_launch_tries(void);
|
||||||
|
u64 cleonos_sys_user_launch_ok(void);
|
||||||
|
u64 cleonos_sys_user_launch_fail(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -51,4 +51,24 @@ u64 cleonos_sys_exec_request_count(void) {
|
|||||||
|
|
||||||
u64 cleonos_sys_exec_success_count(void) {
|
u64 cleonos_sys_exec_success_count(void) {
|
||||||
return cleonos_syscall(CLEONOS_SYSCALL_EXEC_SUCCESS, 0ULL, 0ULL, 0ULL);
|
return cleonos_syscall(CLEONOS_SYSCALL_EXEC_SUCCESS, 0ULL, 0ULL, 0ULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u64 cleonos_sys_user_shell_ready(void) {
|
||||||
|
return cleonos_syscall(CLEONOS_SYSCALL_USER_SHELL_READY, 0ULL, 0ULL, 0ULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
u64 cleonos_sys_user_exec_requested(void) {
|
||||||
|
return cleonos_syscall(CLEONOS_SYSCALL_USER_EXEC_REQUESTED, 0ULL, 0ULL, 0ULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
u64 cleonos_sys_user_launch_tries(void) {
|
||||||
|
return cleonos_syscall(CLEONOS_SYSCALL_USER_LAUNCH_TRIES, 0ULL, 0ULL, 0ULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
u64 cleonos_sys_user_launch_ok(void) {
|
||||||
|
return cleonos_syscall(CLEONOS_SYSCALL_USER_LAUNCH_OK, 0ULL, 0ULL, 0ULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
u64 cleonos_sys_user_launch_fail(void) {
|
||||||
|
return cleonos_syscall(CLEONOS_SYSCALL_USER_LAUNCH_FAIL, 0ULL, 0ULL, 0ULL);
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ enum clks_service_id {
|
|||||||
CLKS_SERVICE_DRIVER = 4,
|
CLKS_SERVICE_DRIVER = 4,
|
||||||
CLKS_SERVICE_SCHED = 5,
|
CLKS_SERVICE_SCHED = 5,
|
||||||
CLKS_SERVICE_KELF = 6,
|
CLKS_SERVICE_KELF = 6,
|
||||||
|
CLKS_SERVICE_USER = 7,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum clks_service_state {
|
enum clks_service_state {
|
||||||
|
|||||||
@@ -19,9 +19,14 @@
|
|||||||
#define CLKS_SYSCALL_EXEC_PATH 13ULL
|
#define CLKS_SYSCALL_EXEC_PATH 13ULL
|
||||||
#define CLKS_SYSCALL_EXEC_REQUESTS 14ULL
|
#define CLKS_SYSCALL_EXEC_REQUESTS 14ULL
|
||||||
#define CLKS_SYSCALL_EXEC_SUCCESS 15ULL
|
#define CLKS_SYSCALL_EXEC_SUCCESS 15ULL
|
||||||
|
#define CLKS_SYSCALL_USER_SHELL_READY 16ULL
|
||||||
|
#define CLKS_SYSCALL_USER_EXEC_REQUESTED 17ULL
|
||||||
|
#define CLKS_SYSCALL_USER_LAUNCH_TRIES 18ULL
|
||||||
|
#define CLKS_SYSCALL_USER_LAUNCH_OK 19ULL
|
||||||
|
#define CLKS_SYSCALL_USER_LAUNCH_FAIL 20ULL
|
||||||
|
|
||||||
void clks_syscall_init(void);
|
void clks_syscall_init(void);
|
||||||
u64 clks_syscall_dispatch(void *frame_ptr);
|
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);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -4,5 +4,11 @@
|
|||||||
#include <clks/types.h>
|
#include <clks/types.h>
|
||||||
|
|
||||||
clks_bool clks_userland_init(void);
|
clks_bool clks_userland_init(void);
|
||||||
|
void clks_userland_tick(u64 tick);
|
||||||
|
clks_bool clks_userland_shell_ready(void);
|
||||||
|
clks_bool clks_userland_shell_exec_requested(void);
|
||||||
|
u64 clks_userland_launch_attempts(void);
|
||||||
|
u64 clks_userland_launch_success(void);
|
||||||
|
u64 clks_userland_launch_failures(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -58,7 +58,12 @@ static void clks_task_kelfd(u64 tick) {
|
|||||||
clks_kelf_tick(tick);
|
clks_kelf_tick(tick);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clks_stage11_syscall_probe(void) {
|
static void clks_task_usrd(u64 tick) {
|
||||||
|
clks_service_heartbeat(CLKS_SERVICE_USER, tick);
|
||||||
|
clks_userland_tick(tick);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void clks_stage12_syscall_probe(void) {
|
||||||
char child_name[96];
|
char child_name[96];
|
||||||
char read_buf[160];
|
char read_buf[160];
|
||||||
u64 root_children;
|
u64 root_children;
|
||||||
@@ -109,6 +114,27 @@ static void clks_stage11_syscall_probe(void) {
|
|||||||
"EXEC",
|
"EXEC",
|
||||||
"SUCCESS",
|
"SUCCESS",
|
||||||
clks_syscall_invoke_kernel(CLKS_SYSCALL_EXEC_SUCCESS, 0ULL, 0ULL, 0ULL));
|
clks_syscall_invoke_kernel(CLKS_SYSCALL_EXEC_SUCCESS, 0ULL, 0ULL, 0ULL));
|
||||||
|
|
||||||
|
clks_log_hex(CLKS_LOG_INFO,
|
||||||
|
"USER",
|
||||||
|
"SHELL_READY",
|
||||||
|
clks_syscall_invoke_kernel(CLKS_SYSCALL_USER_SHELL_READY, 0ULL, 0ULL, 0ULL));
|
||||||
|
clks_log_hex(CLKS_LOG_INFO,
|
||||||
|
"USER",
|
||||||
|
"EXEC_REQUESTED",
|
||||||
|
clks_syscall_invoke_kernel(CLKS_SYSCALL_USER_EXEC_REQUESTED, 0ULL, 0ULL, 0ULL));
|
||||||
|
clks_log_hex(CLKS_LOG_INFO,
|
||||||
|
"USER",
|
||||||
|
"LAUNCH_TRIES",
|
||||||
|
clks_syscall_invoke_kernel(CLKS_SYSCALL_USER_LAUNCH_TRIES, 0ULL, 0ULL, 0ULL));
|
||||||
|
clks_log_hex(CLKS_LOG_INFO,
|
||||||
|
"USER",
|
||||||
|
"LAUNCH_OK",
|
||||||
|
clks_syscall_invoke_kernel(CLKS_SYSCALL_USER_LAUNCH_OK, 0ULL, 0ULL, 0ULL));
|
||||||
|
clks_log_hex(CLKS_LOG_INFO,
|
||||||
|
"USER",
|
||||||
|
"LAUNCH_FAIL",
|
||||||
|
clks_syscall_invoke_kernel(CLKS_SYSCALL_USER_LAUNCH_FAIL, 0ULL, 0ULL, 0ULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
void clks_kernel_main(void) {
|
void clks_kernel_main(void) {
|
||||||
@@ -136,7 +162,7 @@ void clks_kernel_main(void) {
|
|||||||
clks_tty_init();
|
clks_tty_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
clks_log(CLKS_LOG_INFO, "BOOT", "CLEONOS STAGE11 START");
|
clks_log(CLKS_LOG_INFO, "BOOT", "CLEONOS STAGE12 START");
|
||||||
|
|
||||||
if (boot_fb == CLKS_NULL) {
|
if (boot_fb == CLKS_NULL) {
|
||||||
clks_log(CLKS_LOG_WARN, "VIDEO", "NO FRAMEBUFFER FROM LIMINE");
|
clks_log(CLKS_LOG_WARN, "VIDEO", "NO FRAMEBUFFER FROM LIMINE");
|
||||||
@@ -198,6 +224,8 @@ void clks_kernel_main(void) {
|
|||||||
clks_cpu_halt_forever();
|
clks_cpu_halt_forever();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clks_exec_init();
|
||||||
|
|
||||||
if (clks_userland_init() == CLKS_FALSE) {
|
if (clks_userland_init() == CLKS_FALSE) {
|
||||||
clks_log(CLKS_LOG_ERROR, "USER", "USERLAND INIT FAILED");
|
clks_log(CLKS_LOG_ERROR, "USER", "USERLAND INIT FAILED");
|
||||||
clks_cpu_halt_forever();
|
clks_cpu_halt_forever();
|
||||||
@@ -205,7 +233,6 @@ void clks_kernel_main(void) {
|
|||||||
|
|
||||||
clks_driver_init();
|
clks_driver_init();
|
||||||
clks_kelf_init();
|
clks_kelf_init();
|
||||||
clks_exec_init();
|
|
||||||
|
|
||||||
clks_scheduler_init();
|
clks_scheduler_init();
|
||||||
|
|
||||||
@@ -221,6 +248,10 @@ void clks_kernel_main(void) {
|
|||||||
clks_log(CLKS_LOG_WARN, "SCHED", "FAILED TO ADD KELFD TASK");
|
clks_log(CLKS_LOG_WARN, "SCHED", "FAILED TO ADD KELFD TASK");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (clks_scheduler_add_kernel_task_ex("usrd", 2U, clks_task_usrd) == CLKS_FALSE) {
|
||||||
|
clks_log(CLKS_LOG_WARN, "SCHED", "FAILED TO ADD USRD TASK");
|
||||||
|
}
|
||||||
|
|
||||||
sched_stats = clks_scheduler_get_stats();
|
sched_stats = clks_scheduler_get_stats();
|
||||||
clks_log_hex(CLKS_LOG_INFO, "SCHED", "TASK_COUNT", sched_stats.task_count);
|
clks_log_hex(CLKS_LOG_INFO, "SCHED", "TASK_COUNT", sched_stats.task_count);
|
||||||
|
|
||||||
@@ -240,10 +271,11 @@ void clks_kernel_main(void) {
|
|||||||
syscall_ticks = clks_syscall_invoke_kernel(CLKS_SYSCALL_TIMER_TICKS, 0ULL, 0ULL, 0ULL);
|
syscall_ticks = clks_syscall_invoke_kernel(CLKS_SYSCALL_TIMER_TICKS, 0ULL, 0ULL, 0ULL);
|
||||||
clks_log_hex(CLKS_LOG_INFO, "SYSCALL", "TICKS", syscall_ticks);
|
clks_log_hex(CLKS_LOG_INFO, "SYSCALL", "TICKS", syscall_ticks);
|
||||||
|
|
||||||
clks_stage11_syscall_probe();
|
clks_stage12_syscall_probe();
|
||||||
|
|
||||||
clks_log(CLKS_LOG_INFO, "TTY", "VIRTUAL TTY0 READY");
|
clks_log(CLKS_LOG_INFO, "TTY", "VIRTUAL TTY0 READY");
|
||||||
clks_log(CLKS_LOG_DEBUG, "KERNEL", "IDLE LOOP ENTER");
|
clks_log(CLKS_LOG_DEBUG, "KERNEL", "IDLE LOOP ENTER");
|
||||||
|
|
||||||
clks_cpu_halt_forever();
|
clks_cpu_halt_forever();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <clks/service.h>
|
#include <clks/service.h>
|
||||||
#include <clks/string.h>
|
#include <clks/string.h>
|
||||||
#include <clks/types.h>
|
#include <clks/types.h>
|
||||||
|
#include <clks/userland.h>
|
||||||
|
|
||||||
#define CLKS_SERVICE_MAX 8U
|
#define CLKS_SERVICE_MAX 8U
|
||||||
|
|
||||||
@@ -84,6 +85,9 @@ void clks_service_init(void) {
|
|||||||
clks_service_register(CLKS_SERVICE_KELF,
|
clks_service_register(CLKS_SERVICE_KELF,
|
||||||
"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,
|
||||||
|
"userland",
|
||||||
|
(clks_userland_shell_ready() == CLKS_TRUE) ? CLKS_SERVICE_STATE_READY : 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());
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <clks/string.h>
|
#include <clks/string.h>
|
||||||
#include <clks/syscall.h>
|
#include <clks/syscall.h>
|
||||||
#include <clks/types.h>
|
#include <clks/types.h>
|
||||||
|
#include <clks/userland.h>
|
||||||
|
|
||||||
#define CLKS_SYSCALL_LOG_MAX_LEN 191U
|
#define CLKS_SYSCALL_LOG_MAX_LEN 191U
|
||||||
#define CLKS_SYSCALL_PATH_MAX 192U
|
#define CLKS_SYSCALL_PATH_MAX 192U
|
||||||
@@ -209,6 +210,16 @@ u64 clks_syscall_dispatch(void *frame_ptr) {
|
|||||||
return clks_exec_request_count();
|
return clks_exec_request_count();
|
||||||
case CLKS_SYSCALL_EXEC_SUCCESS:
|
case CLKS_SYSCALL_EXEC_SUCCESS:
|
||||||
return clks_exec_success_count();
|
return clks_exec_success_count();
|
||||||
|
case CLKS_SYSCALL_USER_SHELL_READY:
|
||||||
|
return (clks_userland_shell_ready() == CLKS_TRUE) ? 1ULL : 0ULL;
|
||||||
|
case CLKS_SYSCALL_USER_EXEC_REQUESTED:
|
||||||
|
return (clks_userland_shell_exec_requested() == CLKS_TRUE) ? 1ULL : 0ULL;
|
||||||
|
case CLKS_SYSCALL_USER_LAUNCH_TRIES:
|
||||||
|
return clks_userland_launch_attempts();
|
||||||
|
case CLKS_SYSCALL_USER_LAUNCH_OK:
|
||||||
|
return clks_userland_launch_success();
|
||||||
|
case CLKS_SYSCALL_USER_LAUNCH_FAIL:
|
||||||
|
return clks_userland_launch_failures();
|
||||||
default:
|
default:
|
||||||
return (u64)-1;
|
return (u64)-1;
|
||||||
}
|
}
|
||||||
@@ -225,4 +236,4 @@ u64 clks_syscall_invoke_kernel(u64 id, u64 arg0, u64 arg1, u64 arg2) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
#include <clks/elf64.h>
|
#include <clks/elf64.h>
|
||||||
|
#include <clks/exec.h>
|
||||||
#include <clks/fs.h>
|
#include <clks/fs.h>
|
||||||
#include <clks/log.h>
|
#include <clks/log.h>
|
||||||
#include <clks/types.h>
|
#include <clks/types.h>
|
||||||
#include <clks/userland.h>
|
#include <clks/userland.h>
|
||||||
|
|
||||||
|
#define CLKS_USERLAND_RETRY_INTERVAL 500ULL
|
||||||
|
|
||||||
|
static clks_bool clks_user_shell_ready = CLKS_FALSE;
|
||||||
|
static clks_bool clks_user_shell_exec_requested_flag = CLKS_FALSE;
|
||||||
|
static u64 clks_user_launch_attempt_count = 0ULL;
|
||||||
|
static u64 clks_user_launch_success_count = 0ULL;
|
||||||
|
static u64 clks_user_launch_fail_count = 0ULL;
|
||||||
|
static u64 clks_user_last_try_tick = 0ULL;
|
||||||
|
|
||||||
static clks_bool clks_userland_probe_elf(const char *path, const char *tag) {
|
static clks_bool clks_userland_probe_elf(const char *path, const char *tag) {
|
||||||
const void *image;
|
const void *image;
|
||||||
u64 size = 0ULL;
|
u64 size = 0ULL;
|
||||||
@@ -29,13 +39,44 @@ static clks_bool clks_userland_probe_elf(const char *path, const char *tag) {
|
|||||||
return CLKS_TRUE;
|
return CLKS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static clks_bool clks_userland_request_shell_exec(void) {
|
||||||
|
u64 status = (u64)-1;
|
||||||
|
|
||||||
|
if (clks_user_shell_ready == CLKS_FALSE) {
|
||||||
|
return CLKS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
clks_user_launch_attempt_count++;
|
||||||
|
|
||||||
|
if (clks_exec_run_path("/shell/shell.elf", &status) == CLKS_TRUE && status == 0ULL) {
|
||||||
|
clks_user_shell_exec_requested_flag = CLKS_TRUE;
|
||||||
|
clks_user_launch_success_count++;
|
||||||
|
|
||||||
|
clks_log(CLKS_LOG_INFO, "USER", "SHELL EXEC REQUESTED");
|
||||||
|
clks_log_hex(CLKS_LOG_INFO, "USER", "SHELL_STATUS", status);
|
||||||
|
return CLKS_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
clks_user_launch_fail_count++;
|
||||||
|
clks_log(CLKS_LOG_WARN, "USER", "SHELL EXEC REQUEST FAILED");
|
||||||
|
return CLKS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
clks_bool clks_userland_init(void) {
|
clks_bool clks_userland_init(void) {
|
||||||
clks_log(CLKS_LOG_INFO, "USER", "USERLAND FRAMEWORK ONLINE");
|
clks_log(CLKS_LOG_INFO, "USER", "USERLAND FRAMEWORK ONLINE");
|
||||||
|
|
||||||
|
clks_user_shell_ready = CLKS_FALSE;
|
||||||
|
clks_user_shell_exec_requested_flag = CLKS_FALSE;
|
||||||
|
clks_user_launch_attempt_count = 0ULL;
|
||||||
|
clks_user_launch_success_count = 0ULL;
|
||||||
|
clks_user_launch_fail_count = 0ULL;
|
||||||
|
clks_user_last_try_tick = 0ULL;
|
||||||
|
|
||||||
if (clks_userland_probe_elf("/shell/shell.elf", "SHELL ELF READY") == CLKS_FALSE) {
|
if (clks_userland_probe_elf("/shell/shell.elf", "SHELL ELF READY") == CLKS_FALSE) {
|
||||||
return CLKS_FALSE;
|
return CLKS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clks_user_shell_ready = CLKS_TRUE;
|
||||||
clks_log(CLKS_LOG_INFO, "USER", "SHELL COMMAND ABI READY");
|
clks_log(CLKS_LOG_INFO, "USER", "SHELL COMMAND ABI READY");
|
||||||
|
|
||||||
if (clks_userland_probe_elf("/system/elfrunner.elf", "ELFRUNNER ELF READY") == CLKS_FALSE) {
|
if (clks_userland_probe_elf("/system/elfrunner.elf", "ELFRUNNER ELF READY") == CLKS_FALSE) {
|
||||||
@@ -46,5 +87,39 @@ clks_bool clks_userland_init(void) {
|
|||||||
return CLKS_FALSE;
|
return CLKS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(void)clks_userland_request_shell_exec();
|
||||||
return CLKS_TRUE;
|
return CLKS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clks_userland_tick(u64 tick) {
|
||||||
|
if (clks_user_shell_ready == CLKS_FALSE || clks_user_shell_exec_requested_flag == CLKS_TRUE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tick - clks_user_last_try_tick < CLKS_USERLAND_RETRY_INTERVAL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
clks_user_last_try_tick = tick;
|
||||||
|
(void)clks_userland_request_shell_exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
clks_bool clks_userland_shell_ready(void) {
|
||||||
|
return clks_user_shell_ready;
|
||||||
|
}
|
||||||
|
|
||||||
|
clks_bool clks_userland_shell_exec_requested(void) {
|
||||||
|
return clks_user_shell_exec_requested_flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
u64 clks_userland_launch_attempts(void) {
|
||||||
|
return clks_user_launch_attempt_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
u64 clks_userland_launch_success(void) {
|
||||||
|
return clks_user_launch_success_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
u64 clks_userland_launch_failures(void) {
|
||||||
|
return clks_user_launch_fail_count;
|
||||||
|
}
|
||||||
|
|||||||
45
docs/stage12.md
Normal file
45
docs/stage12.md
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# CLeonOS Stage12
|
||||||
|
|
||||||
|
## Stage Goal
|
||||||
|
- Add user execution manager in CLKS (`userland manager`) for shell launch lifecycle.
|
||||||
|
- Connect user execution state to scheduler via a dedicated kernel task (`usrd`).
|
||||||
|
- Extend syscall ABI with user execution telemetry (`ready/requested/tries/ok/fail`).
|
||||||
|
- Expose userland status as a first-class kernel service (`CLKS_SERVICE_USER`).
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
- Kernel boots and prints `CLEONOS STAGE12 START`.
|
||||||
|
- Userland logs include:
|
||||||
|
- `USERLAND FRAMEWORK ONLINE`
|
||||||
|
- `SHELL ELF READY`
|
||||||
|
- `SHELL EXEC REQUESTED`
|
||||||
|
- Scheduler task count increases by one (`usrd` added).
|
||||||
|
- Service framework includes USER service (service count increases).
|
||||||
|
- Stage12 syscall probe logs include:
|
||||||
|
- `USER SHELL_READY`
|
||||||
|
- `USER EXEC_REQUESTED`
|
||||||
|
- `USER LAUNCH_TRIES`
|
||||||
|
- `USER LAUNCH_OK`
|
||||||
|
- `USER LAUNCH_FAIL`
|
||||||
|
- System remains stable in idle loop with periodic task dispatch logs.
|
||||||
|
|
||||||
|
## Build Targets
|
||||||
|
- `make setup`
|
||||||
|
- `make userapps`
|
||||||
|
- `make iso`
|
||||||
|
- `make run`
|
||||||
|
- `make debug`
|
||||||
|
|
||||||
|
## QEMU Command
|
||||||
|
- `qemu-system-x86_64 -M q35 -m 1024M -cdrom build/CLeonOS-x86_64.iso -serial stdio`
|
||||||
|
|
||||||
|
## Common Bugs and Debugging
|
||||||
|
- USER syscall counters always 0:
|
||||||
|
- Check syscall IDs 16..20 match in kernel and user headers.
|
||||||
|
- Service count did not increase:
|
||||||
|
- Confirm `CLKS_SERVICE_USER` is registered in `clks_service_init()`.
|
||||||
|
- `SHELL EXEC REQUEST FAILED`:
|
||||||
|
- Ensure `/shell/shell.elf` exists in ramdisk and ELF inspect passes.
|
||||||
|
- `usrd` task missing:
|
||||||
|
- Verify `clks_scheduler_add_kernel_task_ex("usrd", ...)` in `kmain`.
|
||||||
|
- Boot regression after Stage12 merge:
|
||||||
|
- Re-check init order: FS -> userland init -> driver/kelf/exec -> scheduler -> service -> interrupts.
|
||||||
Reference in New Issue
Block a user