Simple VFS layer

This commit is contained in:
2025-08-15 01:41:11 +02:00
parent b470fb03da
commit d91330ba73
16 changed files with 403 additions and 2 deletions

View File

@ -11,6 +11,9 @@ void hal_intr_disable(void);
void hal_intr_enable(void);
void *hal_memset(void *p, int c, size_t n);
void *hal_memcpy(void *dst, const void *src, size_t n);
size_t hal_strlen(char *s);
int hal_memcmp(const void *s1, const void *s2, int len);
#if defined(__x86_64__)
# define HAL_PAGE_SIZE 0x1000

View File

@ -14,3 +14,34 @@ void *hal_memcpy(void *dst, const void *src, size_t n) {
for (size_t i = 0; i < n; i++) a[i] = b[i];
return dst;
}
size_t hal_strlen(char *s) {
char *s2;
for (s2 = s; *s2; ++s2);
return (s2 - s);
}
// https://aticleworld.com/memcmp-in-c/
int hal_memcmp(const void *s1, const void *s2, int len)
{
unsigned char *p = s1;
unsigned char *q = s2;
int charCompareStatus = 0;
//If both pointer pointing same memory block
if (s1 == s2)
{
return charCompareStatus;
}
while (len > 0)
{
if (*p != *q)
{ //compare the mismatching character
charCompareStatus = (*p >*q)?1:-1;
break;
}
len--;
p++;
q++;
}
return charCompareStatus;
}