summaryrefslogtreecommitdiff
path: root/kernel/include
diff options
context:
space:
mode:
authorAleksa Vuckovic <aleksav013@gmail.com>2022-08-07 16:39:28 +0200
committerAleksa Vuckovic <aleksav013@gmail.com>2022-08-07 16:43:26 +0200
commit71396c5cd460890c52e348687e6e7c864e2dfeed (patch)
tree72e7dd114cea46c5209dba2e0c2ed9ffeb7f55b5 /kernel/include
parent50aaae893611af890a6855158ad0a3e32c7b2c43 (diff)
types.h; libk and heap begining
Diffstat (limited to 'kernel/include')
-rw-r--r--kernel/include/debug.h2
-rw-r--r--kernel/include/font.h18
-rw-r--r--kernel/include/graphics.h2
-rw-r--r--kernel/include/heap.h14
-rw-r--r--kernel/include/idt.h16
-rw-r--r--kernel/include/io.h2
-rw-r--r--kernel/include/irq.h2
-rw-r--r--kernel/include/keyboard.h7
-rw-r--r--kernel/include/keymap.h2
-rw-r--r--kernel/include/libk/math.h8
-rw-r--r--kernel/include/libk/string.h11
-rw-r--r--kernel/include/multiboot2.h2
-rw-r--r--kernel/include/types.h8
13 files changed, 67 insertions, 27 deletions
diff --git a/kernel/include/debug.h b/kernel/include/debug.h
index ebe3a52..74648b9 100644
--- a/kernel/include/debug.h
+++ b/kernel/include/debug.h
@@ -1,8 +1,6 @@
#ifndef DEBUG_H
#define DEBUG_H
-#include <stdint.h>
-
void bochs_breakpoint(void);
#endif
diff --git a/kernel/include/font.h b/kernel/include/font.h
index 2bb00fa..f405a90 100644
--- a/kernel/include/font.h
+++ b/kernel/include/font.h
@@ -1,19 +1,19 @@
#ifndef FONT_H
#define FONT_H
-#include <stdint.h>
+#include <types.h>
#define PSF_FONT_MAGIC 0x864ab572
typedef struct {
- uint32_t magic; /* magic bytes to identify PSF */
- uint32_t version; /* zero */
- uint32_t headersize; /* offset of bitmaps in file, 32 */
- uint32_t flags; /* 0 if there's no unicode table */
- uint32_t numglyph; /* number of glyphs */
- uint32_t bytesperglyph; /* size of each glyph */
- uint32_t height; /* height in pixels */
- uint32_t width; /* width in pixels */
+ uint32_t magic; /* magic bytes to identify PSF */
+ uint32_t version; /* zero */
+ uint32_t headersize; /* offset of bitmaps in file, 32 */
+ uint32_t flags; /* 0 if there's no unicode table */
+ uint32_t numglyph; /* number of glyphs */
+ uint32_t bytesperglyph; /* size of each glyph */
+ uint32_t height; /* height in pixels */
+ uint32_t width; /* width in pixels */
} PSF_font;
/* font i used: /usr/share/kbd/consolefonts/lat9-16.psf.gz */
diff --git a/kernel/include/graphics.h b/kernel/include/graphics.h
index 84505d8..2714f62 100644
--- a/kernel/include/graphics.h
+++ b/kernel/include/graphics.h
@@ -1,7 +1,7 @@
#ifndef GRAPHICS_H
#define GRAPHICS_H
-#include <stdint.h>
+#include <types.h>
struct fb_t {
uint64_t addr;
diff --git a/kernel/include/heap.h b/kernel/include/heap.h
new file mode 100644
index 0000000..ae846bd
--- /dev/null
+++ b/kernel/include/heap.h
@@ -0,0 +1,14 @@
+#ifndef HEAP_H
+#define HEAP_H
+
+#include <types.h>
+
+#define HEAP_START_ADDR 0x00200000
+#define HEAP_SIZE 0x00100000
+#define HEAP_BLOCK_SIZE 0x00000100
+
+void init_heap(uint64_t addr, uint64_t size, uint64_t block_size);
+void* kmalloc(uint32_t size);
+void kfree(void *addr);
+
+#endif
diff --git a/kernel/include/idt.h b/kernel/include/idt.h
index 9ca9c3a..cc2278a 100644
--- a/kernel/include/idt.h
+++ b/kernel/include/idt.h
@@ -1,7 +1,7 @@
#ifndef IDT_H
#define IDT_H
-#include <stdint.h>
+#include <types.h>
#define GDT_CODE_SEG 0x08
@@ -9,13 +9,13 @@
#define TRAP_GATE 0x8F
struct idt_entry {
- uint16_t offset_1; // offset bits 0..15
- uint16_t selector; // a code segment selector in GDT or LDT
- uint8_t ist; // bits 0..2 holds Interrupt Stack Table offset, rest of bits zero.
- uint8_t type_attributes; // gate type, dpl, and p fields
- uint16_t offset_2; // offset bits 16..31
- uint32_t offset_3; // offset bits 32..63
- uint32_t zero; // reserved
+ uint16_t offset_1; // offset bits 0..15
+ uint16_t selector; // a code segment selector in GDT or LDT
+ uint8_t ist; // bits 0..2 holds Interrupt Stack Table offset, rest of bits zero.
+ uint8_t type_attributes; // gate type, dpl, and p fields
+ uint16_t offset_2; // offset bits 16..31
+ uint32_t offset_3; // offset bits 32..63
+ uint32_t zero; // reserved
} __attribute__((packed));
typedef struct idt_entry idt_entry;
diff --git a/kernel/include/io.h b/kernel/include/io.h
index 76c401d..d47abb3 100644
--- a/kernel/include/io.h
+++ b/kernel/include/io.h
@@ -1,7 +1,7 @@
#ifndef IO_H
#define IO_H
-#include <stdint.h>
+#include <types.h>
uint8_t inb(uint32_t port);
void outb(uint32_t port, uint8_t value);
diff --git a/kernel/include/irq.h b/kernel/include/irq.h
index f0e38d6..2f22aff 100644
--- a/kernel/include/irq.h
+++ b/kernel/include/irq.h
@@ -1,7 +1,7 @@
#ifndef IRQ_H
#define IRQ_H
-#include <stdint.h>
+#include <types.h>
// exceptions
void isr0(void);
diff --git a/kernel/include/keyboard.h b/kernel/include/keyboard.h
index 050507d..5d7acd0 100644
--- a/kernel/include/keyboard.h
+++ b/kernel/include/keyboard.h
@@ -1,15 +1,16 @@
#ifndef KEYBOARD_H
#define KEYBOARD_H
-#include <stdint.h>
+#include <types.h>
#define KEYBOARD_DATA_PORT 0x60
#define KEYBOARD_STATUS_PORT 0x64
-uint32_t stoi(const char *s);
-void itos(uint32_t num, char** s);
+uint64_t stoi(const char *s);
+void itos(uint64_t num, char* s);
void print_char(char c);
void print_string(char* s);
void keyboard_handler(void);
+void print_int(uint64_t num);
#endif
diff --git a/kernel/include/keymap.h b/kernel/include/keymap.h
index c027146..c9b8697 100644
--- a/kernel/include/keymap.h
+++ b/kernel/include/keymap.h
@@ -1,7 +1,7 @@
#ifndef KEYMAP_H
#define KEYMAP_H
-#include <stdint.h>
+#include <types.h>
#define KEY_ESCAPE 0x01
#define KEY_1 0x02
diff --git a/kernel/include/libk/math.h b/kernel/include/libk/math.h
new file mode 100644
index 0000000..83ac7fe
--- /dev/null
+++ b/kernel/include/libk/math.h
@@ -0,0 +1,8 @@
+#ifndef MATH_H
+#define MATH_H
+
+#include <types.h>
+
+int64_t abs(int64_t val);
+
+#endif
diff --git a/kernel/include/libk/string.h b/kernel/include/libk/string.h
new file mode 100644
index 0000000..64a7f81
--- /dev/null
+++ b/kernel/include/libk/string.h
@@ -0,0 +1,11 @@
+#ifndef STRING_H
+#define STRING_H
+
+#include <types.h>
+
+size_t strlen(const char* s);
+uint64_t stoi(const char *s);
+void itos(uint64_t num, char* s);
+void strrev(char *s);
+
+#endif
diff --git a/kernel/include/multiboot2.h b/kernel/include/multiboot2.h
index f22fd8e..e7935a6 100644
--- a/kernel/include/multiboot2.h
+++ b/kernel/include/multiboot2.h
@@ -1,7 +1,7 @@
#ifndef MULTIBOOT2_H
#define MULTIBOOT2_H
-#include <stdint.h>
+#include <types.h>
struct mb2_tag_header {
uint32_t type;
diff --git a/kernel/include/types.h b/kernel/include/types.h
new file mode 100644
index 0000000..b5f54be
--- /dev/null
+++ b/kernel/include/types.h
@@ -0,0 +1,8 @@
+#ifndef TYPES_H
+#define TYPES_H
+
+#include <stdint.h>
+#include <stddef.h>
+#include <stdbool.h>
+
+#endif