Graphics mode & linear framebuffer update #1
@@ -91,3 +91,4 @@ void scroll()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,12 @@ volatile unsigned long global_ticks = 0;
|
||||
void timer_handler()
|
||||
{
|
||||
global_ticks++;
|
||||
if (global_ticks % 20 == 0)
|
||||
{
|
||||
draw_cursor(white);
|
||||
} else if (global_ticks % 20 == 10) {
|
||||
erase_cursor();
|
||||
}
|
||||
}
|
||||
|
||||
void timer_install()
|
||||
|
||||
@@ -61,15 +61,14 @@ uint8_t *tags = mb_info->tags;
|
||||
tags += ((tag_size + 7) & ~7);
|
||||
}
|
||||
|
||||
serial_printf(3, "Framebuffer Address: 0x%x\r\n", fb_info->framebuffer_addr);
|
||||
serial_printf(3, "Framebuffer Width: %u\r\n", fb_info->framebuffer_width);
|
||||
serial_printf(3, "Framebuffer Height: %u\r\n", fb_info->framebuffer_height);
|
||||
serial_printf(3, "Framebuffer Pitch: %u\r\n", fb_info->framebuffer_pitch);
|
||||
serial_printf(3, "Framebuffer BPP: %u\r\n", fb_info->framebuffer_bpp);
|
||||
serial_printf(3, "Framebuffer Address: 0x%x\r", fb_info->framebuffer_addr);
|
||||
serial_printf(3, "Framebuffer Width: %u\r\n", fb_info->framebuffer_width);
|
||||
serial_printf(3, "Framebuffer Height: %u\r\n", fb_info->framebuffer_height);
|
||||
serial_printf(3, "Framebuffer Pitch: %u\r\n", fb_info->framebuffer_pitch);
|
||||
serial_printf(3, "Framebuffer BPP: %u\r\n", fb_info->framebuffer_bpp);
|
||||
|
||||
|
||||
if (fb_info) {
|
||||
log("Entered fb_info\r\n", 3);
|
||||
framebuffer = (uint32_t *)(uintptr_t) fb_info->framebuffer_addr;
|
||||
|
||||
uint32_t width = fb_info->framebuffer_width;
|
||||
@@ -77,6 +76,7 @@ serial_printf(3, "Framebuffer BPP: %u\r\n", fb_info->framebuffer_bpp);
|
||||
uint32_t pitch = fb_info->framebuffer_pitch;
|
||||
uint32_t bpp = fb_info->framebuffer_bpp;
|
||||
|
||||
|
||||
//8x16 font, not padded
|
||||
VGA_WIDTH = width/8;
|
||||
VGA_HEIGHT = height/16;
|
||||
@@ -92,41 +92,14 @@ serial_printf(3, "Framebuffer BPP: %u\r\n", fb_info->framebuffer_bpp);
|
||||
draw_char(0+i, 0+i, y_offset, white, black);
|
||||
}
|
||||
*/
|
||||
|
||||
/* TEST print red square
|
||||
for (uint32_t y = 0; y < 10; y++) {
|
||||
for (uint32_t x = 0; x < 10; x++) {
|
||||
putpixel(framebuffer, (int)pitch, (int)bpp, x, y, red);
|
||||
//framebuffer[y * (pitch / 4) + x] = 0xFF0000; // Rouge
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
log("Drew to framebuffer.\r\n", 3);
|
||||
}
|
||||
/*
|
||||
puts("This should work by now! Enter Graphics Mode.");
|
||||
printf("\nMy name is %s, and I'm %d. 0x%x", "Alan", 34, 0xdeadbeef);
|
||||
|
||||
for (int i=0; i<512; i++)
|
||||
{
|
||||
printf("%d ", i);
|
||||
}
|
||||
*/
|
||||
|
||||
for (int i=0; i<100; i++)
|
||||
{
|
||||
printf("%d\n", i);
|
||||
}
|
||||
|
||||
//colorputs("Wow, such colorful output!", green, blue);
|
||||
|
||||
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);
|
||||
|
||||
colorputs(ascii_title, green, black);
|
||||
|
||||
while (1);
|
||||
|
||||
|
||||
/*
|
||||
init_serial();
|
||||
log("serial connection established\n", 3);
|
||||
gdt_install();
|
||||
@@ -139,17 +112,16 @@ serial_printf(3, "Framebuffer BPP: %u\r\n", fb_info->framebuffer_bpp);
|
||||
__asm__ __volatile__("sti");
|
||||
log("initialized IRQs\n", 2),
|
||||
|
||||
clear();
|
||||
colorputs(ascii_title, 10);
|
||||
colorputs(" by @xamidev - star the repo for a cookie!\n\n", 14);
|
||||
//clear();
|
||||
//colorputs(ascii_title, 10);
|
||||
//colorputs(" by @xamidev - star the repo for a cookie!\n\n", );
|
||||
|
||||
init_paging();
|
||||
printf("Hello, paging world!\n");
|
||||
//init_paging();
|
||||
|
||||
//test_read_sector();
|
||||
|
||||
uint32_t *ptr = (uint32_t*)0xA0000000;
|
||||
uint32_t do_page_fault = *ptr;
|
||||
//uint32_t *ptr = (uint32_t*)0xA0000000;
|
||||
//uint32_t do_page_fault = *ptr;
|
||||
|
||||
timer_install();
|
||||
serial_printf(2, "%d\tinitialized timer handler", global_ticks);
|
||||
@@ -157,5 +129,5 @@ serial_printf(3, "Framebuffer BPP: %u\r\n", fb_info->framebuffer_bpp);
|
||||
serial_printf(2, "%d\tinitialized keyboard handler", global_ticks);
|
||||
shell_install();
|
||||
serial_printf(2, "%d\tstarted system shell", global_ticks);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@@ -11,11 +11,32 @@ extern uint32_t VGA_WIDTH;
|
||||
extern uint32_t VGA_HEIGHT;
|
||||
unsigned int VGA_X = 0, VGA_Y = 0;
|
||||
|
||||
#define CURSOR_WIDTH 8
|
||||
#define CURSOR_HEIGHT 16
|
||||
extern int scanline;
|
||||
|
||||
void draw_cursor(uint32_t color)
|
||||
{
|
||||
for (int y=12; y<CURSOR_HEIGHT; y++)
|
||||
{
|
||||
for (int x=0; x<CURSOR_WIDTH; x++)
|
||||
{
|
||||
putpixel(framebuffer, scanline, 32, VGA_X * CURSOR_WIDTH + x, VGA_Y * CURSOR_HEIGHT + y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void erase_cursor()
|
||||
{
|
||||
draw_cursor(black);
|
||||
}
|
||||
|
||||
void move_cursor(int x, int y)
|
||||
{
|
||||
erase_cursor();
|
||||
VGA_X = x;
|
||||
VGA_Y = y;
|
||||
draw_cursor(white);
|
||||
}
|
||||
|
||||
// stdio wrapper for draw_char in graphics mode
|
||||
@@ -38,6 +59,7 @@ void clear(void)
|
||||
|
||||
void putc(char c)
|
||||
{
|
||||
erase_cursor();
|
||||
switch(c)
|
||||
{
|
||||
case '\n':
|
||||
@@ -88,6 +110,7 @@ void putc(char c)
|
||||
|
||||
void colorputc(char c, uint32_t fg, uint32_t bg)
|
||||
{
|
||||
erase_cursor();
|
||||
switch(c)
|
||||
{
|
||||
case '\n':
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
#define FB_HIGH_BYTE_CMD 14
|
||||
#define FB_LOW_BYTE_CMD 15
|
||||
|
||||
|
||||
void draw_cursor(uint32_t color);
|
||||
void erase_cursor();
|
||||
|
||||
void move_cursor(int x, int y);
|
||||
void putchar(unsigned short int c, int x, int y, uint32_t fg, uint32_t bg);
|
||||
void puts(const char* str);
|
||||
|
||||
Reference in New Issue
Block a user