Compare commits
6 Commits
99cd492570
...
ce905f1a36
Author | SHA1 | Date |
---|---|---|
antifallobst | ce905f1a36 | |
antifallobst | 1101b83939 | |
antifallobst | 18a0fc3eb7 | |
antifallobst | d493ebc64f | |
antifallobst | 0c084d00c0 | |
antifallobst | ddc47b3ea3 |
|
@ -0,0 +1,39 @@
|
||||||
|
#include "nox/stdio.h"
|
||||||
|
|
||||||
|
#define COMMAND_BUFFER_SIZE 512
|
||||||
|
|
||||||
|
int read_command(char* command_buffer) {
|
||||||
|
char chr = 0;
|
||||||
|
int pos = 0;
|
||||||
|
while (chr != '\n') {
|
||||||
|
chr = getc();
|
||||||
|
switch (chr) {
|
||||||
|
case '\b': {
|
||||||
|
if (pos > 0) pos--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
if (pos < COMMAND_BUFFER_SIZE) {
|
||||||
|
command_buffer[pos] = chr;
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
command_buffer[pos] = '\0';
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _start() {
|
||||||
|
printf("Welcome to the nox shell.\ntype 'help' for a list of commands\n");
|
||||||
|
|
||||||
|
bool running = true;
|
||||||
|
|
||||||
|
while(running) {
|
||||||
|
printf("\n>>> ");
|
||||||
|
char command_buffer[COMMAND_BUFFER_SIZE];
|
||||||
|
read_command(command_buffer);
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
|
@ -64,7 +64,7 @@ void kmain(boot_info_T boot_info) {
|
||||||
|
|
||||||
log(LOG_INFO, "!=====[ Kernel Initialized ]=====!\n");
|
log(LOG_INFO, "!=====[ Kernel Initialized ]=====!\n");
|
||||||
|
|
||||||
void* buffer = vfs_resolve_path(&g_root_fs, "/initrd/test.elf")->cache->buffer;
|
void* buffer = vfs_resolve_path(&g_root_fs, "/initrd/shell.elf")->cache->buffer;
|
||||||
elf_executable_T* exec = elf_executable_create(buffer);
|
elf_executable_T* exec = elf_executable_create(buffer);
|
||||||
pid_t proc = process_spawn(PROCESS_KERNEL, "shell", exec, buffer);
|
pid_t proc = process_spawn(PROCESS_KERNEL, "shell", exec, buffer);
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,15 @@ position_T graphics_buffer_draw_string(graphics_buffer_T* graphics_buffer, uint3
|
||||||
position_T pos = (position_T){x, y};
|
position_T pos = (position_T){x, y};
|
||||||
uint64_t strlen = string_length(string);
|
uint64_t strlen = string_length(string);
|
||||||
for (int i = 0; i < strlen; i++) {
|
for (int i = 0; i < strlen; i++) {
|
||||||
|
if (pos.x + g_renderer.font.width >= graphics_buffer->width) {
|
||||||
|
pos.x = 0;
|
||||||
|
pos.y += g_renderer.font.height;
|
||||||
|
}
|
||||||
|
if (pos.y + g_renderer.font.height >= graphics_buffer->height) {
|
||||||
|
pos.y -= g_renderer.font.height;
|
||||||
|
graphics_buffer_shift_up(graphics_buffer, g_renderer.font.height);
|
||||||
|
}
|
||||||
|
|
||||||
switch (string[i]) {
|
switch (string[i]) {
|
||||||
case '\n': {
|
case '\n': {
|
||||||
pos.x = 0;
|
pos.x = 0;
|
||||||
|
@ -122,14 +131,6 @@ position_T graphics_buffer_draw_string(graphics_buffer_T* graphics_buffer, uint3
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
if (pos.x + g_renderer.font.width >= graphics_buffer->width) {
|
|
||||||
pos.x = 0;
|
|
||||||
pos.y += g_renderer.font.height;
|
|
||||||
}
|
|
||||||
if (pos.y + g_renderer.font.height >= graphics_buffer->height) {
|
|
||||||
pos.y -= g_renderer.font.height;
|
|
||||||
graphics_buffer_shift_up(graphics_buffer, g_renderer.font.height);
|
|
||||||
}
|
|
||||||
graphics_buffer_draw_char(graphics_buffer, pos.x, pos.y, color, string[i]);
|
graphics_buffer_draw_char(graphics_buffer, pos.x, pos.y, color, string[i]);
|
||||||
pos.x += g_renderer.font.width;
|
pos.x += g_renderer.font.width;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -50,6 +50,7 @@ void syscall_handle_nx_fread(cpu_state_T* state) {
|
||||||
|
|
||||||
case FILE_DESCRIPTOR_STDIN: {
|
case FILE_DESCRIPTOR_STDIN: {
|
||||||
read_bytes = pipe_read(&process->stdin, mem, n);
|
read_bytes = pipe_read(&process->stdin, mem, n);
|
||||||
|
state->rax = STATUS_SUCCESS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +89,6 @@ void syscall_handle_nx_fwrite(cpu_state_T* state) {
|
||||||
written_bytes = pipe_write(process->stderr, mem, n);
|
written_bytes = pipe_write(process->stderr, mem, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
log(LOG_DEBUG, "Syscall (nx_fwrite) to stderr: %s", mem);
|
|
||||||
state->rax = STATUS_SUCCESS;
|
state->rax = STATUS_SUCCESS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,6 @@ void syscall_handle_nx_fwrite(cpu_state_T* state) {
|
||||||
written_bytes = pipe_write(process->stdout, mem, n);
|
written_bytes = pipe_write(process->stdout, mem, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
log(LOG_DEBUG, "Syscall (nx_fwrite) to stdout: %s", mem);
|
|
||||||
state->rax = STATUS_SUCCESS;
|
state->rax = STATUS_SUCCESS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,8 +93,8 @@ void scheduler_queue_remove_thread(thread_T* thread) {
|
||||||
|
|
||||||
thread->global_prev->global_next = thread->global_next;
|
thread->global_prev->global_next = thread->global_next;
|
||||||
thread->global_next->global_prev = thread->global_prev;
|
thread->global_next->global_prev = thread->global_prev;
|
||||||
thread->global_prev = NULL;
|
// thread->global_prev = NULL;
|
||||||
thread->global_next = NULL;
|
// thread->global_next = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_T* scheduler_register_thread(thread_T* thread) {
|
thread_T* scheduler_register_thread(thread_T* thread) {
|
||||||
|
|
|
@ -20,8 +20,6 @@ void stream_destruct(stream_T* stream) {
|
||||||
memory_free(stream);
|
memory_free(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "utils/logger.h"
|
|
||||||
|
|
||||||
uint32_t stream_write(stream_T* stream, void* buffer_in, uint32_t n) {
|
uint32_t stream_write(stream_T* stream, void* buffer_in, uint32_t n) {
|
||||||
uint32_t num_top;
|
uint32_t num_top;
|
||||||
uint32_t num_bottom;
|
uint32_t num_bottom;
|
||||||
|
@ -43,6 +41,8 @@ uint32_t stream_write(stream_T* stream, void* buffer_in, uint32_t n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t stream_read(stream_T* stream, void* buffer_out, uint32_t n) {
|
uint32_t stream_read(stream_T* stream, void* buffer_out, uint32_t n) {
|
||||||
|
if (stream->pos_sender == stream->pos_receiver) return 0;
|
||||||
|
|
||||||
uint32_t num_top;
|
uint32_t num_top;
|
||||||
uint32_t num_bottom;
|
uint32_t num_bottom;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue