diff --git a/drivers/x86_64/vga.c b/drivers/x86_64/vga.c new file mode 100644 index 0000000..e47e293 --- /dev/null +++ b/drivers/x86_64/vga.c @@ -0,0 +1,84 @@ +#include +#include "../vga.h" +#include "../../cpu/x86_64/ports.h" +#include +#include +#define xy_to_indx(x,y) ((x+(y*width))*2) +static char* screen; +static int width; +static int height; +static int x; +static int y; +static vga_colors fg_color; +static vga_colors bg_color; + +static void set_char(int x,int y,char c) { + screen[xy_to_indx(x,y)]=c; + screen[xy_to_indx(x,y)+1]=(bg_color<<4)|fg_color; +} + +void vga_clear() { + for (int y=0;y>8); +} + +void vga_init(text_fb_info framebuffer_info) { + x=0; + y=0; + fg_color=VGA_WHITE; + bg_color=VGA_BLACK; + screen=framebuffer_info.address; + width=framebuffer_info.width; + height=framebuffer_info.height; + port_byte_out(0x3D4,0xA); + port_byte_out(0x3D5,(port_byte_in(0x3D5)&0xC0)|14); + port_byte_out(0x3D4,0xB); + port_byte_out(0x3D5,(port_byte_in(0x3D5)&0xE0)|15); + set_cursor(0,0); + vga_clear(); +} + +void vga_write_string(const char* string) { + for (size_t i=0;i +#include // #include // #include // #include @@ -138,17 +138,18 @@ void kmain(multiboot_info_t* header) { // mbd=header; // cpu_init(mbd); - // text_fb_info info; + text_fb_info info; // if (header->flags&MULTIBOOT_INFO_FRAMEBUFFER_INFO&&header->framebuffer_type==2) { // info.address=(char*)(((uint32_t)header->framebuffer_addr&0xFFFFFFFF)+0xC0000000); // info.width=header->framebuffer_width; // info.height=header->framebuffer_height; // } else { - // info.address=(char*)0xB8000; - // info.width=80; - // info.height=25; + info.address=(char*)0xffff8000000B8000; + info.width=80; + info.height=25; // } - // vga_init(info); + vga_init(info); + vga_write_string("Hello long mode world!"); // createTask(init); // for (;;) { // yield();