diff --git a/asm/boot.asm b/asm/boot.asm index 2ff387294..3fe038a9f 100644 --- a/asm/boot.asm +++ b/asm/boot.asm @@ -9,6 +9,7 @@ extern enable_sse ; Entry point for the BSP. boot_bsp: + push 0 call enable_fpu call enable_sse mov rax, kmain diff --git a/src/basic/main.c b/src/basic/main.c index 605101e83..df7a961f5 100644 --- a/src/basic/main.c +++ b/src/basic/main.c @@ -292,12 +292,12 @@ void library_statement(struct basic_ctx* ctx) /* Load the library file from VFS */ size_t library_len = file_info->size; - char* temp_library = kmalloc(library_len); + char* temp_library = kmalloc(library_len + 1); if (!temp_library) { tokenizer_error_print(ctx, "Not enough memory to load library file"); return; } - char* clean_library = kmalloc(library_len); + char* clean_library = kmalloc(library_len + 1); if (!clean_library) { kfree_null(&temp_library); tokenizer_error_print(ctx, "Not enough memory to load library file"); diff --git a/src/memcpy.c b/src/memcpy.c index f49f2fcf4..46bba91bf 100644 --- a/src/memcpy.c +++ b/src/memcpy.c @@ -9,25 +9,29 @@ void* memset(void* dest, char val, uint64_t len) static inline void* movsb(void* dst, const void* src, size_t size) { - __asm__ volatile("rep movsb" : "+D"(dst), "+S"(src), "+c"(size) : : "memory"); + void *copy = dst; + __asm__ volatile("rep movsb" : "+D"(copy), "+S"(src), "+c"(size) : : "memory"); return dst; } static inline void* movsl(void* dst, const void* src, size_t size) { - __asm__ volatile("rep movsl" : "+D"(dst), "+S"(src), "+c"(size) : : "memory"); + void *copy = dst; + __asm__ volatile("rep movsl" : "+D"(copy), "+S"(src), "+c"(size) : : "memory"); return dst; } static inline void* movsw(void* dst, const void* src, size_t size) { - __asm__ volatile("rep movsw" : "+D"(dst), "+S"(src), "+c"(size) : : "memory"); + void *copy = dst; + __asm__ volatile("rep movsw" : "+D"(copy), "+S"(src), "+c"(size) : : "memory"); return dst; } static inline void* movsq(void* dst, const void* src, size_t size) { - __asm__ volatile("rep movsq" : "+D"(dst), "+S"(src), "+c"(size) : : "memory"); + void *copy = dst; + __asm__ volatile("rep movsq" : "+D"(copy), "+S"(src), "+c"(size) : : "memory"); return dst; } diff --git a/src/string.c b/src/string.c index 1732d7319..5cd0c2475 100644 --- a/src/string.c +++ b/src/string.c @@ -234,9 +234,9 @@ char* strdup(const char* string) if (!string) { return NULL; } - uint32_t len = strlen(string) + 1; - char* result = kmalloc(len); - strlcpy(result, string, len); + uint32_t len = strlen(string); + char* result = kmalloc(len + 1); + strlcpy(result, string, len + 1); *(result + len) = 0; return result; } @@ -246,9 +246,9 @@ char* gc_strdup(const char* string) if (!string) { return NULL; } - uint32_t len = strlen(string) + 1; - char* result = kmalloc(len); - strlcpy(result, string, len); + uint32_t len = strlen(string); + char* result = kmalloc(len + 1); + strlcpy(result, string, len + 1); *(result + len) = 0; if (gc_list == NULL) { diff --git a/src/video.c b/src/video.c index b9a82d98d..fe5a5eed5 100644 --- a/src/video.c +++ b/src/video.c @@ -166,10 +166,14 @@ void init_console() wait_forever(); } rr_console_init_from_limine(); - clearscreen(c); struct limine_framebuffer* fb = framebuffer_request.response->framebuffers[0]; + screen_graphics_x = fb->width; + screen_graphics_y = fb->height; + + clearscreen(c); + dprintf("Bringing up flanterm...\n"); struct limine_module_response* mods = module_request.response; @@ -211,8 +215,6 @@ void init_console() flanterm_get_dimensions(ft_ctx, &x, &y); screen_x = x; screen_y = y; - screen_graphics_x = fb->width; - screen_graphics_y = fb->height; dprintf("Framebuffer address: %llx x resolution=%d y resolution=%d\n", framebuffer_address(), screen_get_width(), screen_get_height()); setforeground(current_console, COLOUR_LIGHTYELLOW);