~kernel/kernel.cr
.cr
Crystal
(text/x-crystal)
require "./tiny_alloc_i386.cr"
require "./vga.cr"
# require "./pmm.cr"
# require "./ps2.cr"

lib LibBootstrap
  @[Packed]
  struct StartInfo
    multiboot_ptr : UInt32
    end_of_kernel : UInt32
  end
end

fun kearly(info_ptr: LibBootstrap::StartInfo*)
  # Get the startup info
  info = info_ptr.value
end

fun kmain
  # PMM.init # Physical Memory Init
  # TinyAllocI386.init # Tiny Bump Allocator

  VGA.init

  VGA.puts(
    "[CrystalOS Kernel] Hello from Crystal.",
    VGA::Colors::BLACK_ON_CYAN,
  )
  VGA.puts("\n")
  VGA.puts("Hello world!\n\nWorks maybe?\n", line: 1)
  VGA.puts("Can print on multiple lines\n", line: 2, color: VGA::Colors::BLACK_ON_LIME)
  VGA.puts("But because we don't have a Heap, we need to set lines number in puts call for now...\n", line: 3)
  
  VGA.set_cursor(5, 4)
  VGA.hide_cursor

  while true
    asm (%(hlt))
  end
end