feat: initial booting kernel, copy libc stuff from myke
This commit is contained in:
45
yak-kernel/include/errno.h
Normal file
45
yak-kernel/include/errno.h
Normal file
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// Created by rick on 10-03-21.
|
||||
//
|
||||
|
||||
#ifndef NEW_KERNEL_ERRNO_H
|
||||
#define NEW_KERNEL_ERRNO_H
|
||||
|
||||
extern int errno;
|
||||
|
||||
#define EPERM 1 /* Operation not permitted */
|
||||
#define ENOENT 2 /* No such file or directory */
|
||||
#define ESRCH 3 /* No such process */
|
||||
#define EINTR 4 /* Interrupted system call */
|
||||
#define EIO 5 /* I/O error */
|
||||
#define ENXIO 6 /* No such device or address */
|
||||
#define E2BIG 7 /* Argument list too long */
|
||||
#define ENOEXEC 8 /* Exec format error */
|
||||
#define EBADF 9 /* Bad file number */
|
||||
#define ECHILD 10 /* No child processes */
|
||||
#define EAGAIN 11 /* Try again */
|
||||
#define ENOMEM 12 /* Out of memory */
|
||||
#define EACCES 13 /* Permission denied */
|
||||
#define EFAULT 14 /* Bad address */
|
||||
#define ENOTBLK 15 /* Block device required */
|
||||
#define EBUSY 16 /* Device or resource busy */
|
||||
#define EEXIST 17 /* File exists */
|
||||
#define EXDEV 18 /* Cross-device link */
|
||||
#define ENODEV 19 /* No such device */
|
||||
#define ENOTDIR 20 /* Not a directory */
|
||||
#define EISDIR 21 /* Is a directory */
|
||||
#define EINVAL 22 /* Invalid argument */
|
||||
#define ENFILE 23 /* File table overflow */
|
||||
#define EMFILE 24 /* Too many open files */
|
||||
#define ENOTTY 25 /* Not a typewriter */
|
||||
#define ETXTBSY 26 /* Text file busy */
|
||||
#define EFBIG 27 /* File too large */
|
||||
#define ENOSPC 28 /* No space left on device */
|
||||
#define ESPIPE 29 /* Illegal seek */
|
||||
#define EROFS 30 /* Read-only file system */
|
||||
#define EMLINK 31 /* Too many links */
|
||||
#define EPIPE 32 /* Broken pipe */
|
||||
#define EDOM 33 /* Math argument out of domain of func */
|
||||
#define ERANGE 34 /* Math result not representable */
|
||||
|
||||
#endif //NEW_KERNEL_ERRNO_H
|
||||
2
yak-kernel/include/stdio.h
Normal file
2
yak-kernel/include/stdio.h
Normal file
@@ -0,0 +1,2 @@
|
||||
#define PRINTF_ALIAS_STANDARD_FUNCTION_NAMES_SOFT 1
|
||||
#include <printf/printf.h>
|
||||
37
yak-kernel/include/stdlib.h
Normal file
37
yak-kernel/include/stdlib.h
Normal file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// Created by rick on 10-03-21.
|
||||
//
|
||||
|
||||
#ifndef NEW_KERNEL_STDLIB_H
|
||||
#define NEW_KERNEL_STDLIB_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
void __attribute__((__noreturn__)) abort();
|
||||
|
||||
int atexit(void (*)(void));
|
||||
|
||||
int atoi(const char *);
|
||||
|
||||
char *itoa(uint32_t value, char *buffer, int base);
|
||||
|
||||
char *getenv(const char *);
|
||||
|
||||
int abs(int val);
|
||||
|
||||
long labs(long val);
|
||||
|
||||
long long llabs(long long val);
|
||||
|
||||
void qsort(void *base, size_t num, size_t size, int (*compar)(const void *, const void *));
|
||||
|
||||
long strtol(const char *nptr, char **endptr, int base);
|
||||
|
||||
void *malloc(size_t size);
|
||||
void free(void *ptr);
|
||||
void *calloc(size_t nmemb, size_t size);
|
||||
void *realloc(void *ptr, size_t size);
|
||||
void *reallocarray(void *ptr, size_t nmemb, size_t size);
|
||||
|
||||
#endif //NEW_KERNEL_STDLIB_H
|
||||
40
yak-kernel/include/string.h
Normal file
40
yak-kernel/include/string.h
Normal file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// Created by rick on 01-02-21.
|
||||
//
|
||||
|
||||
#ifndef NEW_KERNEL_STRING_H
|
||||
#define NEW_KERNEL_STRING_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
void *memcpy(void *dst, const void *src, size_t amount);
|
||||
|
||||
void *memset(void *dst, int data, size_t amount);
|
||||
|
||||
void *memmove(void *dst, const void *src, size_t amount);
|
||||
|
||||
void *strcpy(char *dst, const char *src);
|
||||
|
||||
void *strncpy(char *dst, const char *src, size_t n);
|
||||
|
||||
size_t strlen(const char *str);
|
||||
|
||||
char *strchr(const char *s, char c);
|
||||
|
||||
char *strrchr(const char *s, char c);
|
||||
|
||||
int memcmp(const void *s1, const void *s2, size_t n);
|
||||
|
||||
int strcmp(const char *s1, const char *s2);
|
||||
|
||||
int strncmp(const char *s1, const char *s2, size_t n);
|
||||
|
||||
char *strdup(const char *s);
|
||||
|
||||
char *strndup(const char *s, size_t n);
|
||||
|
||||
char *strcat(char *dest, const char *src);
|
||||
|
||||
char *strncat(char *dest, const char *src, size_t n);
|
||||
|
||||
#endif //NEW_KERNEL_STRING_H
|
||||
11
yak-kernel/include/sys/param.h
Normal file
11
yak-kernel/include/sys/param.h
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// Created by rick on 10-03-21.
|
||||
//
|
||||
|
||||
#ifndef NEW_KERNEL_PARAM_H
|
||||
#define NEW_KERNEL_PARAM_H
|
||||
|
||||
#define MIN(a, b) (((a)<(b))?(a):(b))
|
||||
#define MAX(a, b) (((a)>(b))?(a):(b))
|
||||
|
||||
#endif //NEW_KERNEL_PARAM_H
|
||||
16
yak-kernel/include/sys/types.h
Normal file
16
yak-kernel/include/sys/types.h
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* types.h
|
||||
*
|
||||
* Created on: Nov 1, 2018
|
||||
* Author: rick
|
||||
*/
|
||||
|
||||
#ifndef KERNEL_LIBC_TYPES_H_
|
||||
#define KERNEL_LIBC_TYPES_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef int pid_t;
|
||||
|
||||
#endif /* KERNEL_LIBC_TYPES_H_ */
|
||||
12
yak-kernel/include/yak/platform/generic/platform.h
Normal file
12
yak-kernel/include/yak/platform/generic/platform.h
Normal file
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Created by rick on 22-3-23.
|
||||
//
|
||||
|
||||
#ifndef YAK_PLATFORM_H
|
||||
#define YAK_PLATFORM_H
|
||||
|
||||
void platform_init();
|
||||
|
||||
void __attribute__((noreturn)) halt_forever();
|
||||
|
||||
#endif //YAK_PLATFORM_H
|
||||
10
yak-kernel/include/yak/rt/kmain.h
Normal file
10
yak-kernel/include/yak/rt/kmain.h
Normal file
@@ -0,0 +1,10 @@
|
||||
//
|
||||
// Created by rick on 22-3-23.
|
||||
//
|
||||
|
||||
#ifndef YAK_KMAIN_H
|
||||
#define YAK_KMAIN_H
|
||||
|
||||
void kmain();
|
||||
|
||||
#endif //YAK_KMAIN_H
|
||||
18
yak-kernel/include/yak/rt/kprint.h
Normal file
18
yak-kernel/include/yak/rt/kprint.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Created by rick on 21-3-23.
|
||||
//
|
||||
|
||||
#ifndef YAK_KPRINT_H
|
||||
#define YAK_KPRINT_H
|
||||
|
||||
typedef void (*print_function)(char c);
|
||||
|
||||
void kprint_now(char* msg);
|
||||
|
||||
void kprint_putc_now(char c);
|
||||
|
||||
void kprint_register(print_function print);
|
||||
|
||||
void kprint_unregister(print_function print);
|
||||
|
||||
#endif //YAK_KPRINT_H
|
||||
10
yak-kernel/include/yak/rt/panic.h
Normal file
10
yak-kernel/include/yak/rt/panic.h
Normal file
@@ -0,0 +1,10 @@
|
||||
//
|
||||
// Created by rick on 21-3-23.
|
||||
//
|
||||
|
||||
#ifndef YAK_PANIC_H
|
||||
#define YAK_PANIC_H
|
||||
|
||||
void __attribute__((__noreturn__)) panic(char* reason);
|
||||
|
||||
#endif //YAK_PANIC_H
|
||||
Reference in New Issue
Block a user