From e641c2bf77add319ab2ede41e511db8c2f065ffb Mon Sep 17 00:00:00 2001 From: Ivan G <59960116+dreamos82@users.noreply.github.com> Date: Thu, 28 Dec 2023 12:14:06 +0000 Subject: [PATCH] Add line handling in fb_printStr (#196) * Add line handling in fb_printStr * fix build issue * fix build issue * Fix \t case handling * Rename psf functions * Add number of lines and rows to framebuffer_data * Add _fb_printStrAndNumber that uses cur_fb_line * Reset cur_fb_line if reaching bottom limit * Changes requested --- Makefile | 1 + src/asm/boot.s | 3 +- src/include/kernel/framebuffer.h | 9 +++- src/include/kernel/psf.h | 10 ++-- src/kernel/arch/x86_64/mem/vmm_mapping.c | 2 +- src/kernel/framebuffer/framebuffer.c | 43 +++++++++++---- src/kernel/graphics/psf.c | 8 +-- src/kernel/hardware/keyboard.c | 2 +- src/kernel/hardware/timer.c | 8 +-- src/kernel/io/video.c | 9 ++-- src/kernel/logging.c | 14 ++--- src/kernel/main.c | 67 +++++++++++++----------- src/kernel/mem/hh_direct_map.c | 2 +- src/kernel/mem/vmm.c | 4 +- 14 files changed, 109 insertions(+), 73 deletions(-) diff --git a/Makefile b/Makefile index 953245ae..21dac19a 100644 --- a/Makefile +++ b/Makefile @@ -57,6 +57,7 @@ debug: DEBUG=1 debug: CFLAGS += $(C_DEBUG_FLAGS) debug: ASM_FLAGS += $(ASM_DEBUG_FLAGS) debug: $(BUILD_FOLDER)/$(ISO_IMAGE_FILENAME) + # TODO could be useful to use stdio as both log output and monitor input # qemu-system-x86_64 -monitor unix:qemu-monitor-socket,server,nowait -cpu qemu64,+x2apic -cdrom $(BUILD_FOLDER)/$(ISO_IMAGE_FILENAME) -serial file:dreamos64.log -m 1G -d int -no-reboot -no-shutdown $(QEMU_SYSTEM) -monitor unix:qemu-monitor-socket,server,nowait -cpu qemu64,+x2apic -cdrom $(BUILD_FOLDER)/$(ISO_IMAGE_FILENAME) -serial stdio -m 2G -no-reboot -no-shutdown diff --git a/src/asm/boot.s b/src/asm/boot.s index 4b0d1deb..e36f435e 100644 --- a/src/asm/boot.s +++ b/src/asm/boot.s @@ -233,10 +233,9 @@ higher_half: lgdt [gdt64.pointer] ; The two lines below are needed to un map the kernel in the lower half - ; But i'll leave them commented for now because the code in the kernel need - ; to be changed and some addresses need to be updated (i.e. multiboot stuff) mov eax, 0x0 mov dword [(p4_table - KERNEL_VIRTUAL_ADDR) + 0], eax + mov rax, cr3 mov cr3, rax call kernel_start diff --git a/src/include/kernel/framebuffer.h b/src/include/kernel/framebuffer.h index d4b23a41..802fc67f 100644 --- a/src/include/kernel/framebuffer.h +++ b/src/include/kernel/framebuffer.h @@ -16,16 +16,21 @@ typedef struct framebuffer_info { uint32_t width; uint32_t height; + uint32_t number_of_lines; + uint32_t number_of_rows; + uint64_t phys_address; } framebuffer_info; void _fb_putchar(char symbol, size_t cx, size_t cy, uint32_t fg, uint32_t bg); -void _fb_printStr(const char *string, size_t cx, size_t cy, uint32_t fg, uint32_t bg); +void _fb_printStrAt(const char *string, size_t cx, size_t cy, uint32_t fg, uint32_t bg); +void _fb_printStr(const char *string, uint32_t fg, uint32_t bg); void _fb_put_pixel(uint32_t, uint32_t, uint32_t); /*void map_framebuffer(struct multiboot_tag_framebuffer *);*/ void set_fb_data(struct multiboot_tag_framebuffer *); -void _fb_printStrAndNumber(const char*, uint64_t, size_t, size_t, uint32_t, uint32_t); +void _fb_printStrAndNumber(const char*, uint64_t, uint32_t, uint32_t); +void _fb_printStrAndNumberAt(const char*, uint64_t, size_t, size_t, uint32_t, uint32_t); void get_framebuffer_mode(uint32_t* pixels_w, uint32_t* pixels_h, uint32_t* chars_w, uint32_t* chars_h); void draw_logo(uint32_t start_x, uint32_t start_y); diff --git a/src/include/kernel/psf.h b/src/include/kernel/psf.h index a5affc81..3a7bcf57 100644 --- a/src/include/kernel/psf.h +++ b/src/include/kernel/psf.h @@ -6,7 +6,7 @@ #define MAGIC_V1_0 0x36 #define MAGIC_V1_1 0x04 -#define MAGIC_V2 0x864ab572 +#define MAGIC_V2 0x864ab572 #define PSF1_MODE512 0x01 #define PSF1_MODEHASTAB 0x02 @@ -37,10 +37,10 @@ extern char _binary_fonts_default_psf_size; extern char _binary_fonts_default_psf_start[]; extern char _binary_fonts_default_psf_end; -uint8_t get_PSF_version(char *); +uint8_t _psf_get_version(char *); -uint8_t* get_glyph(uint8_t, uint8_t); -uint32_t get_height(uint8_t); -uint32_t get_width(uint8_t); +uint8_t* _psf_get_glyph(uint8_t, uint8_t); +uint32_t _psf_get_height(uint8_t); +uint32_t _psf_get_width(uint8_t); #endif diff --git a/src/kernel/arch/x86_64/mem/vmm_mapping.c b/src/kernel/arch/x86_64/mem/vmm_mapping.c index b392ef53..68704f1a 100644 --- a/src/kernel/arch/x86_64/mem/vmm_mapping.c +++ b/src/kernel/arch/x86_64/mem/vmm_mapping.c @@ -143,7 +143,7 @@ void *map_phys_to_virt_addr(void* physical_address, void* address, size_t flags) if( !(pdpr_table[pdpr_e] & 0b1) ) { uint64_t *new_table = pmm_alloc_frame(); pdpr_table[pdpr_e] = (uint64_t) new_table | user_mode_status | WRITE_BIT | PRESENT_BIT; -// pretty_logf(Verbose, " PDPR entry value: 0x%x", pdpr_table[pdpr_e]); + //pretty_logf(Verbose, " PDPR entry value: 0x%x", pdpr_table[pdpr_e]); clean_new_table(pd_table); } diff --git a/src/kernel/framebuffer/framebuffer.c b/src/kernel/framebuffer/framebuffer.c index a7f16dfd..aa75f819 100644 --- a/src/kernel/framebuffer/framebuffer.c +++ b/src/kernel/framebuffer/framebuffer.c @@ -31,6 +31,7 @@ uint32_t FRAMEBUFFER_HEIGHT; struct framebuffer_info framebuffer_data; size_t cur_fb_line; +uint32_t number_of_lines; void map_framebuffer(struct framebuffer_info fbdata) { uint32_t fb_entries = fbdata.memory_size / PAGE_SIZE_IN_BYTES; @@ -104,8 +105,11 @@ void set_fb_data(struct multiboot_tag_framebuffer *fbtag){ framebuffer_data.height = fbtag->common.framebuffer_height; framebuffer_data.phys_address = fbtag->common.framebuffer_addr; + number_of_lines = 0; + map_framebuffer(framebuffer_data); cur_fb_line = 0; + #endif } @@ -113,13 +117,13 @@ void _fb_putchar(char symbol, size_t cx, size_t cy, uint32_t fg, uint32_t bg){ uint8_t *framebuffer = (uint8_t *) framebuffer_data.address; uint32_t pitch = framebuffer_data.pitch; uint32_t width, height; - width = get_width(psf_font_version); - height = get_height(psf_font_version); + width = _psf_get_width(psf_font_version); + height = _psf_get_height(psf_font_version); //uint32_t charsize = default_font->height * ((default_font->width + 7)/8); //uint8_t *glyph = (uint8_t*)&_binary_fonts_default_psf_start + // default_font->headersize + (symbol>0&&symbolnumglyph?symbol:0) * default_font->bytesperglyph; - uint8_t *glyph = get_glyph(symbol, psf_font_version); + uint8_t *glyph = _psf_get_glyph(symbol, psf_font_version); //bytesperline is the number of bytes per each row of the glyph size_t bytesperline = (width + 7)/8; size_t offset = (cy * height * pitch) + @@ -147,11 +151,32 @@ void _fb_putchar(char symbol, size_t cx, size_t cy, uint32_t fg, uint32_t bg){ } } -void _fb_printStr(const char *string, size_t cx, size_t cy, uint32_t fg, uint32_t bg){ +void _fb_printStr( const char *string, uint32_t fg, uint32_t bg ) { + _fb_printStrAt(string, 0, cur_fb_line, fg, bg); + cur_fb_line++; + if ( cur_fb_line >= framebuffer_data.number_of_lines ) { + pretty_log(Verbose, "Exceeding number of lines, cycling"); + cur_fb_line = 0; + } +} + +void _fb_printStrAndNumber(const char *string, uint64_t number, uint32_t fg, uint32_t bg) { + _fb_printStrAndNumberAt(string, number, 0, cur_fb_line, fg, bg); + cur_fb_line++; + if ( cur_fb_line >= framebuffer_data.number_of_lines ) { + pretty_log(Verbose, "Exceeding number of lines, cycling"); + cur_fb_line = 0; + } +} + +void _fb_printStrAt( const char *string, size_t cx, size_t cy, uint32_t fg, uint32_t bg ){ while (*string != '\0'){ if (*string == '\n'){ cx=0; cy++; + cur_fb_line = cy; + } else if (*string == '\t'){ + cx += 4; } else { _fb_putchar(*string, cx, cy, fg, bg); cx++; @@ -160,18 +185,18 @@ void _fb_printStr(const char *string, size_t cx, size_t cy, uint32_t fg, uint32_ } } -void _fb_printStrAndNumber(const char *string, uint64_t number, size_t cx, size_t cy, uint32_t fg, uint32_t bg){ +void _fb_printStrAndNumberAt(const char *string, uint64_t number, size_t cx, size_t cy, uint32_t fg, uint32_t bg){ char buffer[30]; _getHexString(buffer, number, true); - _fb_printStr(string, cx, cy, fg, bg); + _fb_printStrAt(string, cx, cy, fg, bg); int counter = 0; while(*string != '\0') { counter++; string++; } - _fb_printStr(buffer, cx + counter, cy, fg, bg); + _fb_printStrAt(buffer, cx + counter, cy, fg, bg); } void get_framebuffer_mode(uint32_t* pixels_w, uint32_t* pixels_h, uint32_t* chars_w, uint32_t* chars_h) @@ -182,9 +207,9 @@ void get_framebuffer_mode(uint32_t* pixels_w, uint32_t* pixels_h, uint32_t* char *pixels_h = framebuffer_data.height; if (chars_w != NULL) - *chars_w = framebuffer_data.width / get_width(psf_font_version); + *chars_w = framebuffer_data.width / _psf_get_width(psf_font_version); if (chars_h != NULL) - *chars_h = framebuffer_data.height / get_height(psf_font_version); + *chars_h = framebuffer_data.height / _psf_get_height(psf_font_version); } void _fb_put_pixel(uint32_t x, uint32_t y, uint32_t color) { diff --git a/src/kernel/graphics/psf.c b/src/kernel/graphics/psf.c index afbd3c7d..8a5a17da 100644 --- a/src/kernel/graphics/psf.c +++ b/src/kernel/graphics/psf.c @@ -9,7 +9,7 @@ char _binary_fonts_default_psf_end; uint8_t psf_font_version; -uint8_t get_PSF_version(char *_font_structure){ +uint8_t _psf_get_version(char *_font_structure){ PSFv1_Font *_v1_font = (PSFv1_Font*) _font_structure; if( _v1_font->magic[0] == MAGIC_V1_0 && _v1_font->magic[1] == MAGIC_V1_1){ return PSF_V1; @@ -21,7 +21,7 @@ uint8_t get_PSF_version(char *_font_structure){ return 0; } -uint8_t* get_glyph(uint8_t symbolnumber, uint8_t version){ +uint8_t* _psf_get_glyph(uint8_t symbolnumber, uint8_t version){ if (version == PSF_V1){ PSFv1_Font* loaded_font = (PSFv1_Font *) &_binary_fonts_default_psf_start; return (uint8_t *) loaded_font + sizeof(PSFv1_Font) + (symbolnumber * loaded_font->charsize); @@ -32,14 +32,14 @@ uint8_t* get_glyph(uint8_t symbolnumber, uint8_t version){ return 0; } -uint32_t get_width(uint8_t version){ +uint32_t _psf_get_width(uint8_t version){ if ( version == PSF_V1) { return 8; } return ((PSF_font *) &_binary_fonts_default_psf_start)->width; } -uint32_t get_height(uint8_t version){ +uint32_t _psf_get_height(uint8_t version){ if ( version == PSF_V1) { return ((PSFv1_Font *) &_binary_fonts_default_psf_start)->charsize; } diff --git a/src/kernel/hardware/keyboard.c b/src/kernel/hardware/keyboard.c index 158fbb70..aea2fe36 100644 --- a/src/kernel/hardware/keyboard.c +++ b/src/kernel/hardware/keyboard.c @@ -104,7 +104,7 @@ void handle_keyboard_interrupt() { string[9] = read_char; string[10] = '-'; //printf("%s\n", string); - _fb_printStr(string, 0, 10, 0x000000, 0x1ad652); + _fb_printStrAt(string, 0, 10, 0x000000, 0x1ad652); } #endif pretty_logf(Verbose, "\t+ Key is pressed pos %d: SC: %x - Code: %x - Mod: %x %c", buf_position, scancode, keyboard_buffer[buf_position].code, keyboard_buffer[buf_position].modifiers, kgetch(keyboard_buffer[buf_position])); diff --git a/src/kernel/hardware/timer.c b/src/kernel/hardware/timer.c index 56989b0e..ac832c26 100644 --- a/src/kernel/hardware/timer.c +++ b/src/kernel/hardware/timer.c @@ -72,10 +72,10 @@ void timer_handler() { #if USE_FRAMEBUFFER == 1 if(pit_timer_counter == 0) { pit_timer_counter = 1; - //_fb_printStr("*", 0, 14, 0x000000, 0xE169CD); + // _fb_printStrAt("+", 0, 12, 0x000000, 0x365B00); } else { pit_timer_counter = 0; - //_fb_printStr("/", 0, 14, 0x000000, 0xE169CD); + // _fb_printStrAt("-", 0, 12, 0x000000, 0x365B00); } #endif @@ -88,10 +88,10 @@ void pit_irq_handler() { #if USE_FRAMEBUFFER == 1 if(pit_timer_counter == 0) { pit_timer_counter = 1; - _fb_printStr("-", 0, 11, 0x000000, 0xE169CD); + // _fb_printStrAt("-", 0, 12, 0x000000, 0x365B00); } else { pit_timer_counter = 0; - _fb_printStr("+", 0, 11, 0x000000, 0xE169CD); + // _fb_printStrAt("+", 0, 12, 0x000000, 0x365B00); } #endif } diff --git a/src/kernel/io/video.c b/src/kernel/io/video.c index 5c0b33ad..40e4be94 100644 --- a/src/kernel/io/video.c +++ b/src/kernel/io/video.c @@ -6,7 +6,7 @@ #include #endif //#include - +//TODO: Remove legacy VGA support char *VIDEO_MEM = (char *) _VIDEO_MEM_START; char *VIDEO_PTR = (char *) _VIDEO_MEM_START; @@ -21,7 +21,7 @@ char *VIDEO_PTR = (char *) _VIDEO_MEM_START; px_addr[j*4+1] = MagickImage[i+j+1 + k]; px_addr[j*4+2] = MagickImage[i+j+2 + k]; k +=3; - //px_addr = FRAMEBUFFER_MEM + row + j * FRAMEBUFFER_BPP; + //px_addr = FRAMEBUFFER_MEM + row + j * FRAMEBUFFER_BPP; } px_addr +=3200; } @@ -59,14 +59,13 @@ void _printStringAndNumber(char *string, unsigned long number){ void _printNumber(char *buffer, unsigned long number, int base){ switch(base){ - case 10: - break; + case 10: + break; case 16: _getHexString(buffer, number, false); break; } _printStr(buffer); - } void _printHex(char *buffer, unsigned long hexnumber){ diff --git a/src/kernel/logging.c b/src/kernel/logging.c index b854b597..b7c6efd8 100644 --- a/src/kernel/logging.c +++ b/src/kernel/logging.c @@ -25,7 +25,7 @@ bool useVgaOutput; void init_log(size_t defaultOutputs, log_level_t trimBelowLevel, bool useVgaVideo){ if (defaultOutputs == LOG_OUTPUT_DONT_CARE) defaultOutputs = LOG_OUTPUT_SERIAL; //default to serial - + logDestBitmap = defaultOutputs; logTrimLevel = trimBelowLevel; @@ -48,7 +48,7 @@ void set_log_trim_level(size_t newTrim){ void logline(log_level_t level, const char* msg){ if (level < logTrimLevel) return; //dont log things that we dont want to see for now. (would be nice to store these somewhere in the future perhaps, just not display them?) - + for (size_t i = 0; i < LOG_OUTPUT_COUNT; i++){ if ((logDestBitmap & (1 << i)) == 0) continue; //bit is cleared, we should not log there @@ -74,15 +74,17 @@ void logline(log_level_t level, const char* msg){ fbCurrentLine++; } else { - _fb_printStr(logLevelStrings[level], 0, fbCurrentLine, 0xFFFFFFFF, 0); - _fb_printStr(msg, logLevelStrLen, fbCurrentLine, 0xFFFFFFFF, 0); + //TODO: fbCurrentLine should be aligned with cur_fbLine in the framebuffer case. + // fbCurrentLine can be removed, but we probably need to still use _fb_printStrAt + _fb_printStrAt(logLevelStrings[level], 0, fbCurrentLine, 0xFFFFFFFF, 0); + _fb_printStrAt(msg, logLevelStrLen, fbCurrentLine, 0xFFFFFFFF, 0); fbCurrentLine++; } if (fbCurrentLine > fbMaxLine) fbCurrentLine = 0; break; - + default: continue; } @@ -98,7 +100,7 @@ void logline(log_level_t level, const char* msg){ void loglinef(log_level_t level, const char* msg, ...) { char format_buffer[formatBufferLen]; - + va_list format_args; va_start(format_args, msg); vsprintf(format_buffer, msg, format_args); diff --git a/src/kernel/main.c b/src/kernel/main.c index 8684cc5f..e772befb 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -65,7 +65,7 @@ void _init_basic_system(unsigned long addr){ struct multiboot_tag* tag; uint32_t mbi_size = *(uint32_t *) (addr + _HIGHER_HALF_KERNEL_MEM_START); pretty_log(Verbose, "Initialize base system"); - //These data structure are initialized durinig the boot process. + //These data structure are initialized during the boot process. tagmem = (struct multiboot_tag_basic_meminfo *)(multiboot_basic_meminfo + _HIGHER_HALF_KERNEL_MEM_START); tagmmap = (struct multiboot_tag_mmap *) (multiboot_mmap_data + _HIGHER_HALF_KERNEL_MEM_START); tagfb = (struct multiboot_tag_framebuffer *) (multiboot_framebuffer_data + _HIGHER_HALF_KERNEL_MEM_START); @@ -79,8 +79,16 @@ void _init_basic_system(unsigned long addr){ //Print framebuffer info pretty_logf(Verbose, "Framebuffer info: (type: 0x%x) Address: 0x%x", tagfb->common.framebuffer_type, tagfb->common.framebuffer_addr); - pretty_logf(Verbose, "width: 0x%x - height: 0x%x - bpp: 0x%x - pitch: 0x%x", tagfb->common.framebuffer_width, tagfb->common.framebuffer_height, tagfb->common.framebuffer_bpp, tagfb->common.framebuffer_pitch); + pretty_logf(Verbose, "width: 0x%d - height: 0x%d - bpp: 0x%x - pitch: 0x%x", tagfb->common.framebuffer_width, tagfb->common.framebuffer_height, tagfb->common.framebuffer_bpp, tagfb->common.framebuffer_pitch); set_fb_data(tagfb); + + uint32_t pw, ph, cw, ch; + get_framebuffer_mode(&pw, &ph, &cw, &ch); + + framebuffer_data.number_of_rows = cw; + framebuffer_data.number_of_lines = ch; + pretty_logf(Verbose, "Number of lines: %d", framebuffer_data.number_of_lines); + pretty_logf(Verbose, "Total framebuffer size is: 0x%x", framebuffer_data.memory_size); tagacpi = (struct multiboot_tag *) (multiboot_acpi_info + _HIGHER_HALF_KERNEL_MEM_START); @@ -98,10 +106,9 @@ void _init_basic_system(unsigned long addr){ validate_SDT((char *) descriptor, sizeof(RSDPDescriptor20)); } - for (tag=(struct multiboot_tag *) (addr + _HIGHER_HALF_KERNEL_MEM_START + 8); - tag->type != MULTIBOOT_TAG_TYPE_END; - tag = (struct multiboot_tag *) ((multiboot_uint8_t *) tag - + ((tag->size + 7) & ~7))){ + for (tag=(struct multiboot_tag *) (addr + _HIGHER_HALF_KERNEL_MEM_START + 8); + tag->type != MULTIBOOT_TAG_TYPE_END; + tag = (struct multiboot_tag *) ((multiboot_uint8_t *) tag + ((tag->size + 7) & ~7))){ switch(tag->type){ default: pretty_logf(Verbose, "\t[Tag 0x%x] Size: 0x%x", tag->type, tag->size); @@ -112,43 +119,41 @@ void _init_basic_system(unsigned long addr){ void kernel_start(unsigned long addr, unsigned long magic){ qemu_init_debug(); - psf_font_version = get_PSF_version(_binary_fonts_default_psf_start); + psf_font_version = _psf_get_version(_binary_fonts_default_psf_start); init_idt(); load_idt(); init_log(LOG_OUTPUT_SERIAL, Verbose, false); - _init_basic_system(addr); - pretty_logf(Verbose, "Kernel End: 0x%x - Physical: %x", (unsigned long)&_kernel_end, (unsigned long)&_kernel_physical_end); - // Reminder here: The first 8 bytes have a fixed structure in the multiboot info: - // They are: 0-4: size of the boot information in bytes - // 4-8: Reserved (0) - unsigned size = *(unsigned*)(addr + _HIGHER_HALF_KERNEL_MEM_START); - - if(magic != 0x36d76289){ - pretty_log(Fatal, "Failed to verify magic number. Something is wrong"); - } - -#if USE_FRAMEBUFFER == 1 + #if USE_FRAMEBUFFER == 1 + uint8_t psf_type = _psf_get_version(_binary_fonts_default_psf_start); + pretty_logf(Verbose, "PSF v%d found", psf_type); - if(get_PSF_version(_binary_fonts_default_psf_start) == 1){ - pretty_log(Verbose, "PSF v1 found"); + if(psf_type == 1){ PSFv1_Font *font = (PSFv1_Font*)_binary_fonts_default_psf_start; pretty_logf(Verbose, "\tMagic: [%x %x] - Flags: 0x%x - Charsize: 0x%x", font->magic[1], font->magic[0], font->mode, font->charsize); } else { PSF_font *font = (PSF_font*)&_binary_fonts_default_psf_start; - pretty_log(Verbose, "PSF v2 found"); pretty_logf(Verbose, "\tVersion: [0x%x] - Magic: [0x%x] - Header size: 0x%x - flags: 0x%x", font->version, font->magic, font->headersize, font->flags); pretty_logf(Verbose, "\tNumber of glyphs: [0x%x] - Bytes per glyphs: [0x%x]", font->numglyph, font->bytesperglyph); pretty_logf(Verbose, "\tWidth: [0x%x] - Height: [0x%x]", font->width, font->height); } - uint32_t pw, ph, cw, ch; - get_framebuffer_mode(&pw, &ph, &cw, &ch); - pretty_logf(Verbose, "Number of lines: %d", ch); + _init_basic_system(addr); + pretty_logf(Verbose, "Kernel End: 0x%x - Physical: %x", (unsigned long)&_kernel_end, (unsigned long)&_kernel_physical_end); + // Reminder here: The first 8 bytes have a fixed structure in the multiboot info: + // They are: 0-4: size of the boot information in bytes + // 4-8: Reserved (0) + unsigned size = *(unsigned*)(addr + _HIGHER_HALF_KERNEL_MEM_START); + + if(magic != 0x36d76289){ + pretty_log(Fatal, "Failed to verify magic number. Something is wrong"); + } - _fb_printStr("Ciao!", 1, 0, 0x000000, 0xFFFFFF); - _fb_printStr("Dreamos64", 0, 1, 0xFFFFFF, 0x3333ff); - _fb_printStr("Thanks\nfor\n using it", 0, 7, 0xFFFFFF, 0x3333ff); - _fb_printStr(" -- Welcome --", 0, 3, 0xFFFFFF, 0x3333ff); + _fb_printStr("Ciao!", 0x000000, 0xEB72F9); + _fb_printStr(" -- Welcome --", 0x000000, 0x00FF80); + _fb_printStr(" -- Benvenuti --", 0x000000, 0xFFFFFF); + _fb_printStr(" -- Bienvenidos --", 0x000000, 0xFF0000); + _fb_printStr("\tDreamos64", 0xFFFFFF, 0x3333ff); + _fb_printStr("Thanks\n\tfor\n using it", 0xFFFFFF, 0x3333ff); draw_logo(0, 400); #endif @@ -168,7 +173,7 @@ void kernel_start(unsigned long addr, unsigned long magic){ init_apic(); //The table containing the IOAPIC information is called MADT MADT* madt_table = (MADT*) get_SDT_item(MADT_ID); - pretty_logf(Verbose, "Madt SIGNATURE: %x - ADDRESS: %.4s", madt_table->header.Signature, madt_table); + pretty_logf(Verbose, "MADT SIGNATURE: %x - ADDRESS: %.4s", madt_table->header.Signature, madt_table); pretty_logf(Verbose, "MADT local apic base: %x - Madt Length: %d", madt_table->local_apic_base, madt_table->header.Length); print_madt_table(madt_table); init_ioapic(madt_table); @@ -187,7 +192,7 @@ void kernel_start(unsigned long addr, unsigned long magic){ uint64_t unix_timestamp = read_rtc_time(); #if USE_FRAMEBUFFER == 1 - _fb_printStrAndNumber("Epoch time: ", unix_timestamp, 0, 5, 0xf5c4f1, 0x000000); + _fb_printStrAndNumberAt("Epoch time: ", unix_timestamp, 0, 11, 0xf5c4f1, 0x000000); #endif init_scheduler(); char a = 'a'; diff --git a/src/kernel/mem/hh_direct_map.c b/src/kernel/mem/hh_direct_map.c index a517306f..d9371a8c 100644 --- a/src/kernel/mem/hh_direct_map.c +++ b/src/kernel/mem/hh_direct_map.c @@ -29,7 +29,7 @@ void *hhdm_get_variable ( uintptr_t phys_address ) { void hhdm_map_physical_memory() { - // This function should be called only once, and the hhdm shouldn't chnage during the kernel uptime + // This function should be called only once, and the hhdm shouldn't change during the kernel uptime // This function needs to map the entire phyisical memory inside the virtual memory environment. // The starting address is _HIGHER_HALF_KERNEL_MEM_START uint64_t end_of_mapped_physical_memory = end_of_mapped_memory - _HIGHER_HALF_KERNEL_MEM_START; diff --git a/src/kernel/mem/vmm.c b/src/kernel/mem/vmm.c index d4a091ab..a5d2ff4f 100644 --- a/src/kernel/mem/vmm.c +++ b/src/kernel/mem/vmm.c @@ -36,11 +36,11 @@ void vmm_init(vmm_level_t vmm_level, VmmInfo *vmm_info) { uint64_t *root_table_hh; if ( vmm_info == NULL ) { - pretty_log(Verbose, "kernel vmm initialization"); + pretty_log(Verbose, "Kernel vmm initialization"); vmm_info = &vmm_kernel; root_table_hh = kernel_settings.paging.hhdm_page_root_address; } else { - pretty_logf(Verbose, "task vmm initialization: root_table_hhdm: 0x%x", vmm_info->root_table_hhdm); + pretty_logf(Verbose, "Task vmm initialization: root_table_hhdm: 0x%x", vmm_info->root_table_hhdm); root_table_hh = (uint64_t *) vmm_info->root_table_hhdm; }