1#![no_std]
18use alloc::string::ToString;
20
21use buddy_system_allocator::LockedHeap;
22use guest_function_register::GuestFunctionRegister;
23use hyperlight_common::flatbuffer_wrappers::guest_error::ErrorCode;
24use hyperlight_common::mem::HyperlightPEB;
25
26use crate::entrypoint::abort_with_code_and_message;
27extern crate alloc;
28
29pub mod entrypoint;
31pub mod shared_input_data;
32pub mod shared_output_data;
33
34pub mod guest_error;
35pub mod guest_function_call;
36pub mod guest_function_definition;
37pub mod guest_function_register;
38
39pub mod host_function_call;
40
41pub(crate) mod guest_logger;
42pub mod memory;
43pub mod print;
44
45pub mod error;
46#[cfg(target_arch = "x86_64")]
47pub mod exceptions {
48 pub mod gdt;
49 pub mod handlers;
50 pub mod idt;
51 pub mod idtr;
52 pub mod interrupt_entry;
53}
54pub mod logging;
55
56#[cfg_attr(not(test), panic_handler)]
61#[allow(clippy::panic)]
62#[allow(dead_code)]
64fn panic(info: &core::panic::PanicInfo) -> ! {
65 let msg = info.to_string();
66 let c_string = alloc::ffi::CString::new(msg)
67 .unwrap_or_else(|_| alloc::ffi::CString::new("panic (invalid utf8)").unwrap());
68
69 unsafe { abort_with_code_and_message(&[ErrorCode::UnknownError as u8], c_string.as_ptr()) }
70}
71
72#[global_allocator]
74pub(crate) static HEAP_ALLOCATOR: LockedHeap<32> = LockedHeap::<32>::empty();
75
76pub(crate) static mut P_PEB: Option<*mut HyperlightPEB> = None;
77pub static mut MIN_STACK_ADDRESS: u64 = 0;
78
79pub static mut OS_PAGE_SIZE: u32 = 0;
80
81pub(crate) static mut REGISTERED_GUEST_FUNCTIONS: GuestFunctionRegister =
82 GuestFunctionRegister::new();