aboutsummaryrefslogtreecommitdiff
path: root/include/10.libc
diff options
context:
space:
mode:
authorAleksa Vučković <aleksav013@gmail.com>2022-01-02 22:56:02 +0100
committerAleksa Vučković <aleksav013@gmail.com>2022-01-02 22:56:02 +0100
commite2b78d20b80d89321d8d9df3ab8ade8407642dfc (patch)
tree148cb3bc894b974ae91290e493046120d04987b0 /include/10.libc
parentead31873b971044cd3ecb7e40ae03bdb2e6f7642 (diff)
Adding code
Diffstat (limited to 'include/10.libc')
-rw-r--r--include/10.libc/asm.h9
-rw-r--r--include/10.libc/errno.h0
-rw-r--r--include/10.libc/heap.h11
-rw-r--r--include/10.libc/irq.h39
-rw-r--r--include/10.libc/stdio.h28
-rw-r--r--include/10.libc/stdlib.h15
-rw-r--r--include/10.libc/string.h26
-rw-r--r--include/10.libc/sys/types.h4
-rw-r--r--include/10.libc/time.h0
-rw-r--r--include/10.libc/types.h8
-rw-r--r--include/10.libc/unistd.h14
-rw-r--r--include/10.libc/vga.h29
12 files changed, 183 insertions, 0 deletions
diff --git a/include/10.libc/asm.h b/include/10.libc/asm.h
new file mode 100644
index 0000000..9f2a9e6
--- /dev/null
+++ b/include/10.libc/asm.h
@@ -0,0 +1,9 @@
+#ifndef ASM_H
+#define ASM_H
+
+#include<types.h>
+
+extern uint8_t ioport_in(uint8_t port);
+extern void ioport_out(uint8_t port, char data);
+
+#endif
diff --git a/include/10.libc/errno.h b/include/10.libc/errno.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/include/10.libc/errno.h
diff --git a/include/10.libc/heap.h b/include/10.libc/heap.h
new file mode 100644
index 0000000..fa32f26
--- /dev/null
+++ b/include/10.libc/heap.h
@@ -0,0 +1,11 @@
+#ifndef HEAP_H
+#define HEAP_H
+
+#include<types.h>
+
+void kheapinit();
+int kheapaddblock(uintptr_t addr,uint32_t size,uint32_t bsize);
+void *kmalloc(uint32_t size);
+void kfree(void *ptr);
+
+#endif
diff --git a/include/10.libc/irq.h b/include/10.libc/irq.h
new file mode 100644
index 0000000..58b3cd3
--- /dev/null
+++ b/include/10.libc/irq.h
@@ -0,0 +1,39 @@
+#ifndef IRQ_H
+#define IRQ_H
+
+extern void irq0();
+extern void irq1();
+extern void irq2();
+extern void irq3();
+extern void irq4();
+extern void irq5();
+extern void irq6();
+extern void irq7();
+extern void irq8();
+extern void irq9();
+extern void irq10();
+extern void irq11();
+extern void irq12();
+extern void irq13();
+extern void irq14();
+extern void irq15();
+extern void irq16();
+extern void irq17();
+extern void irq18();
+extern void irq19();
+extern void irq20();
+extern void irq21();
+extern void irq22();
+extern void irq23();
+extern void irq24();
+extern void irq25();
+extern void irq26();
+extern void irq27();
+extern void irq28();
+extern void irq29();
+extern void irq30();
+extern void irq31();
+extern void timer_irq();
+extern void keyboard_irq();
+
+#endif
diff --git a/include/10.libc/stdio.h b/include/10.libc/stdio.h
new file mode 100644
index 0000000..45c9215
--- /dev/null
+++ b/include/10.libc/stdio.h
@@ -0,0 +1,28 @@
+#ifndef _STDIO_H
+#define _STDIO_H
+#include <stdarg.h>
+#include <stddef.h>
+#define SEEK_SET 0
+typedef struct { int unused; } FILE;
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern FILE* stderr;
+#define stderr stderr
+int fclose(FILE*);
+int fflush(FILE*);
+FILE* fopen(const char*, const char*);
+int fprintf(FILE*, const char*, ...);
+size_t fread(void*, size_t, size_t, FILE*);
+int fseek(FILE*, long, int);
+long ftell(FILE*);
+size_t fwrite(const void*, size_t, size_t, FILE*);
+void setbuf(FILE*, char*);
+int vfprintf(FILE*, const char*, va_list);
+
+void printf(char *str, ...);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/10.libc/stdlib.h b/include/10.libc/stdlib.h
new file mode 100644
index 0000000..a0afe38
--- /dev/null
+++ b/include/10.libc/stdlib.h
@@ -0,0 +1,15 @@
+#ifndef _STDLIB_H
+#define _STDLIB_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+void abort(void);
+int atexit(void (*)(void));
+int atoi(const char*);
+void free(void*);
+char* getenv(const char*);
+void* malloc(size_t);
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/10.libc/string.h b/include/10.libc/string.h
new file mode 100644
index 0000000..bef5854
--- /dev/null
+++ b/include/10.libc/string.h
@@ -0,0 +1,26 @@
+#ifndef _STRING_H
+#define _STRING_H
+#include <stddef.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+void* memcpy(void*, const void*, size_t);
+void* memset(void*, int, size_t);
+char* strcpy(char*, const char*);
+size_t strlen(const char*);
+#ifdef __cplusplus
+}
+#endif
+
+#include<types.h>
+
+size_t stringlen(char *str);
+bool stringcmp(char *str1,char *str2);
+void stringcat(char *str1,char *str2);
+void stringrev(char *str);
+void itos(uint32_t num,char *str);
+uint32_t stoi(const char *str);
+double stof(const char *str);
+void ftos(double num, char *str);
+
+#endif
diff --git a/include/10.libc/sys/types.h b/include/10.libc/sys/types.h
new file mode 100644
index 0000000..4f55189
--- /dev/null
+++ b/include/10.libc/sys/types.h
@@ -0,0 +1,4 @@
+#ifndef _SYS_TYPES_H
+#define _SYS_TYPES_H
+typedef int pid_t;
+#endif
diff --git a/include/10.libc/time.h b/include/10.libc/time.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/include/10.libc/time.h
diff --git a/include/10.libc/types.h b/include/10.libc/types.h
new file mode 100644
index 0000000..a6d6530
--- /dev/null
+++ b/include/10.libc/types.h
@@ -0,0 +1,8 @@
+#ifndef TYPES_H
+#define TYPES_H
+
+#include<stdbool.h>
+#include<stddef.h>
+#include<stdint.h>
+
+#endif
diff --git a/include/10.libc/unistd.h b/include/10.libc/unistd.h
new file mode 100644
index 0000000..a6bfee0
--- /dev/null
+++ b/include/10.libc/unistd.h
@@ -0,0 +1,14 @@
+#ifndef _UNISTD_H
+#define _UNISTD_H
+#include <sys/types.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+int execv(const char*, char* const[]);
+int execve(const char*, char* const[], char* const[]);
+int execvp(const char*, char* const[]);
+pid_t fork(void);
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/10.libc/vga.h b/include/10.libc/vga.h
new file mode 100644
index 0000000..eb43644
--- /dev/null
+++ b/include/10.libc/vga.h
@@ -0,0 +1,29 @@
+#ifndef VGA_H
+#define VGA_H
+
+#include<types.h>
+
+static const size_t VGA_WIDTH = 80;
+static const size_t VGA_HEIGHT = 25;
+
+enum vga_color {
+ VGA_COLOR_BLACK = 0,
+ VGA_COLOR_DARK_BLUE = 1,
+ VGA_COLOR_GREEN = 2,
+ VGA_COLOR_TURQUOISE = 3,
+ VGA_COLOR_RED = 4,
+ VGA_COLOR_PURPLE = 5,
+ VGA_COLOR_BROWN = 6,
+ VGA_COLOR_LIGHT_GREY = 7,
+ VGA_COLOR_DARK_GREY = 8,
+ VGA_COLOR_BLUE = 9,
+ VGA_COLOR_LIGHT_GREEN = 10,
+ VGA_COLOR_LIGHT_BLUE = 11,
+ VGA_COLOR_LIGHT_RED = 12,
+ VGA_COLOR_PINK = 13,
+ VGA_COLOR_YELLOW = 14,
+ VGA_COLOR_WHITE = 15,
+};
+void set_color(enum vga_color fg, enum vga_color bg);
+
+#endif