mirror of
https://github.com/Leonmmcoset/cleonos.git
synced 2026-04-21 10:40:00 +00:00
Stage 14
This commit is contained in:
@@ -27,6 +27,9 @@ typedef unsigned long long usize;
|
||||
#define CLEONOS_SYSCALL_USER_LAUNCH_TRIES 18ULL
|
||||
#define CLEONOS_SYSCALL_USER_LAUNCH_OK 19ULL
|
||||
#define CLEONOS_SYSCALL_USER_LAUNCH_FAIL 20ULL
|
||||
#define CLEONOS_SYSCALL_TTY_COUNT 21ULL
|
||||
#define CLEONOS_SYSCALL_TTY_ACTIVE 22ULL
|
||||
#define CLEONOS_SYSCALL_TTY_SWITCH 23ULL
|
||||
|
||||
u64 cleonos_syscall(u64 id, u64 arg0, u64 arg1, u64 arg2);
|
||||
u64 cleonos_sys_log_write(const char *message, u64 length);
|
||||
@@ -49,5 +52,9 @@ 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);
|
||||
u64 cleonos_sys_tty_count(void);
|
||||
u64 cleonos_sys_tty_active(void);
|
||||
u64 cleonos_sys_tty_switch(u64 tty_index);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -92,3 +92,16 @@ u64 cleonos_sys_user_launch_ok(void) {
|
||||
u64 cleonos_sys_user_launch_fail(void) {
|
||||
return cleonos_syscall(CLEONOS_SYSCALL_USER_LAUNCH_FAIL, 0ULL, 0ULL, 0ULL);
|
||||
}
|
||||
|
||||
u64 cleonos_sys_tty_count(void) {
|
||||
return cleonos_syscall(CLEONOS_SYSCALL_TTY_COUNT, 0ULL, 0ULL, 0ULL);
|
||||
}
|
||||
|
||||
u64 cleonos_sys_tty_active(void) {
|
||||
return cleonos_syscall(CLEONOS_SYSCALL_TTY_ACTIVE, 0ULL, 0ULL, 0ULL);
|
||||
}
|
||||
|
||||
u64 cleonos_sys_tty_switch(u64 tty_index) {
|
||||
return cleonos_syscall(CLEONOS_SYSCALL_TTY_SWITCH, tty_index, 0ULL, 0ULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,13 @@
|
||||
#define CLKS_SYSCALL_USER_LAUNCH_TRIES 18ULL
|
||||
#define CLKS_SYSCALL_USER_LAUNCH_OK 19ULL
|
||||
#define CLKS_SYSCALL_USER_LAUNCH_FAIL 20ULL
|
||||
#define CLKS_SYSCALL_TTY_COUNT 21ULL
|
||||
#define CLKS_SYSCALL_TTY_ACTIVE 22ULL
|
||||
#define CLKS_SYSCALL_TTY_SWITCH 23ULL
|
||||
|
||||
void clks_syscall_init(void);
|
||||
u64 clks_syscall_dispatch(void *frame_ptr);
|
||||
u64 clks_syscall_invoke_kernel(u64 id, u64 arg0, u64 arg1, u64 arg2);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -8,5 +8,8 @@ void clks_tty_write(const char *text);
|
||||
void clks_tty_write_char(char ch);
|
||||
void clks_tty_switch(u32 tty_index);
|
||||
u32 clks_tty_active(void);
|
||||
u32 clks_tty_count(void);
|
||||
clks_bool clks_tty_ready(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ static void clks_task_usrd(u64 tick) {
|
||||
clks_userland_tick(tick);
|
||||
}
|
||||
|
||||
static void clks_stage13_syscall_probe(void) {
|
||||
static void clks_stage14_syscall_probe(void) {
|
||||
char child_name[96];
|
||||
char read_buf[160];
|
||||
u64 root_children;
|
||||
@@ -135,8 +135,16 @@ static void clks_stage13_syscall_probe(void) {
|
||||
"USER",
|
||||
"LAUNCH_FAIL",
|
||||
clks_syscall_invoke_kernel(CLKS_SYSCALL_USER_LAUNCH_FAIL, 0ULL, 0ULL, 0ULL));
|
||||
}
|
||||
|
||||
clks_log_hex(CLKS_LOG_INFO,
|
||||
"TTY",
|
||||
"COUNT",
|
||||
clks_syscall_invoke_kernel(CLKS_SYSCALL_TTY_COUNT, 0ULL, 0ULL, 0ULL));
|
||||
clks_log_hex(CLKS_LOG_INFO,
|
||||
"TTY",
|
||||
"ACTIVE",
|
||||
clks_syscall_invoke_kernel(CLKS_SYSCALL_TTY_ACTIVE, 0ULL, 0ULL, 0ULL));
|
||||
}
|
||||
void clks_kernel_main(void) {
|
||||
const struct limine_framebuffer *boot_fb;
|
||||
const struct limine_memmap_response *boot_memmap;
|
||||
@@ -162,7 +170,7 @@ void clks_kernel_main(void) {
|
||||
clks_tty_init();
|
||||
}
|
||||
|
||||
clks_log(CLKS_LOG_INFO, "BOOT", "CLEONOS STAGE13 START");
|
||||
clks_log(CLKS_LOG_INFO, "BOOT", "CLEONOS STAGE14 START");
|
||||
|
||||
if (boot_fb == CLKS_NULL) {
|
||||
clks_log(CLKS_LOG_WARN, "VIDEO", "NO FRAMEBUFFER FROM LIMINE");
|
||||
@@ -271,7 +279,7 @@ void clks_kernel_main(void) {
|
||||
syscall_ticks = clks_syscall_invoke_kernel(CLKS_SYSCALL_TIMER_TICKS, 0ULL, 0ULL, 0ULL);
|
||||
clks_log_hex(CLKS_LOG_INFO, "SYSCALL", "TICKS", syscall_ticks);
|
||||
|
||||
clks_stage13_syscall_probe();
|
||||
clks_stage14_syscall_probe();
|
||||
|
||||
clks_log(CLKS_LOG_INFO, "TTY", "VIRTUAL TTY0 READY");
|
||||
clks_log(CLKS_LOG_DEBUG, "KERNEL", "IDLE LOOP ENTER");
|
||||
@@ -279,4 +287,3 @@ void clks_kernel_main(void) {
|
||||
clks_cpu_halt_forever();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <clks/service.h>
|
||||
#include <clks/string.h>
|
||||
#include <clks/syscall.h>
|
||||
#include <clks/tty.h>
|
||||
#include <clks/types.h>
|
||||
#include <clks/userland.h>
|
||||
|
||||
@@ -220,6 +221,13 @@ u64 clks_syscall_dispatch(void *frame_ptr) {
|
||||
return clks_userland_launch_success();
|
||||
case CLKS_SYSCALL_USER_LAUNCH_FAIL:
|
||||
return clks_userland_launch_failures();
|
||||
case CLKS_SYSCALL_TTY_COUNT:
|
||||
return (u64)clks_tty_count();
|
||||
case CLKS_SYSCALL_TTY_ACTIVE:
|
||||
return (u64)clks_tty_active();
|
||||
case CLKS_SYSCALL_TTY_SWITCH:
|
||||
clks_tty_switch((u32)frame->rbx);
|
||||
return (u64)clks_tty_active();
|
||||
default:
|
||||
return (u64)-1;
|
||||
}
|
||||
@@ -237,3 +245,4 @@ u64 clks_syscall_invoke_kernel(u64 id, u64 arg0, u64 arg1, u64 arg2) {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -192,3 +192,11 @@ void clks_tty_switch(u32 tty_index) {
|
||||
u32 clks_tty_active(void) {
|
||||
return clks_tty_active_index;
|
||||
}
|
||||
u32 clks_tty_count(void) {
|
||||
return CLKS_TTY_COUNT;
|
||||
}
|
||||
|
||||
clks_bool clks_tty_ready(void) {
|
||||
return clks_tty_is_ready;
|
||||
}
|
||||
|
||||
|
||||
51
docs/stage14.md
Normal file
51
docs/stage14.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# CLeonOS Stage14
|
||||
|
||||
## Stage Goal
|
||||
- Pause risky ELF runtime expansion and prioritize non-ELF core capability.
|
||||
- Expose virtual TTY manager controls through syscall ABI.
|
||||
- Keep Stage13 boot flow stable while adding TTY observability and control hooks.
|
||||
|
||||
## What Was Added
|
||||
- New kernel syscalls:
|
||||
- `CLKS_SYSCALL_TTY_COUNT` (21)
|
||||
- `CLKS_SYSCALL_TTY_ACTIVE` (22)
|
||||
- `CLKS_SYSCALL_TTY_SWITCH` (23)
|
||||
- New TTY kernel API exports:
|
||||
- `clks_tty_count()`
|
||||
- `clks_tty_ready()`
|
||||
- New user C wrappers:
|
||||
- `cleonos_sys_tty_count()`
|
||||
- `cleonos_sys_tty_active()`
|
||||
- `cleonos_sys_tty_switch(u64 tty_index)`
|
||||
- Boot probe now logs TTY syscall status (`COUNT` and `ACTIVE`).
|
||||
|
||||
## Acceptance Criteria
|
||||
- Kernel boots and prints `CLEONOS STAGE14 START`.
|
||||
- Syscall framework remains online (`INT80 FRAMEWORK ONLINE`).
|
||||
- Probe logs include:
|
||||
- `[INFO][TTY] COUNT: 0X...`
|
||||
- `[INFO][TTY] ACTIVE: 0X...`
|
||||
- No regression in existing scheduler/service/FS/driver initialization sequence.
|
||||
|
||||
## 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
|
||||
- TTY syscall value always `-1`:
|
||||
- Check kernel/user syscall ID tables are aligned.
|
||||
- `TTY_ACTIVE` never changes after switch:
|
||||
- Validate `clks_tty_switch()` receives index `< clks_tty_count()`.
|
||||
- Missing TTY probe logs:
|
||||
- Ensure `clks_stage14_syscall_probe()` is still called after `clks_syscall_init()` and `clks_interrupts_init()`.
|
||||
- Build fails with undeclared syscall IDs:
|
||||
- Rebuild after syncing both headers:
|
||||
- `clks/include/clks/syscall.h`
|
||||
- `cleonos/c/include/cleonos_syscall.h`
|
||||
|
||||
Reference in New Issue
Block a user