kv2: add paging

this also fixes up a bunch of formatting, adding the type vaddr_t

Signed-off-by: Michael Shaw <spencershawiscool@gmail.com>
This commit is contained in:
Michael Shaw 2026-04-13 00:04:26 -04:00
commit d6873d6c7a
18 changed files with 130 additions and 66 deletions

View file

@ -839,13 +839,13 @@ static int _vsnprintf(out_fct_type out, char *buffer, const size_t maxlen, const
width = sizeof(void *) * 2U;
flags |= FLAGS_ZEROPAD | FLAGS_UPPERCASE;
#if defined(PRINTF_SUPPORT_LONG_LONG)
const bool is_ll = sizeof(uintptr_t) == sizeof(long long);
const bool is_ll = sizeof(vaddr_t) == sizeof(long long);
if (is_ll) {
idx = _ntoa_long_long(out, buffer, idx, maxlen, (uintptr_t)va_arg(va, void *), false, 16U,
idx = _ntoa_long_long(out, buffer, idx, maxlen, (vaddr_t)va_arg(va, void *), false, 16U,
precision, width, flags);
} else {
#endif
idx = _ntoa_long(out, buffer, idx, maxlen, (unsigned long)((uintptr_t)va_arg(va, void *)), false,
idx = _ntoa_long(out, buffer, idx, maxlen, (unsigned long)((vaddr_t)va_arg(va, void *)), false,
16U, precision, width, flags);
#if defined(PRINTF_SUPPORT_LONG_LONG)
}
@ -919,7 +919,7 @@ int fctprintf(void (*out)(char character, void *arg), void *arg, const char *for
va_list va;
va_start(va, format);
const out_fct_wrap_type out_fct_wrap = { out, arg };
const int ret = _vsnprintf(_out_fct, (char *)(uintptr_t)&out_fct_wrap, (size_t)-1, format, va);
const int ret = _vsnprintf(_out_fct, (char *)(vaddr_t)&out_fct_wrap, (size_t)-1, format, va);
va_end(va);
return ret;
}

View file

@ -1,4 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <kernel/types.h>
#include <lib/string.h>
void *memcpy(void *dest, const void *src, size_t num)
@ -71,19 +72,19 @@ int memcmp(const void *aa, const void *bb, size_t num)
void *memset(void *str, int c, size_t n)
{
uintptr_t ptr = (uintptr_t)str;
uintptr_t val = (uintptr_t)c;
vaddr_t ptr = (vaddr_t)str;
vaddr_t val = (vaddr_t)c;
val |= val << 8;
val |= val << 16;
val |= val << 32;
for (size_t i = 0; i < (n >> 3); i++) {
*(uintptr_t *)ptr = val;
*(vaddr_t *)ptr = val;
ptr += 8;
}
if (n & 7) {
ptr = (uintptr_t)str + (n & (~7ull));
ptr = (vaddr_t)str + (n & (~7ull));
for (size_t i = 0; i < (n & 7); i++) {
*(char *)ptr = c;
ptr++;