mirror of
https://github.com/Leonmmcoset/cleonos.git
synced 2026-04-21 18:44:01 +00:00
试图修复bug但没成功+CLeonOS Wine
This commit is contained in:
@@ -15,6 +15,7 @@ extern u64 clks_exec_call_on_stack_x86_64(void *entry_ptr, void *stack_top);
|
||||
|
||||
static u64 clks_exec_requests = 0ULL;
|
||||
static u64 clks_exec_success = 0ULL;
|
||||
static u32 clks_exec_running_depth = 0U;
|
||||
|
||||
static clks_bool clks_exec_invoke_entry(void *entry_ptr, u64 *out_ret) {
|
||||
if (entry_ptr == CLKS_NULL || out_ret == CLKS_NULL) {
|
||||
@@ -45,6 +46,7 @@ static clks_bool clks_exec_invoke_entry(void *entry_ptr, u64 *out_ret) {
|
||||
void clks_exec_init(void) {
|
||||
clks_exec_requests = 0ULL;
|
||||
clks_exec_success = 0ULL;
|
||||
clks_exec_running_depth = 0U;
|
||||
clks_log(CLKS_LOG_INFO, "EXEC", "PATH EXEC FRAMEWORK ONLINE");
|
||||
}
|
||||
|
||||
@@ -100,12 +102,20 @@ clks_bool clks_exec_run_path(const char *path, u64 *out_status) {
|
||||
clks_log_hex(CLKS_LOG_INFO, "EXEC", "ENTRY", info.entry);
|
||||
clks_log_hex(CLKS_LOG_INFO, "EXEC", "PHNUM", (u64)info.phnum);
|
||||
|
||||
clks_exec_running_depth++;
|
||||
if (clks_exec_invoke_entry(entry_ptr, &run_ret) == CLKS_FALSE) {
|
||||
if (clks_exec_running_depth > 0U) {
|
||||
clks_exec_running_depth--;
|
||||
}
|
||||
|
||||
clks_log(CLKS_LOG_WARN, "EXEC", "EXEC RUN INVOKE FAILED");
|
||||
clks_log(CLKS_LOG_WARN, "EXEC", path);
|
||||
clks_elf64_unload(&loaded);
|
||||
return CLKS_FALSE;
|
||||
}
|
||||
if (clks_exec_running_depth > 0U) {
|
||||
clks_exec_running_depth--;
|
||||
}
|
||||
|
||||
clks_log(CLKS_LOG_INFO, "EXEC", "RUN RETURNED");
|
||||
clks_log(CLKS_LOG_INFO, "EXEC", path);
|
||||
@@ -128,3 +138,8 @@ u64 clks_exec_request_count(void) {
|
||||
u64 clks_exec_success_count(void) {
|
||||
return clks_exec_success;
|
||||
}
|
||||
|
||||
clks_bool clks_exec_is_running(void) {
|
||||
return (clks_exec_running_depth > 0U) ? CLKS_TRUE : CLKS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <clks/exec.h>
|
||||
#include <clks/keyboard.h>
|
||||
#include <clks/log.h>
|
||||
#include <clks/shell.h>
|
||||
@@ -105,6 +106,18 @@ static clks_bool clks_keyboard_shell_input_enabled(void) {
|
||||
return (clks_tty_active() == 0U) ? CLKS_TRUE : CLKS_FALSE;
|
||||
}
|
||||
|
||||
static clks_bool clks_keyboard_should_pump_shell_now(void) {
|
||||
if (clks_keyboard_shell_input_enabled() == CLKS_FALSE) {
|
||||
return CLKS_FALSE;
|
||||
}
|
||||
|
||||
if (clks_exec_is_running() == CLKS_TRUE) {
|
||||
return CLKS_FALSE;
|
||||
}
|
||||
|
||||
return CLKS_TRUE;
|
||||
}
|
||||
|
||||
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_TRUE
|
||||
@@ -174,7 +187,9 @@ void clks_keyboard_handle_scancode(u8 scancode) {
|
||||
clks_kbd_e0_prefix = CLKS_FALSE;
|
||||
|
||||
if (ext != '\0' && clks_keyboard_shell_input_enabled() == CLKS_TRUE) {
|
||||
(void)clks_keyboard_queue_push(ext);
|
||||
if (clks_keyboard_queue_push(ext) == CLKS_TRUE && clks_keyboard_should_pump_shell_now() == CLKS_TRUE) {
|
||||
clks_shell_pump_input(1U);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -202,7 +217,9 @@ void clks_keyboard_handle_scancode(u8 scancode) {
|
||||
char translated = clks_keyboard_translate_scancode(code);
|
||||
|
||||
if (translated != '\0' && clks_keyboard_shell_input_enabled() == CLKS_TRUE) {
|
||||
(void)clks_keyboard_queue_push(translated);
|
||||
if (clks_keyboard_queue_push(translated) == CLKS_TRUE && clks_keyboard_should_pump_shell_now() == CLKS_TRUE) {
|
||||
clks_shell_pump_input(1U);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@ static u64 clks_shell_cmd_total = 0ULL;
|
||||
static u64 clks_shell_cmd_ok = 0ULL;
|
||||
static u64 clks_shell_cmd_fail = 0ULL;
|
||||
static u64 clks_shell_cmd_unknown = 0ULL;
|
||||
static clks_bool clks_shell_pending_command = CLKS_FALSE;
|
||||
static char clks_shell_pending_line[CLKS_SHELL_LINE_MAX];
|
||||
|
||||
extern void clks_rusttest_hello(void);
|
||||
|
||||
@@ -1358,6 +1360,16 @@ static void clks_shell_execute_line(const char *line) {
|
||||
}
|
||||
}
|
||||
|
||||
static void clks_shell_process_pending_command(void) {
|
||||
if (clks_shell_ready == CLKS_FALSE || clks_shell_pending_command == CLKS_FALSE) {
|
||||
return;
|
||||
}
|
||||
|
||||
clks_shell_pending_command = CLKS_FALSE;
|
||||
clks_shell_execute_line(clks_shell_pending_line);
|
||||
clks_shell_pending_line[0] = '\0';
|
||||
}
|
||||
|
||||
static void clks_shell_handle_char(char ch) {
|
||||
if (ch == '\r') {
|
||||
return;
|
||||
@@ -1367,7 +1379,14 @@ static void clks_shell_handle_char(char ch) {
|
||||
clks_shell_write_char('\n');
|
||||
clks_shell_line[clks_shell_line_len] = '\0';
|
||||
clks_shell_history_push(clks_shell_line);
|
||||
clks_shell_execute_line(clks_shell_line);
|
||||
|
||||
if (clks_shell_pending_command == CLKS_FALSE) {
|
||||
clks_shell_copy_line(clks_shell_pending_line, sizeof(clks_shell_pending_line), clks_shell_line);
|
||||
clks_shell_pending_command = CLKS_TRUE;
|
||||
} else {
|
||||
clks_shell_writeln("shell: command queue busy");
|
||||
}
|
||||
|
||||
clks_shell_reset_line();
|
||||
clks_shell_history_cancel_nav();
|
||||
clks_shell_prompt();
|
||||
@@ -1496,6 +1515,8 @@ void clks_shell_init(void) {
|
||||
clks_shell_cmd_ok = 0ULL;
|
||||
clks_shell_cmd_fail = 0ULL;
|
||||
clks_shell_cmd_unknown = 0ULL;
|
||||
clks_shell_pending_command = CLKS_FALSE;
|
||||
clks_shell_pending_line[0] = '\0';
|
||||
|
||||
if (clks_tty_ready() == CLKS_FALSE) {
|
||||
clks_shell_ready = CLKS_FALSE;
|
||||
@@ -1539,5 +1560,6 @@ void clks_shell_pump_input(u32 max_chars) {
|
||||
void clks_shell_tick(u64 tick) {
|
||||
(void)tick;
|
||||
clks_shell_drain_input(CLKS_SHELL_INPUT_BUDGET);
|
||||
clks_shell_process_pending_command();
|
||||
}
|
||||
|
||||
|
||||
@@ -145,6 +145,67 @@ static void clks_tty_put_visible(u32 tty_index, u32 row, u32 col, char ch) {
|
||||
}
|
||||
}
|
||||
|
||||
static void clks_tty_put_char_raw(u32 tty_index, char ch) {
|
||||
u32 row = clks_tty_cursor_row[tty_index];
|
||||
u32 col = clks_tty_cursor_col[tty_index];
|
||||
|
||||
if (ch == '\r') {
|
||||
clks_tty_cursor_col[tty_index] = 0U;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ch == '\n') {
|
||||
clks_tty_cursor_col[tty_index] = 0U;
|
||||
clks_tty_cursor_row[tty_index]++;
|
||||
|
||||
if (clks_tty_cursor_row[tty_index] >= clks_tty_rows) {
|
||||
clks_tty_scroll_up(tty_index);
|
||||
clks_tty_cursor_row[tty_index] = clks_tty_rows - 1U;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ch == '\b') {
|
||||
if (col == 0U && row == 0U) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (col == 0U) {
|
||||
row--;
|
||||
col = clks_tty_cols - 1U;
|
||||
} else {
|
||||
col--;
|
||||
}
|
||||
|
||||
clks_tty_put_visible(tty_index, row, col, ' ');
|
||||
clks_tty_cursor_row[tty_index] = row;
|
||||
clks_tty_cursor_col[tty_index] = col;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ch == '\t') {
|
||||
clks_tty_put_char_raw(tty_index, ' ');
|
||||
clks_tty_put_char_raw(tty_index, ' ');
|
||||
clks_tty_put_char_raw(tty_index, ' ');
|
||||
clks_tty_put_char_raw(tty_index, ' ');
|
||||
return;
|
||||
}
|
||||
|
||||
clks_tty_put_visible(tty_index, row, col, ch);
|
||||
clks_tty_cursor_col[tty_index]++;
|
||||
|
||||
if (clks_tty_cursor_col[tty_index] >= clks_tty_cols) {
|
||||
clks_tty_cursor_col[tty_index] = 0U;
|
||||
clks_tty_cursor_row[tty_index]++;
|
||||
|
||||
if (clks_tty_cursor_row[tty_index] >= clks_tty_rows) {
|
||||
clks_tty_scroll_up(tty_index);
|
||||
clks_tty_cursor_row[tty_index] = clks_tty_rows - 1U;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void clks_tty_init(void) {
|
||||
struct clks_framebuffer_info info;
|
||||
u32 tty;
|
||||
@@ -202,8 +263,6 @@ void clks_tty_init(void) {
|
||||
|
||||
void clks_tty_write_char(char ch) {
|
||||
u32 tty_index;
|
||||
u32 row;
|
||||
u32 col;
|
||||
|
||||
if (clks_tty_is_ready == CLKS_FALSE) {
|
||||
return;
|
||||
@@ -212,88 +271,30 @@ void clks_tty_write_char(char ch) {
|
||||
clks_tty_hide_cursor();
|
||||
|
||||
tty_index = clks_tty_active_index;
|
||||
row = clks_tty_cursor_row[tty_index];
|
||||
col = clks_tty_cursor_col[tty_index];
|
||||
|
||||
if (ch == '\r') {
|
||||
clks_tty_cursor_col[tty_index] = 0;
|
||||
clks_tty_draw_cursor();
|
||||
clks_tty_reset_blink_timer();
|
||||
return;
|
||||
}
|
||||
|
||||
if (ch == '\n') {
|
||||
clks_tty_cursor_col[tty_index] = 0;
|
||||
clks_tty_cursor_row[tty_index]++;
|
||||
|
||||
if (clks_tty_cursor_row[tty_index] >= clks_tty_rows) {
|
||||
clks_tty_scroll_up(tty_index);
|
||||
clks_tty_cursor_row[tty_index] = clks_tty_rows - 1;
|
||||
}
|
||||
|
||||
clks_tty_draw_cursor();
|
||||
clks_tty_reset_blink_timer();
|
||||
return;
|
||||
}
|
||||
|
||||
if (ch == '\b') {
|
||||
if (col == 0U && row == 0U) {
|
||||
clks_tty_draw_cursor();
|
||||
clks_tty_reset_blink_timer();
|
||||
return;
|
||||
}
|
||||
|
||||
if (col == 0U) {
|
||||
row--;
|
||||
col = clks_tty_cols - 1U;
|
||||
} else {
|
||||
col--;
|
||||
}
|
||||
|
||||
clks_tty_put_visible(tty_index, row, col, ' ');
|
||||
clks_tty_cursor_row[tty_index] = row;
|
||||
clks_tty_cursor_col[tty_index] = col;
|
||||
clks_tty_draw_cursor();
|
||||
clks_tty_reset_blink_timer();
|
||||
return;
|
||||
}
|
||||
|
||||
if (ch == '\t') {
|
||||
clks_tty_write_char(' ');
|
||||
clks_tty_write_char(' ');
|
||||
clks_tty_write_char(' ');
|
||||
clks_tty_write_char(' ');
|
||||
return;
|
||||
}
|
||||
|
||||
clks_tty_put_visible(tty_index, row, col, ch);
|
||||
clks_tty_cursor_col[tty_index]++;
|
||||
|
||||
if (clks_tty_cursor_col[tty_index] >= clks_tty_cols) {
|
||||
clks_tty_cursor_col[tty_index] = 0;
|
||||
clks_tty_cursor_row[tty_index]++;
|
||||
|
||||
if (clks_tty_cursor_row[tty_index] >= clks_tty_rows) {
|
||||
clks_tty_scroll_up(tty_index);
|
||||
clks_tty_cursor_row[tty_index] = clks_tty_rows - 1;
|
||||
}
|
||||
}
|
||||
clks_tty_put_char_raw(tty_index, ch);
|
||||
|
||||
clks_tty_draw_cursor();
|
||||
clks_tty_reset_blink_timer();
|
||||
}
|
||||
|
||||
void clks_tty_write(const char *text) {
|
||||
usize i = 0;
|
||||
usize i = 0U;
|
||||
u32 tty_index;
|
||||
|
||||
if (clks_tty_is_ready == CLKS_FALSE) {
|
||||
if (clks_tty_is_ready == CLKS_FALSE || text == CLKS_NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
clks_tty_hide_cursor();
|
||||
tty_index = clks_tty_active_index;
|
||||
|
||||
while (text[i] != '\0') {
|
||||
clks_tty_write_char(text[i]);
|
||||
clks_tty_put_char_raw(tty_index, text[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
clks_tty_draw_cursor();
|
||||
clks_tty_reset_blink_timer();
|
||||
}
|
||||
|
||||
void clks_tty_switch(u32 tty_index) {
|
||||
@@ -360,4 +361,4 @@ u32 clks_tty_count(void) {
|
||||
|
||||
clks_bool clks_tty_ready(void) {
|
||||
return clks_tty_is_ready;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user