~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.\n",
    color: VGA::Colors::BLACK_ON_CYAN,
  )
  VGA.puts("weeeeeeee\n")

  VGA.puts("Hello world!\n \nWorks maybe?\n")
  VGA.puts("Can print on multiple lines\n", color: VGA::Colors::BLACK_ON_LIME)
  VGA.puts("\n\nWe still don't have a heap, but now the puts stores the last row and col so it can call the putchar method with the right col / row instead of overlaying subsequent calls on-top one of another (this is super long line to test word wrap).\n")

  # VGA.set_cursor(0, 5)
  # VGA.hide_cursor

  while true
    asm (%(hlt))
  end
end