Initial commit

This commit is contained in:
2021-01-28 22:59:39 +01:00
commit d7f0e8dd36
30 changed files with 2092 additions and 0 deletions

40
kernel/libc/libc.c Normal file
View File

@@ -0,0 +1,40 @@
/*
* libc.c
*
* Created on: Oct 11, 2018
* Author: rick
*/
#include "libc.h"
int memcpy(char *dst, char *src, int amount) {
for (int i = 0; i < amount; i++) {
dst[i] = src[i];
}
return 0;
}
int memset(char *dst, char data, int amount) {
for (int i = 0; i < amount; ++i) {
dst[i] = data;
}
return 0;
}
int itoa(int i, char *target) {
target[0] = (char) (i % 10 + '0');
target[1] = '\0';
if (i > 9) {
itoa(i / 10, target + 1);
}
return 0;
}
int strlen(char *str) {
int length = 0;
while (str[length] != 0) {
length++;
}
return length;
}

19
kernel/libc/libc.h Normal file
View File

@@ -0,0 +1,19 @@
/*
* libc.h
*
* Created on: Oct 11, 2018
* Author: rick
*/
#ifndef KERNEL_LIBC_LIBC_H_
#define KERNEL_LIBC_LIBC_H_
int memcpy(char *dst, char *src, int amount);
int memset(char *dst, char data, int amount);
int itoa(int i, char *target);
int strlen(char *str);
#endif /* KERNEL_LIBC_LIBC_H_ */