~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!\nWorks maybe?\n", line: 1)
  VGA.puts("Can print on multiple lines\n", line: 2)
  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.puts(%(
  #   Works well
  #   multiline buffer?
  # ),
  #   VGA::Colors::BLACK_ON_LIME,
  # )
  # VGA.puts("\n\n\n")
  # VGA.puts "hello world\n"
  
  #VGA.dump_cursor_and_cells

  while true
    asm (%(hlt))
  end
end