summaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/bits/x86_64/descriptor.h30
-rw-r--r--api/bits/x86_64/msr.h20
-rw-r--r--api/lib/kstdio.h18
-rw-r--r--api/lib/kstring.h11
-rw-r--r--api/libc/stdio.h20
-rw-r--r--api/libc/stdlib.h9
-rw-r--r--api/libc/string.h12
-rw-r--r--api/libc/wchar.h6
-rw-r--r--api/posix/sys/mman.h8
9 files changed, 52 insertions, 82 deletions
diff --git a/api/bits/x86_64/descriptor.h b/api/bits/x86_64/descriptor.h
index c0c00f6..c55a493 100644
--- a/api/bits/x86_64/descriptor.h
+++ b/api/bits/x86_64/descriptor.h
@@ -1,3 +1,5 @@
+#pragma once
+
#include <stdint.h>
struct descriptor_table_register_long
@@ -16,3 +18,31 @@ struct segment_descriptor
uint8_t base24;
} __attribute__((packed, aligned(8)));
+struct system_segment_descrptor_long
+{
+ struct segment_descriptor segment;
+ uint32_t base32;
+ uint32_t r0;
+} __attribute__((packed, aligned(8)));
+
+struct gate_descriptor
+{
+ uint16_t offset0;
+ uint16_t selector;
+ uint8_t ist;
+ uint8_t access;
+ uint16_t offset16;
+ uint64_t offset32;
+} __attribute__((packed, aligned(8)));
+
+struct task_state_segment_long
+{
+ uint32_t r0;
+ uint64_t rsp[3];
+ uint64_t r1;
+ uint64_t ist[7];
+ uint64_t r2;
+ uint16_t r3;
+ uint16_t iomap_base;
+} __attribute__((packed, aligned(8)));
+
diff --git a/api/bits/x86_64/msr.h b/api/bits/x86_64/msr.h
index a25af7d..95486cc 100644
--- a/api/bits/x86_64/msr.h
+++ b/api/bits/x86_64/msr.h
@@ -1,13 +1,13 @@
+#pragma once
+
#include <stdint.h>
#define MSR_INDEX_EFER 0xc0000080
#define MSR_INDEX_STAR 0xc0000081
#define MSR_INDEX_LSTAR 0xc0000082
-
-union msr_efer
-{
- uint64_t value;
-};
+#define MSR_INDEX_SFMASK 0xc0000084
+#define MSR_INDEX_KERNELGSBASE 0xc0000102
+#define MSR_EFER_SCE 1
union msr_star
{
@@ -27,3 +27,13 @@ union msr_lstar
uint64_t value;
};
+union msr_sfmask
+{
+ struct
+ {
+ uint32_t mask;
+ uint32_t reserved;
+ };
+ uint64_t value;
+};
+
diff --git a/api/lib/kstdio.h b/api/lib/kstdio.h
deleted file mode 100644
index 80e47cc..0000000
--- a/api/lib/kstdio.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#pragma once
-
-#include <lib/kstring.h>
-
-#include <stdarg.h>
-
-typedef struct FILE FILE;
-
-extern FILE *kstdout;
-extern FILE *kstderr;
-
-extern int kfputc(int c, FILE *f);
-
-int kvfprintf(FILE *f, const char *restrict format, va_list arguments);
-int kfprintf(FILE *f, const char *restrict format, ...);
-int kvprintf(const char *restrict format, va_list arguments);
-int kprintf(const char *restrict format, ...);
-
diff --git a/api/lib/kstring.h b/api/lib/kstring.h
deleted file mode 100644
index d1d45d5..0000000
--- a/api/lib/kstring.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#pragma once
-
-#include <stddef.h>
-
-void *memcpy(void *dest, const void *src, size_t size);
-void *memmove(void *dest, const void *src, size_t size);
-void *memset(void *dest, int val, size_t size);
-int memcmp(const void *str1, const void *str2, size_t count);
-size_t strlen(const char *s);
-unsigned long long strtoull(const char *restrict begin, char **restrict end, int base);
-
diff --git a/api/libc/stdio.h b/api/libc/stdio.h
deleted file mode 100644
index 63d1ad8..0000000
--- a/api/libc/stdio.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-
-#include <libc/string.h>
-
-#include <stdarg.h>
-
-typedef struct FILE FILE;
-
-extern FILE *stdin;
-extern FILE *stdout;
-extern FILE *stderr;
-
-int fputc(int c, FILE *f);
-int fputs(const char *str, FILE *f);
-
-int vfprintf(FILE *f, const char *restrict format, va_list arguments);
-int fprintf(FILE *f, const char *restrict format, ...);
-int vprintf(const char *restrict format, va_list arguments);
-int printf(const char *restrict format, ...);
-
diff --git a/api/libc/stdlib.h b/api/libc/stdlib.h
deleted file mode 100644
index d1f3d3b..0000000
--- a/api/libc/stdlib.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#pragma once
-
-#include <stddef.h>
-
-size_t mbstowcs(wchar_t *dst, const char *src, size_t length);
-void *malloc(size_t size);
-void *calloc(size_t count, size_t size);
-void free(void *block);
-
diff --git a/api/libc/string.h b/api/libc/string.h
deleted file mode 100644
index 849275d..0000000
--- a/api/libc/string.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#pragma once
-
-#include <stddef.h>
-
-void *memcpy(void *dest, const void *src, size_t size);
-void *memmove(void *dest, const void *src, size_t size);
-void *memset(void *dest, int val, size_t size);
-int memcmp(const void *str1, const void *str2, size_t count);
-size_t strlen(const char *s);
-int strcmp(const char *s1, const char *s2);
-unsigned long long strtoull(const char *restrict begin, char **restrict end, int base);
-
diff --git a/api/libc/wchar.h b/api/libc/wchar.h
deleted file mode 100644
index 350c209..0000000
--- a/api/libc/wchar.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#pragma once
-
-#include <stddef.h>
-
-size_t wcslen(const wchar_t *s);
-wchar_t *wcsdup(const wchar_t *s);
diff --git a/api/posix/sys/mman.h b/api/posix/sys/mman.h
index dd8d6f5..d347c76 100644
--- a/api/posix/sys/mman.h
+++ b/api/posix/sys/mman.h
@@ -1,6 +1,12 @@
#pragma once
-#define MAP_FAILED ((void *) 1)
+#include <stddef.h>
+
+#include "types.h"
+
+#define MAP_FAILED ((void *) -1)
+
+#define MAP_ANONYMOUS (1 >> 0)
void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
int munmap(void *addr, size_t length);