lib.rs 860 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #![no_std]
  2. #[macro_use]
  3. extern crate alloc;
  4. use core::panic::PanicInfo;
  5. use log::error;
  6. use qemu_exit::QEMUExit;
  7. static QEMU_EXIT: qemu_exit::X86 = qemu_exit::X86::new(QEMU_EXIT_PORT, QEMU_EXIT_SUCCESS);
  8. #[macro_use]
  9. pub mod macros;
  10. pub mod allocator;
  11. pub mod debugcon;
  12. const QEMU_EXIT_PORT: u16 = 0xf4;
  13. /// Custom error code to report success.
  14. const QEMU_EXIT_SUCCESS: u32 = 73;
  15. /// Initializes the environment.
  16. pub fn init_environment() {
  17. debugcon::DebugconLogger::init();
  18. log::info!("Logger initialized!");
  19. allocator::init();
  20. log::info!("Allocator initialized! {:?}", vec![1, 2, 3]);
  21. }
  22. #[panic_handler]
  23. fn panic_handler(info: &PanicInfo) -> ! {
  24. error!("PANIC! {}", info);
  25. qemu_exit_failure()
  26. }
  27. pub fn qemu_exit_success() -> ! {
  28. QEMU_EXIT.exit_success()
  29. }
  30. pub fn qemu_exit_failure() -> ! {
  31. QEMU_EXIT.exit_failure()
  32. }