summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/asm/io.h4
-rw-r--r--include/asm/system.h3
-rw-r--r--include/kernel/memory.h18
-rw-r--r--include/kernel/sched.h26
-rw-r--r--include/string.h37
5 files changed, 86 insertions, 2 deletions
diff --git a/include/asm/io.h b/include/asm/io.h
index 6ca5bbc..1c2e5bc 100644
--- a/include/asm/io.h
+++ b/include/asm/io.h
@@ -6,9 +6,9 @@
#define inb(port) ({ \
unsigned char _val; \
- asm volatile ("inb %%dx, %%al" : "=a" (_val) : "d" (port)); \
+ __asm__ volatile ("inb %%dx, %%al" : "=a" (_val) : "d" (port)); \
_val; \
})
#define outb(port, val) \
- asm volatile ("outb %%al, %%dx" : : "d" (port), "a" (val));
+ __asm__ volatile ("outb %%al, %%dx" : : "d" (port), "a" (val));
diff --git a/include/asm/system.h b/include/asm/system.h
new file mode 100644
index 0000000..02c2f62
--- /dev/null
+++ b/include/asm/system.h
@@ -0,0 +1,3 @@
+#include <kernel/sched.h>
+
+volatile void switch_to(struct task_struct*, struct task_state*);
diff --git a/include/kernel/memory.h b/include/kernel/memory.h
new file mode 100644
index 0000000..7217427
--- /dev/null
+++ b/include/kernel/memory.h
@@ -0,0 +1,18 @@
+#include <stdint.h>
+
+#define PGENT 1024
+
+typedef uint32_t pte_t;
+typedef uint32_t __attribute__((aligned (4096))) ptab_t[PGENT];
+typedef uint32_t pde_t;
+typedef uint32_t __attribute__((aligned (4096))) pdir_t[PGENT];
+
+extern ptab_t ktab;
+
+void *alloc_physical_page(void);
+int free_physical_page(void*);
+void *alloc_physical_pages(unsigned int);
+
+void *map_page(void*);
+
+void paging_init(void);
diff --git a/include/kernel/sched.h b/include/kernel/sched.h
new file mode 100644
index 0000000..fa8e036
--- /dev/null
+++ b/include/kernel/sched.h
@@ -0,0 +1,26 @@
+#ifndef _SCHED_H
+#define _SCHED_H
+
+#include <stdint.h>
+
+struct task_state {
+ uint32_t ss;
+ uint32_t esp;
+ uint32_t eflags;
+ uint32_t cs;
+ uint32_t eip;
+ uint32_t eax;
+ uint32_t ecx;
+ uint32_t edx;
+ uint32_t ebx;
+ uint32_t esp_garbage;
+ uint32_t ebp;
+ uint32_t esi;
+ uint32_t edi;
+} __attribute__((packed));
+
+struct task_struct {
+ struct task_state state;
+} __attribute__((packed));
+
+#endif
diff --git a/include/string.h b/include/string.h
new file mode 100644
index 0000000..72c2b2e
--- /dev/null
+++ b/include/string.h
@@ -0,0 +1,37 @@
+#ifndef STRING_H
+#define STRING_H
+
+#include <stdint.h>
+
+#ifndef NULL
+#define NULL ((void*) 0)
+#endif
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef uint32_t size_t;
+#endif
+
+void* memchr(const void*, int, size_t);
+int memcmp(const void*, const void*, size_t);
+void* memcpy(void*, const void*, size_t);
+void* memmove(void*, const void*, size_t);
+void* memset(void*, int, size_t);
+
+size_t strlen(const char*);
+char* strcat(char*, const char*);
+char* strncat(char*, const char*, size_t);
+char* strchr(const char*, int);
+char* strrchr(char*, int);
+int strcmp(const char*, const char*);
+int strncmp(const char*, const char*, size_t);
+char* strcpy(char*, const char*);
+char* strncpy(char*, const char*, size_t);
+size_t strcspn(const char*, const char*);
+size_t strspn(const char*, const char*);
+char* strpbrk(const char*, const char*);
+char* strstr(const char*, const char*);
+char* strtok(char*, const char*);
+size_t strxfrm(char*, const char*, size_t);
+
+#endif