aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/system.h
diff options
context:
space:
mode:
authorMarvin Borner2019-10-26 22:15:29 +0200
committerMarvin Borner2019-10-26 22:15:29 +0200
commit5d4180c67cea08bb76eebde6b41b8935e60fed98 (patch)
tree1f3bd2be8e20dc754dcc73af36684fdc3642d7ba /src/kernel/system.h
parentb2cf27bb1d8239a7ccc55c29df996370c8f1bed6 (diff)
Improved VESA and fixed warnings
Diffstat (limited to 'src/kernel/system.h')
-rw-r--r--src/kernel/system.h96
1 files changed, 5 insertions, 91 deletions
diff --git a/src/kernel/system.h b/src/kernel/system.h
index c80b6ee..45e88de 100644
--- a/src/kernel/system.h
+++ b/src/kernel/system.h
@@ -1,12 +1,6 @@
#ifndef MELVIX_SYSTEM_H
#define MELVIX_SYSTEM_H
-#include <stdint.h>
-#include "timer/timer.h"
-#include "lib/lib.h"
-#include "graphics/vesa.h"
-#include "io/io.h"
-
/**
* Initialize the basic features of the OS
*/
@@ -28,115 +22,35 @@ typedef struct __attribute__ ((packed)) {
extern void int32(unsigned char intnum, regs16_t *regs);
/**
- * ASM segment:offset pointer
- */
-struct far_ptr {
- union {
- uint32_t ptr;
- struct {
- uint16_t offset, segment;
- };
- };
-} __attribute__ ((packed));
-
-/**
- * Get offset from ASM segment:offset pointer
- */
-static inline uint16_t get_offset(const volatile void *p) {
- return (uint16_t) (uintptr_t) p & 0x000F;
-}
-
-/**
- * Get segment from ASM segment:offset pointer
- */
-static inline uint16_t get_segment(const volatile void *p) {
- return (uint16_t) (((uintptr_t) p) >> 4);
-}
-
-/**
- * Convert pointer to far_ptr
- * @param __ptr The ASM segment:offset pointer
- * @return The new far pointer
- */
-static inline struct far_ptr FAR_PTR(void *__ptr) {
- struct far_ptr __fptr;
- __fptr.offset = get_offset(__ptr);
- __fptr.segment = get_segment(__ptr);
- return __fptr;
-}
-
-/**
- * Get pointer from ASM segment:offset far pointer
- * @param fptr The ASM far pointer
- * @return The normalized pointer
- */
-static inline void *get_ptr(struct far_ptr fptr) {
- return (void *) (unsigned long) ((fptr.segment << 4) + fptr.offset);
-}
-
-/**
* Print the current kernel time
*/
-static inline void kernel_time() {
- vesa_draw_string("\n");
- vesa_draw_string("[");
- vesa_draw_number(get_time());
- vesa_draw_string("] ");
-}
+void kernel_time();
/**
* Display an information message
* @param msg The information
*/
-static inline void info(char *msg) {
- // terminal_set_color(9);
- kernel_time();
- vesa_draw_string("INFO: ");
- vesa_draw_string(msg);
- vesa_draw_string("\r");
- // terminal_set_color(7);
-}
+void info(char *msg);
/**
* Display a warning message
* TODO: Add line number and file name
* @param msg The warning cause/reason
*/
-static inline void warn(char *msg) {
- // terminal_set_color(6);
- kernel_time();
- vesa_draw_string("WARNING: ");
- vesa_draw_string(msg);
- vesa_draw_string("\r");
- // terminal_set_color(7);
-}
+void warn(char *msg);
/**
* Halt the entire system and display a message
* TODO: Add line number and file name
* @param msg The error cause/reason
*/
-static inline void panic(char *msg) {
- asm volatile ("cli");
- // terminal_set_color(4);
- kernel_time();
- serial_write("PANIC: ");
- serial_write(msg);
- serial_write(" - System Halted!\n");
- loop:
- asm volatile ("hlt");
- goto loop;
-}
+void panic(char *msg);
/**
* Assert that a value is non-zero, else panic
* TODO: Add line number and file name
* @param x The value
*/
-static inline void assert(int x) {
- if (x == 0) {
- panic("Assertion failed");
- }
-}
+void assert(int x);
#endif