aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/system.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/system.h')
-rw-r--r--src/kernel/system.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/kernel/system.h b/src/kernel/system.h
index 47d902c..c7ed2fd 100644
--- a/src/kernel/system.h
+++ b/src/kernel/system.h
@@ -1,15 +1,29 @@
#ifndef MELVIX_SYSTEM_H
#define MELVIX_SYSTEM_H
+/**
+ * Initialize the basic features of the OS
+ */
void init();
+/**
+ * The ASM registers as packed structure
+ */
typedef struct __attribute__ ((packed)) {
unsigned short di, si, bp, sp, bx, dx, cx, ax;
unsigned short gs, fs, es, ds, eflags;
} regs16_t;
+/**
+ * Execute BIOS interrupts by switching to real mode
+ * @param intnum The interrupt number (e.g. 0x10)
+ * @param regs The ASM registers
+ */
extern void int32(unsigned char intnum, regs16_t *regs);
+/**
+ * ASM segment:offset pointer
+ */
struct far_ptr {
union {
uint32_t ptr;
@@ -19,14 +33,25 @@ struct far_ptr {
};
} __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);
@@ -34,6 +59,11 @@ static inline struct far_ptr FAR_PTR(void *__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);
}