diff --git a/include/acpi.h b/include/acpi.h index 429977a..015c6e2 100644 --- a/include/acpi.h +++ b/include/acpi.h @@ -1,5 +1,5 @@ -#ifndef ACPI_H_ -#define ACPI_H_ +#ifndef RK_ACPI_H_ +#define RK_ACPI_H_ #include diff --git a/include/gdt.h b/include/gdt.h index d7094e7..d12b650 100644 --- a/include/gdt.h +++ b/include/gdt.h @@ -1,5 +1,5 @@ -#ifndef GDT_H_ -#define GDT_H_ +#ifndef RK_GDT_H_ +#define RK_GDT_H_ #define GDT_NULL 0 #define GDT_KERNEL_CODE 1 diff --git a/include/ide.h b/include/ide.h index 926aa0c..603c746 100644 --- a/include/ide.h +++ b/include/ide.h @@ -1,5 +1,5 @@ -#ifndef IDE_H_ -#define IDE_H_ +#ifndef RK_IDE_H_ +#define RK_IDE_H_ enum IDE_MODE { ISA_ONLY = 0x00, diff --git a/include/idt.h b/include/idt.h index 8bf634b..d493ef4 100644 --- a/include/idt.h +++ b/include/idt.h @@ -1,5 +1,5 @@ -#ifndef ANDEWOS_IDT_H_ -#define ANDEWOS_IDT_H_ +#ifndef RK_IDT_H_ +#define RK_IDT_H_ #include diff --git a/include/io.h b/include/io.h index 62474ca..27ac7f2 100644 --- a/include/io.h +++ b/include/io.h @@ -1,5 +1,5 @@ -#ifndef IO_H_ -#define IO_H_ +#ifndef RK_IO_H_ +#define RK_IO_H_ #include diff --git a/include/multiboot.h b/include/multiboot.h index aca2ecf..c1e83f3 100644 --- a/include/multiboot.h +++ b/include/multiboot.h @@ -1,5 +1,5 @@ -#ifndef MULTIBOOT_H_ -#define MULTIBOOT_H_ +#ifndef RK_MULTIBOOT_H_ +#define RK_MULTIBOOT_H_ #include diff --git a/include/pci.h b/include/pci.h index 789cf93..3611004 100644 --- a/include/pci.h +++ b/include/pci.h @@ -1,5 +1,5 @@ -#ifndef PCI_H_ -#define PCI_H_ +#ifndef RK_PCI_H_ +#define RK_PCI_H_ #include #include diff --git a/include/pic8259.h b/include/pic8259.h index f3f0298..a2e78e0 100644 --- a/include/pic8259.h +++ b/include/pic8259.h @@ -1,5 +1,5 @@ -#ifndef ANDEWOS_PIC8259_H -#define ANDEWOS_PIC8259_H +#ifndef RK_PIC8259_H +#define RK_PIC8259_H #define PIC_1_COMMAND 0x20 #define PIC_2_COMMAND 0xA0 diff --git a/include/ps2.h b/include/ps2.h index abcbc39..bea23a4 100644 --- a/include/ps2.h +++ b/include/ps2.h @@ -1,5 +1,5 @@ -#ifndef ANDEWOS_PS2_H -#define ANDEWOS_PS2_H +#ifndef RK_PS2_H +#define RK_PS2_H #define PS2_8042_DATA 0x60 #define PS2_8042_STATUS 0x64 diff --git a/include/vga.h b/include/vga.h index 5a6a2c4..1187295 100644 --- a/include/vga.h +++ b/include/vga.h @@ -13,14 +13,31 @@ #define VGA_MAX_COLS 80 #define VGA_MAX_ROWS 25 -#define WHITE_ON_BLACK 0x0f - #define CRTC_ADDR_PORT 0x3d4 #define CRTC_DATA_PORT 0x3d5 #define CRTC_CURSOR_LO_REGISTER 0x0f #define CRTC_CURSOR_HI_REGISTER 0x0e +enum VGA_COLOR { + VGA_COLOR_BLACK = 0, + VGA_COLOR_BLUE = 1, + VGA_COLOR_GREEN = 2, + VGA_COLOR_CYAN = 3, + VGA_COLOR_RED = 4, + VGA_COLOR_MAGENTA = 5, + VGA_COLOR_BROWN = 6, + VGA_COLOR_LIGHT_GREY = 7, + VGA_COLOR_DARK_GREY = 8, + VGA_COLOR_LIGHT_BLUE = 9, + VGA_COLOR_LIGHT_GREEN = 10, + VGA_COLOR_LIGHT_CYAN = 11, + VGA_COLOR_LIGHT_RED = 12, + VGA_COLOR_LIGHT_MAGENTA = 13, + VGA_COLOR_LIGHT_BROWN = 14, + VGA_COLOR_WHITE = 15 +}; + /** * @brief Gets the text-mode cursor's position. * @@ -43,4 +60,6 @@ void clear_screen(void); void popchar(); +void set_color(enum VGA_COLOR col); + #endif diff --git a/kmain.c b/kmain.c index 4c55917..2b0a890 100644 --- a/kmain.c +++ b/kmain.c @@ -28,6 +28,7 @@ extern void ps2_isr(); void kmain(struct multiboot_info *info) { clear_screen(); + set_color(VGA_COLOR_CYAN); // Check if the bootloader gave us the upper and lower memory if (!(info->flags & 0x1)) goto halt; @@ -41,16 +42,17 @@ void kmain(struct multiboot_info *info) { asm volatile ("lidt %0" :: "m"(g_idtr)); + struct rsdp *found_rsdp = acpi_locate_rsdp(); if (!found_rsdp) { + set_color(VGA_COLOR_RED); printf("Failed to find RSDP signature\n"); goto halt; } - printf("RSDP detected at 0x%X\n", found_rsdp); - if (found_rsdp->Revision == ACPI_VER_1) { if (!acpi_validate_rsdp_checksum(found_rsdp)) { + set_color(VGA_COLOR_RED); printf("RSDP has an invalid checksum\n"); goto halt; } @@ -58,18 +60,19 @@ void kmain(struct multiboot_info *info) { ctx.xsdp = 0; if (!acpi_validate_sdt_checksum((struct ACPISDTHeader *)found_rsdp->RsdtAddress)) { + set_color(VGA_COLOR_RED); printf("RSDT has an invalid checksum\n"); goto halt; } ctx.rsdt = (struct rsdt*)found_rsdp->RsdtAddress; - printf("RSDT detected at 0x%X\n", found_rsdp->RsdtAddress); - } else if (found_rsdp->Revision == ACPI_VER_OTHER) { - printf("ACPI versions higher than 1.0 are not supported\n"); + set_color(VGA_COLOR_RED); + printf("ACPI versions higher than 1.0 are not yet supported because I'm lazy\n"); goto halt; } else { + set_color(VGA_COLOR_RED); printf("Invalid RSDP\n"); goto halt; } @@ -78,13 +81,15 @@ void kmain(struct multiboot_info *info) { struct fadt *fadt = acpi_locate_sdt(ctx.rsdt, "FACP"); if (!fadt) { + set_color(VGA_COLOR_RED); printf("Failed to find FADT\n"); goto halt; } printf("Found FADT at 0x%x\n", fadt); if (fadt->Flags & 1) - printf("Legacy devices are supported.\n"); + printf("Legacy devices are supported\n"); else { + set_color(VGA_COLOR_RED); printf("Legacy devices are not supported. I'm too lazy to support modern devices, bye bye.\n"); goto halt; } @@ -96,14 +101,18 @@ void kmain(struct multiboot_info *info) { struct mcfg *mcfg = acpi_locate_sdt(ctx.rsdt, "MCFG"); if (!mcfg) { - printf("failed to find mcfg\n"); + set_color(VGA_COLOR_RED); + printf("Failed to find MCFG\n"); } else { - printf("Found MCFG at 0x%x\n", mcfg); + printf("Looks like you are using PCIe- Found MCFG at 0x%x\n", mcfg); struct pci_config_space *ide = pcie_find_device(mcfg, MASS_STORAGE_CONTROLLER, IDE_INTERFACE); if (ide) printf("IDE controller detected. Program Interface: %X\n", ide->program_interface); } + + set_color(VGA_COLOR_WHITE); + printf("You are now being dropped into a kernel shell\n$ "); halt: for (;;) {} } diff --git a/ps2.c b/ps2.c index 3a7f8de..ed62678 100644 --- a/ps2.c +++ b/ps2.c @@ -33,14 +33,14 @@ void initialize_8042ps2() { outportb(PS2_8042_COMMAND, 0xAA); while (!(inportb(PS2_8042_STATUS) & 0x1)) cpu_relax; uint8_t result = inportb(PS2_8042_DATA); - if (result == 0x55) printf("Passed PS/2 self test!\n"); + if (result == 0x55) printf("Passed PS/2 self test\n"); else printf("Failed!\n"); // perform port test outportb(PS2_8042_COMMAND, 0xAB); while (!(inportb(PS2_8042_STATUS) & 0x1)) cpu_relax; result = inportb(PS2_8042_DATA); - if (!result) printf("Passed PS/2 port 1 test!!\n"); + if (!result) printf("Passed PS/2 port 1 test\n"); else printf("Failed!\n"); // enable ps/2 port diff --git a/vga.c b/vga.c index a4f65f8..4a26359 100644 --- a/vga.c +++ b/vga.c @@ -10,6 +10,8 @@ #include #include +enum VGA_COLOR vga_color = VGA_COLOR_WHITE; + uint16_t get_cursor_pos() { uint16_t pos = 0; @@ -55,7 +57,7 @@ void _putchar(char character) { set_cursor_pos(next_line); } else { video_memory[0] = character; - video_memory[1] = WHITE_ON_BLACK; + video_memory[1] = vga_color; set_cursor_pos(pos + 1); } } @@ -67,3 +69,7 @@ void popchar() { video_memory[0] = 0; set_cursor_pos(pos - 1); } + +void set_color(enum VGA_COLOR col) { + vga_color = col; +}