diff --git a/external/uefi/boot_services.h b/external/uefi/boot_services.h new file mode 100644 index 0000000..8130ad6 --- /dev/null +++ b/external/uefi/boot_services.h @@ -0,0 +1,101 @@ +#pragma once +#ifndef _uefi_boot_services_h_ +#define _uefi_boot_services_h_ + +// This Source Code Form is part of the j6-uefi-headers project and is subject +// to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was +// not distributed with this file, You can obtain one at +// http://mozilla.org/MPL/2.0/. + +#include +#include +#include + +namespace uefi { +namespace bs_impl { + using allocate_pages = status (*)(allocate_type, memory_type, size_t, void**); + using get_memory_map = status (*)(size_t*, memory_descriptor*, size_t*, size_t*, uint32_t*); + using allocate_pool = status (*)(memory_type, uint64_t, void**); + using handle_protocol = status (*)(handle, const guid*, void**); + using create_event = status (*)(evt, tpl, event_notify, void*, event*); + using exit_boot_services = status (*)(handle, size_t); + using locate_protocol = status (*)(const guid*, void*, void**); + using copy_mem = void (*)(void*, void*, size_t); + using set_mem = void (*)(void*, uint64_t, uint8_t); +} + +struct boot_services { + static constexpr uint64_t signature = 0x56524553544f4f42ull; + + table_header header; + + // Task Priority Level management + void *raise_tpl; + void *restore_tpl; + + // Memory Services + bs_impl::allocate_pages allocate_pages; + void *free_pages; + bs_impl::get_memory_map get_memory_map; + bs_impl::allocate_pool allocate_pool; + void *free_pool; + + // Event & Timer Services + bs_impl::create_event create_event; + void *set_timer; + void *wait_for_event; + void *signal_event; + void *close_event; + void *check_event; + + // Protocol Handler Services + void *install_protocol_interface; + void *reinstall_protocol_interface; + void *uninstall_protocol_interface; + bs_impl::handle_protocol handle_protocol; + void *_reserved; + void *register_protocol_notify; + void *locate_handle; + void *locate_device_path; + void *install_configuration_table; + + // Image Services + void *load_image; + void *start_image; + void *exit; + void *unload_image; + bs_impl::exit_boot_services exit_boot_services; + + // Miscellaneous Services + void *get_next_monotonic_count; + void *stall; + void *set_watchdog_timer; + + // DriverSupport Services + void *connect_controller; + void *disconnect_controller; + + // Open and Close Protocol Services + void *open_protocol; + void *close_protocol; + void *open_protocol_information; + + // Library Services + void *protocols_per_handle; + void *locate_handle_buffer; + bs_impl::locate_protocol locate_protocol; + void *install_multiple_protocol_interfaces; + void *uninstall_multiple_protocol_interfaces; + + // 32-bit CRC Services + void *calculate_crc32; + + // Miscellaneous Services + bs_impl::copy_mem copy_mem; + bs_impl::set_mem set_mem; + void *create_event_ex; +}; + +} // namespace uefi + +#endif diff --git a/external/uefi/errors.inc b/external/uefi/errors.inc new file mode 100644 index 0000000..b63f3c0 --- /dev/null +++ b/external/uefi/errors.inc @@ -0,0 +1,39 @@ +STATUS_WARNING( warn_unknown_glyph, 1) +STATUS_WARNING( warn_delete_failure, 2) +STATUS_WARNING( warn_write_failure, 3) +STATUS_WARNING( warn_buffer_too_small,4) +STATUS_WARNING( warn_stale_data, 5) +STATUS_WARNING( warn_file_system, 6) + +STATUS_ERROR( load_error, 1) +STATUS_ERROR( invalid_parameter, 2) +STATUS_ERROR( unsupported, 3) +STATUS_ERROR( bad_buffer_size, 4) +STATUS_ERROR( buffer_too_small, 5) +STATUS_ERROR( not_ready, 6) +STATUS_ERROR( device_error, 7) +STATUS_ERROR( write_protected, 8) +STATUS_ERROR( out_of_resources, 9) +STATUS_ERROR( volume_corrupted, 10) +STATUS_ERROR( volume_full, 11) +STATUS_ERROR( no_media, 12) +STATUS_ERROR( media_changed, 13) +STATUS_ERROR( not_found, 14) +STATUS_ERROR( access_denied, 15) +STATUS_ERROR( no_response, 16) +STATUS_ERROR( no_mapping, 17) +STATUS_ERROR( timeout, 18) +STATUS_ERROR( not_started, 19) +STATUS_ERROR( already_started, 20) +STATUS_ERROR( aborted, 21) +STATUS_ERROR( icmp_error, 22) +STATUS_ERROR( tftp_error, 23) +STATUS_ERROR( protocol_error, 24) +STATUS_ERROR( incompatible_version, 25) +STATUS_ERROR( security_violation, 26) +STATUS_ERROR( crc_error, 27) +STATUS_ERROR( end_of_media, 28) +STATUS_ERROR( end_of_file, 31) +STATUS_ERROR( invalid_language, 32) +STATUS_ERROR( compromised_data, 33) +STATUS_ERROR( http_error, 35) diff --git a/external/uefi/graphics.h b/external/uefi/graphics.h new file mode 100644 index 0000000..e1b06da --- /dev/null +++ b/external/uefi/graphics.h @@ -0,0 +1,92 @@ +#pragma once +#ifndef _uefi_graphics_h_ +#define _uefi_graphics_h_ + +// This Source Code Form is part of the j6-uefi-headers project and is subject +// to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was +// not distributed with this file, You can obtain one at +// http://mozilla.org/MPL/2.0/. + +#include +#include + +namespace uefi { + +struct text_output_mode +{ + int32_t max_mode; + int32_t mode; + int32_t attribute; + int32_t cursor_column; + int32_t cursor_row; + bool cursor_visible; +}; + +struct pixel_bitmask +{ + uint32_t red_mask; + uint32_t green_mask; + uint32_t blue_mask; + uint32_t reserved_mask; +}; + +enum class pixel_format +{ + rgb8, + bgr8, + bitmask, + blt_only +}; + +struct graphics_output_mode_info +{ + uint32_t version; + uint32_t horizontal_resolution; + uint32_t vertical_resolution; + pixel_format pixel_format; + pixel_bitmask pixel_information; + uint32_t pixels_per_scanline; +}; + +struct graphics_output_mode +{ + uint32_t max_mode; + uint32_t mode; + graphics_output_mode_info *info; + uint64_t size_of_info; + uintptr_t frame_buffer_base; + uint64_t frame_buffer_size; +}; + +enum class attribute : uint64_t +{ + black, + blue, + green, + cyan, + red, + magenta, + brown, + light_gray, + dark_gray, + light_blue, + light_green, + light_cyan, + light_red, + light_magenta, + yellow, + white, + + background_black = 0x00, + background_blue = 0x10, + background_green = 0x20, + background_cyan = 0x30, + background_red = 0x40, + background_magenta = 0x50, + background_brown = 0x60, + background_light_gray = 0x70, +}; + +} // namespace uefi + +#endif diff --git a/external/uefi/guid.h b/external/uefi/guid.h new file mode 100644 index 0000000..112b1ec --- /dev/null +++ b/external/uefi/guid.h @@ -0,0 +1,29 @@ +#pragma once +#ifndef _uefi_guid_h_ +#define _uefi_guid_h_ + +// This Source Code Form is part of the j6-uefi-headers project and is subject +// to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was +// not distributed with this file, You can obtain one at +// http://mozilla.org/MPL/2.0/. + +#include + +namespace uefi { + +struct guid +{ + uint32_t data1; + uint16_t data2; + uint16_t data3; + uint8_t data4[8]; + + inline bool operator==(const guid &other) const { + return reinterpret_cast(this)[0] == reinterpret_cast(&other)[0] + && reinterpret_cast(this)[1] == reinterpret_cast(&other)[1]; + } +}; + +} // namespace uefi + +#endif diff --git a/external/uefi/protos/device_path.h b/external/uefi/protos/device_path.h new file mode 100644 index 0000000..3317cbb --- /dev/null +++ b/external/uefi/protos/device_path.h @@ -0,0 +1,30 @@ +#pragma once +#ifndef _uefi_protos_device_path_h_ +#define _uefi_protos_device_path_h_ + +// This file was auto generated by the j6-uefi-headers project. Please see +// https://github.com/justinian/j6-uefi-headers for more information. + +#include +#include + +namespace uefi { +namespace protos { +struct device_path; + +struct device_path +{ + static constexpr uefi::guid guid{ 0x09576e91,0x6d3f,0x11d2,{0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b} }; + + uint8_t type; + uint8_t sub_type; + uint16_t length; + +protected: +public: +}; + +} // namespace protos +} // namespace uefi + +#endif // _uefi_protos_device_path_h_ diff --git a/external/uefi/protos/file.h b/external/uefi/protos/file.h new file mode 100644 index 0000000..37ab5bf --- /dev/null +++ b/external/uefi/protos/file.h @@ -0,0 +1,126 @@ +#pragma once +#ifndef _uefi_protos_file_h_ +#define _uefi_protos_file_h_ + +// This file was auto generated by the j6-uefi-headers project. Please see +// https://github.com/justinian/j6-uefi-headers for more information. + +#include +#include + +namespace uefi { +namespace protos { +struct file; + +struct file +{ + + + inline uefi::status open(file ** new_handle, const wchar_t * file_name, file_mode open_mode, file_attr attributes) { + return _open(this, new_handle, file_name, open_mode, attributes); + } + + inline uefi::status close() { + return _close(this); + } + + inline uefi::status delete_file() { + return _delete_file(this); + } + + inline uefi::status read(uint64_t * buffer_size, void * buffer) { + return _read(this, buffer_size, buffer); + } + + inline uefi::status write(uint64_t * buffer_size, void * buffer) { + return _write(this, buffer_size, buffer); + } + + inline uefi::status get_position(uint64_t * position) { + return _get_position(this, position); + } + + inline uefi::status set_position(uint64_t position) { + return _set_position(this, position); + } + + inline uefi::status get_info(const guid * info_type, uint64_t * buffer_size, void * buffer) { + return _get_info(this, info_type, buffer_size, buffer); + } + + inline uefi::status set_info(const guid * info_type, uint64_t buffer_size, void * buffer) { + return _set_info(this, info_type, buffer_size, buffer); + } + + inline uefi::status flush() { + return _flush(this); + } + + inline uefi::status open_ex(file ** new_handle, const wchar_t * file_name, uint64_t open_mode, uint64_t attributes, file_io_token * token) { + return _open_ex(this, new_handle, file_name, open_mode, attributes, token); + } + + inline uefi::status read_ex(file_io_token * token) { + return _read_ex(this, token); + } + + inline uefi::status write_ex(file_io_token * token) { + return _write_ex(this, token); + } + + inline uefi::status flush_ex(file_io_token * token) { + return _flush_ex(this, token); + } + + uint64_t revision; + +protected: + using _open_def = uefi::status (*)(uefi::protos::file *, file **, const wchar_t *, file_mode, file_attr); + _open_def _open; + + using _close_def = uefi::status (*)(uefi::protos::file *); + _close_def _close; + + using _delete_file_def = uefi::status (*)(uefi::protos::file *); + _delete_file_def _delete_file; + + using _read_def = uefi::status (*)(uefi::protos::file *, uint64_t *, void *); + _read_def _read; + + using _write_def = uefi::status (*)(uefi::protos::file *, uint64_t *, void *); + _write_def _write; + + using _get_position_def = uefi::status (*)(uefi::protos::file *, uint64_t *); + _get_position_def _get_position; + + using _set_position_def = uefi::status (*)(uefi::protos::file *, uint64_t); + _set_position_def _set_position; + + using _get_info_def = uefi::status (*)(uefi::protos::file *, const guid *, uint64_t *, void *); + _get_info_def _get_info; + + using _set_info_def = uefi::status (*)(uefi::protos::file *, const guid *, uint64_t, void *); + _set_info_def _set_info; + + using _flush_def = uefi::status (*)(uefi::protos::file *); + _flush_def _flush; + + using _open_ex_def = uefi::status (*)(uefi::protos::file *, file **, const wchar_t *, uint64_t, uint64_t, file_io_token *); + _open_ex_def _open_ex; + + using _read_ex_def = uefi::status (*)(uefi::protos::file *, file_io_token *); + _read_ex_def _read_ex; + + using _write_ex_def = uefi::status (*)(uefi::protos::file *, file_io_token *); + _write_ex_def _write_ex; + + using _flush_ex_def = uefi::status (*)(uefi::protos::file *, file_io_token *); + _flush_ex_def _flush_ex; + +public: +}; + +} // namespace protos +} // namespace uefi + +#endif // _uefi_protos_file_h_ diff --git a/external/uefi/protos/file_info.h b/external/uefi/protos/file_info.h new file mode 100644 index 0000000..3f6d026 --- /dev/null +++ b/external/uefi/protos/file_info.h @@ -0,0 +1,35 @@ +#pragma once +#ifndef _uefi_protos_file_info_h_ +#define _uefi_protos_file_info_h_ + +// This file was auto generated by the j6-uefi-headers project. Please see +// https://github.com/justinian/j6-uefi-headers for more information. + +#include +#include + +namespace uefi { +namespace protos { +struct file_info; + +struct file_info +{ + static constexpr uefi::guid guid{ 0x09576e92,0x6d3f,0x11d2,{0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b} }; + + uint64_t size; + uint64_t file_size; + uint64_t physical_size; + time create_time; + time last_access_time; + time modification_time; + uint64_t attribute; + wchar_t file_name[]; + +protected: +public: +}; + +} // namespace protos +} // namespace uefi + +#endif // _uefi_protos_file_info_h_ diff --git a/external/uefi/protos/graphics_output.h b/external/uefi/protos/graphics_output.h new file mode 100644 index 0000000..6c17ce6 --- /dev/null +++ b/external/uefi/protos/graphics_output.h @@ -0,0 +1,50 @@ +#pragma once +#ifndef _uefi_protos_graphics_output_h_ +#define _uefi_protos_graphics_output_h_ + +// This file was auto generated by the j6-uefi-headers project. Please see +// https://github.com/justinian/j6-uefi-headers for more information. + +#include +#include +#include + +namespace uefi { +namespace protos { +struct graphics_output; + +struct graphics_output +{ + static constexpr uefi::guid guid{ 0x9042a9de,0x23dc,0x4a38,{0x96,0xfb,0x7a,0xde,0xd0,0x80,0x51,0x6a} }; + + inline uefi::status query_mode(uint32_t mode_number, uint64_t * size_of_info, uefi::graphics_output_mode_info ** info) { + return _query_mode(this, mode_number, size_of_info, info); + } + + inline uefi::status set_mode(uint32_t mode_number) { + return _set_mode(this, mode_number); + } + + inline uefi::status blt() { + return _blt(this); + } + + +protected: + using _query_mode_def = uefi::status (*)(uefi::protos::graphics_output *, uint32_t, uint64_t *, uefi::graphics_output_mode_info **); + _query_mode_def _query_mode; + + using _set_mode_def = uefi::status (*)(uefi::protos::graphics_output *, uint32_t); + _set_mode_def _set_mode; + + using _blt_def = uefi::status (*)(uefi::protos::graphics_output *); + _blt_def _blt; + +public: + uefi::graphics_output_mode * mode; +}; + +} // namespace protos +} // namespace uefi + +#endif // _uefi_protos_graphics_output_h_ diff --git a/external/uefi/protos/loaded_image.h b/external/uefi/protos/loaded_image.h new file mode 100644 index 0000000..420ca94 --- /dev/null +++ b/external/uefi/protos/loaded_image.h @@ -0,0 +1,48 @@ +#pragma once +#ifndef _uefi_protos_loaded_image_h_ +#define _uefi_protos_loaded_image_h_ + +// This file was auto generated by the j6-uefi-headers project. Please see +// https://github.com/justinian/j6-uefi-headers for more information. + +#include +#include +#include +#include + +namespace uefi { +namespace protos { +struct loaded_image; + +struct loaded_image +{ + static constexpr uefi::guid guid{ 0x5b1b31a1,0x9562,0x11d2,{0x8e,0x3f,0x00,0xa0,0xc9,0x69,0x72,0x3b} }; + + inline uefi::status unload(uefi::handle image_handle) { + return _unload(image_handle); + } + + uint32_t revision; + uefi::handle parent_handle; + uefi::system_table * system_table; + uefi::handle device_handle; + uefi::protos::device_path * file_path; + void * reserved; + uint32_t load_options_size; + void * load_options; + void * image_base; + uint64_t image_size; + uefi::memory_type image_code_type; + uefi::memory_type image_data_type; + +protected: + using _unload_def = uefi::status (*)(uefi::handle); + _unload_def _unload; + +public: +}; + +} // namespace protos +} // namespace uefi + +#endif // _uefi_protos_loaded_image_h_ diff --git a/external/uefi/protos/simple_file_system.h b/external/uefi/protos/simple_file_system.h new file mode 100644 index 0000000..7bf1600 --- /dev/null +++ b/external/uefi/protos/simple_file_system.h @@ -0,0 +1,36 @@ +#pragma once +#ifndef _uefi_protos_simple_file_system_h_ +#define _uefi_protos_simple_file_system_h_ + +// This file was auto generated by the j6-uefi-headers project. Please see +// https://github.com/justinian/j6-uefi-headers for more information. + +#include +#include +#include + +namespace uefi { +namespace protos { +struct simple_file_system; + +struct simple_file_system +{ + static constexpr uefi::guid guid{ 0x0964e5b22,0x6459,0x11d2,{0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b} }; + + inline uefi::status open_volume(uefi::protos::file ** root) { + return _open_volume(this, root); + } + + uint64_t revision; + +protected: + using _open_volume_def = uefi::status (*)(uefi::protos::simple_file_system *, uefi::protos::file **); + _open_volume_def _open_volume; + +public: +}; + +} // namespace protos +} // namespace uefi + +#endif // _uefi_protos_simple_file_system_h_ diff --git a/external/uefi/protos/simple_text_output.h b/external/uefi/protos/simple_text_output.h new file mode 100644 index 0000000..bb4ca09 --- /dev/null +++ b/external/uefi/protos/simple_text_output.h @@ -0,0 +1,92 @@ +#pragma once +#ifndef _uefi_protos_simple_text_output_h_ +#define _uefi_protos_simple_text_output_h_ + +// This file was auto generated by the j6-uefi-headers project. Please see +// https://github.com/justinian/j6-uefi-headers for more information. + +#include +#include +#include + +namespace uefi { +namespace protos { +struct simple_text_output; + +struct simple_text_output +{ + static constexpr uefi::guid guid{ 0x387477c2,0x69c7,0x11d2,{0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b} }; + + inline uefi::status reset(bool extended_verification) { + return _reset(this, extended_verification); + } + + inline uefi::status output_string(const wchar_t * string) { + return _output_string(this, string); + } + + inline uefi::status test_string(const wchar_t * string) { + return _test_string(this, string); + } + + inline uefi::status query_mode(uint64_t mode_number, uint64_t * columns, uint64_t * rows) { + return _query_mode(this, mode_number, columns, rows); + } + + inline uefi::status set_mode(uint64_t mode_number) { + return _set_mode(this, mode_number); + } + + inline uefi::status set_attribute(uefi::attribute attribute) { + return _set_attribute(this, attribute); + } + + inline uefi::status clear_screen() { + return _clear_screen(this); + } + + inline uefi::status set_cursor_position(uint64_t column, uint64_t row) { + return _set_cursor_position(this, column, row); + } + + inline uefi::status enable_cursor(bool visible) { + return _enable_cursor(this, visible); + } + + +protected: + using _reset_def = uefi::status (*)(uefi::protos::simple_text_output *, bool); + _reset_def _reset; + + using _output_string_def = uefi::status (*)(uefi::protos::simple_text_output *, const wchar_t *); + _output_string_def _output_string; + + using _test_string_def = uefi::status (*)(uefi::protos::simple_text_output *, const wchar_t *); + _test_string_def _test_string; + + using _query_mode_def = uefi::status (*)(uefi::protos::simple_text_output *, uint64_t, uint64_t *, uint64_t *); + _query_mode_def _query_mode; + + using _set_mode_def = uefi::status (*)(uefi::protos::simple_text_output *, uint64_t); + _set_mode_def _set_mode; + + using _set_attribute_def = uefi::status (*)(uefi::protos::simple_text_output *, uefi::attribute); + _set_attribute_def _set_attribute; + + using _clear_screen_def = uefi::status (*)(uefi::protos::simple_text_output *); + _clear_screen_def _clear_screen; + + using _set_cursor_position_def = uefi::status (*)(uefi::protos::simple_text_output *, uint64_t, uint64_t); + _set_cursor_position_def _set_cursor_position; + + using _enable_cursor_def = uefi::status (*)(uefi::protos::simple_text_output *, bool); + _enable_cursor_def _enable_cursor; + +public: + uefi::text_output_mode * mode; +}; + +} // namespace protos +} // namespace uefi + +#endif // _uefi_protos_simple_text_output_h_ diff --git a/external/uefi/runtime_services.h b/external/uefi/runtime_services.h new file mode 100644 index 0000000..53ae166 --- /dev/null +++ b/external/uefi/runtime_services.h @@ -0,0 +1,52 @@ +#pragma once +#ifndef _uefi_runtime_services_h_ +#define _uefi_runtime_services_h_ + +// This Source Code Form is part of the j6-uefi-headers project and is subject +// to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was +// not distributed with this file, You can obtain one at +// http://mozilla.org/MPL/2.0/. + +#include +#include + +namespace uefi { +namespace rs_impl { + using convert_pointer = uefi::status (*)(uint64_t, void **); + using set_virtual_address_map = uefi::status (*)(size_t, size_t, uint32_t, memory_descriptor *); +} + +struct runtime_services { + static constexpr uint64_t signature = 0x56524553544e5552ull; + + table_header header; + + // Time Services + void *get_time; + void *set_time; + void *get_wakeup_time; + void *set_wakeup_time; + + // Virtual Memory Services + rs_impl::set_virtual_address_map set_virtual_address_map; + rs_impl::convert_pointer convert_pointer; + + // Variable Services + void *get_variable; + void *get_next_variable_name; + void *set_variable; + + // Miscellaneous Services + void *get_next_high_monotonic_count; + void *reset_system; + + // UEFI 2.0 Capsule Services + void *update_capsule; + void *query_capsule_capabilities; + + // Miscellaneous UEFI 2.0 Service + void *query_variable_info; +}; + +} // namespace uefi +#endif diff --git a/external/uefi/tables.h b/external/uefi/tables.h new file mode 100644 index 0000000..e675b65 --- /dev/null +++ b/external/uefi/tables.h @@ -0,0 +1,73 @@ +#pragma once +#ifndef _uefi_tables_h_ +#define _uefi_tables_h_ + +// This Source Code Form is part of the j6-uefi-headers project and is subject +// to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was +// not distributed with this file, You can obtain one at +// http://mozilla.org/MPL/2.0/. + +#include +#include +#include + +namespace uefi { + +struct runtime_services; +struct boot_services; +namespace protos { + struct simple_text_input; + struct simple_text_output; +} + +struct table_header +{ + uint64_t signature; + uint32_t revision; + uint32_t header_size; + uint32_t crc32; + uint32_t reserved; +}; + +struct configuration_table +{ + guid vendor_guid; + void *vendor_table; +}; + +struct system_table +{ + table_header header; + + char16_t *firmware_vendor; + uint32_t firmware_revision; + + handle console_in_handle; + protos::simple_text_input *con_in; + handle console_out_handle; + protos::simple_text_output *con_out; + handle standard_error_handle; + protos::simple_text_output *std_err; + + runtime_services *runtime_services; + boot_services *boot_services; + + unsigned int number_of_table_entries; + configuration_table *configuration_table; +}; + +constexpr uint32_t make_system_table_revision(int major, int minor) { + return (major << 16) | minor; +} + +constexpr uint64_t system_table_signature = 0x5453595320494249ull; +constexpr uint32_t system_table_revision = make_system_table_revision(2, 70); +constexpr uint32_t specification_revision = system_table_revision; + +namespace vendor_guids { + constexpr guid acpi1{ 0xeb9d2d30,0x2d88,0x11d3,{0x9a,0x16,0x00,0x90,0x27,0x3f,0xc1,0x4d} }; + constexpr guid acpi2{ 0x8868e871,0xe4f1,0x11d3,{0xbc,0x22,0x00,0x80,0xc7,0x3c,0x88,0x81} }; +} // namespace vendor_guids +} // namespace uefi + +#endif diff --git a/external/uefi/types.h b/external/uefi/types.h new file mode 100644 index 0000000..3e37595 --- /dev/null +++ b/external/uefi/types.h @@ -0,0 +1,157 @@ +#pragma once +#ifndef _uefi_types_h_ +#define _uefi_types_h_ + +// This Source Code Form is part of the j6-uefi-headers project and is subject +// to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was +// not distributed with this file, You can obtain one at +// http://mozilla.org/MPL/2.0/. + +#include + +namespace uefi { + +using handle = void *; + + +// +// Error and status code definitions +// +constexpr uint64_t error_bit = 0x8000000000000000ull; +constexpr uint64_t make_error(uint64_t e) { return e|error_bit; } + +enum class status : uint64_t +{ + success = 0, + +#define STATUS_WARNING(name, num) name = num, +#define STATUS_ERROR(name, num) name = make_error(num), +#include "uefi/errors.inc" +#undef STATUS_WARNING +#undef STATUS_ERROR +}; + +inline bool is_error(status s) { return static_cast(s) & error_bit; } +inline bool is_warning(status s) { return !is_error(s) && s != status::success; } + + +// +// Time defitions +// +struct time +{ + uint16_t year; + uint8_t month; + uint8_t day; + uint8_t hour; + uint8_t minute; + uint8_t second; + uint8_t _pad0; + uint32_t nanosecond; + int16_t time_zone; + uint8_t daylight; + uint8_t _pad1; +}; + + +// +// Memory and allocation defitions +// +enum class memory_type : uint32_t +{ + reserved, + loader_code, + loader_data, + boot_services_code, + boot_services_data, + runtime_services_code, + runtime_services_data, + conventional_memory, + unusable_memory, + acpi_reclaim_memory, + acpi_memory_nvs, + memory_mapped_io, + memory_mapped_io_port_space, + pal_code, + persistent_memory, + max_memory_type +}; + +enum class allocate_type : uint32_t +{ + any_pages, + max_address, + address +}; + +struct memory_descriptor +{ + memory_type type; + uintptr_t physical_start; + uintptr_t virtual_start; + uint64_t number_of_pages; + uint64_t attribute; +}; + + +// +// Event handling defitions +// +using event = void *; + +enum class evt : uint32_t +{ + notify_wait = 0x00000100, + notify_signal = 0x00000200, + + signal_exit_boot_services = 0x00000201, + signal_virtual_address_change = 0x60000202, + + runtime = 0x40000000, + timer = 0x80000000 +}; + +enum class tpl : uint64_t +{ + application = 4, + callback = 8, + notify = 16, + high_level = 31 +}; + +using event_notify = void (*)(event, void*); + + +// +// File IO defitions +// +struct file_io_token +{ + event event; + status status; + uint64_t buffer_size; + void *buffer; +}; + +enum class file_mode : uint64_t +{ + read = 0x0000000000000001ull, + write = 0x0000000000000002ull, + + create = 0x8000000000000000ull +}; + +enum class file_attr : uint64_t +{ + none = 0, + read_only = 0x0000000000000001ull, + hidden = 0x0000000000000002ull, + system = 0x0000000000000004ull, + reserved = 0x0000000000000008ull, + directory = 0x0000000000000010ull, + archive = 0x0000000000000020ull +}; + +} // namespace uefi + +#endif