Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified userland/init_service/init.bin
Binary file not shown.
10 changes: 1 addition & 9 deletions userland/init_service/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ static int64_t allocate_user_stack(int slave_vspace, uint64_t stack_top, uint64_
return stack_top;
}

void *memcpy(void *dst, const void *src, uint64_t n) {
uint8_t *d = (uint8_t *)dst;
const uint8_t *s = (const uint8_t *)src;
while (n--)
*d++ = *s++;
return dst;
}

__attribute__((noreturn, section(".text._start")))
void _start(BootInfo_t* boot_info) {
int64_t ret;
Expand Down Expand Up @@ -181,4 +173,4 @@ void _start(BootInfo_t* boot_info) {

printf("Slave process started, init going idle\n");
for (;;) { spin_pause(); }
}
}
9 changes: 5 additions & 4 deletions userland/libOs/shared.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#pragma once

#include "types.h"
#include "syscalls.h"
#include "stdlib.h"
#include "stdio.h"
#include "ipc.h"
#include "memory.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "syscalls.h"
#include "tcb.h"
#include "types.h"

#define SYS_CAP_COPY 0x80

Expand Down
71 changes: 71 additions & 0 deletions userland/libOs/string.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#pragma once

#include "types.h"

static inline int memcmp(const char *s1, const char *s2, size_t n) {
unsigned char u1, u2;

for (; n--; s1++, s2++){
u1 = *(unsigned char *)s1;
u2 = *(unsigned char *)s2;

if (u1 != u2){
return (u1 - u2);
}
}

return 0;
}

static inline void* memcpy(void *restrict destination, const void *restrict source, size_t n) {
size_t *tmp_dest = (size_t *)destination;
size_t *tmp_src = (size_t *)source;
size_t len = n / sizeof(size_t);
size_t i = 0;
size_t tail = n & (sizeof(size_t) - 1);

for (; i < len; i++) {
*tmp_dest++ = *tmp_src++;
}

if(tail) {
char *dest = (char *)destination;
const char *src = (const char *)source;

for(i = n - tail; i < n; i++) {
dest[i] = src[i];
}
}

return destination;
}

static inline void* memset(void* ptr, int value, size_t num) {
uint8_t* bytes = ptr;

while(num--) {
*bytes++ = (uint8_t)value;
}
}

static inline void* memmove(void *dest, void *src, size_t count) {
void* ret = dest;

if (dest <= src || (char*)dest >= ((char*)src + count)) {
while (count--) {
*(char*)dest = *(char*)src;
dest = (char*)dest + 1;
src = (char*)src + 1;
}
} else {
dest = (char*)dest + count - 1;
src = (char*)src + count - 1;
while (count--) {
*(char*)dest = *(char*)src;
dest = (char*)dest - 1;
src = (char*)src - 1;
}
}

return ret;
}
2 changes: 2 additions & 0 deletions userland/libOs/syscalls.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "types.h"

static inline int64_t syscall0(uint64_t number) {
int64_t ret;
__asm__ volatile (
Expand Down
11 changes: 11 additions & 0 deletions userland/libOs/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,21 @@ typedef unsigned char __uint8_t;
typedef unsigned short int __uint16_t;
typedef unsigned int __uint32_t;
typedef unsigned long int __uint64_t;

typedef signed char __int8_t;
typedef signed short int __int16_t;
typedef signed int __int32_t;
typedef signed long int __int64_t;

typedef __uint8_t uint8_t;
typedef __uint16_t uint16_t;
typedef __uint32_t uint32_t;
typedef __uint64_t uint64_t;

typedef __int8_t int8_t;
typedef __int16_t int16_t;
typedef __int32_t int32_t;
typedef __int64_t int64_t;

typedef __SIZE_TYPE__ size_t;
typedef int64_t ssize_t;