Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

Commit

Permalink
Added simple TTY support
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinAlavik committed Mar 25, 2024
1 parent a38a439 commit 655f42a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 19 deletions.
12 changes: 6 additions & 6 deletions arch/x86_64/cpu/panic.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@

void panic(const char *reason, int_frame_t frame)
{
printf("\t* %s\n\n", reason);
printf("\n\n* %s\n\n", reason);

printf("\trax: 0x%.16llX, rbx: 0x%.16llX, rcx: 0x%.16llX, rdx: 0x%.16llX\n",
printf("rax: 0x%.16llX, rbx: 0x%.16llX, rcx: 0x%.16llX, rdx: 0x%.16llX\n",
frame.rax, frame.rbx, frame.rcx, frame.rdx);

printf("\trsp: 0x%.16llX, rbp: 0x%.16llX, rsi: 0x%.16llX, rdi: 0x%.16llX\n",
printf("rsp: 0x%.16llX, rbp: 0x%.16llX, rsi: 0x%.16llX, rdi: 0x%.16llX\n",
frame.rsp, frame.rbp, frame.rsi, frame.rdi);

printf("\tr8: 0x%.16llX, r9: 0x%.16llX, r10: 0x%.16llX, r11: 0x%.16llX\n",
printf("r8: 0x%.16llX, r9: 0x%.16llX, r10: 0x%.16llX, r11: 0x%.16llX\n",
frame.r8, frame.r9, frame.r10, frame.r11);

printf("\tr12: 0x%.16llX, r13: 0x%.16llX, r14: 0x%.16llX, r15: 0x%.16llX\n",
printf("r12: 0x%.16llX, r13: 0x%.16llX, r14: 0x%.16llX, r15: 0x%.16llX\n",
frame.r12, frame.r13, frame.r14, frame.r15);

printf("\trfl: 0x%.16llX, rip: 0x%.16llX, cs: 0x%.16llX, ss: 0x%.16llX\n",
printf("rfl: 0x%.16llX, rip: 0x%.16llX, cs: 0x%.16llX, ss: 0x%.16llX\n",
frame.rflags, frame.rip, frame.cs, frame.ss);

dprintf("[\e[0;31mKernel Panic\e[0m] rax: 0x%.16llX, rbx: 0x%.16llX, rcx: "
Expand Down
1 change: 1 addition & 0 deletions initrd/usr/share/paradox/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.69.420-dev
8 changes: 4 additions & 4 deletions kernel/entry/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ void init_boot(int debug_info)
else if (kstatus == KERNEL_QUIT_ERROR)
{
dprintf(
"[\e[0;32mKernel Error] A kernel error occured, check kmesg for rason! "
"[\e[0;32mKernel Error\e[0m] A kernel error occured, check kmesg for reason! "
"Rebooting...\n");
reboot();
}
else if (kstatus == KERNEL_QUIT_PANIC)
{
panic("[Kernel Panic] Kernel quit with a critical error code, please see "
panic("[\e[0;32mKernel Panic\e[0m] Kernel quit with a critical error code, please see "
"kmsg for extra info.\n",
*cur_frame);
dprintf(
"[\e[0;32mKernel\e[0m Panic] Kernel quit with a critical error code, "
"[\e[0;32mKernel Panic\e[0m] Kernel quit with a critical error code, "
"the kernel "
"process returned with a 2 that means something went really wrong, "
"and we are shutting down your computer in 10 seconds!\n");
Expand All @@ -103,7 +103,7 @@ void init_boot(int debug_info)
}
else
{
dprintf("[\e[0;32mKernel\e[0m Warning] Kernel returned %d\n", kstatus);
dprintf("[\e[0;32mKernel Warning\e[0m] Kernel returned %d\n", kstatus);
}

// If we reach this point, something unexpected happened
Expand Down
12 changes: 6 additions & 6 deletions kernel/entry/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ return codes)
#include <transform.h>
#include <vector.h>

void test()
void terminal_launch()
{
printf("Hello from PID 0!\n");
tty_spawn(1, "/usr/share/fonts/Uni3-Terminus20x10.psf");
printf("Paradox 1.4.1-dev (tty1)\n\n");
keyboard.out = true;
}

int main()
{
keyboard.out = false;
tty_spawn(0);
tty_spawn(0, "/usr/share/fonts/Uni3-Terminus12x6.psf");
register_pci();
pit_sleep(1000);
tty_spawn(1);
printf("local @ tty1\n");
terminal_launch();
return KERNEL_QUIT_HANG;
}
4 changes: 2 additions & 2 deletions kernel/tty/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void tty_flush() {
nighterm_set_cursor_position(cur_tty->context, 0, 0);
}

int tty_spawn(uint8_t id)
int tty_spawn(uint8_t id, char* font_path)
{
if(ttys[id] != NULL)
return 1;
Expand All @@ -29,7 +29,7 @@ int tty_spawn(uint8_t id)
return 4;

char *font_data;
vfs_op_status status = driver_read(vfs_b, 0x00000000, "/usr/share/fonts/Uni3-Terminus12x6.psf", &font_data);
vfs_op_status status = driver_read(vfs_b, 0x00000000, font_path, &font_data);

if (status != STATUS_OK) {
free(context);
Expand Down
2 changes: 1 addition & 1 deletion kernel/tty/tty.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ typedef struct {
extern tty* ttys[MAX_TTYS];

void tty_init(VFS_t *vfs, struct limine_framebuffer *framebuffer);
int tty_spawn(uint8_t id);
int tty_spawn(uint8_t id, char* font_path);
int tty_destroy(uint8_t id);

void tty_switch(uint8_t id);
Expand Down

0 comments on commit 655f42a

Please sign in to comment.