Graphics mode & linear framebuffer update #1

Merged
xamidev merged 13 commits from dev into main 2024-08-23 15:24:09 +02:00
10 changed files with 40 additions and 30 deletions
Showing only changes of commit a029218acd - Show all commits

View File

@@ -130,6 +130,7 @@ void keyboard_handler()
void keyboard_install() void keyboard_install()
{ {
irq_install_handler(1, keyboard_handler); irq_install_handler(1, keyboard_handler);
printf("[keyboard] installed irq handler\n");
} }
char keyboard_getchar() char keyboard_getchar()

View File

@@ -20,6 +20,7 @@ int init_serial()
} }
outb(PORT+4, 0x0F); outb(PORT+4, 0x0F);
puts("[serial] initialized i/o on port COM1\n");
return 0; return 0;
} }

View File

@@ -17,6 +17,7 @@ void timer_handler()
void timer_install() void timer_install()
{ {
irq_install_handler(0, timer_handler); irq_install_handler(0, timer_handler);
printf("[timer] initialized, starting g_ticks...\n");
} }
void delay(int ticks) void delay(int ticks)

View File

@@ -1,4 +1,5 @@
#include "gdt.h" #include "gdt.h"
#include "../libc/stdio.h"
struct gdt_entry struct gdt_entry
{ {
@@ -50,4 +51,5 @@ void gdt_install()
gdt_set_gate(4, 0, 0xFFFFFFFF, 0xF2, 0xCF); gdt_set_gate(4, 0, 0xFFFFFFFF, 0xF2, 0xCF);
gdt_flush(); gdt_flush();
printf("[kernel] GDT gates set (ring 0 and 3), gdt=0x%x\n", &gdt);
} }

View File

@@ -1,5 +1,6 @@
#include "idt.h" #include "idt.h"
#include "system.h" #include "system.h"
#include "../libc/stdio.h"
struct idt_entry struct idt_entry
{ {
@@ -39,4 +40,5 @@ void idt_install()
memset(&idt, 0, sizeof(struct idt_entry)*256); memset(&idt, 0, sizeof(struct idt_entry)*256);
idt_load(); idt_load();
printf("[kernel] loaded IDT at idt=0x%x\n", &idt);
} }

View File

@@ -1,6 +1,7 @@
#include "system.h" #include "system.h"
#include "io.h" #include "io.h"
#include "idt.h" #include "idt.h"
#include "../libc/stdio.h"
extern void irq0(); extern void irq0();
extern void irq1(); extern void irq1();
@@ -69,6 +70,7 @@ void irq_install()
idt_set_gate(45, (unsigned)irq13, 0x08, 0x8E); idt_set_gate(45, (unsigned)irq13, 0x08, 0x8E);
idt_set_gate(46, (unsigned)irq14, 0x08, 0x8E); idt_set_gate(46, (unsigned)irq14, 0x08, 0x8E);
idt_set_gate(47, (unsigned)irq15, 0x08, 0x8E); idt_set_gate(47, (unsigned)irq15, 0x08, 0x8E);
printf("[kernel] installed irq 0-15\n");
} }
void irq_handler(struct regs *r) void irq_handler(struct regs *r)

View File

@@ -70,6 +70,7 @@ void isr_install()
idt_set_gate(29, (unsigned)isr29, 0x08, 0x8E); idt_set_gate(29, (unsigned)isr29, 0x08, 0x8E);
idt_set_gate(30, (unsigned)isr30, 0x08, 0x8E); idt_set_gate(30, (unsigned)isr30, 0x08, 0x8E);
idt_set_gate(31, (unsigned)isr31, 0x08, 0x8E); idt_set_gate(31, (unsigned)isr31, 0x08, 0x8E);
printf("[kernel] set ISRs 0-31\n");
} }
char *exception_messages[] = char *exception_messages[] =

View File

@@ -26,13 +26,6 @@ typedef struct {
uint8_t tags[0]; uint8_t tags[0];
} multiboot2_info; } multiboot2_info;
char* ascii_title =
"\n"
"*******************************\n"
"| Blank OS version 0.3.68-dev |\n"
"*******************************\n"
"\n";
unsigned int g_multiboot_info_address; unsigned int g_multiboot_info_address;
uint32_t* framebuffer; uint32_t* framebuffer;
@@ -73,7 +66,7 @@ uint8_t *tags = mb_info->tags;
uint32_t width = fb_info->framebuffer_width; uint32_t width = fb_info->framebuffer_width;
uint32_t height = fb_info->framebuffer_height; uint32_t height = fb_info->framebuffer_height;
uint32_t pitch = fb_info->framebuffer_pitch; //uint32_t pitch = fb_info->framebuffer_pitch;
uint32_t bpp = fb_info->framebuffer_bpp; uint32_t bpp = fb_info->framebuffer_bpp;
@@ -94,28 +87,18 @@ uint8_t *tags = mb_info->tags;
*/ */
} }
printf("[kernel] multiboot2 info at 0x%x, size=%u\n", mb_info, mb_info->total_size);
printf("[kernel] framebuffer discovered at 0x%x\n", fb_info->framebuffer_addr); printf("[kernel] framebuffer discovered at 0x%x\n", fb_info->framebuffer_addr);
printf("[kernel] fb0: width=%u, height=%u, pitch=%u, bpp=%u\n", fb_info->framebuffer_width, fb_info->framebuffer_height, fb_info->framebuffer_pitch, fb_info->framebuffer_bpp); printf("[kernel] fb0: width=%u, height=%u, pitch=%u, bpp=%u\n", fb_info->framebuffer_width, fb_info->framebuffer_height, fb_info->framebuffer_pitch, fb_info->framebuffer_bpp);
colorputs(ascii_title, green, black);
init_serial(); init_serial();
log("serial connection established\n", 3);
gdt_install(); gdt_install();
log("initialized GDT entries\n", 2);
idt_install(); idt_install();
log("initialized IDT\n", 2);
isr_install(); isr_install();
log("initialized ISRs\n", 2);
irq_install(); irq_install();
__asm__ __volatile__("sti"); __asm__ __volatile__("sti");
log("initialized IRQs\n", 2),
//clear();
//colorputs(ascii_title, 10);
//colorputs(" by @xamidev - star the repo for a cookie!\n\n", );
//init_paging(); //init_paging();
//test_read_sector(); //test_read_sector();
@@ -124,10 +107,8 @@ uint8_t *tags = mb_info->tags;
//uint32_t do_page_fault = *ptr; //uint32_t do_page_fault = *ptr;
timer_install(); timer_install();
serial_printf(2, "%d\tinitialized timer handler", global_ticks); keyboard_install();
keyboard_install(); printf("[kernel] spawning shell...\n");
serial_printf(2, "%d\tinitialized keyboard handler", global_ticks);
shell_install(); shell_install();
serial_printf(2, "%d\tstarted system shell", global_ticks);
} }

View File

@@ -8,6 +8,16 @@
#define MAX_COMMANDS 16 #define MAX_COMMANDS 16
#define MAX_ARGS 64 #define MAX_ARGS 64
char* ascii_title =
"\n"
"----------------------------------------------\n"
"Blank OS version 0.3.71-dev\n"
"Author: @xamidev - star the repo for a cookie!\n"
"----------------------------------------------\n"
"\n";
typedef void (*command_func_t)(int argc, char *argv[]); typedef void (*command_func_t)(int argc, char *argv[]);
typedef struct typedef struct
@@ -53,7 +63,9 @@ int parse_input(char* input, char* argv[], int max_args)
} }
void shell_install() void shell_install()
{ {
colorputs(ascii_title, yellow, black);
register_command("help", program_help); register_command("help", program_help);
register_command("panic", program_panic); register_command("panic", program_panic);
register_command("words", program_words); register_command("words", program_words);
@@ -73,7 +85,13 @@ void shell_install()
{ {
char input_buffer[BUFFER_SIZE]; char input_buffer[BUFFER_SIZE];
char* argv[MAX_ARGS]; char* argv[MAX_ARGS];
//colorputs("blankos> ", 9);
// Prompt
colorputs("root", blue, black);
colorputs("@", white, black);
colorputs("blankos", green, black);
colorputs("~$ ", white, black);
get_input(input_buffer, BUFFER_SIZE); get_input(input_buffer, BUFFER_SIZE);
puts("\n"); puts("\n");

View File

@@ -49,11 +49,12 @@ void dtostrf(double val, char *buffer, int precision);
enum Colors enum Colors
{ {
// AARRGGBB? // AARRGGBB?
white = 0xFFFFFFFF, white = 0xFFFFFFFF,
black = 0x00000000, black = 0x00000000,
red = 0x00FF0000, red = 0x00FF0000,
green = 0x0000FF00, green = 0x0000FF00,
blue = 0x000000FF, blue = 0x000000FF,
yellow = 0x00FFFF00,
}; };
#endif #endif