Compare commits

..

No commits in common. "ce905f1a36b7c9f7ad09ebb5676cf6f9fad37e81" and "99cd4925705bc51c6c456ee2e68fbdbdb9742ea0" have entirely different histories.

7 changed files with 15 additions and 54 deletions

View File

@ -1,39 +0,0 @@
#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.

View File

@ -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/shell.elf")->cache->buffer; void* buffer = vfs_resolve_path(&g_root_fs, "/initrd/test.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);

View File

@ -99,15 +99,6 @@ 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;
@ -131,6 +122,14 @@ 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;

View File

@ -50,7 +50,6 @@ 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;
} }
@ -89,6 +88,7 @@ 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,6 +98,7 @@ 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;
} }

View File

@ -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) {

View File

@ -20,6 +20,8 @@ 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;
@ -41,8 +43,6 @@ 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;