diff options
author | Marvin Borner | 2019-09-26 20:22:39 +0200 |
---|---|---|
committer | Marvin Borner | 2019-09-26 20:22:39 +0200 |
commit | 181947c70d7a6c5ff769243885d76f3af39560ce (patch) | |
tree | ffaca16d00fa5636eb10607b206530067606b244 /src/kernel/system.h | |
parent | 8ebf584bbb43584b671b79d5166e00268a7c9661 (diff) |
Added working support for segment:offset pointer
Diffstat (limited to 'src/kernel/system.h')
-rw-r--r-- | src/kernel/system.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/kernel/system.h b/src/kernel/system.h index 6044570..47d902c 100644 --- a/src/kernel/system.h +++ b/src/kernel/system.h @@ -3,4 +3,39 @@ void init(); +typedef struct __attribute__ ((packed)) { + unsigned short di, si, bp, sp, bx, dx, cx, ax; + unsigned short gs, fs, es, ds, eflags; +} regs16_t; + +extern void int32(unsigned char intnum, regs16_t *regs); + +struct far_ptr { + union { + uint32_t ptr; + struct { + uint16_t offset, segment; + }; + }; +} __attribute__ ((packed)); + +static inline uint16_t get_offset(const volatile void *p) { + return (uint16_t) (uintptr_t) p & 0x000F; +} + +static inline uint16_t get_segment(const volatile void *p) { + return (uint16_t) (((uintptr_t) p) >> 4); +} + +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; +} + +static inline void *get_ptr(struct far_ptr fptr) { + return (void *) (unsigned long) ((fptr.segment << 4) + fptr.offset); +} + #endif |