aboutsummaryrefslogtreecommitdiff
path: root/kernel/initrd.c
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2024-11-26 22:27:02 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2024-11-26 22:27:02 +0100
commitfa8f9e9f44d47f5b2d0b4cc6a2cc8f328e0caa80 (patch)
tree46dea3fa328b013d1d9bd021d2afea2fa9b69c30 /kernel/initrd.c
parent87d1a2597ceedd03a7d4005db1bf82b72b423a18 (diff)
downloadfbos-fa8f9e9f44d47f5b2d0b4cc6a2cc8f328e0caa80.tar.gz
fbos-fa8f9e9f44d47f5b2d0b4cc6a2cc8f328e0caa80.zip
Move 'memcpy' to assembly
And apparently 'memmove' is not needed anymore, so we dodged a bullet there. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'kernel/initrd.c')
-rw-r--r--kernel/initrd.c27
1 files changed, 5 insertions, 22 deletions
diff --git a/kernel/initrd.c b/kernel/initrd.c
index d503dd8..62a4e20 100644
--- a/kernel/initrd.c
+++ b/kernel/initrd.c
@@ -9,33 +9,16 @@
#define CPIO_HEADER_NAMESIZE 94
#define CPIO_HEADER_SIZE 110
-// TODO: move to assembly
-__kernel void *memcpy(void *dest, const void *src, size_t count)
-{
- char *destc = dest;
- const char *srcc = src;
-
- for (uint64_t i = 0; i < count; i++) {
- *destc++ = *srcc++;
- }
- return dest;
-}
-
-// TODO: this is required by GCC which must be doing some optimization
-// underneath. For now let's keep it simple (and wrong) by just calling memcpy.
-__kernel void *memmove(void *dest, const void *src, size_t count)
-{
- return memcpy(dest, src, count);
-}
-
-__kernel uint64_t strtoul16(const char *str, size_t count)
+// Converts the given string 'str' of 'n' length to an integer by assuming it's
+// in base 16.
+__kernel uint64_t strtoul16(const char *str, size_t n)
{
char c;
uint64_t ret = 0;
uint64_t aux = 0;
- for (uint64_t i = 1; count > 0; i *= 16, count--) {
- c = str[count - 1];
+ for (uint64_t i = 1; n > 0; i *= 16, n--) {
+ c = str[n - 1];
if (c >= 'A' && c <= 'F') {
aux = 10 + (uint64_t)(c - 'A');
} else if (c >= 'a' && c <= 'f') {