diff options
author | Gunnar Beutner <gbeutner@serenityos.org> | 2021-07-18 14:47:32 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-18 17:31:13 +0200 |
commit | 7e94b090fed491f3ca9c0957e7ed2af8ed2e8468 (patch) | |
tree | 1ca195269e74ef7fa879229db362a47290d67eba /Kernel/StdLib.cpp | |
parent | 357ddd393ebd38321f8bc02274942fcad29a1ac9 (diff) | |
download | serenity-7e94b090fed491f3ca9c0957e7ed2af8ed2e8468.zip |
Kernel: Introduce basic pre-kernel environment
This implements a simple bootloader that is capable of loading ELF64
kernel images. It does this by using QEMU/GRUB to load the kernel image
from disk and pass it to our bootloader as a Multiboot module.
The bootloader then parses the ELF image and sets it up appropriately.
The kernel's entry point is a C++ function with architecture-native
code.
Co-authored-by: Liav A <liavalb@gmail.com>
Diffstat (limited to 'Kernel/StdLib.cpp')
-rw-r--r-- | Kernel/StdLib.cpp | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/Kernel/StdLib.cpp b/Kernel/StdLib.cpp index dc8da48252..a4487d36c6 100644 --- a/Kernel/StdLib.cpp +++ b/Kernel/StdLib.cpp @@ -236,48 +236,6 @@ bool copy_from_user(void* dest_ptr, const void* src_ptr, size_t n) return true; } -void* memcpy(void* dest_ptr, const void* src_ptr, size_t n) -{ - size_t dest = (size_t)dest_ptr; - size_t src = (size_t)src_ptr; - // FIXME: Support starting at an unaligned address. - if (!(dest & 0x3) && !(src & 0x3) && n >= 12) { - size_t size_ts = n / sizeof(size_t); -#if ARCH(I386) - asm volatile( - "rep movsl\n" - : "=S"(src), "=D"(dest) - : "S"(src), "D"(dest), "c"(size_ts) - : "memory"); -#else - asm volatile( - "rep movsq\n" - : "=S"(src), "=D"(dest) - : "S"(src), "D"(dest), "c"(size_ts) - : "memory"); -#endif - n -= size_ts * sizeof(size_t); - if (n == 0) - return dest_ptr; - } - asm volatile( - "rep movsb\n" ::"S"(src), "D"(dest), "c"(n) - : "memory"); - return dest_ptr; -} - -void* memmove(void* dest, const void* src, size_t n) -{ - if (dest < src) - return memcpy(dest, src, n); - - u8* pd = (u8*)dest; - const u8* ps = (const u8*)src; - for (pd += n, ps += n; n--;) - *--pd = *--ps; - return dest; -} - const void* memmem(const void* haystack, size_t haystack_length, const void* needle, size_t needle_length) { return AK::memmem(haystack, haystack_length, needle, needle_length); @@ -297,46 +255,6 @@ const void* memmem(const void* haystack, size_t haystack_length, const void* nee return true; } -void* memset(void* dest_ptr, int c, size_t n) -{ - size_t dest = (size_t)dest_ptr; - // FIXME: Support starting at an unaligned address. - if (!(dest & 0x3) && n >= 12) { - size_t size_ts = n / sizeof(size_t); - size_t expanded_c = explode_byte((u8)c); -#if ARCH(I386) - asm volatile( - "rep stosl\n" - : "=D"(dest) - : "D"(dest), "c"(size_ts), "a"(expanded_c) - : "memory"); -#else - asm volatile( - "rep stosq\n" - : "=D"(dest) - : "D"(dest), "c"(size_ts), "a"(expanded_c) - : "memory"); -#endif - n -= size_ts * sizeof(size_t); - if (n == 0) - return dest_ptr; - } - asm volatile( - "rep stosb\n" - : "=D"(dest), "=c"(n) - : "0"(dest), "1"(n), "a"(c) - : "memory"); - return dest_ptr; -} - -size_t strlen(const char* str) -{ - size_t len = 0; - while (*(str++)) - ++len; - return len; -} - size_t strnlen(const char* str, size_t maxlen) { size_t len = 0; |