summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/debug.h11
-rw-r--r--include/graphics.h32
-rw-r--r--include/multiboot2.h40
3 files changed, 83 insertions, 0 deletions
diff --git a/include/debug.h b/include/debug.h
new file mode 100644
index 0000000..1c53148
--- /dev/null
+++ b/include/debug.h
@@ -0,0 +1,11 @@
+#ifndef DEBUG_H
+#define DEBUG_H
+
+#include <stdint.h>
+
+void bochs_breakpoint(void);
+void put_in_r8(uint64_t value);
+void put_in_r9(uint64_t value);
+void put_in_r10(uint64_t value);
+
+#endif
diff --git a/include/graphics.h b/include/graphics.h
new file mode 100644
index 0000000..d00e8d8
--- /dev/null
+++ b/include/graphics.h
@@ -0,0 +1,32 @@
+#ifndef GRAPHICS_H
+#define GRAPHICS_H
+
+#include <stdint.h>
+
+struct fb_t {
+ uint64_t addr;
+ uint32_t pitch;
+ uint32_t width;
+ uint32_t height;
+ uint8_t bpp;
+ uint8_t type;
+} __attribute__((packed, aligned(8)));
+typedef struct fb_t fb_t;
+
+extern fb_t fb;
+
+#define RED 0x00ff0000
+#define GREEN 0x0000ff00
+#define BLUE 0x000000ff
+#define YELLOW 0x00ffff00
+#define PURPLE 0x00ff00ff
+#define WHITE 0x00ffffff
+#define BLACK 0x00000000
+
+uint64_t* pixel_offset(fb_t fb, uint32_t x, uint32_t y);
+void fb_draw_pixel(fb_t fb, uint32_t x, uint32_t y, uint32_t col);
+void fb_draw_line_low(fb_t fb, uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint32_t col);
+void fb_draw_line_high(fb_t fb, int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t col);
+void fb_draw_line(fb_t fb, int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t col);
+
+#endif
diff --git a/include/multiboot2.h b/include/multiboot2.h
new file mode 100644
index 0000000..f22fd8e
--- /dev/null
+++ b/include/multiboot2.h
@@ -0,0 +1,40 @@
+#ifndef MULTIBOOT2_H
+#define MULTIBOOT2_H
+
+#include <stdint.h>
+
+struct mb2_tag_header {
+ uint32_t type;
+ uint32_t size;
+} __attribute__((packed, aligned(8)));
+typedef struct mb2_tag_header mb2_tag_header;
+
+struct mb2_tag_fb {
+ uint32_t type;
+ uint32_t size;
+ uint64_t framebuffer_addr;
+ uint32_t framebuffer_pitch;
+ uint32_t framebuffer_width;
+ uint32_t framebuffer_height;
+ uint8_t framebuffer_bpp;
+ uint8_t framebuffer_type;
+} __attribute__((packed, aligned(8)));
+typedef struct mb2_tag_fb mb2_tag_fb;
+
+// multiboot2 magic check
+#define MB2_MAGIC 0x36D76289
+
+// multiboot2 tag
+#define MB2_TAG_END 0
+#define MB2_TAG_CMDLINE 1
+#define MB2_TAG_BOOTLOADER 2
+#define MB2_TAG_MODULES 3
+#define MB2_TAG_MEM 4
+#define MB2_TAG_BIOS 5
+#define MB2_TAG_MMAP 6
+#define MB2_TAG_VBE 7
+#define MB2_TAG_FB 8
+
+void init_fb(mb2_tag_header* multiboot_bootinfo, uint32_t multiboot_magic);
+
+#endif