diff --git a/build/Common.mk b/build/Common.mk index 95a8ae2..bdc01b7 100644 --- a/build/Common.mk +++ b/build/Common.mk @@ -1,4 +1,4 @@ -DEF_FLAGS := -D USE_FRAMEBUFFER=$(USE_FRAMEBUFFER) -D SMALL_PAGES=$(SMALL_PAGES) +DEF_FLAGS := -D USE_FRAMEBUFFER=$(USE_FRAMEBUFFER) -D SMALL_PAGES=$(SMALL_PAGES) -D PIN_LOGO=$(PIN_LOGO) CFLAGS := -std=gnu99 \ -ffreestanding \ diff --git a/build/Config.mk b/build/Config.mk index d5a0bb6..20e778d 100644 --- a/build/Config.mk +++ b/build/Config.mk @@ -3,7 +3,10 @@ # Kernel Configuration USE_FRAMEBUFFER ?= 1 -SMALL_PAGES ?= 0 +SMALL_PAGES ?= 1 + +# PIN_LOGO set to 0 if we want the logo to be scrolled. +PIN_LOGO ?= 1 # Build Configuration diff --git a/docs/Building.md b/docs/Building.md index 98d51ae..3851f04 100644 --- a/docs/Building.md +++ b/docs/Building.md @@ -30,6 +30,7 @@ They can change at any moment, or can be removed in the future * `USE_FRAMEBUFFER` if set to 1 it use the framebuffer video mode, if set to 0 it use the legacy VGA driver. * `SMALL_PAGES` if set to 1 the virtual memory will use 4k pages if set to 0 it will use 2mb pages +* `PIN_LOGO` if set to 1 the dreamos logo will stay on the top right corner when the frambuffer is scrolling, otherwise will scroll up with the rest of the screen. They are experimental temporary features, there are chances that they can be removed in the future. diff --git a/src/include/kernel/framebuffer.h b/src/include/kernel/framebuffer.h index 9e63d82..e615a62 100644 --- a/src/include/kernel/framebuffer.h +++ b/src/include/kernel/framebuffer.h @@ -44,6 +44,6 @@ void get_framebuffer_mode(uint32_t* pixels_w, uint32_t* pixels_h, uint32_t* char void draw_logo(uint32_t start_x, uint32_t start_y); void _fb_scrollLine(_fb_window_t *scrolling_window, uint32_t line_height, uint32_t number_of_lines_to_scroll, _fb_window_t *area_to_pin); -void _fb_scroll(_fb_window_t *scrolling_window, uint32_t line_height, uint32_t number_of_lines_to_scroll, _fb_window_t *area_to_pin); +void _fb_scroll(_fb_window_t *scrolling_window, uint32_t line_height, uint32_t number_of_lines_to_scroll, _fb_window_t *area_to_pin, bool clear_last_line); #endif diff --git a/src/kernel/framebuffer/framebuffer.c b/src/kernel/framebuffer/framebuffer.c index d4ed8cb..879ac1d 100644 --- a/src/kernel/framebuffer/framebuffer.c +++ b/src/kernel/framebuffer/framebuffer.c @@ -34,6 +34,7 @@ uint32_t number_of_lines; _fb_window_t framebuffer_main_window; _fb_window_t framebuffer_logo_area; +_fb_window_t *logo_area_ptr; void map_framebuffer(struct framebuffer_info fbdata) { uint32_t fb_entries = fbdata.memory_size / PAGE_SIZE_IN_BYTES; @@ -116,6 +117,7 @@ void set_fb_data(struct multiboot_tag_framebuffer *fbtag){ framebuffer_main_window.y_orig = 0; framebuffer_main_window.width = framebuffer_data.width; framebuffer_main_window.height = framebuffer_data.height; + logo_area_ptr = NULL; #endif } @@ -163,7 +165,8 @@ void _fb_printStr( const char *string, uint32_t fg, uint32_t bg ) { cur_fb_line++; if ( cur_fb_line >= framebuffer_data.number_of_lines ) { //pretty_log(Verbose, "Exceeding number of lines, calling _fb_scrollLine"); - _fb_scrollLine(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, &framebuffer_logo_area); + //_fb_scrollLine(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, &framebuffer_logo_area); + _fb_scroll(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, logo_area_ptr, true); cur_fb_line--; } } @@ -173,7 +176,8 @@ void _fb_printStrAndNumber(const char *string, uint64_t number, uint32_t fg, uin cur_fb_line++; if ( cur_fb_line >= framebuffer_data.number_of_lines ) { //pretty_log(Verbose, "Exceeding number of lines, calling _fb_scrollLine"); - _fb_scrollLine(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, &framebuffer_logo_area); + //_fb_scrollLine(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, &framebuffer_logo_area); + _fb_scroll(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, logo_area_ptr, true); cur_fb_line--; } } @@ -186,7 +190,8 @@ void _fb_printStrAt( const char *string, size_t cx, size_t cy, uint32_t fg, uint cur_fb_line = cy; if ( cur_fb_line+1 >= framebuffer_data.number_of_lines ) { //pretty_log(Verbose, "Exceeding number of lines, calling _fb_scrollLine"); - _fb_scrollLine(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, &framebuffer_logo_area); + //_fb_scrollLine(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, &framebuffer_logo_area); + _fb_scroll(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, logo_area_ptr, true); } else { cy++; cur_fb_line = cy; @@ -260,6 +265,11 @@ void draw_logo(uint32_t start_x, uint32_t start_y) { framebuffer_logo_area.y_orig = start_y; framebuffer_logo_area.width = width; framebuffer_logo_area.height = height; +#if PIN_LOGO == 1 + logo_area_ptr = &framebuffer_logo_area; +#else + logo_area_ptr = NULL; +#endif char *logo_data = header_data; char *data = header_data; unsigned char pixel[4]; @@ -276,7 +286,7 @@ void draw_logo(uint32_t start_x, uint32_t start_y) { } } -void _fb_scroll(_fb_window_t *scrolling_window, uint32_t line_height, uint32_t number_of_lines_to_scroll, _fb_window_t *area_to_pin) { +void _fb_scroll(_fb_window_t *scrolling_window, uint32_t line_height, uint32_t number_of_lines_to_scroll, _fb_window_t *area_to_pin, bool clear_last_line) { _fb_window_t rectangles[4]; uint32_t *framebuffer = (uint32_t *) framebuffer_data.address; uint8_t n_rects = _fb_get_rectangles(rectangles, &framebuffer_main_window, area_to_pin); @@ -298,7 +308,9 @@ void _fb_scroll(_fb_window_t *scrolling_window, uint32_t line_height, uint32_t n while ( cur_y < (rectangles[i].y_orig + rectangles[i].height - line_height)) { while (cur_x < (rectangles[i].x_orig + rectangles[i].width)) { _fb_put_pixel(cur_x, cur_y, _fb_get_pixel(cur_x, cur_y + line_height)); - _fb_put_pixel(cur_x, cur_y + line_height, 0x000000); + if (clear_last_line) { + _fb_put_pixel(cur_x, cur_y + line_height, 0x000000); + } cur_x++; } cur_y++; diff --git a/src/kernel/main.c b/src/kernel/main.c index f3a9720..e46e8fe 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -216,20 +216,12 @@ void kernel_start(unsigned long addr, unsigned long magic){ draw_logo(framebuffer_data.width - width, 0); _fb_printStr("Thanks\n\tfor\n using it\n", 0xFFFFFF, 0x3333ff); - /*_fb_window_t squares[4]; - uint8_t n_rectangles = _fb_get_rectangles(squares, &framebuffer_main_window, &framebuffer_logo_area); - for (int i = 0; i < n_rectangles; i++) { - pretty_logf(Verbose, "Square: %d, x_orig: %d, y_orig: %d, widht: %d, height: %d", i, squares[i].x_orig, squares[i].y_orig, squares[i].width, squares[i].height); - } - _fb_window_t rect_to_draw = {600, 500, 100, 120}; - _fb_window_t main_area = {400, 300, 400, 400}; - size_t n_rects = _fb_get_rectangles(squares, &main_area, &rect_to_draw); - pretty_logf(Verbose, "Checking size of rectangles returned: %d", n_rects); - uint32_t colours[4] = {0x83A06A, 0x465259, 0x8FD8F9, 0xF7E65A}; - for (size_t i = 0; i < n_rects; i++) { - _fb_draw_rectangle(main_area, squares[i], colours[i]); + _fb_printStrAt("Test String", 0, 49, 0xff33aa, 0x000000); + /*pretty_logf(Verbose, "Framebuffer addr: 0x%x", framebuffer_data.address); + for (int i = 0; i < 60; i++) { + _fb_printStrAndNumber("Counting up to: ", i, 0xFF33AA+i, 0x000000); }*/ - _fb_scroll(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, &framebuffer_logo_area); + //_fb_scroll(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, &framebuffer_logo_area, false); //_fb_scroll(&framebuffer_main_window, _psf_get_height(psf_font_version), 1, NULL); #endif _syscalls_init();