feat(kernel.cr): make the crystal kernel on-part with c++ one@@ -19,6 +19,22 @@ fun kearly(info_ptr: LibBootstrap::StartInfo*)
# IDT.init
end
+def outb(port : UInt16, value : UInt8)
+ asm (%(outb %al, %dx) : : "a"(value), "Nd"(port))
+end
+
+def set_cursor_position(row : Int32, col : Int32)
+ position = (80 * row + col).to_u16
+
+ # # Write the high byte
+ # outb(0x3D4_u16, 0x0E_u8);
+ # outb(0x3D5_u16, ((position >> 8) & 0xFF).to_u8);
+
+ # # Write the low byte
+ # outb(0x3D4_u16, 0x0F_u8);
+ # outb(0x3D5_u16, (position & 0xFF).to_u8);
+end
+
def clear_screen
video_memory = Pointer(UInt8).new(0xB8000_u64)
screen_size = 80 * 25
@@ -34,11 +50,22 @@ fun kmain
# IDT.enable_interrupts
# kprint "Hello from Fluorite."
- asm("cli")
+ message = "[CrystalOS Kernel] Hello from Crystal"
+
clear_screen
+ set_cursor_position(0, 0)
- message = "[CrystalOS Kernel] Hello from Crystal\n"
- puts message
+ _str : Pointer(UInt8) = message.to_unsafe
+ video_memory = Pointer(UInt8).new(0xB8000_u64)
+ i = 0
+ ch = _str.value
+ while ch > 0
+ ch = (_str + i).value
+ break if ch == 0
+ (video_memory + (i * 2)).value = ch
+ (video_memory + (i * 2) + 1).value = 0xB0_u8
+ i += 1
+ end
while true
end