summaryrefslogtreecommitdiff
path: root/kernel/include
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-04-17 00:51:46 -0400
committerFreya Murphy <freya@freyacat.org>2025-04-17 00:51:46 -0400
commitf3e6838b44a5b37ce7664db5b8662e3d02e5f539 (patch)
treee97eeeabab78ba2c84d3b0069c8db9911cd021b2 /kernel/include
parentfmt (diff)
downloadcomus-f3e6838b44a5b37ce7664db5b8662e3d02e5f539.tar.gz
comus-f3e6838b44a5b37ce7664db5b8662e3d02e5f539.tar.bz2
comus-f3e6838b44a5b37ce7664db5b8662e3d02e5f539.zip
font rending in framebuffer yay!!
Diffstat (limited to 'kernel/include')
-rw-r--r--kernel/include/comus/drivers/gpu.h50
-rw-r--r--kernel/include/comus/drivers/gpu/bochs.h40
-rw-r--r--kernel/include/comus/drivers/term.h37
-rw-r--r--kernel/include/comus/drivers/vga.h22
-rw-r--r--kernel/include/comus/limits.h4
-rw-r--r--kernel/include/comus/term.h85
-rw-r--r--kernel/include/lib/kctype.h5
7 files changed, 206 insertions, 37 deletions
diff --git a/kernel/include/comus/drivers/gpu.h b/kernel/include/comus/drivers/gpu.h
new file mode 100644
index 0000000..d6b4266
--- /dev/null
+++ b/kernel/include/comus/drivers/gpu.h
@@ -0,0 +1,50 @@
+/**
+ * @file gpu.h
+ *
+ * @author Freya Murphy <freya@freyacat.org>
+ *
+ * Graphics Driver Initalization
+ */
+
+#ifndef GPU_H_
+#define GPU_H_
+
+#include <stdint.h>
+
+/**
+ * Loads any gpu graphics driver
+ * @returns 0 on success
+ */
+int gpu_init(void);
+
+/**
+ * @returns the width of the framebuffer
+ */
+uint32_t gpu_width(void);
+
+/**
+ * @returns the height of the framebuffer
+ */
+uint32_t gpu_height(void);
+
+/**
+ * @returns the bit depth of the framebuffer
+ */
+uint8_t gpu_bit_depth(void);
+
+/**
+ * Sets the pixel at a given position
+ */
+void gpu_set_pixel(uint32_t x, uint32_t y, uint32_t r, uint32_t g, uint32_t b);
+
+/**
+ * Draw a character on the gpu at a given (terminal) position
+ */
+void gpu_draw_char(char c, uint16_t x, uint16_t y);
+
+/**
+ * Reports the state of the gpu
+ */
+void gpu_report(void);
+
+#endif /* gpu.h */
diff --git a/kernel/include/comus/drivers/gpu/bochs.h b/kernel/include/comus/drivers/gpu/bochs.h
new file mode 100644
index 0000000..5933a3a
--- /dev/null
+++ b/kernel/include/comus/drivers/gpu/bochs.h
@@ -0,0 +1,40 @@
+/**
+ * @file bochs.h
+ *
+ * @author Freya Murphy <freya@freyacat.org>
+ *
+ * Bochs Graphics Driver
+ */
+
+#ifndef BOCHS_H_
+#define BOCHS_H_
+
+#include <stdint.h>
+
+/**
+ * Loads the bochs graphics driver
+ * @returns 0 on success
+ */
+int bochs_init(void);
+
+/**
+ * @returns the width of the framebuffer
+ */
+uint32_t bochs_width(void);
+
+/**
+ * @returns the height of the framebuffer
+ */
+uint32_t bochs_height(void);
+
+/**
+ * @returns the bit depth of the framebuffer
+ */
+uint8_t bochs_bit_depth(void);
+
+/**
+ * Sets the pixel at a given position
+ */
+void bochs_set_pixel(uint32_t x, uint32_t y, uint32_t r, uint32_t g, uint32_t b);
+
+#endif /* bochs.h */
diff --git a/kernel/include/comus/drivers/term.h b/kernel/include/comus/drivers/term.h
deleted file mode 100644
index ad55bfd..0000000
--- a/kernel/include/comus/drivers/term.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * @file tty.h
- *
- * @author Freya Murphy <freya@freyacat.org>
- *
- * Terminal output
- */
-
-#ifndef TERM_H_
-#define TERM_H_
-
-/**
- * Output a character to the terminal
- */
-void term_out(char c);
-
-/**
- * Output a string to the terminal
- */
-void term_out_str(const char *str);
-
-/**
- * Clear all lines on the terminal
- */
-void term_clear(void);
-
-/**
- * Clear a specifc line on the terminal terminal
- */
-void term_clear_line(int line);
-
-/**
- * Scroll terminal
- */
-void term_scroll(int lines);
-
-#endif /* tty.h */
diff --git a/kernel/include/comus/drivers/vga.h b/kernel/include/comus/drivers/vga.h
new file mode 100644
index 0000000..71906f6
--- /dev/null
+++ b/kernel/include/comus/drivers/vga.h
@@ -0,0 +1,22 @@
+/**
+ * @file vga.h
+ *
+ * @author Freya Murphy <freya@freyacat.org>
+ *
+ * VGA Text Mode Functions
+ */
+
+#ifndef VGA_H_
+#define VGA_H_
+
+#define VGA_WIDTH 80
+#define VGA_HEIGHT 25
+
+#include <stdint.h>
+
+/**
+ * Draw a character to the vga text mode at a given position
+ */
+void vga_draw_char(char c, uint16_t x, uint16_t y);
+
+#endif /* vga.h */
diff --git a/kernel/include/comus/limits.h b/kernel/include/comus/limits.h
index 173d013..2942b89 100644
--- a/kernel/include/comus/limits.h
+++ b/kernel/include/comus/limits.h
@@ -8,3 +8,7 @@
/// max number of processes
#define N_PROCS 256
+
+/// length of terminal buffer
+#define TERM_MAX_WIDTH 480
+#define TERM_MAX_HEIGHT 270
diff --git a/kernel/include/comus/term.h b/kernel/include/comus/term.h
new file mode 100644
index 0000000..2d39915
--- /dev/null
+++ b/kernel/include/comus/term.h
@@ -0,0 +1,85 @@
+/**
+ * @file term.h
+ *
+ * @author Freya Murphy <freya@freyacat.org>
+ *
+ * Terminal output
+ */
+
+#ifndef TERM_H_
+#define TERM_H_
+
+#include <stdint.h>
+
+/// vtable structure for terminal handlers
+///
+/// required:
+/// out_at - put out char at position
+/// scroll - scroll the terminal count lines
+///
+/// optional:
+/// clear - clear terminal
+/// clear_line - clear a specific line on the terminal
+///
+struct terminal {
+ uint16_t width;
+ uint16_t height;
+ void (*draw_char)(char c, uint16_t x, uint16_t y);
+};
+
+/**
+ * Get the character width of the terminal
+ */
+uint16_t term_width(void);
+
+/**
+ * Get the character height of the terminal
+ */
+uint16_t term_height(void);
+
+/**
+ * Output a character to the terminal
+ */
+void term_out(char c);
+
+/**
+ * Output a character to the terminal at a given position
+ */
+void term_out_at(char c, uint16_t x, uint16_t y);
+
+/**
+ * Output a string to the terminal
+ */
+void term_out_str(const char *str);
+
+/**
+ * Output a string to the terminal at a given position
+ */
+void term_out_str_at(const char *str, uint16_t x, uint16_t y);
+
+/**
+ * Clear all lines on the terminal
+ */
+void term_clear(void);
+
+/**
+ * Clear a specifc line on the terminal terminal
+ */
+void term_clear_line(uint16_t line);
+
+/**
+ * Redraw terminal
+ */
+void term_redraw(void);
+
+/**
+ * Scroll terminal
+ */
+void term_scroll(uint16_t lines);
+
+/**
+ * Switch terminal handler
+ */
+void term_switch_handler(uint16_t width, uint16_t height, void (*draw_char)(char c, uint16_t x, uint16_t y));
+
+#endif /* term.h */
diff --git a/kernel/include/lib/kctype.h b/kernel/include/lib/kctype.h
index 6d090c6..aee1bb9 100644
--- a/kernel/include/lib/kctype.h
+++ b/kernel/include/lib/kctype.h
@@ -19,4 +19,9 @@ int isspace(int c);
*/
int isdigit(int c);
+/**
+ * @returns if a character is ascii printable
+ */
+int isprint(int c);
+
#endif /* kctype.h */