mirror of
https://github.com/Bareflank/hypervisor
synced 2026-08-17 06:23:04 -04:00
Add UEFI suppport
This patch adds support for UEFI, as well as some additional cleanup tasks including: - compressing the TLS block - build system fixes - some todos that were needed to support UEFI - addresses some bugs with the GDT TSS busy bit
This commit is contained in:
parent
b4af35e31b
commit
47f23f1841
218 changed files with 12061 additions and 2829 deletions
2
.doxygen
2
.doxygen
|
|
@ -897,7 +897,7 @@ RECURSIVE = YES
|
|||
# Note that relative paths are relative to the directory from which doxygen is
|
||||
# run.
|
||||
|
||||
EXCLUDE = loader/windows
|
||||
EXCLUDE = loader/windows loader/efi/include/efi
|
||||
|
||||
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
|
||||
# directories that are symbolic links (a Unix file system feature) are excluded
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -69,6 +69,7 @@ loader/**/*.mod.o
|
|||
loader/**/*.mod.cmd
|
||||
loader/**/*.o
|
||||
loader/**/*.o.cmd
|
||||
loader/**/*.cmd
|
||||
|
||||
# Windows Loader
|
||||
loader/windows/x64/
|
||||
|
|
|
|||
|
|
@ -32,5 +32,14 @@ if(HYPERVISOR_BUILD_VMMCTL)
|
|||
add_subdirectory(vmmctl)
|
||||
endif()
|
||||
|
||||
hypervisor_add_mk_cross_compile(cmake/mk_cross_compile)
|
||||
hypervisor_add_ext_cross_compile(cmake/ext_cross_compile)
|
||||
if(HYPERVISOR_BUILD_MICROKERNEL)
|
||||
hypervisor_add_mk_cross_compile(cmake/mk_cross_compile)
|
||||
endif()
|
||||
|
||||
if(HYPERVISOR_BUILD_EXAMPLES)
|
||||
hypervisor_add_ext_cross_compile(cmake/ext_cross_compile)
|
||||
endif()
|
||||
|
||||
if(HYPERVISOR_BUILD_EFI)
|
||||
hypervisor_add_efi_cross_compile(cmake/efi_cross_compile)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -31,6 +31,18 @@ if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL Darwin)
|
|||
set(HAVE_FLAG_SEARCH_PATHS_FIRST 0 CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CMAKE_C_COMPILER)
|
||||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
|
||||
set(CMAKE_C_COMPILER llvm-clang CACHE INTERNAL "")
|
||||
else()
|
||||
set(CMAKE_C_COMPILER clang CACHE INTERNAL "")
|
||||
endif()
|
||||
find_program(CMAKE_C_COMPILER ${CMAKE_C_COMPILER})
|
||||
if(NOT CMAKE_C_COMPILER)
|
||||
message(FATAL_ERROR "Unable to find a default C++ compiler")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CMAKE_CXX_COMPILER)
|
||||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
|
||||
set(CMAKE_CXX_COMPILER llvm-clang++ CACHE INTERNAL "")
|
||||
|
|
|
|||
23
README.md
23
README.md
|
|
@ -111,6 +111,29 @@ make info
|
|||
make
|
||||
```
|
||||
|
||||
### **UEFI**
|
||||
To compile for UEFI, simply follow the steps for your OS above, but add the following to the cmake:
|
||||
```cmake
|
||||
-DHYPERVISOR_BUILD_EFI=ON
|
||||
```
|
||||
|
||||
You can then build the hypervisor as normal and the UEFI loader will be compiled for you automatically. Once the kernel, extensions and UEFI loader are compiled, you can copy them to your UEFI FS0 partition. **Note that all binaries must be copied to your FS0 partition, and on some systems, this might be a USB stick**. To aid in this copy process, the build system includes the following command:
|
||||
```bash
|
||||
make copy_to_efi_partition
|
||||
```
|
||||
|
||||
By default this uses the EFI partition, but it can be relocated using:
|
||||
```cmake
|
||||
-DHYPERVISOR_EFI_FS0=<path to FS0>
|
||||
```
|
||||
|
||||
Some systems require you to provide the UEFI shell, and so Bareflank contains a copy of this shell which will be copied along with the kernel, extensions and UEFI loader. Once you have rebooted into the UEFI shell, you can start the hypervisor using
|
||||
```
|
||||
start_bareflank.efi
|
||||
```
|
||||
|
||||
Note that by default, the hypervisor is not able to boot an OS. You must either use a non-default example that provides more complete UEFI support, or provide your own extension that is capable of successfully booting an OS. Finally, we currently *do not* provide any of the other vmmctl functions like stop or dump.
|
||||
|
||||
## Usage Instructions
|
||||
To use the hypervisor, run the following commands (on Windows, replace make with ninja):
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ include(${bsl_SOURCE_DIR}/cmake/function/bf_add_config.cmake)
|
|||
|
||||
option(HYPERVISOR_BUILD_LOADER "Turns on/off building the loader" ON)
|
||||
option(HYPERVISOR_BUILD_VMMCTL "Turns on/off building the vmmctl" ON)
|
||||
option(HYPERVISOR_BUILD_MICROKERNEL "Turns on/off building the microkernel" ON)
|
||||
option(HYPERVISOR_BUILD_EXAMPLES "Turns on/off building the examples" ON)
|
||||
option(HYPERVISOR_BUILD_EFI "Turns on/off building the EFI loader" ON)
|
||||
|
||||
if (NOT DEFINED HYPERVISOR_TARGET_ARCH)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
|
|
@ -56,6 +59,30 @@ else()
|
|||
set(HYPERVISOR_DEFAULT_CXX_LINKER ${HYPERVISOR_CXX_LINKER})
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED HYPERVISOR_EFI_LINKER)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
set(HYPERVISOR_DEFAULT_EFI_LINKER "lld-link")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(HYPERVISOR_DEFAULT_EFI_LINKER "lld-link")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
|
||||
endif()
|
||||
else()
|
||||
set(HYPERVISOR_DEFAULT_EFI_LINKER ${HYPERVISOR_EFI_LINKER})
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED HYPERVISOR_EFI_FS0)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
set(HYPERVISOR_DEFAULT_EFI_FS0 "/boot/efi/")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(HYPERVISOR_DEFAULT_EFI_FS0 "X:/")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
|
||||
endif()
|
||||
else()
|
||||
set(HYPERVISOR_DEFAULT_EFI_FS0 ${HYPERVISOR_EFI_FS0})
|
||||
endif()
|
||||
|
||||
bf_add_config(
|
||||
CONFIG_NAME HYPERVISOR_TARGET_ARCH
|
||||
CONFIG_TYPE STRING
|
||||
|
|
@ -68,7 +95,23 @@ bf_add_config(
|
|||
CONFIG_NAME HYPERVISOR_CXX_LINKER
|
||||
CONFIG_TYPE STRING
|
||||
DEFAULT_VAL ${HYPERVISOR_DEFAULT_CXX_LINKER}
|
||||
DESCRIPTION "Define the linker to use for cross-compiling. Does not effect native linking"
|
||||
DESCRIPTION "Define the linker to use for cross-compiling"
|
||||
SKIP_VALIDATION
|
||||
)
|
||||
|
||||
bf_add_config(
|
||||
CONFIG_NAME HYPERVISOR_EFI_LINKER
|
||||
CONFIG_TYPE STRING
|
||||
DEFAULT_VAL ${HYPERVISOR_DEFAULT_EFI_LINKER}
|
||||
DESCRIPTION "Define the linker to use for linking EFI applications"
|
||||
SKIP_VALIDATION
|
||||
)
|
||||
|
||||
bf_add_config(
|
||||
CONFIG_NAME HYPERVISOR_EFI_FS0
|
||||
CONFIG_TYPE STRING
|
||||
DEFAULT_VAL ${HYPERVISOR_DEFAULT_EFI_FS0}
|
||||
DESCRIPTION "Define the file location of FS0 for UEFI"
|
||||
SKIP_VALIDATION
|
||||
)
|
||||
|
||||
|
|
@ -139,7 +182,7 @@ bf_add_config(
|
|||
bf_add_config(
|
||||
CONFIG_NAME HYPERVISOR_MAX_PPS
|
||||
CONFIG_TYPE STRING
|
||||
DEFAULT_VAL "256"
|
||||
DEFAULT_VAL "128"
|
||||
DESCRIPTION "Defines the hypervisor's max number of physical processors supported"
|
||||
SKIP_VALIDATION
|
||||
)
|
||||
|
|
@ -147,7 +190,7 @@ bf_add_config(
|
|||
bf_add_config(
|
||||
CONFIG_NAME HYPERVISOR_MAX_VPS
|
||||
CONFIG_TYPE STRING
|
||||
DEFAULT_VAL "512"
|
||||
DEFAULT_VAL "256"
|
||||
DESCRIPTION "Defines the hypervisor's max number of virtual processors supported"
|
||||
SKIP_VALIDATION
|
||||
)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
FetchContent_Declare(
|
||||
bsl
|
||||
GIT_REPOSITORY https://github.com/bareflank/bsl.git
|
||||
GIT_TAG 0406b10a6b6dacde00f0649ea37b42a2ba31362b
|
||||
GIT_TAG 92dff4d9e701b7ae18c9dbdfe579d9f6f2decbb2
|
||||
)
|
||||
|
||||
FetchContent_GetProperties(bsl)
|
||||
|
|
|
|||
28
cmake/efi_cross_compile/CMakeLists.txt
Normal file
28
cmake/efi_cross_compile/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#
|
||||
# Copyright (C) 2020 Assured Information Security, Inc.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
project(hypervisor_extensions C ASM)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../silence.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../write_constants.cmake)
|
||||
|
||||
add_subdirectory(../../loader/efi loader)
|
||||
|
|
@ -26,6 +26,7 @@ macro(hypervisor_add_cmake_args)
|
|||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||
-DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE}
|
||||
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-DCMAKE_INSTALL_MESSAGE=LAZY
|
||||
)
|
||||
|
|
@ -49,6 +50,8 @@ macro(hypervisor_add_cmake_args)
|
|||
list(APPEND CMAKE_ARGS
|
||||
-DHYPERVISOR_TARGET_ARCH=${HYPERVISOR_TARGET_ARCH}
|
||||
-DHYPERVISOR_CXX_LINKER=${HYPERVISOR_CXX_LINKER}
|
||||
-DHYPERVISOR_EFI_LINKER=${HYPERVISOR_EFI_LINKER}
|
||||
-DHYPERVISOR_EFI_FS0=${HYPERVISOR_EFI_FS0}
|
||||
-DHYPERVISOR_PAGE_SIZE=${HYPERVISOR_PAGE_SIZE}
|
||||
-DHYPERVISOR_PAGE_SHIFT=${HYPERVISOR_PAGE_SHIFT}
|
||||
-DHYPERVISOR_SERIAL_PORT=${HYPERVISOR_SERIAL_PORT}
|
||||
|
|
|
|||
72
cmake/function/hypervisor_add_efi_cross_compile.cmake
Normal file
72
cmake/function/hypervisor_add_efi_cross_compile.cmake
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
#
|
||||
# Copyright (C) 2020 Assured Information Security, Inc.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
include(ExternalProject)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/hypervisor_add_cmake_args.cmake)
|
||||
|
||||
# Add EFI Cross Compile Directory
|
||||
#
|
||||
# Uses ExternalProject_Add to add a subdirectory, but cross compiles instead
|
||||
# instead of adding a subdirectory to the main project like add_subdirectory.
|
||||
# This is needed to ensure the cross compiled code can have it's own toolchain.
|
||||
#
|
||||
# SOURCE_DIR: The location of the CMakeLists.txt that describes how to compile
|
||||
# the cross compiled components
|
||||
#
|
||||
function(hypervisor_add_efi_cross_compile SOURCE_DIR)
|
||||
if(CMAKE_BUILD_TYPE STREQUAL ASAN OR
|
||||
CMAKE_BUILD_TYPE STREQUAL UBSAN)
|
||||
set(CMAKE_BUILD_TYPE DEBUG)
|
||||
endif()
|
||||
|
||||
if(HYPERVISOR_TARGET_ARCH STREQUAL "GenuineIntel")
|
||||
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/cmake/toolchain/x64/efi.cmake)
|
||||
elseif(HYPERVISOR_TARGET_ARCH STREQUAL "AuthenticAMD")
|
||||
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/cmake/toolchain/x64/efi.cmake)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported HYPERVISOR_TARGET_ARCH: ${HYPERVISOR_TARGET_ARCH}")
|
||||
endif()
|
||||
|
||||
hypervisor_add_cmake_args()
|
||||
|
||||
list(APPEND CMAKE_ARGS
|
||||
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/efi_cross_compile
|
||||
)
|
||||
|
||||
ExternalProject_Add(
|
||||
efi_cross_compile
|
||||
PREFIX ${CMAKE_BINARY_DIR}/efi_cross_compile
|
||||
STAMP_DIR ${CMAKE_BINARY_DIR}/efi_cross_compile/stamp
|
||||
TMP_DIR ${CMAKE_BINARY_DIR}/efi_cross_compile/tmp
|
||||
BINARY_DIR ${CMAKE_BINARY_DIR}/efi_cross_compile/build
|
||||
LOG_DIR ${CMAKE_BINARY_DIR}/efi_cross_compile/logs
|
||||
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/${SOURCE_DIR}
|
||||
CMAKE_ARGS ${CMAKE_ARGS}
|
||||
UPDATE_COMMAND cmake -E echo -- Checking for changes
|
||||
)
|
||||
|
||||
ExternalProject_Add_Step(
|
||||
efi_cross_compile
|
||||
efi_cross_compile_cleanup
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/efi_cross_compile/src
|
||||
DEPENDEES configure
|
||||
)
|
||||
endfunction(hypervisor_add_efi_cross_compile)
|
||||
|
|
@ -61,6 +61,46 @@ macro(hypervisor_add_info)
|
|||
)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(HYPERVISOR_BUILD_MICROKERNEL)
|
||||
add_custom_command(TARGET info
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "${BF_COLOR_YLW} HYPERVISOR_BUILD_MICROKERNEL ${BF_COLOR_GRN}enabled${BF_COLOR_RST}"
|
||||
VERBATIM
|
||||
)
|
||||
else()
|
||||
add_custom_command(TARGET info
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "${BF_COLOR_YLW} HYPERVISOR_BUILD_MICROKERNEL ${BF_COLOR_RED}disabled${BF_COLOR_RST}"
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
|
||||
if(HYPERVISOR_BUILD_EXAMPLES)
|
||||
add_custom_command(TARGET info
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "${BF_COLOR_YLW} HYPERVISOR_BUILD_EXAMPLES ${BF_COLOR_GRN}enabled${BF_COLOR_RST}"
|
||||
VERBATIM
|
||||
)
|
||||
else()
|
||||
add_custom_command(TARGET info
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "${BF_COLOR_YLW} HYPERVISOR_BUILD_EXAMPLES ${BF_COLOR_RED}disabled${BF_COLOR_RST}"
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
|
||||
if(HYPERVISOR_BUILD_EFI)
|
||||
add_custom_command(TARGET info
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "${BF_COLOR_YLW} HYPERVISOR_BUILD_EFI ${BF_COLOR_GRN}enabled${BF_COLOR_RST}"
|
||||
VERBATIM
|
||||
)
|
||||
else()
|
||||
add_custom_command(TARGET info
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "${BF_COLOR_YLW} HYPERVISOR_BUILD_EFI ${BF_COLOR_RED}disabled${BF_COLOR_RST}"
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
|
||||
add_custom_command(TARGET info
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "${BF_COLOR_YLW} HYPERVISOR_TARGET_ARCH ${BF_COLOR_CYN}${HYPERVISOR_TARGET_ARCH}${BF_COLOR_RST}"
|
||||
VERBATIM
|
||||
|
|
@ -71,6 +111,16 @@ macro(hypervisor_add_info)
|
|||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_command(TARGET info
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "${BF_COLOR_YLW} HYPERVISOR_EFI_LINKER ${BF_COLOR_CYN}${HYPERVISOR_EFI_LINKER}${BF_COLOR_RST}"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_command(TARGET info
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "${BF_COLOR_YLW} HYPERVISOR_EFI_FS0 ${BF_COLOR_CYN}${HYPERVISOR_EFI_FS0}${BF_COLOR_RST}"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_command(TARGET info
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "${BF_COLOR_YLW} HYPERVISOR_EXTENSIONS ${BF_COLOR_CYN}${HYPERVISOR_EXTENSIONS}${BF_COLOR_RST}"
|
||||
VERBATIM
|
||||
|
|
|
|||
28
cmake/function/hypervisor_silence.cmake
Normal file
28
cmake/function/hypervisor_silence.cmake
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#
|
||||
# Copyright (C) 2020 Assured Information Security, Inc.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
# Silence unused variable warnings
|
||||
#
|
||||
macro(hypervisor_silence NAME)
|
||||
if(DEFINED ${NAME})
|
||||
set(${NAME} ${${NAME}})
|
||||
endif()
|
||||
endmacro(hypervisor_silence)
|
||||
|
|
@ -27,6 +27,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/depend/bsl.cmake)
|
|||
include(${bsl_SOURCE_DIR}/cmake/config/all_projects.cmake)
|
||||
include(${bsl_SOURCE_DIR}/cmake/config/cmake.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/config/default.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/validate.cmake)
|
||||
|
||||
include(${bsl_SOURCE_DIR}/cmake/build_types.cmake)
|
||||
include(${bsl_SOURCE_DIR}/cmake/find_programs.cmake)
|
||||
|
|
@ -40,6 +41,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/target/loader_load.cmake)
|
|||
include(${CMAKE_CURRENT_LIST_DIR}/target/loader_unload.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/target/loader_clean.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/target/loader_quick.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/target/copy_to_efi_partition.cmake)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/write_constants.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/write_toolchain_x64_ext_ld.cmake)
|
||||
|
|
@ -51,5 +53,6 @@ endif()
|
|||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/function/hypervisor_add_mk_cross_compile.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/function/hypervisor_add_ext_cross_compile.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/function/hypervisor_add_efi_cross_compile.cmake)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/interface/hypervisor.cmake)
|
||||
|
|
|
|||
|
|
@ -26,20 +26,9 @@ include(${CMAKE_CURRENT_LIST_DIR}/depend/bsl.cmake)
|
|||
include(${bsl_SOURCE_DIR}/cmake/config/cmake.cmake)
|
||||
include(${bsl_SOURCE_DIR}/cmake/build_types.cmake)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/silence.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/write_constants.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/write_toolchain_x64_ext_ld.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/write_toolchain_x64_mk_ld.cmake)
|
||||
|
||||
if(DEFINED CMAKE_TOOLCHAIN_FILE)
|
||||
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE})
|
||||
endif()
|
||||
|
||||
if(DEFINED bsl_SOURCE_DIR)
|
||||
set(bsl_SOURCE_DIR ${bsl_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
if(DEFINED HYPERVISOR_TARGET_ARCH)
|
||||
set(HYPERVISOR_TARGET_ARCH ${HYPERVISOR_TARGET_ARCH})
|
||||
endif()
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/interface/hypervisor.cmake)
|
||||
|
|
|
|||
78
cmake/silence.cmake
Normal file
78
cmake/silence.cmake
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#
|
||||
# Copyright (C) 2020 Assured Information Security, Inc.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/function/hypervisor_silence.cmake)
|
||||
|
||||
hypervisor_silence(CMAKE_BUILD_TYPE)
|
||||
hypervisor_silence(CMAKE_VERBOSE_MAKEFILE)
|
||||
hypervisor_silence(CMAKE_TOOLCHAIN_FILE)
|
||||
hypervisor_silence(CMAKE_C_COMPILER)
|
||||
hypervisor_silence(CMAKE_CXX_COMPILER)
|
||||
hypervisor_silence(CMAKE_INSTALL_MESSAGE)
|
||||
|
||||
hypervisor_silence(bsl_SOURCE_DIR)
|
||||
hypervisor_silence(FETCHCONTENT_UPDATES_DISCONNECTED)
|
||||
hypervisor_silence(FETCHCONTENT_SOURCE_DIR_BSL)
|
||||
|
||||
hypervisor_silence(BUILD_EXAMPLES)
|
||||
hypervisor_silence(BUILD_TESTS)
|
||||
hypervisor_silence(ENABLE_CLANG_FORMAT)
|
||||
hypervisor_silence(ENABLE_DOXYGEN)
|
||||
hypervisor_silence(ENABLE_COLOR)
|
||||
hypervisor_silence(BSL_DEBUG_LEVEL)
|
||||
hypervisor_silence(BSL_PAGE_SIZE)
|
||||
|
||||
hypervisor_silence(HYPERVISOR_TARGET_ARCH)
|
||||
hypervisor_silence(HYPERVISOR_CXX_LINKER)
|
||||
hypervisor_silence(HYPERVISOR_EFI_LINKER)
|
||||
hypervisor_silence(HYPERVISOR_EFI_FS0)
|
||||
hypervisor_silence(HYPERVISOR_PAGE_SIZE)
|
||||
hypervisor_silence(HYPERVISOR_PAGE_SHIFT)
|
||||
hypervisor_silence(HYPERVISOR_SERIAL_PORT)
|
||||
hypervisor_silence(HYPERVISOR_MAX_ELF_FILE_SIZE)
|
||||
hypervisor_silence(HYPERVISOR_MAX_SEGMENTS)
|
||||
hypervisor_silence(HYPERVISOR_MAX_EXTENSIONS)
|
||||
hypervisor_silence(HYPERVISOR_MAX_VMS)
|
||||
hypervisor_silence(HYPERVISOR_MAX_PPS)
|
||||
hypervisor_silence(HYPERVISOR_MAX_VPS)
|
||||
hypervisor_silence(HYPERVISOR_MAX_VPS_PER_VM)
|
||||
hypervisor_silence(HYPERVISOR_MAX_VPSS_PER_VP)
|
||||
hypervisor_silence(HYPERVISOR_MAX_VPSS)
|
||||
hypervisor_silence(HYPERVISOR_DEBUG_RING_SIZE)
|
||||
hypervisor_silence(HYPERVISOR_DIRECT_MAP_ADDR)
|
||||
hypervisor_silence(HYPERVISOR_MK_STACK_ADDR)
|
||||
hypervisor_silence(HYPERVISOR_MK_STACK_SIZE)
|
||||
hypervisor_silence(HYPERVISOR_MK_CODE_ADDR)
|
||||
hypervisor_silence(HYPERVISOR_MK_CODE_SIZE)
|
||||
hypervisor_silence(HYPERVISOR_MK_MAP_ADDR)
|
||||
hypervisor_silence(HYPERVISOR_MK_MAP_SIZE)
|
||||
hypervisor_silence(HYPERVISOR_EXT_STACK_ADDR)
|
||||
hypervisor_silence(HYPERVISOR_EXT_STACK_SIZE)
|
||||
hypervisor_silence(HYPERVISOR_EXT_CODE_ADDR)
|
||||
hypervisor_silence(HYPERVISOR_EXT_CODE_SIZE)
|
||||
hypervisor_silence(HYPERVISOR_EXT_TLS_ADDR)
|
||||
hypervisor_silence(HYPERVISOR_EXT_TLS_SIZE)
|
||||
hypervisor_silence(HYPERVISOR_EXT_PAGE_POOL_ADDR)
|
||||
hypervisor_silence(HYPERVISOR_EXT_PAGE_POOL_SIZE)
|
||||
hypervisor_silence(HYPERVISOR_EXT_HEAP_POOL_ADDR)
|
||||
hypervisor_silence(HYPERVISOR_EXT_HEAP_POOL_SIZE)
|
||||
hypervisor_silence(HYPERVISOR_HUGE_POOL_SIZE)
|
||||
hypervisor_silence(HYPERVISOR_PAGE_POOL_SIZE)
|
||||
45
cmake/target/copy_to_efi_partition.cmake
Normal file
45
cmake/target/copy_to_efi_partition.cmake
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#
|
||||
# Copyright (C) 2020 Assured Information Security, Inc.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
if(HYPERVISOR_BUILD_EFI)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
add_custom_target(copy_to_efi_partition
|
||||
COMMAND sudo cmake -E copy efi_cross_compile/bin/bareflank_efi_loader ${HYPERVISOR_EFI_FS0}/start_bareflank.efi
|
||||
COMMAND sudo cmake -E copy mk_cross_compile/bin/kernel ${HYPERVISOR_EFI_FS0}/bareflank_kernel
|
||||
COMMAND sudo cmake -E copy ${HYPERVISOR_EXTENSIONS} ${HYPERVISOR_EFI_FS0}/bareflank_extension0
|
||||
COMMAND sudo cmake -E copy ${CMAKE_SOURCE_DIR}/utils/Shell.efi ${HYPERVISOR_EFI_FS0}/bareflank_efi_shell.efi
|
||||
VERBATIM
|
||||
)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
add_custom_target(copy_to_efi_partition
|
||||
COMMAND mountvol X: /d | true
|
||||
COMMAND mountvol X: /s | true
|
||||
COMMAND cmake -E copy efi_cross_compile/bin/bareflank_efi_loader ${HYPERVISOR_EFI_FS0}/start_bareflank.efi
|
||||
COMMAND cmake -E copy mk_cross_compile/bin/kernel ${HYPERVISOR_EFI_FS0}/bareflank_kernel
|
||||
COMMAND cmake -E copy ${HYPERVISOR_EXTENSIONS} ${HYPERVISOR_EFI_FS0}/bareflank_extension0
|
||||
COMMAND cmake -E copy ${CMAKE_SOURCE_DIR}/utils/Shell.efi ${HYPERVISOR_EFI_FS0}/bareflank_efi_shell.efi
|
||||
COMMAND mountvol X: /d | true
|
||||
VERBATIM
|
||||
)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
|
||||
endif()
|
||||
endif()
|
||||
79
cmake/toolchain/x64/efi.cmake
Normal file
79
cmake/toolchain/x64/efi.cmake
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
#
|
||||
# Copyright (C) 2020 Assured Information Security, Inc.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
set(CMAKE_C_COMPILER_WORKS 1)
|
||||
|
||||
string(CONCAT HYPERVISOR_EFI_C_FLAGS
|
||||
"--target=x86_64-unknown-windows "
|
||||
"-ffreestanding "
|
||||
"-fshort-wchar "
|
||||
"-mno-mmx "
|
||||
"-mno-sse "
|
||||
"-mno-sse2 "
|
||||
"-mno-sse3 "
|
||||
"-mno-ssse3 "
|
||||
"-mno-sse4.1 "
|
||||
"-mno-sse4.2 "
|
||||
"-mno-sse4 "
|
||||
"-mno-avx "
|
||||
"-mno-aes "
|
||||
"-mno-sse4a "
|
||||
)
|
||||
|
||||
string(CONCAT HYPERVISOR_EFI_LINK_FLAGS
|
||||
"--target=x86_64-unknown-windows "
|
||||
"-nostdlib "
|
||||
"-Wl,-entry:efi_main "
|
||||
"-Wl,-subsystem:efi_application "
|
||||
"-fuse-ld=${HYPERVISOR_EFI_LINKER}"
|
||||
)
|
||||
|
||||
set(CMAKE_ASM_COMPILE_OBJECT
|
||||
"<CMAKE_C_COMPILER> ${HYPERVISOR_EFI_C_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
|
||||
|
||||
set(CMAKE_C_COMPILE_OBJECT
|
||||
"<CMAKE_C_COMPILER> ${HYPERVISOR_EFI_C_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
|
||||
|
||||
set(CMAKE_C_LINK_EXECUTABLE
|
||||
"<CMAKE_C_COMPILER> ${HYPERVISOR_EFI_LINK_FLAGS} <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>"
|
||||
)
|
||||
|
||||
################################################################################
|
||||
# Hack For Windows
|
||||
################################################################################
|
||||
|
||||
# For some reason, CMake on Windows is adding extra stuff to the compiler
|
||||
# includes and flags. The following fixes this issue by telling CMake not
|
||||
# to configure the compiler. We need to add C++20 to the command above
|
||||
# to make this work.
|
||||
# https://gitlab.kitware.com/cmake/cmake/-/issues/21789
|
||||
|
||||
set(__COMPILER_CLANG 1)
|
||||
|
||||
macro(__compiler_clang lang)
|
||||
endmacro()
|
||||
|
||||
macro(__compiler_clang_C_standards lang)
|
||||
endmacro()
|
||||
|
||||
macro(__compiler_check_default_language_standard lang)
|
||||
endmacro()
|
||||
29
cmake/validate.cmake
Normal file
29
cmake/validate.cmake
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#
|
||||
# Copyright (C) 2020 Assured Information Security, Inc.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
list(LENGTH HYPERVISOR_EXTENSIONS HYPERVISOR_EXTENSIONS_LENGTH)
|
||||
if(NOT HYPERVISOR_EXTENSIONS_LENGTH EQUAL 1)
|
||||
message(FATAL_ERROR "More than one extension is currently not supported")
|
||||
endif()
|
||||
|
||||
# TODO:
|
||||
# - Validate the rest of the configuration
|
||||
#
|
||||
|
|
@ -22,40 +22,62 @@
|
|||
add_executable(example_default)
|
||||
|
||||
# NOTE:
|
||||
# - Include your source files
|
||||
# - Include your headers and include directories
|
||||
#
|
||||
|
||||
target_sources(example_default PRIVATE
|
||||
x64/intrinsic_cpuid.S
|
||||
main.cpp
|
||||
)
|
||||
|
||||
# NOTE:
|
||||
# - Include your arch specific source files
|
||||
#
|
||||
if(HYPERVISOR_TARGET_ARCH STREQUAL "AuthenticAMD" OR HYPERVISOR_TARGET_ARCH STREQUAL "GenuineIntel")
|
||||
target_include_directories(example_default PRIVATE
|
||||
x64
|
||||
)
|
||||
list(APPEND HEADERS
|
||||
${CMAKE_CURRENT_LIST_DIR}/x64/common_arch_support.hpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(HYPERVISOR_TARGET_ARCH STREQUAL "AuthenticAMD")
|
||||
target_include_directories(example_default PRIVATE
|
||||
x64
|
||||
x64/amd
|
||||
)
|
||||
set_property(SOURCE main.cpp APPEND PROPERTY OBJECT_DEPENDS
|
||||
${CMAKE_CURRENT_LIST_DIR}/x64/common_arch_support.hpp
|
||||
list(APPEND HEADERS
|
||||
${CMAKE_CURRENT_LIST_DIR}/x64/amd/arch_support.hpp
|
||||
)
|
||||
elseif(HYPERVISOR_TARGET_ARCH STREQUAL "GenuineIntel")
|
||||
target_include_directories(example_default PRIVATE
|
||||
x64
|
||||
x64/intel
|
||||
)
|
||||
set_property(SOURCE main.cpp APPEND PROPERTY OBJECT_DEPENDS
|
||||
${CMAKE_CURRENT_LIST_DIR}/x64/common_arch_support.hpp
|
||||
list(APPEND HEADERS
|
||||
${CMAKE_CURRENT_LIST_DIR}/x64/intel/arch_support.hpp
|
||||
)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported HYPERVISOR_TARGET_ARCH: ${HYPERVISOR_TARGET_ARCH}")
|
||||
endif()
|
||||
|
||||
# NOTE:
|
||||
# - Include your source files and dependencies
|
||||
#
|
||||
|
||||
target_sources(example_default PRIVATE
|
||||
main.cpp
|
||||
)
|
||||
|
||||
set_property(SOURCE main.cpp APPEND PROPERTY OBJECT_DEPENDS ${HEADERS})
|
||||
|
||||
if(HYPERVISOR_TARGET_ARCH STREQUAL "AuthenticAMD" OR HYPERVISOR_TARGET_ARCH STREQUAL "GenuineIntel")
|
||||
target_sources(example_default PRIVATE
|
||||
x64/intrinsic_cpuid.S
|
||||
)
|
||||
endif()
|
||||
|
||||
if(HYPERVISOR_TARGET_ARCH STREQUAL "AuthenticAMD")
|
||||
# target_sources(example_default PRIVATE
|
||||
# )
|
||||
elseif(HYPERVISOR_TARGET_ARCH STREQUAL "GenuineIntel")
|
||||
# target_sources(example_default PRIVATE
|
||||
# )
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported HYPERVISOR_TARGET_ARCH: ${HYPERVISOR_TARGET_ARCH}")
|
||||
endif()
|
||||
|
||||
# NOTE:
|
||||
# - Include your libraries. Note that if you use our runtime libary,
|
||||
# you must include it first, otherwise your extension will try to use
|
||||
|
|
@ -70,7 +92,7 @@ target_link_libraries(example_default PRIVATE
|
|||
)
|
||||
|
||||
# NOTE:
|
||||
# - Include your extension somewhere.
|
||||
# - Install your extension somewhere.
|
||||
#
|
||||
|
||||
install(TARGETS example_default DESTINATION bin)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ add_executable(kernel)
|
|||
|
||||
target_include_directories(kernel PRIVATE
|
||||
src
|
||||
src/x64
|
||||
)
|
||||
|
||||
list(APPEND HEADERS
|
||||
|
|
@ -59,18 +58,6 @@ list(APPEND HEADERS
|
|||
${CMAKE_CURRENT_LIST_DIR}/src/vp_pool_t.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/vps_pool_t.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/vp_t.hpp
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/dispatch_esr.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/dispatch_syscall_intrinsic_op.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/pdpt_t.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/pdt_t.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/pml4t_t.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/pt_t.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/root_page_table_t.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/serial_write.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/smap_guard_t.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/tls_t.hpp
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/bsl/cstdio.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/bsl/details/print_thread_id.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/bsl/details/putc_stderr.hpp
|
||||
|
|
@ -79,14 +66,29 @@ list(APPEND HEADERS
|
|||
${CMAKE_CURRENT_LIST_DIR}/src/bsl/details/puts_stdout.hpp
|
||||
)
|
||||
|
||||
if(HYPERVISOR_TARGET_ARCH STREQUAL "AuthenticAMD" OR HYPERVISOR_TARGET_ARCH STREQUAL "GenuineIntel")
|
||||
target_include_directories(kernel PRIVATE
|
||||
src/x64
|
||||
)
|
||||
|
||||
list(APPEND HEADERS
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/dispatch_esr.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/dispatch_syscall_intrinsic_op.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/pdpt_t.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/pdt_t.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/pml4t_t.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/pt_t.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/root_page_table_t.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/serial_write.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/smap_guard_t.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/tls_t.hpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(HYPERVISOR_TARGET_ARCH STREQUAL "AuthenticAMD")
|
||||
target_include_directories(kernel PRIVATE
|
||||
src/x64/amd
|
||||
)
|
||||
target_sources(kernel PRIVATE
|
||||
src/x64/amd/intrinsic_t.S
|
||||
src/x64/amd/promote.S
|
||||
)
|
||||
list(APPEND HEADERS
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/amd/dispatch_esr_nmi.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/amd/intrinsic_t.hpp
|
||||
|
|
@ -97,10 +99,6 @@ elseif(HYPERVISOR_TARGET_ARCH STREQUAL "GenuineIntel")
|
|||
target_include_directories(kernel PRIVATE
|
||||
src/x64/intel
|
||||
)
|
||||
target_sources(kernel PRIVATE
|
||||
src/x64/intel/intrinsic_t.S
|
||||
src/x64/intel/promote.S
|
||||
)
|
||||
list(APPEND HEADERS
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/intel/dispatch_esr_nmi.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/x64/intel/intrinsic_t.hpp
|
||||
|
|
@ -113,21 +111,6 @@ else()
|
|||
endif()
|
||||
|
||||
target_sources(kernel PRIVATE
|
||||
src/x64/__stack_chk_fail.S
|
||||
src/x64/call_ext.S
|
||||
src/x64/dispatch_esr_entry.S
|
||||
src/x64/dispatch_syscall_entry.S
|
||||
src/x64/fast_fail_entry.S
|
||||
src/x64/get_current_tls.S
|
||||
src/x64/mk_main_entry.S
|
||||
src/x64/return_to_current_fast_fail.S
|
||||
src/x64/return_to_mk.S
|
||||
src/x64/return_to_vmexit_loop.S
|
||||
src/x64/serial_write.S
|
||||
src/x64/set_esr.S
|
||||
src/x64/smap_guard_t.S
|
||||
src/x64/vmexit_loop_entry.S
|
||||
|
||||
src/dispatch_esr_trampoline.cpp
|
||||
src/dispatch_syscall_trampoline.cpp
|
||||
src/fast_fail_trampoline.cpp
|
||||
|
|
@ -145,6 +128,39 @@ hypervisor_add_header_depends(src/msg_halt.cpp ${HEADERS})
|
|||
hypervisor_add_header_depends(src/msg_stack_chk_fail.cpp ${HEADERS})
|
||||
hypervisor_add_header_depends(src/vmexit_loop_trampoline.cpp ${HEADERS})
|
||||
|
||||
if(HYPERVISOR_TARGET_ARCH STREQUAL "AuthenticAMD" OR HYPERVISOR_TARGET_ARCH STREQUAL "GenuineIntel")
|
||||
target_sources(kernel PRIVATE
|
||||
src/x64/__stack_chk_fail.S
|
||||
src/x64/call_ext.S
|
||||
src/x64/dispatch_esr_entry.S
|
||||
src/x64/dispatch_syscall_entry.S
|
||||
src/x64/fast_fail_entry.S
|
||||
src/x64/get_current_tls.S
|
||||
src/x64/mk_main_entry.S
|
||||
src/x64/return_to_current_fast_fail.S
|
||||
src/x64/return_to_mk.S
|
||||
src/x64/return_to_vmexit_loop.S
|
||||
src/x64/serial_write.S
|
||||
src/x64/set_esr.S
|
||||
src/x64/smap_guard_t.S
|
||||
src/x64/vmexit_loop_entry.S
|
||||
)
|
||||
endif()
|
||||
|
||||
if(HYPERVISOR_TARGET_ARCH STREQUAL "AuthenticAMD")
|
||||
target_sources(kernel PRIVATE
|
||||
src/x64/amd/intrinsic_t.S
|
||||
src/x64/amd/promote.S
|
||||
)
|
||||
elseif(HYPERVISOR_TARGET_ARCH STREQUAL "GenuineIntel")
|
||||
target_sources(kernel PRIVATE
|
||||
src/x64/intel/intrinsic_t.S
|
||||
src/x64/intel/promote.S
|
||||
)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported HYPERVISOR_TARGET_ARCH: ${HYPERVISOR_TARGET_ARCH}")
|
||||
endif()
|
||||
|
||||
target_link_libraries(kernel PRIVATE
|
||||
bsl
|
||||
loader
|
||||
|
|
|
|||
|
|
@ -85,8 +85,7 @@ namespace mk
|
|||
intrinsic_t, // --
|
||||
page_pool_t<HYPERVISOR_PAGE_SIZE>, // --
|
||||
HYPERVISOR_PAGE_SIZE, // --
|
||||
HYPERVISOR_PAGE_SHIFT, // --
|
||||
HYPERVISOR_MK_MAP_ADDR>; // --
|
||||
HYPERVISOR_PAGE_SHIFT>; // --
|
||||
|
||||
/// @brief defines the extension type to use
|
||||
using mk_ext_type = ext_t< // --
|
||||
|
|
|
|||
|
|
@ -211,13 +211,6 @@ namespace mk
|
|||
|
||||
if (m_initialized) {
|
||||
m_system_rpt.activate();
|
||||
|
||||
ret = m_system_rpt.add_root_vp_state(args->root_vp_state);
|
||||
if (bsl::unlikely(!ret)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
return bsl::errc_success;
|
||||
}
|
||||
|
||||
|
|
@ -263,25 +256,6 @@ namespace mk
|
|||
|
||||
m_system_rpt.activate();
|
||||
|
||||
ret = m_system_rpt.add_root_vp_state(args->root_vp_state);
|
||||
if (bsl::unlikely(!ret)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
/// NOTE:
|
||||
/// - At this point, if an error occurs, it will safely exit.
|
||||
/// Prior to this point, if an error occurs, we will likely
|
||||
/// see a page fault when exiting as the microkernel has no
|
||||
/// way of restoring the GDT as the TSS busy bit cannot be
|
||||
/// cleared without successfully mapping in the GDT. To fix
|
||||
/// this issue, we would need to add a LOT of code to the
|
||||
/// loader as it would need enough pageing logic to create
|
||||
/// a temporary set of page tables capable of walking the
|
||||
/// root OS's page tables to locate the physical address of
|
||||
/// the GDT, since Linux will not provide that.
|
||||
///
|
||||
|
||||
ret = m_vps_pool.initialize();
|
||||
if (bsl::unlikely(!ret)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
|
|
@ -448,13 +422,13 @@ namespace mk
|
|||
// [ ] implement make ack
|
||||
// [ ] implement debugging mutex/transaction support
|
||||
// [x] implement Windows support
|
||||
// [ ] implement UEFI support
|
||||
// [x] implement UEFI support
|
||||
// [ ] implement huge_pool
|
||||
// [ ] implement huge
|
||||
// [ ] implement alloc physically contiguous page
|
||||
// [ ] implement free physically contiguous page
|
||||
// [ ] implement per-VM direct maps
|
||||
// [ ] implement reduce the size of the TLS block
|
||||
// [x] implement reduce the size of the TLS block
|
||||
// [ ] implement optimizations for release builds
|
||||
// [ ] implement dump functions for all types
|
||||
// [ ] implement all debug ops
|
||||
|
|
@ -472,24 +446,6 @@ namespace mk
|
|||
// [ ] implement remaining todos
|
||||
// [ ] implement c extension example
|
||||
// [ ] implement mitigations for transient execution vulnerabilities
|
||||
|
||||
// NMI Notes:
|
||||
// - On AMD, they are disabled, so we should never see them.
|
||||
// - On Intel, we cannot disable them. We can, however, generate
|
||||
// an NMI VMExit. If an NMI fires while we are trying to start
|
||||
// and the attempt to start fails, you might have to reboot as
|
||||
// the NMI would be dropped, and we will warn the user. If an
|
||||
// NMI fires at any other time, we make a note of it in the
|
||||
// TLS block. Once we are in the "transition" portion for a
|
||||
// VMResume, we will make note of that in the TLS block, and
|
||||
// then we will check to see if an NMI was caught. If it was,
|
||||
// we will then execute an int 2, which will force the NMI
|
||||
// handler to execute. When the NMI handler executes, and it
|
||||
// knows that we are in the "transition" portion of the
|
||||
// code, it will always set the NMI window in whatever VMCS has
|
||||
// been loaded, which will generate a VMExit that the extension
|
||||
// will have to handle.
|
||||
//
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ extern "C"
|
|||
/// @return Returns the same result as std::memset.
|
||||
///
|
||||
[[maybe_unused]] extern "C" auto
|
||||
memset(void *const dst, bsl::char_type const ch, bsl::uintmax const num) -> void *
|
||||
memset(void *const dst, bsl::char_type const ch, bsl::uintmax const num) noexcept -> void *
|
||||
{
|
||||
return bsl::builtin_memset(dst, ch, num);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ intrinsic_halt:
|
|||
intrinsic_rdmsr:
|
||||
|
||||
lea rax, [rip + intrinsic_rdmsr_failed]
|
||||
mov gs:[0x850], rax
|
||||
mov gs:[0x250], rax
|
||||
|
||||
mov ecx, edi
|
||||
xor rax, rax
|
||||
|
|
@ -160,7 +160,7 @@ intrinsic_rdmsr:
|
|||
mov [rsi], rax
|
||||
|
||||
xor rax, rax
|
||||
mov gs:[0x850], rax
|
||||
mov gs:[0x250], rax
|
||||
|
||||
ret
|
||||
int 3
|
||||
|
|
@ -168,7 +168,7 @@ intrinsic_rdmsr:
|
|||
intrinsic_rdmsr_failed:
|
||||
|
||||
xor rax, rax
|
||||
mov gs:[0x850], rax
|
||||
mov gs:[0x250], rax
|
||||
|
||||
mov rax, 0x1
|
||||
ret
|
||||
|
|
@ -201,7 +201,7 @@ intrinsic_rdmsr_unsafe:
|
|||
intrinsic_wrmsr:
|
||||
|
||||
lea rax, [rip + intrinsic_wrmsr_failed]
|
||||
mov gs:[0x850], rax
|
||||
mov gs:[0x250], rax
|
||||
|
||||
mov ecx, edi
|
||||
mov rax, rsi
|
||||
|
|
@ -210,7 +210,7 @@ intrinsic_wrmsr:
|
|||
wrmsr
|
||||
|
||||
xor rax, rax
|
||||
mov gs:[0x850], rax
|
||||
mov gs:[0x250], rax
|
||||
|
||||
ret
|
||||
int 3
|
||||
|
|
@ -218,7 +218,7 @@ intrinsic_wrmsr:
|
|||
intrinsic_wrmsr_failed:
|
||||
|
||||
xor rax, rax
|
||||
mov gs:[0x850], rax
|
||||
mov gs:[0x250], rax
|
||||
|
||||
mov rax, 0x1
|
||||
ret
|
||||
|
|
|
|||
|
|
@ -33,23 +33,23 @@ call_ext:
|
|||
|
||||
mov r10, rcx
|
||||
|
||||
mov gs:[0x008], rbx
|
||||
mov gs:[0x020], rbp
|
||||
mov gs:[0x058], r12
|
||||
mov gs:[0x060], r13
|
||||
mov gs:[0x068], r14
|
||||
mov gs:[0x070], r15
|
||||
mov gs:[0x000], rbx
|
||||
mov gs:[0x008], rbp
|
||||
mov gs:[0x010], r12
|
||||
mov gs:[0x018], r13
|
||||
mov gs:[0x020], r14
|
||||
mov gs:[0x028], r15
|
||||
|
||||
mov rax, gs:[0x208]
|
||||
stac
|
||||
mov rax, gs:[0x808]
|
||||
mov fs:[0xFF8], rax
|
||||
clac
|
||||
|
||||
mov gs:[0x928], rsp
|
||||
mov rax, gs:[0x920]
|
||||
mov gs:[0x900], rax
|
||||
mov rax, gs:[0x928]
|
||||
mov gs:[0x908], rax
|
||||
mov gs:[0x1A8], rsp
|
||||
mov rax, gs:[0x1A0]
|
||||
mov gs:[0x180], rax
|
||||
mov rax, gs:[0x1A8]
|
||||
mov gs:[0x188], rax
|
||||
|
||||
mov rcx, rdi
|
||||
mov rsp, rsi
|
||||
|
|
@ -70,10 +70,8 @@ call_ext:
|
|||
xor r14, r14
|
||||
xor r15, r15
|
||||
|
||||
swapgs
|
||||
|
||||
.byte 0x48
|
||||
sysret
|
||||
sysretq
|
||||
int 3
|
||||
|
||||
.size call_ext, .-call_ext
|
||||
|
||||
|
|
@ -85,17 +83,17 @@ call_ext:
|
|||
.type call_ext_fast_fail_entry, @function
|
||||
call_ext_fast_fail_entry:
|
||||
|
||||
mov rax, gs:[0x910]
|
||||
mov gs:[0x900], rax
|
||||
mov rax, gs:[0x918]
|
||||
mov gs:[0x908], rax
|
||||
mov rax, gs:[0x190]
|
||||
mov gs:[0x180], rax
|
||||
mov rax, gs:[0x198]
|
||||
mov gs:[0x188], rax
|
||||
|
||||
mov r15, gs:[0x070]
|
||||
mov r14, gs:[0x068]
|
||||
mov r13, gs:[0x060]
|
||||
mov r12, gs:[0x058]
|
||||
mov rbp, gs:[0x020]
|
||||
mov rbx, gs:[0x008]
|
||||
mov r15, gs:[0x028]
|
||||
mov r14, gs:[0x020]
|
||||
mov r13, gs:[0x018]
|
||||
mov r12, gs:[0x010]
|
||||
mov rbp, gs:[0x008]
|
||||
mov rbx, gs:[0x000]
|
||||
|
||||
mov rax, 0x1
|
||||
ret
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -31,66 +31,62 @@
|
|||
.type dispatch_syscall_entry, @function
|
||||
dispatch_syscall_entry:
|
||||
|
||||
swapgs
|
||||
mov gs:[0x040], rcx
|
||||
mov gs:[0x080], r11
|
||||
|
||||
mov gs:[0x110], rcx
|
||||
mov gs:[0x150], r11
|
||||
mov gs:[0x038], rbx
|
||||
mov gs:[0x050], rbp
|
||||
mov gs:[0x088], r12
|
||||
mov gs:[0x090], r13
|
||||
mov gs:[0x098], r14
|
||||
mov gs:[0x0A0], r15
|
||||
|
||||
mov gs:[0x108], rbx
|
||||
mov gs:[0x120], rbp
|
||||
mov gs:[0x158], r12
|
||||
mov gs:[0x160], r13
|
||||
mov gs:[0x168], r14
|
||||
mov gs:[0x170], r15
|
||||
mov gs:[0x030], rax
|
||||
mov gs:[0x060], rdi
|
||||
mov gs:[0x058], rsi
|
||||
mov gs:[0x048], rdx
|
||||
mov gs:[0x078], r10
|
||||
mov gs:[0x068], r8
|
||||
mov gs:[0x070], r9
|
||||
|
||||
mov gs:[0x100], rax
|
||||
mov gs:[0x130], rdi
|
||||
mov gs:[0x128], rsi
|
||||
mov gs:[0x118], rdx
|
||||
mov gs:[0x148], r10
|
||||
mov gs:[0x138], r8
|
||||
mov gs:[0x140], r9
|
||||
mov gs:[0x0A8], rsp
|
||||
mov rsp, gs:[0x1A8]
|
||||
|
||||
mov gs:[0x180], rsp
|
||||
mov rsp, gs:[0x928]
|
||||
mov gs:[0x1B8], rsp
|
||||
mov rax, gs:[0x1B0]
|
||||
mov gs:[0x180], rax
|
||||
mov rax, gs:[0x1B8]
|
||||
mov gs:[0x188], rax
|
||||
|
||||
mov gs:[0x938], rsp
|
||||
mov rax, gs:[0x930]
|
||||
mov gs:[0x900], rax
|
||||
mov rax, gs:[0x938]
|
||||
mov gs:[0x908], rax
|
||||
|
||||
mov rdi, gs:[0x800]
|
||||
mov rdi, gs:[0x200]
|
||||
call dispatch_syscall_trampoline
|
||||
|
||||
mov rdx, gs:[0x920]
|
||||
mov gs:[0x900], rdx
|
||||
mov rdx, gs:[0x928]
|
||||
mov gs:[0x908], rdx
|
||||
mov rdx, gs:[0x1A0]
|
||||
mov gs:[0x180], rdx
|
||||
mov rdx, gs:[0x1A8]
|
||||
mov gs:[0x188], rdx
|
||||
|
||||
mov rsp, gs:[0x180]
|
||||
mov rsp, gs:[0x0A8]
|
||||
|
||||
mov r9, gs:[0x140]
|
||||
mov r8, gs:[0x138]
|
||||
mov r10, gs:[0x148]
|
||||
mov rdx, gs:[0x118]
|
||||
mov rsi, gs:[0x128]
|
||||
mov rdi, gs:[0x130]
|
||||
mov r9, gs:[0x070]
|
||||
mov r8, gs:[0x068]
|
||||
mov r10, gs:[0x078]
|
||||
mov rdx, gs:[0x048]
|
||||
mov rsi, gs:[0x058]
|
||||
mov rdi, gs:[0x060]
|
||||
|
||||
mov r15, gs:[0x170]
|
||||
mov r14, gs:[0x168]
|
||||
mov r13, gs:[0x160]
|
||||
mov r12, gs:[0x158]
|
||||
mov rbp, gs:[0x120]
|
||||
mov rbx, gs:[0x108]
|
||||
mov r15, gs:[0x0A0]
|
||||
mov r14, gs:[0x098]
|
||||
mov r13, gs:[0x090]
|
||||
mov r12, gs:[0x088]
|
||||
mov rbp, gs:[0x050]
|
||||
mov rbx, gs:[0x038]
|
||||
|
||||
mov r11, gs:[0x150]
|
||||
mov rcx, gs:[0x110]
|
||||
mov r11, gs:[0x080]
|
||||
mov rcx, gs:[0x040]
|
||||
|
||||
swapgs
|
||||
|
||||
.byte 0x48
|
||||
sysret
|
||||
sysretq
|
||||
int 3
|
||||
|
||||
.size dispatch_syscall_entry, .-dispatch_syscall_entry
|
||||
|
||||
|
|
@ -102,34 +98,32 @@ dispatch_syscall_entry:
|
|||
.type dispatch_syscall_fast_fail_entry, @function
|
||||
dispatch_syscall_fast_fail_entry:
|
||||
|
||||
mov rax, gs:[0x920]
|
||||
mov gs:[0x900], rax
|
||||
mov rax, gs:[0x928]
|
||||
mov gs:[0x908], rax
|
||||
mov rax, gs:[0x1A0]
|
||||
mov gs:[0x180], rax
|
||||
mov rax, gs:[0x1A8]
|
||||
mov gs:[0x188], rax
|
||||
|
||||
mov rsp, gs:[0x180]
|
||||
mov rsp, gs:[0x0A8]
|
||||
|
||||
mov r9, gs:[0x140]
|
||||
mov r8, gs:[0x138]
|
||||
mov r10, gs:[0x148]
|
||||
mov rdx, gs:[0x118]
|
||||
mov rsi, gs:[0x128]
|
||||
mov rdi, gs:[0x130]
|
||||
mov r9, gs:[0x070]
|
||||
mov r8, gs:[0x068]
|
||||
mov r10, gs:[0x078]
|
||||
mov rdx, gs:[0x048]
|
||||
mov rsi, gs:[0x058]
|
||||
mov rdi, gs:[0x060]
|
||||
|
||||
mov r15, gs:[0x170]
|
||||
mov r14, gs:[0x168]
|
||||
mov r13, gs:[0x160]
|
||||
mov r12, gs:[0x158]
|
||||
mov rbp, gs:[0x120]
|
||||
mov rbx, gs:[0x108]
|
||||
mov r15, gs:[0x0A0]
|
||||
mov r14, gs:[0x098]
|
||||
mov r13, gs:[0x090]
|
||||
mov r12, gs:[0x088]
|
||||
mov rbp, gs:[0x050]
|
||||
mov rbx, gs:[0x038]
|
||||
|
||||
mov r11, gs:[0x150]
|
||||
mov rcx, gs:[0x110]
|
||||
|
||||
swapgs
|
||||
mov r11, gs:[0x080]
|
||||
mov rcx, gs:[0x040]
|
||||
|
||||
mov rax, 0xDEAD000000010001
|
||||
.byte 0x48
|
||||
sysret
|
||||
sysretq
|
||||
int 3
|
||||
|
||||
.size dispatch_syscall_fast_fail_entry, .-dispatch_syscall_fast_fail_entry
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
.type fast_fail_entry, @function
|
||||
fast_fail_entry:
|
||||
|
||||
mov rdi, gs:[0x800]
|
||||
mov rdi, gs:[0x200]
|
||||
call fast_fail_trampoline
|
||||
|
||||
jmp intrinsic_halt
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
.type get_current_tls, @function
|
||||
get_current_tls:
|
||||
|
||||
mov rax, gs:[0x800]
|
||||
mov rax, gs:[0x200]
|
||||
|
||||
ret
|
||||
int 3
|
||||
|
|
|
|||
|
|
@ -40,6 +40,117 @@ intrinsic_invlpg:
|
|||
|
||||
|
||||
|
||||
.globl intrinsic_es_selector
|
||||
.type intrinsic_es_selector, @function
|
||||
intrinsic_es_selector:
|
||||
|
||||
xor rax, rax
|
||||
mov ax, es
|
||||
|
||||
ret
|
||||
int 3
|
||||
|
||||
.size intrinsic_es_selector, .-intrinsic_es_selector
|
||||
|
||||
|
||||
|
||||
.globl intrinsic_cs_selector
|
||||
.type intrinsic_cs_selector, @function
|
||||
intrinsic_cs_selector:
|
||||
|
||||
xor rax, rax
|
||||
mov ax, cs
|
||||
|
||||
ret
|
||||
int 3
|
||||
|
||||
.size intrinsic_cs_selector, .-intrinsic_cs_selector
|
||||
|
||||
|
||||
|
||||
.globl intrinsic_ss_selector
|
||||
.type intrinsic_ss_selector, @function
|
||||
intrinsic_ss_selector:
|
||||
|
||||
xor rax, rax
|
||||
mov ax, ss
|
||||
|
||||
ret
|
||||
int 3
|
||||
|
||||
.size intrinsic_ss_selector, .-intrinsic_ss_selector
|
||||
|
||||
|
||||
|
||||
.globl intrinsic_ds_selector
|
||||
.type intrinsic_ds_selector, @function
|
||||
intrinsic_ds_selector:
|
||||
|
||||
xor rax, rax
|
||||
mov ax, ds
|
||||
|
||||
ret
|
||||
int 3
|
||||
|
||||
.size intrinsic_ds_selector, .-intrinsic_ds_selector
|
||||
|
||||
|
||||
|
||||
.globl intrinsic_fs_selector
|
||||
.type intrinsic_fs_selector, @function
|
||||
intrinsic_fs_selector:
|
||||
|
||||
xor rax, rax
|
||||
mov ax, fs
|
||||
|
||||
ret
|
||||
int 3
|
||||
|
||||
.size intrinsic_fs_selector, .-intrinsic_fs_selector
|
||||
|
||||
|
||||
|
||||
.globl intrinsic_gs_selector
|
||||
.type intrinsic_gs_selector, @function
|
||||
intrinsic_gs_selector:
|
||||
|
||||
xor rax, rax
|
||||
mov ax, gs
|
||||
|
||||
ret
|
||||
int 3
|
||||
|
||||
.size intrinsic_gs_selector, .-intrinsic_gs_selector
|
||||
|
||||
|
||||
|
||||
.globl intrinsic_tr_selector
|
||||
.type intrinsic_tr_selector, @function
|
||||
intrinsic_tr_selector:
|
||||
|
||||
xor rax, rax
|
||||
str ax
|
||||
|
||||
ret
|
||||
int 3
|
||||
|
||||
.size intrinsic_tr_selector, .-intrinsic_tr_selector
|
||||
|
||||
|
||||
|
||||
.globl intrinsic_cr0
|
||||
.type intrinsic_cr0, @function
|
||||
intrinsic_cr0:
|
||||
|
||||
mov rax, cr0
|
||||
|
||||
ret
|
||||
int 3
|
||||
|
||||
.size intrinsic_cr0, .-intrinsic_cr0
|
||||
|
||||
|
||||
|
||||
.globl intrinsic_cr3
|
||||
.type intrinsic_cr3, @function
|
||||
intrinsic_cr3:
|
||||
|
|
@ -66,6 +177,19 @@ intrinsic_set_cr3:
|
|||
|
||||
|
||||
|
||||
.globl intrinsic_cr4
|
||||
.type intrinsic_cr4, @function
|
||||
intrinsic_cr4:
|
||||
|
||||
mov rax, cr4
|
||||
|
||||
ret
|
||||
int 3
|
||||
|
||||
.size intrinsic_cr4, .-intrinsic_cr4
|
||||
|
||||
|
||||
|
||||
.globl intrinsic_tp
|
||||
.type intrinsic_tp, @function
|
||||
intrinsic_tp:
|
||||
|
|
@ -148,7 +272,7 @@ intrinsic_halt:
|
|||
intrinsic_rdmsr:
|
||||
|
||||
lea rax, [rip + intrinsic_rdmsr_failed]
|
||||
mov gs:[0x850], rax
|
||||
mov gs:[0x250], rax
|
||||
|
||||
mov ecx, edi
|
||||
xor rax, rax
|
||||
|
|
@ -160,7 +284,7 @@ intrinsic_rdmsr:
|
|||
mov [rsi], rax
|
||||
|
||||
xor rax, rax
|
||||
mov gs:[0x850], rax
|
||||
mov gs:[0x250], rax
|
||||
|
||||
ret
|
||||
int 3
|
||||
|
|
@ -168,7 +292,7 @@ intrinsic_rdmsr:
|
|||
intrinsic_rdmsr_failed:
|
||||
|
||||
xor rax, rax
|
||||
mov gs:[0x850], rax
|
||||
mov gs:[0x250], rax
|
||||
|
||||
mov rax, 0x1
|
||||
ret
|
||||
|
|
@ -201,7 +325,7 @@ intrinsic_rdmsr_unsafe:
|
|||
intrinsic_wrmsr:
|
||||
|
||||
lea rax, [rip + intrinsic_wrmsr_failed]
|
||||
mov gs:[0x850], rax
|
||||
mov gs:[0x250], rax
|
||||
|
||||
mov ecx, edi
|
||||
mov rax, rsi
|
||||
|
|
@ -210,7 +334,7 @@ intrinsic_wrmsr:
|
|||
wrmsr
|
||||
|
||||
xor rax, rax
|
||||
mov gs:[0x850], rax
|
||||
mov gs:[0x250], rax
|
||||
|
||||
ret
|
||||
int 3
|
||||
|
|
@ -218,7 +342,7 @@ intrinsic_wrmsr:
|
|||
intrinsic_wrmsr_failed:
|
||||
|
||||
xor rax, rax
|
||||
mov gs:[0x850], rax
|
||||
mov gs:[0x250], rax
|
||||
|
||||
mov rax, 0x1
|
||||
ret
|
||||
|
|
@ -441,9 +565,9 @@ intrinsic_vmrun:
|
|||
/**************************************************************************/
|
||||
|
||||
xor rax, rax
|
||||
mov gs:[0x858], rax
|
||||
mov gs:[0x258], rax
|
||||
|
||||
mov rax, gs:[0x860]
|
||||
mov rax, gs:[0x260]
|
||||
cmp rax, 0x1
|
||||
jne nmis_complete
|
||||
|
||||
|
|
@ -505,7 +629,7 @@ intrinsic_vmrun_failure:
|
|||
/**************************************************************************/
|
||||
|
||||
mov rax, 0x1
|
||||
mov gs:[0x858], rax
|
||||
mov gs:[0x258], rax
|
||||
|
||||
/**************************************************************************/
|
||||
/* MSRs */
|
||||
|
|
@ -611,22 +735,22 @@ intrinsic_vmexit:
|
|||
/* Signal First Launch Success */
|
||||
/**************************************************************************/
|
||||
|
||||
mov rax, gs:[0x870]
|
||||
mov rax, gs:[0x270]
|
||||
cmp rax, 0x0
|
||||
jne skip_first_launch_logic
|
||||
|
||||
mov rax, 0x1
|
||||
mov gs:[0x870], rax
|
||||
mov gs:[0x270], rax
|
||||
|
||||
lea rax, [rip + fast_fail_entry]
|
||||
mov gs:[0x900], rax
|
||||
mov gs:[0x180], rax
|
||||
mov rax, 0x0
|
||||
mov gs:[0x908], rax
|
||||
mov gs:[0x188], rax
|
||||
|
||||
lea rax, [rip + fast_fail_entry]
|
||||
mov gs:[0x910], rax
|
||||
mov gs:[0x190], rax
|
||||
mov rax, 0x0
|
||||
mov gs:[0x918], rax
|
||||
mov gs:[0x198], rax
|
||||
|
||||
skip_first_launch_logic:
|
||||
|
||||
|
|
@ -635,7 +759,7 @@ skip_first_launch_logic:
|
|||
/**************************************************************************/
|
||||
|
||||
mov rax, 0x1
|
||||
mov gs:[0x858], rax
|
||||
mov gs:[0x258], rax
|
||||
|
||||
/**************************************************************************/
|
||||
/* MSRs */
|
||||
|
|
|
|||
|
|
@ -45,6 +45,70 @@ namespace mk
|
|||
///
|
||||
extern "C" void intrinsic_invlpg(bsl::uint64 const val) noexcept;
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Implements intrinsic_t::es_selector
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @return n/a
|
||||
///
|
||||
extern "C" [[nodiscard]] auto intrinsic_es_selector() noexcept -> bsl::uint16;
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Implements intrinsic_t::es_selector
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @return n/a
|
||||
///
|
||||
extern "C" [[nodiscard]] auto intrinsic_cs_selector() noexcept -> bsl::uint16;
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Implements intrinsic_t::es_selector
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @return n/a
|
||||
///
|
||||
extern "C" [[nodiscard]] auto intrinsic_ss_selector() noexcept -> bsl::uint16;
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Implements intrinsic_t::es_selector
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @return n/a
|
||||
///
|
||||
extern "C" [[nodiscard]] auto intrinsic_ds_selector() noexcept -> bsl::uint16;
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Implements intrinsic_t::es_selector
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @return n/a
|
||||
///
|
||||
extern "C" [[nodiscard]] auto intrinsic_fs_selector() noexcept -> bsl::uint16;
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Implements intrinsic_t::es_selector
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @return n/a
|
||||
///
|
||||
extern "C" [[nodiscard]] auto intrinsic_gs_selector() noexcept -> bsl::uint16;
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Implements intrinsic_t::tr_selector
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @return n/a
|
||||
///
|
||||
extern "C" [[nodiscard]] auto intrinsic_tr_selector() noexcept -> bsl::uint16;
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Implements intrinsic_t::cr0
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @return n/a
|
||||
///
|
||||
extern "C" [[nodiscard]] auto intrinsic_cr0() noexcept -> bsl::uint64;
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Implements intrinsic_t::cr3
|
||||
///
|
||||
|
|
@ -61,6 +125,14 @@ namespace mk
|
|||
///
|
||||
extern "C" void intrinsic_set_cr3(bsl::uint64 const val) noexcept;
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Implements intrinsic_t::cr4
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @return n/a
|
||||
///
|
||||
extern "C" [[nodiscard]] auto intrinsic_cr4() noexcept -> bsl::uint64;
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Implements intrinsic_t::tp
|
||||
///
|
||||
|
|
@ -291,6 +363,134 @@ namespace mk
|
|||
details::intrinsic_invlpg(val.get());
|
||||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Returns the value of ES
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @return Returns the value of ES
|
||||
///
|
||||
[[nodiscard]] static constexpr auto
|
||||
es_selector() noexcept -> bsl::safe_uint16
|
||||
{
|
||||
if (bsl::is_constant_evaluated()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return details::intrinsic_es_selector();
|
||||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Returns the value of CS
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @return Returns the value of CS
|
||||
///
|
||||
[[nodiscard]] static constexpr auto
|
||||
cs_selector() noexcept -> bsl::safe_uint16
|
||||
{
|
||||
if (bsl::is_constant_evaluated()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return details::intrinsic_cs_selector();
|
||||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Returns the value of SS
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @return Returns the value of SS
|
||||
///
|
||||
[[nodiscard]] static constexpr auto
|
||||
ss_selector() noexcept -> bsl::safe_uint16
|
||||
{
|
||||
if (bsl::is_constant_evaluated()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return details::intrinsic_ss_selector();
|
||||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Returns the value of DS
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @return Returns the value of DS
|
||||
///
|
||||
[[nodiscard]] static constexpr auto
|
||||
ds_selector() noexcept -> bsl::safe_uint16
|
||||
{
|
||||
if (bsl::is_constant_evaluated()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return details::intrinsic_ds_selector();
|
||||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Returns the value of FS
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @return Returns the value of FS
|
||||
///
|
||||
[[nodiscard]] static constexpr auto
|
||||
fs_selector() noexcept -> bsl::safe_uint16
|
||||
{
|
||||
if (bsl::is_constant_evaluated()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return details::intrinsic_fs_selector();
|
||||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Returns the value of GS
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @return Returns the value of GS
|
||||
///
|
||||
[[nodiscard]] static constexpr auto
|
||||
gs_selector() noexcept -> bsl::safe_uint16
|
||||
{
|
||||
if (bsl::is_constant_evaluated()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return details::intrinsic_gs_selector();
|
||||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Returns the value of TR
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @return Returns the value of TR
|
||||
///
|
||||
[[nodiscard]] static constexpr auto
|
||||
tr_selector() noexcept -> bsl::safe_uint16
|
||||
{
|
||||
if (bsl::is_constant_evaluated()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return details::intrinsic_tr_selector();
|
||||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Returns the value of CR0
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @return Returns the value of CR0
|
||||
///
|
||||
[[nodiscard]] static constexpr auto
|
||||
cr0() noexcept -> bsl::safe_uint64
|
||||
{
|
||||
if (bsl::is_constant_evaluated()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return details::intrinsic_cr0();
|
||||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Returns the value of CR3
|
||||
///
|
||||
|
|
@ -332,6 +532,22 @@ namespace mk
|
|||
details::intrinsic_set_cr3(val.get());
|
||||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Returns the value of CR4
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @return Returns the value of CR4
|
||||
///
|
||||
[[nodiscard]] static constexpr auto
|
||||
cr4() noexcept -> bsl::safe_uint64
|
||||
{
|
||||
if (bsl::is_constant_evaluated()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return details::intrinsic_cr4();
|
||||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Returns the value of tp (TLS pointer)
|
||||
///
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ promote:
|
|||
* is extremely unlikely.
|
||||
*/
|
||||
|
||||
mov rax, gs:[0x860]
|
||||
mov rax, gs:[0x260]
|
||||
cmp rax, 0x1
|
||||
jne nmi_pending_transfer_complete
|
||||
|
||||
|
|
|
|||
|
|
@ -39,8 +39,6 @@
|
|||
|
||||
namespace mk
|
||||
{
|
||||
/// @brief entry point prototype
|
||||
extern "C" void dispatch_syscall_entry(void) noexcept;
|
||||
/// @brief entry point prototype
|
||||
extern "C" void intrinsic_vmexit(void) noexcept;
|
||||
|
||||
|
|
@ -49,8 +47,32 @@ namespace mk
|
|||
|
||||
namespace details
|
||||
{
|
||||
/// @brief defines the VMX BASIC MSR
|
||||
constexpr bsl::safe_uint32 IA32_VMX_BASIC{bsl::to_u32(0x480)};
|
||||
/// @brief defines the IA32_VMX_BASIC MSR
|
||||
constexpr bsl::safe_uint32 IA32_VMX_BASIC{bsl::to_u32(0x480U)};
|
||||
/// @brief defines the IA32_PAT MSR
|
||||
constexpr bsl::safe_uint32 IA32_PAT{bsl::to_u32(0x277U)};
|
||||
/// @brief defines the IA32_SYSENTER_CS MSR
|
||||
constexpr bsl::safe_uint32 IA32_SYSENTER_CS{bsl::to_u32(0x174U)};
|
||||
/// @brief defines the IA32_SYSENTER_ESP MSR
|
||||
constexpr bsl::safe_uint32 IA32_SYSENTER_ESP{bsl::to_u32(0x175U)};
|
||||
/// @brief defines the IA32_SYSENTER_EIP MSR
|
||||
constexpr bsl::safe_uint32 IA32_SYSENTER_EIP{bsl::to_u32(0x176U)};
|
||||
/// @brief defines the IA32_EFER MSR
|
||||
constexpr bsl::safe_uint32 IA32_EFER{bsl::to_u32(0xC0000080U)};
|
||||
/// @brief defines the IA32_STAR MSR
|
||||
constexpr bsl::safe_uint32 IA32_STAR{bsl::to_u32(0xC0000081U)};
|
||||
/// @brief defines the IA32_LSTAR MSR
|
||||
constexpr bsl::safe_uint32 IA32_LSTAR{bsl::to_u32(0xC0000082U)};
|
||||
/// @brief defines the IA32_CSTAR MSR
|
||||
constexpr bsl::safe_uint32 IA32_CSTAR{bsl::to_u32(0xC0000083U)};
|
||||
/// @brief defines the IA32_FMASK MSR
|
||||
constexpr bsl::safe_uint32 IA32_FMASK{bsl::to_u32(0xC0000084U)};
|
||||
/// @brief defines the IA32_FS_BASE MSR
|
||||
constexpr bsl::safe_uint32 IA32_FS_BASE{bsl::to_u32(0xC0000100U)};
|
||||
/// @brief defines the IA32_GS_BASE MSR
|
||||
constexpr bsl::safe_uint32 IA32_GS_BASE{bsl::to_u32(0xC0000101U)};
|
||||
/// @brief defines the IA32_KERNEL_GS_BASE MSR
|
||||
constexpr bsl::safe_uint32 IA32_KERNEL_GS_BASE{bsl::to_u32(0xC0000102U)};
|
||||
}
|
||||
|
||||
/// @class mk::vps_t
|
||||
|
|
@ -1156,7 +1178,11 @@ namespace mk
|
|||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Ensures that this VPS is loaded
|
||||
/// @brief This is executed on each core when a VPS is first
|
||||
/// allocated, and ensures the VMCS contains the current host
|
||||
/// states of the CPU it is running on. We don't use the state
|
||||
/// that the loader provides as this state can change as the
|
||||
/// microkernel completes it's bootstrapping process.
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @tparam TLS_CONCEPT defines the type of TLS block to use
|
||||
|
|
@ -1179,73 +1205,69 @@ namespace mk
|
|||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
ret = m_intrinsic->vmwrite16(VMCS_HOST_ES_SELECTOR, state->es_selector);
|
||||
ret = m_intrinsic->vmwrite16(VMCS_HOST_ES_SELECTOR, m_intrinsic->es_selector());
|
||||
if (bsl::unlikely(!ret)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
ret = m_intrinsic->vmwrite16(VMCS_HOST_CS_SELECTOR, state->cs_selector);
|
||||
ret = m_intrinsic->vmwrite16(VMCS_HOST_CS_SELECTOR, m_intrinsic->cs_selector());
|
||||
if (bsl::unlikely(!ret)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
ret = m_intrinsic->vmwrite16(VMCS_HOST_SS_SELECTOR, state->ss_selector);
|
||||
ret = m_intrinsic->vmwrite16(VMCS_HOST_SS_SELECTOR, m_intrinsic->ss_selector());
|
||||
if (bsl::unlikely(!ret)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
ret = m_intrinsic->vmwrite16(VMCS_HOST_DS_SELECTOR, state->ds_selector);
|
||||
ret = m_intrinsic->vmwrite16(VMCS_HOST_DS_SELECTOR, m_intrinsic->ds_selector());
|
||||
if (bsl::unlikely(!ret)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
ret = m_intrinsic->vmwrite16(VMCS_HOST_FS_SELECTOR, state->fs_selector);
|
||||
ret = m_intrinsic->vmwrite16(VMCS_HOST_FS_SELECTOR, m_intrinsic->fs_selector());
|
||||
if (bsl::unlikely(!ret)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
ret = m_intrinsic->vmwrite16(VMCS_HOST_GS_SELECTOR, state->gs_selector);
|
||||
ret = m_intrinsic->vmwrite16(VMCS_HOST_GS_SELECTOR, m_intrinsic->gs_selector());
|
||||
if (bsl::unlikely(!ret)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
ret = m_intrinsic->vmwrite16(VMCS_HOST_TR_SELECTOR, state->tr_selector);
|
||||
ret = m_intrinsic->vmwrite16(VMCS_HOST_TR_SELECTOR, m_intrinsic->tr_selector());
|
||||
if (bsl::unlikely(!ret)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
ret = m_intrinsic->vmwrite64(VMCS_HOST_IA32_PAT, state->ia32_pat);
|
||||
ret = m_intrinsic->vmwrite64(VMCS_HOST_IA32_PAT, m_intrinsic->rdmsr(details::IA32_PAT));
|
||||
if (bsl::unlikely(!ret)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
ret = m_intrinsic->vmwrite64(VMCS_HOST_IA32_EFER, state->ia32_efer);
|
||||
ret =
|
||||
m_intrinsic->vmwrite64(VMCS_HOST_IA32_EFER, m_intrinsic->rdmsr(details::IA32_EFER));
|
||||
if (bsl::unlikely(!ret)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
ret = m_intrinsic->vmwrite64(VMCS_HOST_IA32_PAT, state->ia32_pat);
|
||||
ret = m_intrinsic->vmwrite64(
|
||||
VMCS_HOST_IA32_SYSENTER_CS, m_intrinsic->rdmsr(details::IA32_SYSENTER_CS));
|
||||
if (bsl::unlikely(!ret)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
ret = m_intrinsic->vmwrite64(VMCS_HOST_IA32_SYSENTER_CS, state->ia32_sysenter_cs);
|
||||
if (bsl::unlikely(!ret)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
ret = m_intrinsic->vmwrite64(VMCS_HOST_CR0, state->cr0);
|
||||
ret = m_intrinsic->vmwrite64(VMCS_HOST_CR0, m_intrinsic->cr0());
|
||||
if (bsl::unlikely(!ret)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
|
|
@ -1257,19 +1279,21 @@ namespace mk
|
|||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
ret = m_intrinsic->vmwrite64(VMCS_HOST_CR4, state->cr4);
|
||||
ret = m_intrinsic->vmwrite64(VMCS_HOST_CR4, m_intrinsic->cr4());
|
||||
if (bsl::unlikely(!ret)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
ret = m_intrinsic->vmwrite64(VMCS_HOST_FS_BASE, tls.tp);
|
||||
ret = m_intrinsic->vmwrite64(
|
||||
VMCS_HOST_FS_BASE, m_intrinsic->rdmsr(details::IA32_FS_BASE));
|
||||
if (bsl::unlikely(!ret)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
ret = m_intrinsic->vmwrite64(VMCS_HOST_GS_BASE, bsl::to_umax(&tls));
|
||||
ret = m_intrinsic->vmwrite64(
|
||||
VMCS_HOST_GS_BASE, m_intrinsic->rdmsr(details::IA32_GS_BASE));
|
||||
if (bsl::unlikely(!ret)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
|
|
@ -1293,13 +1317,15 @@ namespace mk
|
|||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
ret = m_intrinsic->vmwrite64(VMCS_HOST_IA32_SYSENTER_ESP, state->ia32_sysenter_esp);
|
||||
ret = m_intrinsic->vmwrite64(
|
||||
VMCS_HOST_IA32_SYSENTER_ESP, m_intrinsic->rdmsr(details::IA32_SYSENTER_ESP));
|
||||
if (bsl::unlikely(!ret)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
ret = m_intrinsic->vmwrite64(VMCS_HOST_IA32_SYSENTER_EIP, state->ia32_sysenter_eip);
|
||||
ret = m_intrinsic->vmwrite64(
|
||||
VMCS_HOST_IA32_SYSENTER_EIP, m_intrinsic->rdmsr(details::IA32_SYSENTER_EIP));
|
||||
if (bsl::unlikely(!ret)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
|
|
@ -1311,11 +1337,16 @@ namespace mk
|
|||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
m_vmcs_missing_registers.host_ia32_star = state->ia32_star;
|
||||
m_vmcs_missing_registers.host_ia32_lstar = bsl::to_umax(&dispatch_syscall_entry).get();
|
||||
m_vmcs_missing_registers.host_ia32_cstar = state->ia32_cstar;
|
||||
m_vmcs_missing_registers.host_ia32_fmask = state->ia32_fmask;
|
||||
m_vmcs_missing_registers.host_ia32_kernel_gs_base = state->ia32_kernel_gs_base;
|
||||
m_vmcs_missing_registers.host_ia32_star = // --
|
||||
m_intrinsic->rdmsr(details::IA32_STAR).get(); // --
|
||||
m_vmcs_missing_registers.host_ia32_lstar = // --
|
||||
m_intrinsic->rdmsr(details::IA32_LSTAR).get(); // --
|
||||
m_vmcs_missing_registers.host_ia32_cstar = // --
|
||||
m_intrinsic->rdmsr(details::IA32_CSTAR).get(); // --
|
||||
m_vmcs_missing_registers.host_ia32_fmask = // --
|
||||
m_intrinsic->rdmsr(details::IA32_FMASK).get(); // --
|
||||
m_vmcs_missing_registers.host_ia32_kernel_gs_base = // --
|
||||
m_intrinsic->rdmsr(details::IA32_KERNEL_GS_BASE).get(); // --
|
||||
|
||||
return bsl::errc_success;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,12 +33,17 @@ mk_main_entry:
|
|||
|
||||
push rdi
|
||||
|
||||
/**
|
||||
* TODO:
|
||||
* - Comment this code
|
||||
*/
|
||||
|
||||
mov r10, [rdi]
|
||||
mov rdx, 0x000000000000FFFF
|
||||
and r10, rdx
|
||||
|
||||
mov rax, r10
|
||||
mov rdx, 0x1000
|
||||
mov rdx, 0x300
|
||||
mul rdx
|
||||
lea rsi, [rip + g_tls_blocks]
|
||||
add rsi, rax
|
||||
|
|
@ -56,20 +61,20 @@ mk_main_entry:
|
|||
mov rdx, 0xFFFFFFFFFFFF0000
|
||||
or rax, rdx
|
||||
|
||||
mov gs:[0x800], rsi
|
||||
mov gs:[0x808], rax
|
||||
mov gs:[0x200], rsi
|
||||
mov gs:[0x208], rax
|
||||
|
||||
lea rax, [rip + mk_main_fast_fail_entry]
|
||||
mov gs:[0x910], rax
|
||||
mov gs:[0x190], rax
|
||||
lea rax, [rip + call_ext_fast_fail_entry]
|
||||
mov gs:[0x920], rax
|
||||
mov gs:[0x1A0], rax
|
||||
lea rax, [rip + dispatch_syscall_fast_fail_entry]
|
||||
mov gs:[0x930], rax
|
||||
mov gs:[0x1B0], rax
|
||||
|
||||
mov rax, [rdi + 0x008]
|
||||
mov gs:[0x828], rax
|
||||
mov gs:[0x228], rax
|
||||
mov rax, [rdi + 0x010]
|
||||
mov gs:[0x830], rax
|
||||
mov gs:[0x230], rax
|
||||
|
||||
lea rax, [rip + g_debug_ring]
|
||||
mov rdx, [rdi + 0x018]
|
||||
|
|
@ -87,7 +92,7 @@ mk_main_entry:
|
|||
*/
|
||||
|
||||
mov rax, 0x1
|
||||
mov gs:[0x858], rax
|
||||
mov gs:[0x258], rax
|
||||
|
||||
mov rdi, 0
|
||||
lea rsi, [rip + dispatch_esr_entry_0]
|
||||
|
|
@ -171,18 +176,18 @@ mk_main_entry:
|
|||
|
||||
mov rdx, [rdi + 0x010]
|
||||
mov rax, [rdx + 0x318]
|
||||
mov gs:[0x860], rax
|
||||
mov gs:[0x260], rax
|
||||
|
||||
xor rax, rax
|
||||
mov [rdx + 0x318], rax
|
||||
|
||||
pop rsi
|
||||
|
||||
mov gs:[0x918], rsp
|
||||
mov rax, gs:[0x910]
|
||||
mov gs:[0x900], rax
|
||||
mov rax, gs:[0x918]
|
||||
mov gs:[0x908], rax
|
||||
mov gs:[0x198], rsp
|
||||
mov rax, gs:[0x190]
|
||||
mov gs:[0x180], rax
|
||||
mov rax, gs:[0x198]
|
||||
mov gs:[0x188], rax
|
||||
|
||||
call mk_main_trampoline
|
||||
jmp return_to_current_fast_fail
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
.type return_to_current_fast_fail, @function
|
||||
return_to_current_fast_fail:
|
||||
|
||||
mov rax, gs:[0x908]
|
||||
mov rax, gs:[0x188]
|
||||
cmp rax, 0
|
||||
je use_current_stack
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ capture_spec:
|
|||
pause
|
||||
jmp capture_spec
|
||||
set_up_target:
|
||||
mov rax, gs:[0x900]
|
||||
mov rax, gs:[0x180]
|
||||
mov [rsp], rax
|
||||
ret
|
||||
int 3
|
||||
|
|
|
|||
|
|
@ -31,19 +31,19 @@
|
|||
.type return_to_mk, @function
|
||||
return_to_mk:
|
||||
|
||||
mov rsp, gs:[0x928]
|
||||
mov rsp, gs:[0x1A8]
|
||||
|
||||
mov rax, gs:[0x910]
|
||||
mov gs:[0x900], rax
|
||||
mov rax, gs:[0x918]
|
||||
mov gs:[0x908], rax
|
||||
mov rax, gs:[0x190]
|
||||
mov gs:[0x180], rax
|
||||
mov rax, gs:[0x198]
|
||||
mov gs:[0x188], rax
|
||||
|
||||
mov r15, gs:[0x070]
|
||||
mov r14, gs:[0x068]
|
||||
mov r13, gs:[0x060]
|
||||
mov r12, gs:[0x058]
|
||||
mov rbp, gs:[0x020]
|
||||
mov rbx, gs:[0x008]
|
||||
mov r15, gs:[0x028]
|
||||
mov r14, gs:[0x020]
|
||||
mov r13, gs:[0x018]
|
||||
mov r12, gs:[0x010]
|
||||
mov rbp, gs:[0x008]
|
||||
mov rbx, gs:[0x000]
|
||||
|
||||
mov rax, rdi
|
||||
ret
|
||||
|
|
|
|||
|
|
@ -31,14 +31,14 @@
|
|||
.type return_to_vmexit_loop, @function
|
||||
return_to_vmexit_loop:
|
||||
|
||||
mov rsp, gs:[0x948]
|
||||
mov rsp, gs:[0x1C8]
|
||||
|
||||
call set_up_target
|
||||
capture_spec:
|
||||
pause
|
||||
jmp capture_spec
|
||||
set_up_target:
|
||||
mov rax, gs:[0x940]
|
||||
mov rax, gs:[0x1C0]
|
||||
mov [rsp], rax
|
||||
ret
|
||||
int 3
|
||||
|
|
|
|||
|
|
@ -55,14 +55,12 @@ namespace mk
|
|||
/// @tparam PAGE_POOL_CONCEPT defines the type of page pool to use
|
||||
/// @tparam PAGE_SIZE defines the size of a page
|
||||
/// @tparam PAGE_SHIFT defines number of bits in a page
|
||||
/// @tparam MAP_ADDR defines the address of the MK's map region
|
||||
///
|
||||
template<
|
||||
typename INTRINSIC_CONCEPT,
|
||||
typename PAGE_POOL_CONCEPT,
|
||||
bsl::uintmax PAGE_SIZE,
|
||||
bsl::uintmax PAGE_SHIFT,
|
||||
bsl::uintmax MAP_ADDR>
|
||||
bsl::uintmax PAGE_SHIFT>
|
||||
class root_page_table_t final
|
||||
{
|
||||
/// @brief stores true if initialized() has been executed
|
||||
|
|
@ -1009,130 +1007,6 @@ namespace mk
|
|||
return bsl::errc_success;
|
||||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Converts the provided virtual address to a physical
|
||||
/// address by walking the provided page table.
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @param rpt_phys the physical address to root page table to walk
|
||||
/// @param page_virt the virtual address to convert
|
||||
/// @return Returns the resulting physical address.
|
||||
///
|
||||
[[nodiscard]] constexpr auto
|
||||
virt_to_phys(
|
||||
bsl::safe_uintmax const &rpt_phys, bsl::safe_uintmax const &page_virt) &noexcept
|
||||
-> bsl::safe_uintmax
|
||||
{
|
||||
bsl::safe_uintmax virt{MAP_ADDR};
|
||||
bsl::safe_uintmax phys{rpt_phys};
|
||||
|
||||
/// PML4
|
||||
///
|
||||
|
||||
if (!this->map_page(virt, phys, false, false, false)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::safe_uintmax::zero(true);
|
||||
}
|
||||
|
||||
auto *const pml4t{bsl::to_ptr<pml4t_t *>(virt)};
|
||||
auto *const pml4te{pml4t->entries.at_if(this->pml4to(page_virt))};
|
||||
if (bsl::ZERO_UMAX == pml4te->p) {
|
||||
bsl::error() << "virtual address " // --
|
||||
<< bsl::hex(page_virt) // --
|
||||
<< " was never mapped" // --
|
||||
<< bsl::endl // --
|
||||
<< bsl::here(); // --
|
||||
|
||||
return bsl::safe_uintmax::zero(true);
|
||||
}
|
||||
|
||||
phys = pml4te->phys << bsl::to_umax(PAGE_SHIFT);
|
||||
if (!this->unmap_page(virt)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::safe_uintmax::zero(true);
|
||||
}
|
||||
|
||||
/// PDPT
|
||||
///
|
||||
|
||||
if (!this->map_page(virt, phys, false, false, false)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::safe_uintmax::zero(true);
|
||||
}
|
||||
|
||||
auto *const pdpt{bsl::to_ptr<pdpt_t *>(virt)};
|
||||
auto *const pdpte{pdpt->entries.at_if(this->pdpto(page_virt))};
|
||||
if (bsl::ZERO_UMAX == pdpte->p) {
|
||||
bsl::error() << "virtual address " // --
|
||||
<< bsl::hex(page_virt) // --
|
||||
<< " was never mapped" // --
|
||||
<< bsl::endl // --
|
||||
<< bsl::here(); // --
|
||||
|
||||
return bsl::safe_uintmax::zero(true);
|
||||
}
|
||||
|
||||
phys = pdpte->phys << bsl::to_umax(PAGE_SHIFT);
|
||||
if (!this->unmap_page(virt)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::safe_uintmax::zero(true);
|
||||
}
|
||||
|
||||
/// PDT
|
||||
///
|
||||
|
||||
if (!this->map_page(virt, phys, false, false, false)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::safe_uintmax::zero(true);
|
||||
}
|
||||
|
||||
auto *const pdt{bsl::to_ptr<pdt_t *>(virt)};
|
||||
auto *const pdte{pdt->entries.at_if(this->pdto(page_virt))};
|
||||
if (bsl::ZERO_UMAX == pdte->p) {
|
||||
bsl::error() << "virtual address " // --
|
||||
<< bsl::hex(page_virt) // --
|
||||
<< " was never mapped" // --
|
||||
<< bsl::endl // --
|
||||
<< bsl::here(); // --
|
||||
|
||||
return bsl::safe_uintmax::zero(true);
|
||||
}
|
||||
|
||||
phys = pdte->phys << bsl::to_umax(PAGE_SHIFT);
|
||||
if (!this->unmap_page(virt)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::safe_uintmax::zero(true);
|
||||
}
|
||||
|
||||
/// PT
|
||||
///
|
||||
|
||||
if (!this->map_page(virt, phys, false, false, false)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::safe_uintmax::zero(true);
|
||||
}
|
||||
|
||||
auto *const pt{bsl::to_ptr<pt_t *>(virt)};
|
||||
auto *const pte{pt->entries.at_if(this->pto(page_virt))};
|
||||
if (bsl::ZERO_UMAX == pte->p) {
|
||||
bsl::error() << "virtual address " // --
|
||||
<< bsl::hex(page_virt) // --
|
||||
<< " was never mapped" // --
|
||||
<< bsl::endl // --
|
||||
<< bsl::here(); // --
|
||||
|
||||
return bsl::safe_uintmax::zero(true);
|
||||
}
|
||||
|
||||
phys = pte->phys << bsl::to_umax(PAGE_SHIFT);
|
||||
if (!this->unmap_page(virt)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::safe_uintmax::zero(true);
|
||||
}
|
||||
|
||||
return phys;
|
||||
}
|
||||
|
||||
public:
|
||||
/// @brief an alias for INTRINSIC_CONCEPT
|
||||
using intrinsic_type = INTRINSIC_CONCEPT;
|
||||
|
|
@ -1361,102 +1235,6 @@ namespace mk
|
|||
return this->add_tables(rpt.m_pml4t);
|
||||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Adds root VP state specific resources to the root page
|
||||
/// tables. This is needed on some architectures like x86 to
|
||||
/// ensure the entire root VP state is mapped in as needed.
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @tparam STATE_SAVE_CONCEPT the type of state save to use
|
||||
/// @param root_vp_state the state of the root_vp
|
||||
/// @return Returns bsl::errc_success on success, bsl::errc_failure
|
||||
/// otherwise
|
||||
///
|
||||
template<typename STATE_SAVE_CONCEPT>
|
||||
[[nodiscard]] constexpr auto
|
||||
add_root_vp_state(STATE_SAVE_CONCEPT const *const root_vp_state) &noexcept -> bsl::errc_type
|
||||
{
|
||||
if (bsl::unlikely(!m_initialized)) {
|
||||
bsl::error() << "root_page_table_t not initialized\n" << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
if (bsl::ZERO_UMAX == root_vp_state->map_gdt) {
|
||||
return bsl::errc_success;
|
||||
}
|
||||
|
||||
/// NOTE:
|
||||
/// - We need to map the root OS's GDT into the microkernel's
|
||||
/// address space so that it can flip the TSS busy bit
|
||||
/// during the promotion process.
|
||||
/// - This is not a simple task as some OS's will not provide
|
||||
/// the physical address of the GDT (like Linux), so we need
|
||||
/// to manually walk the root OS's page tables to get this
|
||||
/// physical address ourselves.
|
||||
///
|
||||
|
||||
if (bsl::unlikely(nullptr == root_vp_state)) {
|
||||
bsl::error() << "root_vp_state is invalid: " // --
|
||||
<< root_vp_state // --
|
||||
<< bsl::endl // --
|
||||
<< bsl::here(); // --
|
||||
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
auto const rpt_phys{this->page_aligned(root_vp_state->cr3)};
|
||||
if (bsl::unlikely(rpt_phys.is_zero())) {
|
||||
bsl::error() << "invalid cr3: " // --
|
||||
<< bsl::hex(rpt_phys) // --
|
||||
<< bsl::endl // --
|
||||
<< bsl::here(); // --
|
||||
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
auto const gdt_virt{bsl::to_umax(root_vp_state->gdtr.base)};
|
||||
if (bsl::unlikely(gdt_virt.is_zero())) {
|
||||
bsl::error() << "invalid gdt address: " // --
|
||||
<< bsl::hex(gdt_virt) // --
|
||||
<< bsl::endl // --
|
||||
<< bsl::here(); // --
|
||||
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
if (bsl::unlikely(!this->is_page_aligned(gdt_virt))) {
|
||||
bsl::error() << "gdt address is not page aligned: " // --
|
||||
<< bsl::hex(gdt_virt) // --
|
||||
<< bsl::endl // --
|
||||
<< bsl::here(); // --
|
||||
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
auto const gdt_limit{bsl::to_umax(root_vp_state->gdtr.limit)};
|
||||
if (bsl::unlikely(gdt_limit.is_zero())) {
|
||||
bsl::error() << "invalid gdt limit: " // --
|
||||
<< bsl::hex(gdt_limit) // --
|
||||
<< bsl::endl // --
|
||||
<< bsl::here(); // --
|
||||
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
auto gdpt_phys{this->virt_to_phys(rpt_phys, gdt_virt)};
|
||||
if (bsl::unlikely(!gdpt_phys)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
if (!this->map_page(gdt_virt, gdpt_phys, false, false, false)) {
|
||||
bsl::print<bsl::V>() << bsl::here();
|
||||
return bsl::errc_failure;
|
||||
}
|
||||
|
||||
return bsl::errc_success;
|
||||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Maps a page into the root page table being managed
|
||||
/// by this class using read/write permissions.
|
||||
|
|
@ -1931,7 +1709,6 @@ namespace mk
|
|||
/// @tparam PAGE_POOL_CONCEPT defines the type of page pool to use
|
||||
/// @tparam PAGE_SIZE defines the size of a page
|
||||
/// @tparam PAGE_SHIFT defines number of bits in a page
|
||||
/// @tparam MAP_ADDR defines the address of the MK's map region
|
||||
/// @param o the instance of the outputter used to output the value.
|
||||
/// @param rpt the root_page_table_t to output
|
||||
/// @return return o
|
||||
|
|
@ -1941,17 +1718,12 @@ namespace mk
|
|||
typename INTRINSIC_CONCEPT,
|
||||
typename PAGE_POOL_CONCEPT,
|
||||
bsl::uintmax PAGE_SIZE,
|
||||
bsl::uintmax PAGE_SHIFT,
|
||||
bsl::uintmax MAP_ADDR>
|
||||
bsl::uintmax PAGE_SHIFT>
|
||||
[[maybe_unused]] constexpr auto
|
||||
operator<<(
|
||||
bsl::out<T> const o,
|
||||
mk::root_page_table_t<
|
||||
INTRINSIC_CONCEPT,
|
||||
PAGE_POOL_CONCEPT,
|
||||
PAGE_SIZE,
|
||||
PAGE_SHIFT,
|
||||
MAP_ADDR> const &rpt) noexcept -> bsl::out<T>
|
||||
mk::root_page_table_t<INTRINSIC_CONCEPT, PAGE_POOL_CONCEPT, PAGE_SIZE, PAGE_SHIFT> const
|
||||
&rpt) noexcept -> bsl::out<T>
|
||||
{
|
||||
if constexpr (!o) {
|
||||
return o;
|
||||
|
|
|
|||
|
|
@ -38,18 +38,12 @@ namespace mk
|
|||
{
|
||||
namespace details
|
||||
{
|
||||
/// @brief defines the size of the reserved0 field in the tls_t
|
||||
constexpr bsl::safe_uintmax TLS_T_RESERVED0_SIZE{bsl::to_umax(0x078U)};
|
||||
/// @brief defines the size of the reserved1 field in the tls_t
|
||||
constexpr bsl::safe_uintmax TLS_T_RESERVED1_SIZE{bsl::to_umax(0x078U)};
|
||||
constexpr bsl::safe_uintmax TLS_T_RESERVED1_SIZE{bsl::to_umax(0x030)};
|
||||
/// @brief defines the size of the reserved2 field in the tls_t
|
||||
constexpr bsl::safe_uintmax TLS_T_RESERVED2_SIZE{bsl::to_umax(0x530U)};
|
||||
/// @brief defines the size of the reserved3 field in the tls_t
|
||||
constexpr bsl::safe_uintmax TLS_T_RESERVED3_SIZE{bsl::to_umax(0x0A0U)};
|
||||
/// @brief defines the size of the reserved4 field in the tls_t
|
||||
constexpr bsl::safe_uintmax TLS_T_RESERVED4_SIZE{bsl::to_umax(0x098U)};
|
||||
/// @brief defines the size of the reserved5 field in the tls_t
|
||||
constexpr bsl::safe_uintmax TLS_T_RESERVED5_SIZE{bsl::to_umax(0x600U)};
|
||||
constexpr bsl::safe_uintmax TLS_T_RESERVED2_SIZE{bsl::to_umax(0x088)};
|
||||
/// @brief defines the the total size of the TLS block
|
||||
constexpr bsl::safe_uintmax TLS_T_SIZE{bsl::to_umax(0x300)};
|
||||
}
|
||||
|
||||
/// @struct mk::tls_t
|
||||
|
|
@ -66,173 +60,172 @@ namespace mk
|
|||
/// Microkernel State
|
||||
/// --------------------------------------------------------------------
|
||||
|
||||
/// @brief stores the value of rax for the microkernel (0x000)
|
||||
bsl::uintmax mk_rax;
|
||||
/// @brief stores the value of rbx for the microkernel (0x008)
|
||||
/// @brief stores the value of rbx for the microkernel (0x000)
|
||||
bsl::uintmax mk_rbx;
|
||||
/// @brief stores the value of rcx for the microkernel (0x010)
|
||||
bsl::uintmax mk_rcx;
|
||||
/// @brief stores the value of rdx for the microkernel (0x018)
|
||||
bsl::uintmax mk_rdx;
|
||||
/// @brief stores the value of rbp for the microkernel (0x020)
|
||||
/// @brief stores the value of rbp for the microkernel (0x008)
|
||||
bsl::uintmax mk_rbp;
|
||||
/// @brief stores the value of rsi for the microkernel (0x028)
|
||||
bsl::uintmax mk_rsi;
|
||||
/// @brief stores the value of rdi for the microkernel (0x030)
|
||||
bsl::uintmax mk_rdi;
|
||||
/// @brief stores the value of r8 for the microkernel (0x038)
|
||||
bsl::uintmax mk_r8;
|
||||
/// @brief stores the value of r9 for the microkernel (0x040)
|
||||
bsl::uintmax mk_r9;
|
||||
/// @brief stores the value of r10 for the microkernel (0x048)
|
||||
bsl::uintmax mk_r10;
|
||||
/// @brief stores the value of r11 for the microkernel (0x050)
|
||||
bsl::uintmax mk_r11;
|
||||
/// @brief stores the value of r12 for the microkernel (0x058)
|
||||
/// @brief stores the value of r12 for the microkernel (0x010)
|
||||
bsl::uintmax mk_r12;
|
||||
/// @brief stores the value of r13 for the microkernel (0x060)
|
||||
/// @brief stores the value of r13 for the microkernel (0x018)
|
||||
bsl::uintmax mk_r13;
|
||||
/// @brief stores the value of r14 for the microkernel (0x068)
|
||||
/// @brief stores the value of r14 for the microkernel (0x020)
|
||||
bsl::uintmax mk_r14;
|
||||
/// @brief stores the value of r15 for the microkernel (0x070)
|
||||
/// @brief stores the value of r15 for the microkernel (0x028)
|
||||
bsl::uintmax mk_r15;
|
||||
/// @brief stores the value of rip for the microkernel (0x078)
|
||||
bsl::uintmax mk_rip;
|
||||
/// @brief stores the value of rsp for the microkernel (0x080)
|
||||
bsl::uintmax mk_rsp;
|
||||
|
||||
/// @brief reserve the rest of the TLS block for later use.
|
||||
bsl::details::carray<bsl::uint8, details::TLS_T_RESERVED0_SIZE.get()> reserved0;
|
||||
|
||||
/// --------------------------------------------------------------------
|
||||
/// Extension State
|
||||
/// --------------------------------------------------------------------
|
||||
|
||||
/// @brief stores the value of the syscall for the extension (0x100)
|
||||
/// @brief RAX, stores the extension's syscall (0x030)
|
||||
bsl::uintmax ext_syscall;
|
||||
/// @brief reserved (0x108)
|
||||
/// @brief RBX, reserved (0x038)
|
||||
bsl::uintmax reserved_reg1;
|
||||
/// @brief reserved (0x110)
|
||||
/// @brief RCX, reserved (0x040)
|
||||
bsl::uintmax reserved_reg2;
|
||||
/// @brief stores the value of REG2 for the extension (0x118)
|
||||
/// @brief RDX, stores the value of REG2 for the extension (0x048)
|
||||
bsl::uintmax ext_reg2;
|
||||
/// @brief reserved (0x120)
|
||||
/// @brief RBP, reserved (0x050)
|
||||
bsl::uintmax reserved_reg3;
|
||||
/// @brief stores the value of REG1 for the extension (0x128)
|
||||
/// @brief RSI, stores the value of REG1 for the extension (0x058)
|
||||
bsl::uintmax ext_reg1;
|
||||
/// @brief stores the value of REG0 for the extension (0x130)
|
||||
/// @brief RDI, stores the value of REG0 for the extension (0x060)
|
||||
bsl::uintmax ext_reg0;
|
||||
/// @brief stores the value of REG4 for the extension (0x138)
|
||||
/// @brief R8, stores the value of REG4 for the extension (0x068)
|
||||
bsl::uintmax ext_reg4;
|
||||
/// @brief stores the value of REG5 for the extension (0x140)
|
||||
/// @brief R9, stores the value of REG5 for the extension (0x070)
|
||||
bsl::uintmax ext_reg5;
|
||||
/// @brief stores the value of REG3 for the extension (0x148)
|
||||
/// @brief R10, stores the value of REG3 for the extension (0x078)
|
||||
bsl::uintmax ext_reg3;
|
||||
/// @brief reserved (0x150)
|
||||
/// @brief R11, reserved (0x080)
|
||||
bsl::uintmax reserved_reg4;
|
||||
/// @brief reserved (0x158)
|
||||
/// @brief R12, reserved (0x088)
|
||||
bsl::uintmax reserved_reg5;
|
||||
/// @brief reserved (0x160)
|
||||
/// @brief R13, reserved (0x090)
|
||||
bsl::uintmax reserved_reg6;
|
||||
/// @brief reserved (0x168)
|
||||
/// @brief R14, reserved (0x098)
|
||||
bsl::uintmax reserved_reg7;
|
||||
/// @brief reserved (0x170)
|
||||
/// @brief R15, reserved (0x0A0)
|
||||
bsl::uintmax reserved_reg8;
|
||||
/// @brief reserved (0x178)
|
||||
/// @brief RSP, reserved (0x0A8)
|
||||
bsl::uintmax reserved_reg9;
|
||||
/// @brief reserved (0x180)
|
||||
bsl::uintmax reserved_rega;
|
||||
|
||||
/// @brief reserve the rest of the TLS block for later use.
|
||||
bsl::details::carray<bsl::uint8, details::TLS_T_RESERVED1_SIZE.get()> reserved1;
|
||||
|
||||
/// --------------------------------------------------------------------
|
||||
/// ESR State
|
||||
/// --------------------------------------------------------------------
|
||||
|
||||
/// @brief stores the value of rax for the ESR (0x200)
|
||||
/// @brief stores the value of rax for the ESR (0x0B0)
|
||||
bsl::uintmax esr_rax;
|
||||
/// @brief stores the value of rbx for the ESR (0x208)
|
||||
/// @brief stores the value of rbx for the ESR (0x0B8)
|
||||
bsl::uintmax esr_rbx;
|
||||
/// @brief stores the value of rcx for the ESR (0x210)
|
||||
/// @brief stores the value of rcx for the ESR (0x0C0)
|
||||
bsl::uintmax esr_rcx;
|
||||
/// @brief stores the value of rdx for the ESR (0x218)
|
||||
/// @brief stores the value of rdx for the ESR (0x0C8)
|
||||
bsl::uintmax esr_rdx;
|
||||
/// @brief stores the value of rbp for the ESR (0x220)
|
||||
/// @brief stores the value of rbp for the ESR (0x0D0)
|
||||
bsl::uintmax esr_rbp;
|
||||
/// @brief stores the value of rsi for the ESR (0x228)
|
||||
/// @brief stores the value of rsi for the ESR (0x0D8)
|
||||
bsl::uintmax esr_rsi;
|
||||
/// @brief stores the value of rdi for the ESR (0x230)
|
||||
/// @brief stores the value of rdi for the ESR (0x0E0)
|
||||
bsl::uintmax esr_rdi;
|
||||
/// @brief stores the value of r8 for the ESR (0x238)
|
||||
/// @brief stores the value of r8 for the ESR (0x0E8)
|
||||
bsl::uintmax esr_r8;
|
||||
/// @brief stores the value of r9 for the ESR (0x240)
|
||||
/// @brief stores the value of r9 for the ESR (0x0F0)
|
||||
bsl::uintmax esr_r9;
|
||||
/// @brief stores the value of r10 for the ESR (0x248)
|
||||
/// @brief stores the value of r10 for the ESR (0x0F8)
|
||||
bsl::uintmax esr_r10;
|
||||
/// @brief stores the value of r11 for the ESR (0x250)
|
||||
/// @brief stores the value of r11 for the ESR (0x100)
|
||||
bsl::uintmax esr_r11;
|
||||
/// @brief stores the value of r12 for the ESR (0x258)
|
||||
/// @brief stores the value of r12 for the ESR (0x108)
|
||||
bsl::uintmax esr_r12;
|
||||
/// @brief stores the value of r13 for the ESR (0x260)
|
||||
/// @brief stores the value of r13 for the ESR (0x110)
|
||||
bsl::uintmax esr_r13;
|
||||
/// @brief stores the value of r14 for the ESR (0x268)
|
||||
/// @brief stores the value of r14 for the ESR (0x118)
|
||||
bsl::uintmax esr_r14;
|
||||
/// @brief stores the value of r15 for the ESR (0x270)
|
||||
/// @brief stores the value of r15 for the ESR (0x120)
|
||||
bsl::uintmax esr_r15;
|
||||
/// @brief stores the value of rip for the ESR (0x278)
|
||||
/// @brief stores the value of rip for the ESR (0x128)
|
||||
bsl::uintmax esr_rip;
|
||||
/// @brief stores the value of rsp for the ESR (0x280)
|
||||
/// @brief stores the value of rsp for the ESR (0x130)
|
||||
bsl::uintmax esr_rsp;
|
||||
|
||||
/// @brief stores the value of the ESR vector (0x288)
|
||||
/// @brief stores the value of the ESR vector (0x138)
|
||||
bsl::uintmax esr_vector;
|
||||
/// @brief stores the value of the ESR error code (0x290)
|
||||
/// @brief stores the value of the ESR error code (0x140)
|
||||
bsl::uintmax esr_error_code;
|
||||
|
||||
/// @brief stores the value of cr0 for the ESR (0x298)
|
||||
/// @brief stores the value of cr0 for the ESR (0x148)
|
||||
bsl::uintmax esr_cr0;
|
||||
/// @brief stores the value of cr2 for the ESR (0x2A0)
|
||||
/// @brief stores the value of cr2 for the ESR (0x150)
|
||||
bsl::uintmax esr_cr2;
|
||||
/// @brief stores the value of cr3 for the ESR (0x2A8)
|
||||
/// @brief stores the value of cr3 for the ESR (0x158)
|
||||
bsl::uintmax esr_cr3;
|
||||
/// @brief stores the value of cr4 for the ESR (0x2B0)
|
||||
/// @brief stores the value of cr4 for the ESR (0x160)
|
||||
bsl::uintmax esr_cr4;
|
||||
|
||||
/// @brief stores the value of cs for the ESR (0x2B8)
|
||||
/// @brief stores the value of cs for the ESR (0x168)
|
||||
bsl::uintmax esr_cs;
|
||||
/// @brief stores the value of ss for the ESR (0x2C0)
|
||||
/// @brief stores the value of ss for the ESR (0x170)
|
||||
bsl::uintmax esr_ss;
|
||||
|
||||
/// @brief stores the value of ss for the ESR (0x2C8)
|
||||
/// @brief stores the value of ss for the ESR (0x178)
|
||||
bsl::uintmax esr_rflags;
|
||||
|
||||
/// --------------------------------------------------------------------
|
||||
/// Fast Fail Information
|
||||
/// --------------------------------------------------------------------
|
||||
|
||||
/// @brief stores the current fast fail address (0x180).
|
||||
bsl::uintmax current_fast_fail_ip;
|
||||
/// @brief stores the current fast fail stack (0x188).
|
||||
bsl::uintmax current_fast_fail_sp;
|
||||
|
||||
/// @brief stores the mk_main fast fail address (0x190).
|
||||
bsl::uintmax mk_main_fast_fail_ip;
|
||||
/// @brief stores the mk_main fast fail stack (0x198).
|
||||
bsl::uintmax mk_main_fast_fail_sp;
|
||||
|
||||
/// @brief stores the call_ext fast fail address (0x1A0).
|
||||
bsl::uintmax call_ext_fast_fail_ip;
|
||||
/// @brief stores the call_ext fast fail stack (0x1A8).
|
||||
bsl::uintmax call_ext_fast_fail_sp;
|
||||
|
||||
/// @brief stores the dispatch_syscall fast fail address (0x1B0).
|
||||
bsl::uintmax dispatch_syscall_fast_fail_ip;
|
||||
/// @brief stores the dispatch_syscall fast fail stack (0x1B8).
|
||||
bsl::uintmax dispatch_syscall_fast_fail_sp;
|
||||
|
||||
/// @brief stores the vmexit loop address (0x1C0).
|
||||
bsl::uintmax vmexit_loop_ip;
|
||||
/// @brief stores the vmexit loop stack (0x1C8).
|
||||
bsl::uintmax vmexit_loop_sp;
|
||||
|
||||
/// @brief reserve the rest of the TLS block for later use.
|
||||
bsl::details::carray<bsl::uint8, details::TLS_T_RESERVED2_SIZE.get()> reserved2;
|
||||
bsl::details::carray<bsl::uint8, details::TLS_T_RESERVED1_SIZE.get()> reserved1;
|
||||
|
||||
/// --------------------------------------------------------------------
|
||||
/// Context Information
|
||||
/// --------------------------------------------------------------------
|
||||
|
||||
/// @brief stores the virtual address of this TLS block (0x800).
|
||||
/// @brief stores the virtual address of this TLS block (0x200).
|
||||
tls_t *self;
|
||||
|
||||
/// @brief stores the thread ID for this TLS block (0x808).
|
||||
/// @brief stores the thread ID for this TLS block (0x208).
|
||||
bsl::uintmax thread_id;
|
||||
|
||||
/// @brief stores the currently running extension (0x810)
|
||||
/// @brief stores the currently running extension (0x210)
|
||||
void *ext;
|
||||
/// @brief stores the extension registered for VMExits (0x818)
|
||||
/// @brief stores the extension registered for VMExits (0x218)
|
||||
void *ext_vmexit;
|
||||
/// @brief stores the extension registered for fast fail events (0x820)
|
||||
/// @brief stores the extension registered for fast fail events (0x220)
|
||||
void *ext_fail;
|
||||
|
||||
/// @brief stores the loader provided state for the microkernel (0x828)
|
||||
/// @brief stores the loader provided state for the microkernel (0x228)
|
||||
loader::state_save_t *mk_state;
|
||||
/// @brief stores the loader provided state for the root VP (0x830)
|
||||
/// @brief stores the loader provided state for the root VP (0x230)
|
||||
loader::state_save_t *root_vp_state;
|
||||
|
||||
/// @brief stores the ID of the active VPS
|
||||
/// @brief stores the ID of the active VPS (0x238)
|
||||
bsl::uint16 active_vpsid;
|
||||
/// @brief reserved.
|
||||
bsl::uint16 reserved_id1;
|
||||
|
|
@ -241,66 +234,27 @@ namespace mk
|
|||
/// @brief reserved.
|
||||
bsl::uint16 reserved_id3;
|
||||
|
||||
/// @brief stores the sp used by extensions for callbacks (0x840).
|
||||
/// @brief stores the sp used by extensions for callbacks (0x240).
|
||||
bsl::uintmax sp;
|
||||
/// @brief stores the tps used by extensions for callbacks (0x848).
|
||||
/// @brief stores the tps used by extensions for callbacks (0x248).
|
||||
bsl::uintmax tp;
|
||||
|
||||
/// @brief used to store a return address for unsafe ops (0x850).
|
||||
/// @brief used to store a return address for unsafe ops (0x250).
|
||||
bsl::uintmax unsafe_rip;
|
||||
|
||||
/// @brief used to signal NMIs are not safe (0x858).
|
||||
/// @brief used to signal NMIs are not safe (0x258).
|
||||
bsl::uintmax nmi_lock;
|
||||
/// @brief used to singal an NMI has fired (0x860).
|
||||
/// @brief used to singal an NMI has fired (0x260).
|
||||
bsl::uintmax nmi_pending;
|
||||
|
||||
/// @brief on Intel, stores the currently loaded VPS (0x868).
|
||||
/// @brief on Intel, stores the currently loaded VPS (0x268).
|
||||
void *loaded_vps;
|
||||
|
||||
/// @brief stores whether or not the first launch succeeded (0x870).
|
||||
/// @brief stores whether or not the first launch succeeded (0x270).
|
||||
bsl::uintmax first_launch_succeeded;
|
||||
|
||||
/// @brief reserve the rest of the TLS block for later use.
|
||||
bsl::details::carray<bsl::uint8, details::TLS_T_RESERVED3_SIZE.get()> reserved3;
|
||||
|
||||
/// --------------------------------------------------------------------
|
||||
/// Fast Fail Information
|
||||
/// --------------------------------------------------------------------
|
||||
|
||||
/// @brief stores the current fast fail address (0x900).
|
||||
bsl::uintmax current_fast_fail_ip;
|
||||
/// @brief stores the current fast fail stack (0x908).
|
||||
bsl::uintmax current_fast_fail_sp;
|
||||
|
||||
/// @brief stores the mk_main fast fail address (0x910).
|
||||
bsl::uintmax mk_main_fast_fail_ip;
|
||||
/// @brief stores the mk_main fast fail stack (0x918).
|
||||
bsl::uintmax mk_main_fast_fail_sp;
|
||||
|
||||
/// @brief stores the call_ext fast fail address (0x920).
|
||||
bsl::uintmax call_ext_fast_fail_ip;
|
||||
/// @brief stores the call_ext fast fail stack (0x928).
|
||||
bsl::uintmax call_ext_fast_fail_sp;
|
||||
|
||||
/// @brief stores the dispatch_syscall fast fail address (0x930).
|
||||
bsl::uintmax dispatch_syscall_fast_fail_ip;
|
||||
/// @brief stores the dispatch_syscall fast fail stack (0x938).
|
||||
bsl::uintmax dispatch_syscall_fast_fail_sp;
|
||||
|
||||
/// @brief stores the vmexit loop address (0x940).
|
||||
bsl::uintmax vmexit_loop_ip;
|
||||
/// @brief stores the vmexit loop stack (0x948).
|
||||
bsl::uintmax vmexit_loop_sp;
|
||||
|
||||
/// @brief reserve the rest of the TLS block for later use.
|
||||
bsl::details::carray<bsl::uint8, details::TLS_T_RESERVED4_SIZE.get()> reserved4;
|
||||
|
||||
/// --------------------------------------------------------------------
|
||||
/// Reserved
|
||||
/// --------------------------------------------------------------------
|
||||
|
||||
/// @brief reserve the rest of the TLS block for later use.
|
||||
bsl::details::carray<bsl::uint8, details::TLS_T_RESERVED5_SIZE.get()> reserved5;
|
||||
bsl::details::carray<bsl::uint8, details::TLS_T_RESERVED2_SIZE.get()> reserved2;
|
||||
|
||||
/// --------------------------------------------------------------------
|
||||
/// Helpers
|
||||
|
|
@ -428,7 +382,7 @@ namespace mk
|
|||
};
|
||||
|
||||
/// @brief make sure the tls_t is the size of a page
|
||||
static_assert(sizeof(tls_t) == bsl::to_umax(HYPERVISOR_PAGE_SIZE));
|
||||
static_assert(sizeof(tls_t) == details::TLS_T_SIZE);
|
||||
}
|
||||
|
||||
#pragma pack(pop)
|
||||
|
|
|
|||
|
|
@ -32,18 +32,18 @@
|
|||
vmexit_loop_entry:
|
||||
|
||||
lea rax, [rip + loop]
|
||||
mov gs:[0x940], rax
|
||||
mov gs:[0x948], rsp
|
||||
mov gs:[0x1C0], rax
|
||||
mov gs:[0x1C8], rsp
|
||||
|
||||
loop:
|
||||
|
||||
mov rdi, gs:[0x800]
|
||||
mov rdi, gs:[0x200]
|
||||
call vmexit_loop_trampoline
|
||||
|
||||
cmp rax, 0x0
|
||||
je loop
|
||||
|
||||
mov rax, gs:[0x870]
|
||||
mov rax, gs:[0x270]
|
||||
cmp rax, 0x0
|
||||
jne fast_fail_entry
|
||||
|
||||
|
|
|
|||
495
loader/efi/CMakeLists.txt
Normal file
495
loader/efi/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,495 @@
|
|||
#
|
||||
# Copyright (C) 2019 Assured Information Security, Inc.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../../cmake/function/hypervisor_add_header_depends.cmake)
|
||||
|
||||
add_executable(bareflank_efi_loader)
|
||||
|
||||
target_include_directories(bareflank_efi_loader PUBLIC
|
||||
include
|
||||
include/std
|
||||
include/platform_interface/c
|
||||
../include
|
||||
../include/interface/c
|
||||
../include/interface/c/bfelf
|
||||
${CMAKE_BINARY_DIR}/include
|
||||
)
|
||||
|
||||
list(APPEND HEADERS
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/debug.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_allocate_type.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_boot_services.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_configuration_table.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_cpu_physical_location2.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_cpu_physical_location.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_device_path_protocol.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_file_info.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_file_io_token.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_file_protocol.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_guid.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_interface_type.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_locate_search_type.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_memory_descriptor.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_memory_type.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_mp_services_protocol.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_open_protocol_information_entry.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_processor_information.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_runtime_services.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_simple_file_system_protocol.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_simple_text_input_protocol.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_simple_text_output_mode.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_simple_text_output_protocol.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_status.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_system_table.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_table_header.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_time.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_timer_delay.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/efi_types.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/efi/extened_processor_information.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/include/types.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/platform_on_each_cpu_callback_args.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/interface/c/bfelf/bfelf_elf64_ehdr_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/interface/c/bfelf/bfelf_elf64_phdr_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/interface/c/bfelf/bfelf_types.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/interface/c/debug_ring_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/interface/c/dump_vmm_args_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/interface/c/mutable_span_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/interface/c/span_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/interface/c/start_vmm_args_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/interface/c/stop_vmm_args_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/alloc_and_copy_ext_elf_files_from_user.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/alloc_and_copy_mk_elf_file_from_user.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/alloc_and_copy_mk_elf_segments.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/alloc_mk_args.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/alloc_mk_debug_ring.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/alloc_mk_huge_pool.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/alloc_mk_page_pool.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/alloc_mk_stack.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/dump_ext_elf_files.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/dump_mk_args.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/dump_mk_debug_ring.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/dump_mk_elf_file.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/dump_mk_elf_segments.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/dump_mk_huge_pool.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/dump_mk_page_pool.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/dump_mk_stack.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/dump_vmm.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/elf_segment_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/free_ext_elf_files.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/free_mk_args.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/free_mk_debug_ring.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/free_mk_elf_file.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/free_mk_elf_segments.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/free_mk_huge_pool.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/free_mk_page_pool.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/free_mk_stack.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/g_ext_elf_files.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/g_mk_args.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/g_mk_debug_ring.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/g_mk_elf_file.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/g_mk_elf_segments.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/g_mk_huge_pool.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/g_mk_page_pool.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/g_mk_stack.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/itoa.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/loader_fini.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/loader_init.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/platform.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/start_vmm.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/start_vmm_per_cpu.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/static_assert.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/stop_and_free_the_vmm.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/stop_vmm.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/stop_vmm_per_cpu.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/vmm_status.h
|
||||
)
|
||||
|
||||
if(HYPERVISOR_TARGET_ARCH STREQUAL "AuthenticAMD" OR HYPERVISOR_TARGET_ARCH STREQUAL "GenuineIntel")
|
||||
target_include_directories(bareflank_efi_loader PUBLIC
|
||||
include/x64
|
||||
../include/x64/
|
||||
../include/interface/c/x64
|
||||
)
|
||||
list(APPEND HEADERS
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/interface/c/x64/cpuid_commands.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/interface/c/x64/global_descriptor_table_register_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/interface/c/x64/interrupt_descriptor_table_register_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/interface/c/x64/mk_args_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/interface/c/x64/pdpte_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/interface/c/x64/pdte_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/interface/c/x64/pml4te_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/interface/c/x64/pte_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/interface/c/x64/state_save_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/interface/c/x64/tss_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/alloc_and_copy_mk_code_aliases.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/alloc_and_copy_mk_state.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/alloc_and_copy_root_vp_state.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/alloc_mk_root_page_table.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/alloc_pdpt.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/alloc_pdt.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/alloc_pt.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/check_for_hve_support.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/code_aliases_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/demote.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/disable_hve.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/dump_mk_code_aliases.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/dump_mk_root_page_table.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/dump_mk_state.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/dump_root_vp_state.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/enable_hve.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/esr_default.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/esr_df.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/esr_gpf.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/esr_nmi.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/esr_pf.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/free_mk_code_aliases.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/free_mk_root_page_table.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/free_mk_state.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/free_pdpt.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/free_pdt.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/free_pml4t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/free_root_vp_state.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/get_gdt_descriptor_attrib.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/get_gdt_descriptor_base.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/get_gdt_descriptor_limit.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/get_mk_huge_pool_addr.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/get_mk_page_pool_addr.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/g_mk_code_aliases.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/g_mk_root_page_table.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/g_mk_state.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/g_root_vp_state.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/intrinsic_cpuid.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/intrinsic_inb.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/intrinsic_lcr4.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/intrinsic_outb.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/intrinsic_rdmsr.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/intrinsic_scr0.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/intrinsic_scr4.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/intrinsic_scs.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/intrinsic_sds.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/intrinsic_ses.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/intrinsic_sfs.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/intrinsic_sgdt.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/intrinsic_sgs.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/intrinsic_sidt.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/intrinsic_sldtr.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/intrinsic_sss.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/intrinsic_str.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/intrinsic_wrmsr.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/map_4k_page.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/map_4k_page_rw.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/map_4k_page_rx.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/map_ext_elf_files.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/map_mk_args.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/map_mk_code_aliases.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/map_mk_debug_ring.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/map_mk_elf_file.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/map_mk_elf_segments.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/map_mk_huge_pool.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/map_mk_page_pool.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/map_mk_stack.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/map_mk_state.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/map_root_vp_state.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/pdpto.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/pdpt_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/pdto.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/pdt_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/pml4to.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/pml4t_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/promote.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/pto.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/pt_t.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/send_command_report_off.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/send_command_report_on.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/send_command_stop.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/serial_init.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/serial_write.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/set_gdt_descriptor.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/set_idt_descriptor.h
|
||||
)
|
||||
endif()
|
||||
|
||||
if(HYPERVISOR_TARGET_ARCH STREQUAL "AuthenticAMD")
|
||||
target_include_directories(bareflank_efi_loader PUBLIC
|
||||
include/x64/amd
|
||||
../include/x64/amd
|
||||
../include/interface/c/x64/amd
|
||||
)
|
||||
elseif(HYPERVISOR_TARGET_ARCH STREQUAL "GenuineIntel")
|
||||
target_include_directories(bareflank_efi_loader PUBLIC
|
||||
include/x64/intel
|
||||
../include/x64/intel
|
||||
../include/interface/c/x64/intel
|
||||
)
|
||||
list(APPEND HEADERS
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/intel/intrinsic_vmxoff.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include/x64/intel/intrinsic_vmxon.h
|
||||
)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported HYPERVISOR_TARGET_ARCH: ${HYPERVISOR_TARGET_ARCH}")
|
||||
endif()
|
||||
|
||||
target_sources(bareflank_efi_loader PUBLIC
|
||||
src/platform.c
|
||||
src/entry.c
|
||||
../src/alloc_and_copy_ext_elf_files_from_user.c
|
||||
../src/alloc_and_copy_mk_elf_file_from_user.c
|
||||
../src/alloc_and_copy_mk_elf_segments.c
|
||||
../src/alloc_mk_args.c
|
||||
../src/alloc_mk_debug_ring.c
|
||||
../src/alloc_mk_huge_pool.c
|
||||
../src/alloc_mk_page_pool.c
|
||||
../src/alloc_mk_stack.c
|
||||
../src/dump_ext_elf_files.c
|
||||
../src/dump_mk_args.c
|
||||
../src/dump_mk_debug_ring.c
|
||||
../src/dump_mk_elf_file.c
|
||||
../src/dump_mk_elf_segments.c
|
||||
../src/dump_mk_huge_pool.c
|
||||
../src/dump_mk_page_pool.c
|
||||
../src/dump_mk_stack.c
|
||||
../src/dump_vmm.c
|
||||
../src/free_ext_elf_files.c
|
||||
../src/free_mk_args.c
|
||||
../src/free_mk_debug_ring.c
|
||||
../src/free_mk_elf_file.c
|
||||
../src/free_mk_elf_segments.c
|
||||
../src/free_mk_huge_pool.c
|
||||
../src/free_mk_page_pool.c
|
||||
../src/free_mk_stack.c
|
||||
../src/g_ext_elf_files.c
|
||||
../src/g_mk_args.c
|
||||
../src/g_mk_debug_ring.c
|
||||
../src/g_mk_elf_file.c
|
||||
../src/g_mk_elf_segments.c
|
||||
../src/g_mk_huge_pool.c
|
||||
../src/g_mk_page_pool.c
|
||||
../src/g_mk_stack.c
|
||||
../src/loader_fini.c
|
||||
../src/loader_init.c
|
||||
../src/start_vmm_per_cpu.c
|
||||
../src/start_vmm.c
|
||||
../src/stop_and_free_the_vmm.c
|
||||
../src/stop_vmm_per_cpu.c
|
||||
../src/stop_vmm.c
|
||||
../src/vmm_status.c
|
||||
)
|
||||
|
||||
hypervisor_add_header_depends(src/platform.c ${HEADERS})
|
||||
hypervisor_add_header_depends(src/entry.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/alloc_and_copy_ext_elf_files_from_user.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/alloc_and_copy_mk_elf_file_from_user.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/alloc_and_copy_mk_elf_segments.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/alloc_mk_args.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/alloc_mk_debug_ring.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/alloc_mk_huge_pool.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/alloc_mk_page_pool.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/alloc_mk_stack.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/dump_ext_elf_files.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/dump_mk_args.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/dump_mk_debug_ring.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/dump_mk_elf_file.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/dump_mk_elf_segments.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/dump_mk_huge_pool.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/dump_mk_page_pool.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/dump_mk_stack.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/dump_vmm.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/free_ext_elf_files.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/free_mk_args.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/free_mk_debug_ring.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/free_mk_elf_file.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/free_mk_elf_segments.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/free_mk_huge_pool.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/free_mk_page_pool.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/free_mk_stack.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/g_ext_elf_files.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/g_mk_args.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/g_mk_debug_ring.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/g_mk_elf_file.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/g_mk_elf_segments.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/g_mk_huge_pool.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/g_mk_page_pool.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/g_mk_stack.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/loader_fini.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/loader_init.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/start_vmm_per_cpu.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/start_vmm.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/stop_and_free_the_vmm.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/stop_vmm_per_cpu.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/stop_vmm.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/vmm_status.c ${HEADERS})
|
||||
|
||||
if(HYPERVISOR_TARGET_ARCH STREQUAL "AuthenticAMD" OR HYPERVISOR_TARGET_ARCH STREQUAL "GenuineIntel")
|
||||
target_sources(bareflank_efi_loader PUBLIC
|
||||
src/x64/demote.S
|
||||
src/x64/esr_default.S
|
||||
src/x64/esr_df.S
|
||||
src/x64/esr_gpf.S
|
||||
src/x64/esr_nmi.S
|
||||
src/x64/esr_pf.S
|
||||
src/x64/intrinsic_cpuid.S
|
||||
src/x64/intrinsic_inb.S
|
||||
src/x64/intrinsic_lcr4.S
|
||||
src/x64/intrinsic_outb.S
|
||||
src/x64/intrinsic_rdmsr.S
|
||||
src/x64/intrinsic_scr0.S
|
||||
src/x64/intrinsic_scr4.S
|
||||
src/x64/intrinsic_scs.S
|
||||
src/x64/intrinsic_sds.S
|
||||
src/x64/intrinsic_ses.S
|
||||
src/x64/intrinsic_sfs.S
|
||||
src/x64/intrinsic_sgdt.S
|
||||
src/x64/intrinsic_sgs.S
|
||||
src/x64/intrinsic_sidt.S
|
||||
src/x64/intrinsic_sldtr.S
|
||||
src/x64/intrinsic_sss.S
|
||||
src/x64/intrinsic_str.S
|
||||
src/x64/intrinsic_wrmsr.S
|
||||
src/x64/promote.S
|
||||
../src/x64/alloc_and_copy_mk_code_aliases.c
|
||||
../src/x64/alloc_and_copy_mk_state.c
|
||||
../src/x64/alloc_and_copy_root_vp_state.c
|
||||
../src/x64/alloc_mk_root_page_table.c
|
||||
../src/x64/alloc_pdpt.c
|
||||
../src/x64/alloc_pdt.c
|
||||
../src/x64/alloc_pt.c
|
||||
../src/x64/dump_mk_code_aliases.c
|
||||
../src/x64/dump_mk_root_page_table.c
|
||||
../src/x64/dump_mk_state.c
|
||||
../src/x64/dump_root_vp_state.c
|
||||
../src/x64/free_mk_code_aliases.c
|
||||
../src/x64/free_mk_root_page_table.c
|
||||
../src/x64/free_mk_state.c
|
||||
../src/x64/free_pdpt.c
|
||||
../src/x64/free_pdt.c
|
||||
../src/x64/free_pml4t.c
|
||||
../src/x64/free_root_vp_state.c
|
||||
../src/x64/g_mk_code_aliases.c
|
||||
../src/x64/g_mk_root_page_table.c
|
||||
../src/x64/g_mk_state.c
|
||||
../src/x64/g_root_vp_state.c
|
||||
../src/x64/get_gdt_descriptor_attrib.c
|
||||
../src/x64/get_gdt_descriptor_base.c
|
||||
../src/x64/get_gdt_descriptor_limit.c
|
||||
../src/x64/get_mk_huge_pool_addr.c
|
||||
../src/x64/get_mk_page_pool_addr.c
|
||||
../src/x64/map_4k_page_rw.c
|
||||
../src/x64/map_4k_page_rx.c
|
||||
../src/x64/map_4k_page.c
|
||||
../src/x64/map_ext_elf_files.c
|
||||
../src/x64/map_mk_args.c
|
||||
../src/x64/map_mk_debug_ring.c
|
||||
../src/x64/map_mk_code_aliases.c
|
||||
../src/x64/map_mk_elf_file.c
|
||||
../src/x64/map_mk_elf_segments.c
|
||||
../src/x64/map_mk_huge_pool.c
|
||||
../src/x64/map_mk_page_pool.c
|
||||
../src/x64/map_mk_stack.c
|
||||
../src/x64/map_mk_state.c
|
||||
../src/x64/map_root_vp_state.c
|
||||
../src/x64/send_command_report_off.c
|
||||
../src/x64/send_command_report_on.c
|
||||
../src/x64/send_command_stop.c
|
||||
../src/x64/serial_init.c
|
||||
../src/x64/serial_write.c
|
||||
../src/x64/set_gdt_descriptor.c
|
||||
../src/x64/set_idt_descriptor.c
|
||||
)
|
||||
|
||||
hypervisor_add_header_depends(../src/x64/alloc_and_copy_mk_code_aliases.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/alloc_and_copy_mk_state.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/alloc_and_copy_root_vp_state.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/alloc_mk_root_page_table.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/alloc_pdpt.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/alloc_pdt.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/alloc_pt.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/dump_mk_code_aliases.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/dump_mk_root_page_table.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/dump_mk_state.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/dump_root_vp_state.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/free_mk_code_aliases.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/free_mk_root_page_table.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/free_mk_state.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/free_pdpt.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/free_pdt.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/free_pml4t.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/free_root_vp_state.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/g_mk_code_aliases.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/g_mk_root_page_table.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/g_mk_state.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/g_root_vp_state.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/get_gdt_descriptor_attrib.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/get_gdt_descriptor_base.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/get_gdt_descriptor_limit.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/get_mk_huge_pool_addr.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/get_mk_page_pool_addr.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/map_4k_page_rw.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/map_4k_page_rx.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/map_4k_page.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/map_ext_elf_files.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/map_mk_args.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/map_mk_debug_ring.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/map_mk_code_aliases.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/map_mk_elf_file.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/map_mk_elf_segments.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/map_mk_huge_pool.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/map_mk_page_pool.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/map_mk_stack.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/map_mk_state.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/map_root_vp_state.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/send_command_report_off.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/send_command_report_on.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/send_command_stop.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/serial_init.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/serial_write.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/set_gdt_descriptor.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/set_idt_descriptor.c ${HEADERS})
|
||||
endif()
|
||||
|
||||
if(HYPERVISOR_TARGET_ARCH STREQUAL "AuthenticAMD")
|
||||
target_sources(bareflank_efi_loader PUBLIC
|
||||
src/x64/amd/disable_interrupts.S
|
||||
src/x64/amd/enable_interrupts.S
|
||||
../src/x64/amd/enable_hve.c
|
||||
../src/x64/amd/disable_hve.c
|
||||
../src/x64/amd/check_for_hve_support.c
|
||||
)
|
||||
hypervisor_add_header_depends(../src/x64/amd/enable_hve.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/amd/disable_hve.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/amd/check_for_hve_support.c ${HEADERS})
|
||||
elseif(HYPERVISOR_TARGET_ARCH STREQUAL "GenuineIntel")
|
||||
target_sources(bareflank_efi_loader PUBLIC
|
||||
src/x64/intel/disable_interrupts.S
|
||||
src/x64/intel/enable_interrupts.S
|
||||
src/x64/intel/intrinsic_vmxoff.S
|
||||
src/x64/intel/intrinsic_vmxon.S
|
||||
../src/x64/intel/enable_hve.c
|
||||
../src/x64/intel/disable_hve.c
|
||||
../src/x64/intel/check_for_hve_support.c
|
||||
)
|
||||
hypervisor_add_header_depends(../src/x64/intel/enable_hve.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/intel/disable_hve.c ${HEADERS})
|
||||
hypervisor_add_header_depends(../src/x64/intel/check_for_hve_support.c ${HEADERS})
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported HYPERVISOR_TARGET_ARCH: ${HYPERVISOR_TARGET_ARCH}")
|
||||
endif()
|
||||
|
||||
install(TARGETS bareflank_efi_loader DESTINATION bin)
|
||||
600
loader/efi/include/debug.h
Normal file
600
loader/efi/include/debug.h
Normal file
|
|
@ -0,0 +1,600 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef DEBUG_H
|
||||
#define DEBUG_H
|
||||
|
||||
#include <efi/efi_system_table.h>
|
||||
#include <efi/efi_types.h>
|
||||
#include <itoa.h>
|
||||
#include <serial_write.h>
|
||||
#include <types.h>
|
||||
|
||||
/** @brief defines a constant for base 10 */
|
||||
#define BASE10 ((uint64_t)10)
|
||||
/** @brief defines a constant for base 16 */
|
||||
#define BASE16 ((uint64_t)16)
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Writes a string to the console.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to write to the console.
|
||||
*/
|
||||
static inline void
|
||||
console_write(char const *const str)
|
||||
{
|
||||
uint64_t i = 0;
|
||||
char buf[4] = {0};
|
||||
|
||||
/**
|
||||
* NOTE:
|
||||
* - We cannot simply send the string to OutputString as it is expecting
|
||||
* a unicode string.
|
||||
* - The minimum sized unicode string is one character (2 bytes) and a
|
||||
* second character for the \0, which is why we have a 4 byte array.
|
||||
* One byte to store the character we wish to print, and a second to
|
||||
* tell OutputString to stop.
|
||||
* - This, of course would not be needed if EFI has a character output
|
||||
* function, which is basically what this function needs to emulate.
|
||||
*/
|
||||
|
||||
while (str[i] != '\0') {
|
||||
buf[0] = str[i];
|
||||
if (g_st->ConOut->OutputString(g_st->ConOut, ((CHAR16 *)buf))) {
|
||||
return;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Outputs a string to the console
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to output
|
||||
*/
|
||||
static inline void
|
||||
bfdebug(char const *const str)
|
||||
{
|
||||
serial_write("[BAREFLANK DEBUG] ");
|
||||
serial_write(str);
|
||||
serial_write("\n");
|
||||
|
||||
console_write("[BAREFLANK DEBUG] ");
|
||||
console_write(str);
|
||||
console_write("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Outputs a string and an 8bit hex to the console
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to output
|
||||
* @param val the 8bit hex value to output
|
||||
*/
|
||||
static inline void
|
||||
bfdebug_x8(char const *const str, uint8_t const val)
|
||||
{
|
||||
char num[65] = {0};
|
||||
bfitoa(((uint64_t)val), num, BASE16);
|
||||
|
||||
serial_write("[BAREFLANK DEBUG] ");
|
||||
serial_write(str);
|
||||
serial_write(": 0x");
|
||||
serial_write(num);
|
||||
serial_write("\n");
|
||||
|
||||
console_write("[BAREFLANK DEBUG] ");
|
||||
console_write(str);
|
||||
console_write(": 0x");
|
||||
console_write(num);
|
||||
console_write("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Outputs a string and an 16bit hex to the console
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to output
|
||||
* @param val the 16bit hex value to output
|
||||
*/
|
||||
static inline void
|
||||
bfdebug_x16(char const *const str, uint16_t const val)
|
||||
{
|
||||
char num[65] = {0};
|
||||
bfitoa(((uint64_t)val), num, BASE16);
|
||||
|
||||
serial_write("[BAREFLANK DEBUG] ");
|
||||
serial_write(str);
|
||||
serial_write(": 0x");
|
||||
serial_write(num);
|
||||
serial_write("\n");
|
||||
|
||||
console_write("[BAREFLANK DEBUG] ");
|
||||
console_write(str);
|
||||
console_write(": 0x");
|
||||
console_write(num);
|
||||
console_write("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Outputs a string and an 32bit hex to the console
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to output
|
||||
* @param val the 32bit hex value to output
|
||||
*/
|
||||
static inline void
|
||||
bfdebug_x32(char const *const str, uint32_t const val)
|
||||
{
|
||||
char num[65] = {0};
|
||||
bfitoa(((uint64_t)val), num, BASE16);
|
||||
|
||||
serial_write("[BAREFLANK DEBUG] ");
|
||||
serial_write(str);
|
||||
serial_write(": 0x");
|
||||
serial_write(num);
|
||||
serial_write("\n");
|
||||
|
||||
console_write("[BAREFLANK DEBUG] ");
|
||||
console_write(str);
|
||||
console_write(": 0x");
|
||||
console_write(num);
|
||||
console_write("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Outputs a string and an 64bit hex to the console
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to output
|
||||
* @param val the 64bit hex value to output
|
||||
*/
|
||||
static inline void
|
||||
bfdebug_x64(char const *const str, uint64_t const val)
|
||||
{
|
||||
char num[65] = {0};
|
||||
bfitoa(((uint64_t)val), num, BASE16);
|
||||
|
||||
serial_write("[BAREFLANK DEBUG] ");
|
||||
serial_write(str);
|
||||
serial_write(": 0x");
|
||||
serial_write(num);
|
||||
serial_write("\n");
|
||||
|
||||
console_write("[BAREFLANK DEBUG] ");
|
||||
console_write(str);
|
||||
console_write(": 0x");
|
||||
console_write(num);
|
||||
console_write("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Outputs a string and an 8bit dec to the console
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to output
|
||||
* @param val the 8bit dec value to output
|
||||
*/
|
||||
static inline void
|
||||
bfdebug_d8(char const *const str, uint8_t const val)
|
||||
{
|
||||
char num[65] = {0};
|
||||
bfitoa(((uint64_t)val), num, BASE10);
|
||||
|
||||
serial_write("[BAREFLANK DEBUG] ");
|
||||
serial_write(str);
|
||||
serial_write(": ");
|
||||
serial_write(num);
|
||||
serial_write("\n");
|
||||
|
||||
console_write("[BAREFLANK DEBUG] ");
|
||||
console_write(str);
|
||||
console_write(": ");
|
||||
console_write(num);
|
||||
console_write("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Outputs a string and an 16bit dec to the console
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to output
|
||||
* @param val the 16bit dec value to output
|
||||
*/
|
||||
static inline void
|
||||
bfdebug_d16(char const *const str, uint16_t const val)
|
||||
{
|
||||
char num[65] = {0};
|
||||
bfitoa(((uint64_t)val), num, BASE10);
|
||||
|
||||
serial_write("[BAREFLANK DEBUG] ");
|
||||
serial_write(str);
|
||||
serial_write(": ");
|
||||
serial_write(num);
|
||||
serial_write("\n");
|
||||
|
||||
console_write("[BAREFLANK DEBUG] ");
|
||||
console_write(str);
|
||||
console_write(": ");
|
||||
console_write(num);
|
||||
console_write("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Outputs a string and an 32bit dec to the console
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to output
|
||||
* @param val the 32bit dec value to output
|
||||
*/
|
||||
static inline void
|
||||
bfdebug_d32(char const *const str, uint32_t const val)
|
||||
{
|
||||
char num[65] = {0};
|
||||
bfitoa(((uint64_t)val), num, BASE10);
|
||||
|
||||
serial_write("[BAREFLANK DEBUG] ");
|
||||
serial_write(str);
|
||||
serial_write(": ");
|
||||
serial_write(num);
|
||||
serial_write("\n");
|
||||
|
||||
console_write("[BAREFLANK DEBUG] ");
|
||||
console_write(str);
|
||||
console_write(": ");
|
||||
console_write(num);
|
||||
console_write("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Outputs a string and an 64bit dec to the console
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to output
|
||||
* @param val the 64bit dec value to output
|
||||
*/
|
||||
static inline void
|
||||
bfdebug_d64(char const *const str, uint64_t const val)
|
||||
{
|
||||
char num[65] = {0};
|
||||
bfitoa(((uint64_t)val), num, BASE10);
|
||||
|
||||
serial_write("[BAREFLANK DEBUG] ");
|
||||
serial_write(str);
|
||||
serial_write(": ");
|
||||
serial_write(num);
|
||||
serial_write("\n");
|
||||
|
||||
console_write("[BAREFLANK DEBUG] ");
|
||||
console_write(str);
|
||||
console_write(": ");
|
||||
console_write(num);
|
||||
console_write("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Outputs a string and an pointer to the console
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to output
|
||||
* @param p the pointer to output
|
||||
*/
|
||||
static inline void
|
||||
bfdebug_ptr(char const *const str, void const *const p)
|
||||
{
|
||||
char num[65] = {0};
|
||||
bfitoa(((uint64_t)p), num, BASE16);
|
||||
|
||||
serial_write("[BAREFLANK DEBUG] ");
|
||||
serial_write(str);
|
||||
serial_write(": 0x");
|
||||
serial_write(num);
|
||||
serial_write("\n");
|
||||
|
||||
console_write("[BAREFLANK DEBUG] ");
|
||||
console_write(str);
|
||||
console_write(": 0x");
|
||||
console_write(num);
|
||||
console_write("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Outputs a string to the console
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to output
|
||||
*/
|
||||
static inline void
|
||||
bferror(char const *const str)
|
||||
{
|
||||
serial_write("[BAREFLANK ERROR] ");
|
||||
serial_write(str);
|
||||
serial_write("\n");
|
||||
|
||||
console_write("[BAREFLANK ERROR] ");
|
||||
console_write(str);
|
||||
console_write("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Outputs a string and an 8bit hex to the console
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to output
|
||||
* @param val the 8bit hex value to output
|
||||
*/
|
||||
static inline void
|
||||
bferror_x8(char const *const str, uint8_t const val)
|
||||
{
|
||||
char num[65] = {0};
|
||||
bfitoa(((uint64_t)val), num, BASE16);
|
||||
|
||||
serial_write("[BAREFLANK ERROR] ");
|
||||
serial_write(str);
|
||||
serial_write(": 0x");
|
||||
serial_write(num);
|
||||
serial_write("\n");
|
||||
|
||||
console_write("[BAREFLANK ERROR] ");
|
||||
console_write(str);
|
||||
console_write(": 0x");
|
||||
console_write(num);
|
||||
console_write("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Outputs a string and an 16bit hex to the console
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to output
|
||||
* @param val the 16bit hex value to output
|
||||
*/
|
||||
static inline void
|
||||
bferror_x16(char const *const str, uint16_t const val)
|
||||
{
|
||||
char num[65] = {0};
|
||||
bfitoa(((uint64_t)val), num, BASE16);
|
||||
|
||||
serial_write("[BAREFLANK ERROR] ");
|
||||
serial_write(str);
|
||||
serial_write(": 0x");
|
||||
serial_write(num);
|
||||
serial_write("\n");
|
||||
|
||||
console_write("[BAREFLANK ERROR] ");
|
||||
console_write(str);
|
||||
console_write(": 0x");
|
||||
console_write(num);
|
||||
console_write("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Outputs a string and an 32bit hex to the console
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to output
|
||||
* @param val the 32bit hex value to output
|
||||
*/
|
||||
static inline void
|
||||
bferror_x32(char const *const str, uint32_t const val)
|
||||
{
|
||||
char num[65] = {0};
|
||||
bfitoa(((uint64_t)val), num, BASE16);
|
||||
|
||||
serial_write("[BAREFLANK ERROR] ");
|
||||
serial_write(str);
|
||||
serial_write(": 0x");
|
||||
serial_write(num);
|
||||
serial_write("\n");
|
||||
|
||||
console_write("[BAREFLANK ERROR] ");
|
||||
console_write(str);
|
||||
console_write(": 0x");
|
||||
console_write(num);
|
||||
console_write("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Outputs a string and an 64bit hex to the console
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to output
|
||||
* @param val the 64bit hex value to output
|
||||
*/
|
||||
static inline void
|
||||
bferror_x64(char const *const str, uint64_t const val)
|
||||
{
|
||||
char num[65] = {0};
|
||||
bfitoa(((uint64_t)val), num, BASE16);
|
||||
|
||||
serial_write("[BAREFLANK ERROR] ");
|
||||
serial_write(str);
|
||||
serial_write(": 0x");
|
||||
serial_write(num);
|
||||
serial_write("\n");
|
||||
|
||||
console_write("[BAREFLANK ERROR] ");
|
||||
console_write(str);
|
||||
console_write(": 0x");
|
||||
console_write(num);
|
||||
console_write("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Outputs a string and an 8bit dec to the console
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to output
|
||||
* @param val the 8bit dec value to output
|
||||
*/
|
||||
static inline void
|
||||
bferror_d8(char const *const str, uint8_t const val)
|
||||
{
|
||||
char num[65] = {0};
|
||||
bfitoa(((uint64_t)val), num, BASE10);
|
||||
|
||||
serial_write("[BAREFLANK ERROR] ");
|
||||
serial_write(str);
|
||||
serial_write(": ");
|
||||
serial_write(num);
|
||||
serial_write("\n");
|
||||
|
||||
console_write("[BAREFLANK ERROR] ");
|
||||
console_write(str);
|
||||
console_write(": ");
|
||||
console_write(num);
|
||||
console_write("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Outputs a string and an 16bit dec to the console
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to output
|
||||
* @param val the 16bit dec value to output
|
||||
*/
|
||||
static inline void
|
||||
bferror_d16(char const *const str, uint16_t const val)
|
||||
{
|
||||
char num[65] = {0};
|
||||
bfitoa(((uint64_t)val), num, BASE10);
|
||||
|
||||
serial_write("[BAREFLANK ERROR] ");
|
||||
serial_write(str);
|
||||
serial_write(": ");
|
||||
serial_write(num);
|
||||
serial_write("\n");
|
||||
|
||||
console_write("[BAREFLANK ERROR] ");
|
||||
console_write(str);
|
||||
console_write(": ");
|
||||
console_write(num);
|
||||
console_write("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Outputs a string and an 32bit dec to the console
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to output
|
||||
* @param val the 32bit dec value to output
|
||||
*/
|
||||
static inline void
|
||||
bferror_d32(char const *const str, uint32_t const val)
|
||||
{
|
||||
char num[65] = {0};
|
||||
bfitoa(((uint64_t)val), num, BASE10);
|
||||
|
||||
serial_write("[BAREFLANK ERROR] ");
|
||||
serial_write(str);
|
||||
serial_write(": ");
|
||||
serial_write(num);
|
||||
serial_write("\n");
|
||||
|
||||
console_write("[BAREFLANK ERROR] ");
|
||||
console_write(str);
|
||||
console_write(": ");
|
||||
console_write(num);
|
||||
console_write("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Outputs a string and an 64bit dec to the console
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to output
|
||||
* @param val the 64bit dec value to output
|
||||
*/
|
||||
static inline void
|
||||
bferror_d64(char const *const str, uint64_t const val)
|
||||
{
|
||||
char num[65] = {0};
|
||||
bfitoa(((uint64_t)val), num, BASE10);
|
||||
|
||||
serial_write("[BAREFLANK ERROR] ");
|
||||
serial_write(str);
|
||||
serial_write(": ");
|
||||
serial_write(num);
|
||||
serial_write("\n");
|
||||
|
||||
console_write("[BAREFLANK ERROR] ");
|
||||
console_write(str);
|
||||
console_write(": ");
|
||||
console_write(num);
|
||||
console_write("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Outputs a string and an pointer to the console
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param str the string to output
|
||||
* @param p the pointer value to output
|
||||
*/
|
||||
static inline void
|
||||
bferror_ptr(char const *const str, void const *const p)
|
||||
{
|
||||
char num[65] = {0};
|
||||
bfitoa(((uint64_t)p), num, BASE16);
|
||||
|
||||
serial_write("[BAREFLANK ERROR] ");
|
||||
serial_write(str);
|
||||
serial_write(": 0x");
|
||||
serial_write(num);
|
||||
serial_write("\n");
|
||||
|
||||
console_write("[BAREFLANK ERROR] ");
|
||||
console_write(str);
|
||||
console_write(": 0x");
|
||||
console_write(num);
|
||||
console_write("\r\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
66
loader/efi/include/efi/efi_allocate_type.h
Normal file
66
loader/efi/include/efi/efi_allocate_type.h
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_ALLOCATE_TYPE_H
|
||||
#define EFI_ALLOCATE_TYPE_H
|
||||
|
||||
/**
|
||||
* @struct EFI_ALLOCATE_TYPE
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_ALLOCATE_TYPE struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/**
|
||||
* @brief Allocation requests of Type AllocateAnyPages allocate any
|
||||
* available range of pages that satisfies the request. On input, the
|
||||
* address pointed to by Memory is ignored.
|
||||
*/
|
||||
AllocateAnyPages,
|
||||
|
||||
/**
|
||||
* @brief Allocation requests of Type AllocateMaxAddress allocate any
|
||||
* available range of pages whose uppermost address is less than or equal
|
||||
* to the address pointed to by Memory on input.
|
||||
*/
|
||||
AllocateMaxAddress,
|
||||
|
||||
/**
|
||||
* @brief Allocation requests of Type AllocateAddress allocate pages at
|
||||
* the address pointed to by Memory on input.
|
||||
*/
|
||||
AllocateAddress,
|
||||
|
||||
/**
|
||||
* @brief The end of the enum
|
||||
*/
|
||||
MaxAllocateType
|
||||
|
||||
} EFI_ALLOCATE_TYPE;
|
||||
|
||||
#endif
|
||||
1243
loader/efi/include/efi/efi_boot_services.h
Normal file
1243
loader/efi/include/efi/efi_boot_services.h
Normal file
File diff suppressed because it is too large
Load diff
41
loader/efi/include/efi/efi_configuration_table.h
Normal file
41
loader/efi/include/efi/efi_configuration_table.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_CONFIGURATION_TABLE_H
|
||||
#define EFI_CONFIGURATION_TABLE_H
|
||||
|
||||
/**
|
||||
* @struct EFI_CONFIGURATION_TABLE
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_CONFIGURATION_TABLE struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
} EFI_CONFIGURATION_TABLE;
|
||||
|
||||
#endif
|
||||
57
loader/efi/include/efi/efi_cpu_physical_location.h
Normal file
57
loader/efi/include/efi/efi_cpu_physical_location.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_CPU_PHYSICAL_LOCATION_H
|
||||
#define EFI_CPU_PHYSICAL_LOCATION_H
|
||||
|
||||
/**
|
||||
* @struct EFI_CPU_PHYSICAL_LOCATION
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_CPU_PHYSICAL_LOCATION struct:
|
||||
* https://uefi.org/sites/default/files/resources/PI_Spec_1_7_A_final_May1.pdf
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/**
|
||||
* @brief Zero-based physical package number that identifies the cartridge
|
||||
* of the processor.
|
||||
*/
|
||||
UINT32 Package;
|
||||
|
||||
/**
|
||||
* @brief Zero-based physical core number within package of the processor.
|
||||
*/
|
||||
UINT32 Core;
|
||||
|
||||
/**
|
||||
* @brief Zero-based logical thread number within core of the processor.
|
||||
*/
|
||||
UINT32 Thread;
|
||||
|
||||
} EFI_CPU_PHYSICAL_LOCATION;
|
||||
|
||||
#endif
|
||||
72
loader/efi/include/efi/efi_cpu_physical_location2.h
Normal file
72
loader/efi/include/efi/efi_cpu_physical_location2.h
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_CPU_PHYSICAL_LOCATION2_H
|
||||
#define EFI_CPU_PHYSICAL_LOCATION2_H
|
||||
|
||||
/**
|
||||
* @struct EFI_CPU_PHYSICAL_LOCATION2
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_CPU_PHYSICAL_LOCATION2 struct:
|
||||
* https://uefi.org/sites/default/files/resources/PI_Spec_1_7_A_final_May1.pdf
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/**
|
||||
* @brief Zero-based physical package number that identifies the cartridge
|
||||
* of the processor.
|
||||
*/
|
||||
UINT32 Package;
|
||||
|
||||
/**
|
||||
* @brief Zero-based physical module number within package of the processor.
|
||||
*/
|
||||
UINT32 Module;
|
||||
|
||||
/**
|
||||
* @brief Zero-based physical tile number within module of the processor.
|
||||
*/
|
||||
UINT32 Tile;
|
||||
|
||||
/**
|
||||
* @brief Zero-based physical die number within tile of the processor.
|
||||
*/
|
||||
UINT32 Die;
|
||||
|
||||
/**
|
||||
* @brief Zero-based physical core number within die of the processor.
|
||||
*/
|
||||
UINT32 Core;
|
||||
|
||||
/**
|
||||
* @brief Zero-based logical thread number within core of the processor.
|
||||
*/
|
||||
UINT32 Thread;
|
||||
|
||||
} EFI_CPU_PHYSICAL_LOCATION2;
|
||||
|
||||
#endif
|
||||
61
loader/efi/include/efi/efi_device_path_protocol.h
Normal file
61
loader/efi/include/efi/efi_device_path_protocol.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_DEVICE_PATH_PROTOCOL_H
|
||||
#define EFI_DEVICE_PATH_PROTOCOL_H
|
||||
|
||||
#include "efi_types.h"
|
||||
|
||||
/** @brief Defined in EFI_DEVICE_PATH_PROTOCOL */
|
||||
#define EFI_DEVICE_PATH_PROTOCOL_LENGTH_SIZE 2
|
||||
|
||||
/**
|
||||
* @struct EFI_DEVICE_PATH_PROTOCOL
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_DEVICE_PATH_PROTOCOL struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef struct _EFI_DEVICE_PATH_PROTOCOL
|
||||
{
|
||||
/**
|
||||
* @brief Defined in EFI_DEVICE_PATH_PROTOCOL
|
||||
*/
|
||||
UINT8 Type;
|
||||
|
||||
/**
|
||||
* @brief Defined in EFI_DEVICE_PATH_PROTOCOL
|
||||
*/
|
||||
UINT8 SubType;
|
||||
|
||||
/**
|
||||
* @brief Defined in EFI_DEVICE_PATH_PROTOCOL
|
||||
*/
|
||||
UINT8 Length[EFI_DEVICE_PATH_PROTOCOL_LENGTH_SIZE];
|
||||
|
||||
} EFI_DEVICE_PATH_PROTOCOL;
|
||||
|
||||
#endif
|
||||
96
loader/efi/include/efi/efi_file_info.h
Normal file
96
loader/efi/include/efi/efi_file_info.h
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_FILE_INFO_H
|
||||
#define EFI_FILE_INFO_H
|
||||
|
||||
#include "efi_time.h"
|
||||
#include "efi_types.h"
|
||||
|
||||
/** @brief defines the GUID for EFI_FILE_INFO */
|
||||
#define EFI_FILE_INFO_ID \
|
||||
{ \
|
||||
0x09576e92, 0x6d3f, 0x11d2, \
|
||||
{ \
|
||||
0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* @struct EFI_FILE_INFO
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_FILE_INFO struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/**
|
||||
* @brief Size of the EFI_FILE_INFO structure, including the
|
||||
* Null-terminated FileName string.
|
||||
*/
|
||||
UINT64 Size;
|
||||
|
||||
/**
|
||||
* @brief The size of the file in bytes.
|
||||
*/
|
||||
UINT64 FileSize;
|
||||
|
||||
/**
|
||||
* @brief The amount of physical space the file consumes on the file
|
||||
* system volume.
|
||||
*/
|
||||
UINT64 PhysicalSize;
|
||||
|
||||
/**
|
||||
* @brief The time the file was created.
|
||||
*/
|
||||
EFI_TIME CreateTime;
|
||||
|
||||
/**
|
||||
* @brief The time when the file was last accessed.
|
||||
*/
|
||||
EFI_TIME LastAccessTime;
|
||||
|
||||
/**
|
||||
* @brief The time when the file’s contents were last modified.
|
||||
*/
|
||||
EFI_TIME ModificationTime;
|
||||
|
||||
/**
|
||||
* @brief The attribute bits for the file.
|
||||
*/
|
||||
UINT64 Attribute;
|
||||
|
||||
/**
|
||||
* @brief The Null-terminated name of the file. For a root directory, the
|
||||
* name is an empty string.
|
||||
*/
|
||||
CHAR16 FileName[];
|
||||
|
||||
} EFI_FILE_INFO;
|
||||
|
||||
#endif
|
||||
81
loader/efi/include/efi/efi_file_io_token.h
Normal file
81
loader/efi/include/efi/efi_file_io_token.h
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_FILE_IO_TOKEN_H
|
||||
#define EFI_FILE_IO_TOKEN_H
|
||||
|
||||
/**
|
||||
* @struct EFI_FILE_IO_TOKEN
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_FILE_IO_TOKEN struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/**
|
||||
* @brief If Event is NULL, then blocking I/O is performed. If Event is not
|
||||
* NULL and non-blocking I/O is supported, then non-blocking I/O is
|
||||
* performed, and Event will be signaled when the read request is
|
||||
* completed. The caller must be prepared to handle the case where the
|
||||
* callback associated with Event occurs before the original asynchronous
|
||||
* I/O request call returns.
|
||||
*/
|
||||
EFI_EVENT Event;
|
||||
|
||||
/**
|
||||
* @brief Defines whether or not the signaled event encountered an error.
|
||||
*/
|
||||
EFI_STATUS Status;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* For OpenEx(): Not Used, ignored
|
||||
*
|
||||
* For ReadEx():On input, the size of the Buffer. On output, the
|
||||
* amount of data returned in Buffer. In both cases, the size is measured
|
||||
* in bytes.
|
||||
*
|
||||
* For WriteEx(): On input, the size of the Buffer. On output, the
|
||||
* amount of data actually written. In both cases, the size is measured
|
||||
* in bytes.
|
||||
*
|
||||
* For FlushEx(): Not used, ignored
|
||||
*/
|
||||
UINTN BufferSize;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* For OpenEx(): Not Used, ignored
|
||||
* For ReadEx(): The buffer into which the data is read
|
||||
* For WriteEx(): The buffer of data to write.
|
||||
* For FlushEx(): Not Used, ignored
|
||||
*/
|
||||
VOID *Buffer;
|
||||
|
||||
} EFI_FILE_IO_TOKEN;
|
||||
|
||||
#endif
|
||||
399
loader/efi/include/efi/efi_file_protocol.h
Normal file
399
loader/efi/include/efi/efi_file_protocol.h
Normal file
|
|
@ -0,0 +1,399 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_FILE_PROTOCOL_H
|
||||
#define EFI_FILE_PROTOCOL_H
|
||||
|
||||
#include "efi_file_info.h"
|
||||
#include "efi_file_io_token.h"
|
||||
#include "efi_guid.h"
|
||||
#include "efi_status.h"
|
||||
#include "efi_types.h"
|
||||
|
||||
/** @brief defines the Revision Number 1 for EFI_FILE_PROTOCOL */
|
||||
#define EFI_FILE_PROTOCOL_REVISION 0x00010000
|
||||
/** @brief defines the Revision Number 2 for EFI_FILE_PROTOCOL */
|
||||
#define EFI_FILE_PROTOCOL_REVISION2 0x00020000
|
||||
/** @brief defines the lastest Revision Number for EFI_FILE_PROTOCOL */
|
||||
#define EFI_FILE_PROTOCOL_LATEST_REVISION EFI_FILE_PROTOCOL_REVISION2
|
||||
|
||||
/** @brief prototype for _EFI_FILE_PROTOCOL */
|
||||
struct _EFI_FILE_PROTOCOL;
|
||||
|
||||
/** @brief prototype for EFI_FILE_PROTOCOL */
|
||||
typedef struct _EFI_FILE_PROTOCOL EFI_FILE_PROTOCOL;
|
||||
|
||||
/** @brief Defined in EFI_FILE_PROTOCOL.Open() */
|
||||
#define EFI_FILE_MODE_READ 0x0000000000000001
|
||||
/** @brief Defined in EFI_FILE_PROTOCOL.Open() */
|
||||
#define EFI_FILE_MODE_WRITE 0x0000000000000002
|
||||
/** @brief Defined in EFI_FILE_PROTOCOL.Open() */
|
||||
#define EFI_FILE_MODE_CREATE 0x8000000000000000
|
||||
|
||||
/** @brief Defined in EFI_FILE_PROTOCOL.Open() */
|
||||
#define EFI_FILE_READ_ONLY 0x0000000000000001
|
||||
/** @brief Defined in EFI_FILE_PROTOCOL.Open() */
|
||||
#define EFI_FILE_HIDDEN 0x0000000000000002
|
||||
/** @brief Defined in EFI_FILE_PROTOCOL.Open() */
|
||||
#define EFI_FILE_SYSTEM 0x0000000000000004
|
||||
/** @brief Defined in EFI_FILE_PROTOCOL.Open() */
|
||||
#define EFI_FILE_RESERVED 0x0000000000000008
|
||||
/** @brief Defined in EFI_FILE_PROTOCOL.Open() */
|
||||
#define EFI_FILE_DIRECTORY 0x0000000000000010
|
||||
/** @brief Defined in EFI_FILE_PROTOCOL.Open() */
|
||||
#define EFI_FILE_ARCHIVE 0x0000000000000020
|
||||
/** @brief Defined in EFI_FILE_PROTOCOL.Open() */
|
||||
#define EFI_FILE_VALID_ATTR 0x0000000000000037
|
||||
|
||||
/** @brief Defines the attributes for all non-create modes */
|
||||
#define EFI_FILE_NONE 0x0000000000000000
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Opens a new file relative to the source file’s location.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
* handle to the source location. This would typically be an open handle
|
||||
* to a directory. See the type EFI_FILE_PROTOCOL description.
|
||||
* @param NewHandle A pointer to the location to return the opened handle
|
||||
* for the new file. See the type EFI_FILE_PROTOCOL description.
|
||||
* @param FileName The Null-terminated string of the name of the file to be
|
||||
* opened. The file name may contain the following path modifiers: “\”,
|
||||
* “.”, and “..”.
|
||||
* @param OpenMode The mode to open the file. The only valid combinations
|
||||
* that the file may be opened with are: Read, Read/Write, or
|
||||
* Create/Read/Write.
|
||||
* @param Attributes Only valid for EFI_FILE_MODE_CREATE, in which case these
|
||||
* are the attribute bits for the newly created file
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_FILE_OPEN)(
|
||||
IN EFI_FILE_PROTOCOL *This,
|
||||
OUT EFI_FILE_PROTOCOL **NewHandle,
|
||||
IN CHAR16 *FileName,
|
||||
IN UINT64 OpenMode,
|
||||
IN UINT64 Attributes);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Closes a specified file handle.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
* handle to close. See the type EFI_FILE_PROTOCOL description.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_FILE_CLOSE)(IN EFI_FILE_PROTOCOL *This);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Closes and deletes a file.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_FILE_PROTOCOL instance that is the handle
|
||||
* to the file to delete. See the type EFI_FILE_PROTOCOL description.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_FILE_DELETE)(IN EFI_FILE_PROTOCOL *This);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Reads data from a file.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
* handle to read data from. See the type EFI_FILE_PROTOCOL description.
|
||||
* @param BufferSize On input, the size of the Buffer. On output, the amount
|
||||
* of data returned in Buffer. In both cases, the size is measured in
|
||||
* bytes.
|
||||
* @param Buffer The buffer into which the data is read.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_FILE_READ)(
|
||||
IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, OUT VOID *Buffer);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Writes data to a file.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
* handle to write data to. See the type EFI_FILE_PROTOCOL description.
|
||||
* @param BufferSize On input, the size of the Buffer. On output, the amount
|
||||
* of data actually written. In both cases, the size is measured in bytes.
|
||||
* @param Buffer The buffer of data to write.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_FILE_WRITE)(
|
||||
IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, IN VOID *Buffer);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Returns a file’s current position.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
* handle to get the current position on. See the type EFI_FILE_PROTOCOL
|
||||
* description.
|
||||
* @param Position The address to return the file’s current position value.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_FILE_GET_POSITION)(IN EFI_FILE_PROTOCOL *This, OUT UINT64 *Position);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Sets a file’s current position.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_FILE_PROTOCOL instance that is the he
|
||||
* file handle to set the requested position on. See the type
|
||||
* EFI_FILE_PROTOCOL description.
|
||||
* @param Position The byte position from the start of the file to set.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_FILE_SET_POSITION)(IN EFI_FILE_PROTOCOL *This, IN UINT64 Position);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Returns information about a file.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
* handle the requested information is for. See the type EFI_FILE_PROTOCOL
|
||||
* description.
|
||||
* @param InformationType The type identifier for the information being
|
||||
* requested. Type EFI_GUID is defined on page 176. See the EFI_FILE_INFO
|
||||
* and EFI_FILE_SYSTEM_INFO descriptions for the related GUID definitions.
|
||||
* @param BufferSize On input, the size of Buffer. On output, the amount of
|
||||
* data returned in Buffer. In both cases, the size is measured in bytes.
|
||||
* @param Buffer A pointer to the data buffer to return. The buffer’s type is
|
||||
* indicated by InformationType.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_FILE_GET_INFO)(
|
||||
IN EFI_FILE_PROTOCOL *This,
|
||||
IN EFI_GUID *InformationType,
|
||||
IN OUT UINTN *BufferSize,
|
||||
OUT VOID *Buffer);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Sets information about a file.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
* handle the information is for. See the type EFI_FILE_PROTOCOL
|
||||
* description.
|
||||
* @param InformationType The type identifier for the information being set.
|
||||
* Type EFI_GUID is defined in page 176. See the EFI_FILE_INFO and
|
||||
* EFI_FILE_SYSTEM_INFO descriptions in this section for the related GUID
|
||||
* definitions.
|
||||
* @param BufferSize The size, in bytes, of Buffer.
|
||||
* @param Buffer A pointer to the data buffer to write. The buffer’s type is
|
||||
* indicated by InformationType.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_FILE_SET_INFO)(
|
||||
IN EFI_FILE_PROTOCOL *This, IN EFI_GUID *InformationType, IN UINTN BufferSize, IN VOID *Buffer);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Flushes all modified data associated with a file to a device.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
* handle to flush. See the type EFI_FILE_PROTOCOL description.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_FILE_FLUSH)(IN EFI_FILE_PROTOCOL *This);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Opens a new file relative to the source directory’s location.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
* handle to read data from. See the type EFI_FILE_PROTOCOL description.
|
||||
* @param NewHandle A pointer to the location to return the opened handle for
|
||||
* the new file. See the type EFI_FILE_PROTOCOL description. For
|
||||
* asynchronous I/O, this pointer must remain valid for the duration of the
|
||||
* asynchronous operation.
|
||||
* @param FileName The Null-terminated string of the name of the file to be
|
||||
* opened. The file name may contain the following path modifiers: “\”,
|
||||
* “.”, and “..”.
|
||||
* @param OpenMode The mode to open the file. The only valid combinations
|
||||
* that the file may be opened with are: Read, Read/Write, or
|
||||
* Create/Read/Write.
|
||||
* @param Attributes Only valid for EFI_FILE_MODE_CREATE, in which case these
|
||||
* are the attribute bits for the
|
||||
* @param Token A pointer to the token associated with the transaction.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_FILE_OPEN_EX)(
|
||||
IN EFI_FILE_PROTOCOL *This,
|
||||
OUT EFI_FILE_PROTOCOL **NewHandle,
|
||||
IN CHAR16 *FileName,
|
||||
IN UINT64 OpenMode,
|
||||
IN UINT64 Attributes,
|
||||
IN OUT EFI_FILE_IO_TOKEN *Token);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Reads data from a file.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
* handle to read data from. See the type EFI_FILE_PROTOCOL description.
|
||||
* @param Token A pointer to the token associated with the transaction.
|
||||
* Type EFI_FILE_IO_TOKEN is defined in "Related Definitions" below.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_FILE_READ_EX)(
|
||||
IN EFI_FILE_PROTOCOL *This, IN OUT EFI_FILE_IO_TOKEN *Token);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Writes data to a file.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
* handle to write data to. See the type EFI_FILE_PROTOCOL description.
|
||||
* @param Token A pointer to the token associated with the transaction.
|
||||
* Type EFI_FILE_IO_TOKEN is defined in "Related Definitions" above.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_FILE_WRITE_EX)(
|
||||
IN EFI_FILE_PROTOCOL *This, IN OUT EFI_FILE_IO_TOKEN *Token);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Flushes all modified data associated with a file to a device.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
* handle to flush. See the type EFI_FILE_PROTOCOL description.
|
||||
* @param Token A pointer to the token associated with the transaction.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_FILE_FLUSH_EX)(
|
||||
IN EFI_FILE_PROTOCOL *This, IN OUT EFI_FILE_IO_TOKEN *Token);
|
||||
|
||||
/**
|
||||
* @struct EFI_FILE_PROTOCOL
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_FILE_PROTOCOL struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef struct _EFI_FILE_PROTOCOL
|
||||
{
|
||||
/**
|
||||
* @brief The version of the EFI_FILE_PROTOCOL interface. The version
|
||||
* specified by this specification is EFI_FILE_PROTOCOL_LATEST_REVISION.
|
||||
* Future versions are required to be backward compatible to version 1.0.
|
||||
*/
|
||||
UINT64 Revision;
|
||||
|
||||
/**
|
||||
* @brief Opens or creates a new file. See the Open() function description.
|
||||
*/
|
||||
EFI_FILE_OPEN Open;
|
||||
|
||||
/**
|
||||
* @brief Closes the current file handle. See the Close() function
|
||||
* description.
|
||||
*/
|
||||
EFI_FILE_CLOSE Close;
|
||||
|
||||
/**
|
||||
* @brief Deletes a file. See the Delete() function description.
|
||||
*/
|
||||
EFI_FILE_DELETE Delete;
|
||||
|
||||
/**
|
||||
* @brief Reads bytes from a file. See the Read() function description.
|
||||
*/
|
||||
EFI_FILE_READ Read;
|
||||
|
||||
/**
|
||||
* @brief Writes bytes to a file. See the Write() function description.
|
||||
*/
|
||||
EFI_FILE_WRITE Write;
|
||||
|
||||
/**
|
||||
* @brief Returns the current file position. See the GetPosition() function
|
||||
* description.
|
||||
*/
|
||||
EFI_FILE_GET_POSITION GetPosition;
|
||||
|
||||
/**
|
||||
* @brief Sets the current file position. See the SetPosition() function
|
||||
* description.
|
||||
*/
|
||||
EFI_FILE_SET_POSITION SetPosition;
|
||||
|
||||
/**
|
||||
* @brief Gets the requested file or volume information. See the GetInfo()
|
||||
* function description.
|
||||
*/
|
||||
EFI_FILE_GET_INFO GetInfo;
|
||||
|
||||
/**
|
||||
* @brief Sets the requested file information. See the SetInfo() function
|
||||
* description.
|
||||
*/
|
||||
EFI_FILE_SET_INFO SetInfo;
|
||||
|
||||
/**
|
||||
* @brief Flushes all modified data associated with the file to the device.
|
||||
* See the Flush() function description.
|
||||
*/
|
||||
EFI_FILE_FLUSH Flush;
|
||||
|
||||
/**
|
||||
* @brief Opens a new file relative to the source directory’s location.
|
||||
*/
|
||||
EFI_FILE_OPEN_EX OpenEx;
|
||||
|
||||
/**
|
||||
* @brief Reads data from a file.
|
||||
*/
|
||||
EFI_FILE_READ_EX ReadEx;
|
||||
|
||||
/**
|
||||
* @brief Writes data to a file.
|
||||
*/
|
||||
EFI_FILE_WRITE_EX WriteEx;
|
||||
|
||||
/**
|
||||
* @brief Flushes all modified data associated with a file to a device.
|
||||
*/
|
||||
EFI_FILE_FLUSH_EX FlushEx;
|
||||
|
||||
} EFI_FILE_PROTOCOL;
|
||||
|
||||
#endif
|
||||
53
loader/efi/include/efi/efi_guid.h
Normal file
53
loader/efi/include/efi/efi_guid.h
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_GUID_H
|
||||
#define EFI_GUID_H
|
||||
|
||||
/** @brief defines the size of the data4 field in EFI_GUID */
|
||||
#define EFI_GUID_DATA4_SIZE 8
|
||||
|
||||
/**
|
||||
* @struct EFI_GUID
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_GUID struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/** @brief Stores the bytes 0-4 of the GUID */
|
||||
UINT32 Data1;
|
||||
/** @brief Stores the bytes 5-6 of the GUID */
|
||||
UINT16 Data2;
|
||||
/** @brief Stores the bytes 7-8 of the GUID */
|
||||
UINT16 Data3;
|
||||
/** @brief Stores the bytes 9-15 of the GUID */
|
||||
UINT8 Data4[EFI_GUID_DATA4_SIZE];
|
||||
|
||||
} EFI_GUID;
|
||||
|
||||
#endif
|
||||
46
loader/efi/include/efi/efi_interface_type.h
Normal file
46
loader/efi/include/efi/efi_interface_type.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_INTERFACE_TYPE_H
|
||||
#define EFI_INTERFACE_TYPE_H
|
||||
|
||||
/**
|
||||
* @struct EFI_INTERFACE_TYPE
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_INTERFACE_TYPE struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/**
|
||||
* @brief Defined in EFI_BOOT_SERVICES.InstallProtocolInterface()
|
||||
*/
|
||||
EFI_NATIVE_INTERFACE
|
||||
|
||||
} EFI_INTERFACE_TYPE;
|
||||
|
||||
#endif
|
||||
63
loader/efi/include/efi/efi_locate_search_type.h
Normal file
63
loader/efi/include/efi/efi_locate_search_type.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_LOCATE_SEARCH_TYPE_H
|
||||
#define EFI_LOCATE_SEARCH_TYPE_H
|
||||
|
||||
/**
|
||||
* @struct EFI_LOCATE_SEARCH_TYPE
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_LOCATE_SEARCH_TYPE struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/**
|
||||
* @brief Protocol and SearchKey are ignored and the function returns an
|
||||
* array of every handle in the system.
|
||||
*/
|
||||
AllHandles,
|
||||
|
||||
/**
|
||||
* @brief SearchKey supplies the Registration value returned by
|
||||
* EFI_BOOT_SERVICES.RegisterProtocolNotify(). The function returns
|
||||
* the next handle that is new for the registration. Only one handle is
|
||||
* returned at a time, starting with the first, and the caller must loop
|
||||
* until no more handles are returned. Protocol is ignored for this
|
||||
* search type.
|
||||
*/
|
||||
ByRegisterNotify,
|
||||
|
||||
/**
|
||||
* @brief All handles that support Protocol are returned. SearchKey is
|
||||
* ignored for this search type.
|
||||
*/
|
||||
ByProtocol
|
||||
|
||||
} EFI_LOCATE_SEARCH_TYPE;
|
||||
|
||||
#endif
|
||||
183
loader/efi/include/efi/efi_memory_descriptor.h
Normal file
183
loader/efi/include/efi/efi_memory_descriptor.h
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_MEMORY_DESCRIPTOR_H
|
||||
#define EFI_MEMORY_DESCRIPTOR_H
|
||||
|
||||
#include "efi_types.h"
|
||||
|
||||
/**
|
||||
* @brief Memory cacheability attribute: The memory region supports being
|
||||
* configured as not cacheable.
|
||||
*/
|
||||
#define EFI_MEMORY_UC 0x0000000000000001
|
||||
|
||||
/**
|
||||
* @brief Memory cacheability attribute: The memory region supports being
|
||||
* configured as write combining.
|
||||
*/
|
||||
#define EFI_MEMORY_WC 0x0000000000000002
|
||||
|
||||
/**
|
||||
* @brief Memory cacheability attribute: The memory region supports being
|
||||
* configured as cacheable with a “write through” policy. Writes that
|
||||
* hit in the cache will also be written to main memory.
|
||||
*/
|
||||
#define EFI_MEMORY_WT 0x0000000000000004
|
||||
|
||||
/**
|
||||
* @brief Memory cacheability attribute: The memory region supports being
|
||||
* configured as cacheable with a “write back” policy. Reads and writes
|
||||
* that hit in the cache do not propagate to main memory. Dirty data is
|
||||
* written back to main memory when a new cache line is allocated.
|
||||
*/
|
||||
#define EFI_MEMORY_WB 0x0000000000000008
|
||||
|
||||
/**
|
||||
* @brief Memory cacheability attribute: The memory region supports being
|
||||
* configured as not cacheable, exported, and supports the “fetch and
|
||||
* add” semaphore mechanism.
|
||||
*/
|
||||
#define EFI_MEMORY_UCE 0x0000000000000010
|
||||
|
||||
/**
|
||||
* @brief Physical memory protection attribute: The memory region supports
|
||||
* being configured as write-protected by system hardware. This is
|
||||
* typically used as a cacheability attribute today. The memory region
|
||||
* supports being configured as cacheable with a "write protected"
|
||||
* policy. Reads come from cache lines when possible, and read misses
|
||||
* cause cache fills. Writes are propagated to the system bus and cause
|
||||
* corresponding cache lines on all processors on the bus to be
|
||||
* invalidated.
|
||||
*/
|
||||
#define EFI_MEMORY_WP 0x0000000000001000
|
||||
|
||||
/**
|
||||
* @brief Physical memory protection attribute: The memory region supports
|
||||
* being configured as read-protected by system hardware.
|
||||
*/
|
||||
#define EFI_MEMORY_RP 0x0000000000002000
|
||||
|
||||
/**
|
||||
* @brief Physical memory protection attribute: The memory region supports
|
||||
* being configured so it is protected by system hardware from
|
||||
* executing code.
|
||||
*/
|
||||
#define EFI_MEMORY_XP 0x0000000000004000
|
||||
|
||||
/**
|
||||
* @brief Runtime memory attribute: The memory region refers to persistent
|
||||
* memory
|
||||
*/
|
||||
#define EFI_MEMORY_NV 0x0000000000008000
|
||||
|
||||
/**
|
||||
* @brief The memory region provides higher reliability relative to other
|
||||
* memory in the system. If all memory has the same reliability, then
|
||||
* this bit is not used.
|
||||
*/
|
||||
#define EFI_MEMORY_MORE_RELIABLE 0x0000000000010000
|
||||
|
||||
/**
|
||||
* @brief Physical memory protection attribute: The memory region supports
|
||||
* making this memory range read-only by system hardware.
|
||||
*/
|
||||
#define EFI_MEMORY_RO 0x0000000000020000
|
||||
|
||||
/**
|
||||
* @brief Specific-purpose memory (SPM). The memory is earmarked for
|
||||
* specific purposes such as for specific device drivers or applications.
|
||||
* The SPM attribute serves as a hint to the OS to avoid allocating this
|
||||
* memory for core OS data or code that can not be relocated.
|
||||
* Prolonged use of this memory for purposes other than the intended
|
||||
* purpose may result in suboptimal platform performance.
|
||||
*/
|
||||
#define EFI_MEMORY_SP 0x0000000000040000
|
||||
|
||||
/**
|
||||
* @brief If this flag is set, the memory region is capable of being
|
||||
* protected with the CPU’s memory cryptographic
|
||||
* capabilities. If this flag is clear, the memory region is not
|
||||
* capable of being protected with the CPU’s memory
|
||||
* cryptographic capabilities or the CPU does not support CPU
|
||||
* memory cryptographic capabilities.
|
||||
*/
|
||||
#define EFI_MEMORY_CPU_CRYPTO 0x0000000000080000
|
||||
|
||||
/**
|
||||
* @brief Runtime memory attribute: The memory region needs to be given a
|
||||
* virtual mapping by the operating system when
|
||||
* SetVirtualAddressMap() is called
|
||||
*/
|
||||
#define EFI_MEMORY_RUNTIME 0x8000000000000000
|
||||
|
||||
/**
|
||||
* @struct EFI_MEMORY_DESCRIPTOR
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_MEMORY_DESCRIPTOR struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/**
|
||||
* @brief Type of the memory region. Type EFI_MEMORY_TYPE is defined in
|
||||
* the AllocatePages() function description.
|
||||
*/
|
||||
UINT32 Type;
|
||||
|
||||
/**
|
||||
* @brief Physical address of the first byte in the memory region.
|
||||
* PhysicalStart must be aligned on a 4 KiB boundary, and must not be
|
||||
* above 0xfffffffffffff000.
|
||||
*/
|
||||
EFI_PHYSICAL_ADDRESS PhysicalStart;
|
||||
|
||||
/**
|
||||
* @brief Virtual address of the first byte in the memory region.
|
||||
* VirtualStart must be aligned on a 4 KiB boundary, and must not be
|
||||
* above 0xfffffffffffff000.
|
||||
*/
|
||||
EFI_VIRTUAL_ADDRESS VirtualStart;
|
||||
|
||||
/**
|
||||
* @brief Number of 4 KiB pages in the memory region. NumberOfPages must
|
||||
* not be 0, and must not be any value that would represent a memory
|
||||
* page with a start address, either physical or virtual, above
|
||||
* 0xfffffffffffff000
|
||||
*/
|
||||
UINT64 NumberOfPages;
|
||||
|
||||
/**
|
||||
* @brief Attributes of the memory region that describe the bit mask of
|
||||
* capabilities for that memory region, and not necessarily the current
|
||||
* settings for that memory region.
|
||||
*/
|
||||
UINT64 Attribute;
|
||||
|
||||
} EFI_MEMORY_DESCRIPTOR;
|
||||
|
||||
#endif
|
||||
132
loader/efi/include/efi/efi_memory_type.h
Normal file
132
loader/efi/include/efi/efi_memory_type.h
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_MEMORY_TYPE_H
|
||||
#define EFI_MEMORY_TYPE_H
|
||||
|
||||
/**
|
||||
* @struct EFI_MEMORY_TYPE
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_MEMORY_TYPE struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/**
|
||||
* @brief Not usable.
|
||||
*/
|
||||
EfiReservedMemoryType,
|
||||
|
||||
/**
|
||||
* @brief The code portions of a loaded UEFI application.
|
||||
*/
|
||||
EfiLoaderCode,
|
||||
|
||||
/**
|
||||
* @brief The data portions of a loaded UEFI application and the default
|
||||
* data allocation type used by a UEFI application to allocate pool
|
||||
* memory.
|
||||
*/
|
||||
EfiLoaderData,
|
||||
|
||||
/**
|
||||
* @brief The code portions of a loaded UEFI Boot Service Driver.
|
||||
*/
|
||||
EfiBootServicesCode,
|
||||
|
||||
/**
|
||||
* @brief The data portions of a loaded UEFI Boot Serve Driver, and the
|
||||
* default data allocation type used by a UEFI Boot Service Driver to
|
||||
* allocate pool memory.
|
||||
*/
|
||||
EfiBootServicesData,
|
||||
|
||||
/**
|
||||
* @brief The code portions of a loaded UEFI Runtime Driver
|
||||
*/
|
||||
EfiRuntimeServicesCode,
|
||||
|
||||
/**
|
||||
* @brief The data portions of a loaded UEFI Runtime Driver and the
|
||||
* default data allocation type used by a UEFI Runtime Driver to
|
||||
* allocate pool memory.
|
||||
*/
|
||||
EfiRuntimeServicesData,
|
||||
|
||||
/**
|
||||
* @brief Free (unallocated) memory.
|
||||
*/
|
||||
EfiConventionalMemory,
|
||||
|
||||
/**
|
||||
* @brief Memory in which errors have been detected.
|
||||
*/
|
||||
EfiUnusableMemory,
|
||||
|
||||
/**
|
||||
* @brief Memory that holds the ACPI tables.
|
||||
*/
|
||||
EfiACPIReclaimMemory,
|
||||
|
||||
/**
|
||||
* @brief Address space reserved for use by the firmware.
|
||||
*/
|
||||
EfiACPIMemoryNVS,
|
||||
|
||||
/**
|
||||
* @brief Used by system firmware to request that a memory-mapped IO
|
||||
* region be mapped by the OS to a virtual address so it can be accessed
|
||||
* by EFI runtime services.
|
||||
*/
|
||||
EfiMemoryMappedIO,
|
||||
|
||||
/**
|
||||
* @brief System memory-mapped IO region that is used to translate memory
|
||||
* cycles to IO cycles by the processor.
|
||||
*/
|
||||
EfiMemoryMappedIOPortSpace,
|
||||
|
||||
/**
|
||||
* @brief Address space reserved by the firmware for code that is part of
|
||||
* the processor.
|
||||
*/
|
||||
EfiPalCode,
|
||||
|
||||
/**
|
||||
* @brief A memory region that operates as EfiConventionalMemory. However,
|
||||
* it happens to also support byte-addressable non-volatility.
|
||||
*/
|
||||
EfiPersistentMemory,
|
||||
|
||||
/**
|
||||
* @brief The end of the enum
|
||||
*/
|
||||
EfiMaxMemoryType
|
||||
|
||||
} EFI_MEMORY_TYPE;
|
||||
|
||||
#endif
|
||||
326
loader/efi/include/efi/efi_mp_services_protocol.h
Normal file
326
loader/efi/include/efi/efi_mp_services_protocol.h
Normal file
|
|
@ -0,0 +1,326 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_MP_SERVICES_PROTOCOL_H
|
||||
#define EFI_MP_SERVICES_PROTOCOL_H
|
||||
|
||||
#include "efi_processor_information.h"
|
||||
#include "efi_types.h"
|
||||
|
||||
/** @brief defines the GUID for EFI_MP_SERVICES_PROTOCOL_GUID */
|
||||
#define EFI_MP_SERVICES_PROTOCOL_GUID \
|
||||
{ \
|
||||
0x3fdda605, 0xa76e, 0x4f46, \
|
||||
{ \
|
||||
0xad, 0x29, 0x12, 0xf4, 0x53, 0x1b, 0x3d, 0x08 \
|
||||
} \
|
||||
}
|
||||
|
||||
/** @brief prototype for _EFI_MP_SERVICES_PROTOCOL */
|
||||
struct _EFI_MP_SERVICES_PROTOCOL;
|
||||
|
||||
/** @brief prototype for EFI_MP_SERVICES_PROTOCOL */
|
||||
typedef struct _EFI_MP_SERVICES_PROTOCOL EFI_MP_SERVICES_PROTOCOL;
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief This service retrieves the number of logical processor in the
|
||||
* platform and the number of those logical processors that are currently
|
||||
* enabled. This service may only be called from the BSP.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
|
||||
* @param NumberOfProcessors Pointer to the total number of logical
|
||||
* processors in the system, including the BSP and all enabled and
|
||||
* disabled APs.
|
||||
* @param NumberOfEnabledProcessors Pointer to the number of logical
|
||||
* processors in the platform including the BSP that are currently
|
||||
* enabled.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS)(
|
||||
IN EFI_MP_SERVICES_PROTOCOL *This,
|
||||
OUT UINTN *NumberOfProcessors,
|
||||
OUT UINTN *NumberOfEnabledProcessors);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Gets detailed MP-related information on the requested processor at
|
||||
* the instant this call is made. This service may only be called from
|
||||
* the BSP.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
|
||||
* @param ProcessorNumber The handle number of processor. The range is from
|
||||
* 0 to the total number of logical processors minus 1. The total number
|
||||
* of logical processors can be retrieved by
|
||||
* EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
|
||||
* @param ProcessorInfoBuffer A pointer to the buffer where information for
|
||||
* the requested processor is deposited. The buffer is allocated by the
|
||||
* caller.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_MP_SERVICES_GET_PROCESSOR_INFO)(
|
||||
IN EFI_MP_SERVICES_PROTOCOL *This,
|
||||
IN UINTN ProcessorNumber,
|
||||
OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer);
|
||||
|
||||
/** Defined in EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() */
|
||||
#define END_OF_CPU_LIST 0xffffffff
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Defined in EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param ProcedureArgument Pointer to the procedure’s argument
|
||||
*/
|
||||
typedef VOID(EFIAPI *EFI_AP_PROCEDURE)(IN VOID *ProcedureArgument);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief This service executes a caller provided function on all enabled
|
||||
* APs. APs can run either simultaneously or one at a time in sequence.
|
||||
* This service supports both blocking and non-blocking requests. The
|
||||
* non-blocking requests use EFI events so the BSP can detect when the
|
||||
* APs have finished.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
|
||||
* @param Procedure A pointer to the function to be run on enabled APs of the
|
||||
* system.
|
||||
* @param SingleThread If TRUE, then all the enabled APs execute the function
|
||||
* specified by Procedure one by one, in ascending order of processor
|
||||
* handle number. If FALSE, then all the enabled APs execute the function
|
||||
* specified by Procedure simultaneously.
|
||||
* @param WaitEvent The event created by the caller with CreateEvent()
|
||||
* service. If it is NULL, then execute in blocking mode. BSP waits until
|
||||
* all APs finish or TimeoutInMicroSeconds expires. If it’s not NULL, then
|
||||
* execute in non-blocking mode. BSP requests the function specified by
|
||||
* Procedure to be started on all the enabled APs, and go on executing
|
||||
* immediately. If all return from Procedure or TimeoutInMicroSeconds
|
||||
* expires, this event is signaled. The BSP can use the CheckEvent() or
|
||||
* WaitForEvent() services to check the state of event. Type EFI_EVENT is
|
||||
* defined in CreateEvent() in the Unified Extensible Firmware Interface
|
||||
* Specification (Version 2.0).
|
||||
* @param TimeoutInMicroSeconds Indicates the time limit in microseconds for
|
||||
* APs to return from Procedure, either for blocking or non-blocking mode.
|
||||
* Zero means infinity. If the timeout expires before all APs return from
|
||||
* Procedure, then Procedure on the failed APs is terminated. All enabled
|
||||
* APs are available for next function assigned by
|
||||
* EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() or
|
||||
* EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). If the timeout expires in
|
||||
* blocking mode, BSP returns EFI_TIMEOUT. If the timeout expires in
|
||||
* non-blocking mode, WaitEvent is signaled with SignalEvent().
|
||||
* @param ProcedureArgument The parameter passed into Procedure for all APs.
|
||||
* @param FailedCpuList If NULL, this parameter is ignored. Otherwise, if all
|
||||
* APs finish successfully, then its content is set to NULL. If not all APs
|
||||
* finish before timeout expires, then its content is set to address of the
|
||||
* buffer holding handle numbers of the failed APs. The buffer is allocated
|
||||
* by MP Service Protocol, and it’s the caller’s responsibility to free the
|
||||
* buffer with FreePool() service. In blocking mode, it is ready for
|
||||
* consumption when the call returns. In non-blocking mode, it is ready
|
||||
* when WaitEvent is signaled. The list of failed CPU is terminated by
|
||||
* END_OF_CPU_LIST.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_MP_SERVICES_STARTUP_ALL_APS)(
|
||||
IN EFI_MP_SERVICES_PROTOCOL *This,
|
||||
IN EFI_AP_PROCEDURE Procedure,
|
||||
IN BOOLEAN SingleThread,
|
||||
IN EFI_EVENT WaitEvent OPTIONAL,
|
||||
IN UINTN TimeoutInMicroSeconds,
|
||||
IN VOID *ProcedureArgument OPTIONAL,
|
||||
OUT UINTN **FailedCpuList OPTIONAL);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief This service lets the caller get one enabled AP to execute a
|
||||
* caller-provided function. The caller can request the BSP to either wait
|
||||
* for the completion of the AP or just proceed with the next task by using
|
||||
* the EFI event mechanism.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
|
||||
* @param Procedure A pointer to the function to be run on the designated AP.
|
||||
* Type EFI_AP_PROCEDURE is defined in
|
||||
* EFI_MP_SERVICES_PROTOCOL.StartupAllAPs().
|
||||
* @param ProcessorNumber The handle number of the AP. The range is from 0
|
||||
* to the total number of logical processors minus 1. The total number of
|
||||
* logical processors can be retrieved by
|
||||
* EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
|
||||
* @param WaitEvent The event created by the caller with CreateEvent()
|
||||
* service. If it is NULL, then execute in blocking mode. BSP waits until
|
||||
* this AP finishes or TimeoutInMicroSeconds expires. If it’s not NULL,
|
||||
* then execute in non-blocking mode. BSP requests the function specified
|
||||
* by Procedure to be started on the AP, and go on executing immediately.
|
||||
* If this AP finishes or TimeoutInMicroSeconds expires, this event is
|
||||
* signaled. BSP can use the CheckEvent() and WaitForEvent() services to
|
||||
* check the state of event. Type EFI_EVENT is defined in CreateEvent() in
|
||||
* the Unified Extensible Firmware Interface Specification (Version 2.0)
|
||||
* @param TimeoutInMicroseconds Indicates the time limit in microseconds
|
||||
* for this AP to finish the function, either for blocking or non-blocking
|
||||
* mode. Zero means infinity. If the timeout expires before this AP returns
|
||||
* from Procedure, then Procedure on the AP is terminated. The AP is
|
||||
* available for subsequent calls to
|
||||
* EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() and
|
||||
* EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). If the timeout expires in
|
||||
* blocking mode, BSP returns EFI_TIMEOUT. If the timeout expires in
|
||||
* non-blocking mode, WaitEvent is signaled with SignalEvent().
|
||||
* @param ProcedureArgument The parameter passed into Procedure on the
|
||||
* specified AP.
|
||||
* @param Finished If NULL, this parameter is ignored. In blocking mode, this
|
||||
* parameter is ignored. In non-blocking mode, if AP returns from Procedure
|
||||
* before the timeout expires, its content is set to TRUE. Otherwise, the
|
||||
* value is set to FALSE. The caller can determine if the AP returned from
|
||||
* Procedure by evaluating this value.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_MP_SERVICES_STARTUP_THIS_AP)(
|
||||
IN EFI_MP_SERVICES_PROTOCOL *This,
|
||||
IN EFI_AP_PROCEDURE Procedure,
|
||||
IN UINTN ProcessorNumber,
|
||||
IN EFI_EVENT WaitEvent OPTIONAL,
|
||||
IN UINTN TimeoutInMicroseconds,
|
||||
IN VOID *ProcedureArgument OPTIONAL,
|
||||
OUT BOOLEAN *Finished OPTIONAL);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief This service switches the requested AP to be the BSP from that
|
||||
* point onward. This service changes the BSP for all purposes. This
|
||||
* service may only be called from the current BSP.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
|
||||
* @param ProcessorNumber The handle number of AP that is to become the new
|
||||
* BSP. The range is from 0 to the total number of logical processors
|
||||
* minus 1. The total number of logical processors can be retrieved by
|
||||
* EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
|
||||
* @param EnableOldBSP If TRUE, then the old BSP will be listed as an enabled
|
||||
* AP. Otherwise, it will be disabled.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_MP_SERVICES_SWITCH_BSP)(
|
||||
IN EFI_MP_SERVICES_PROTOCOL *This, IN UINTN ProcessorNumber, IN BOOLEAN EnableOldBSP);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief This service lets the caller enable or disable an AP from this
|
||||
* point onward. This service may only be called from the BSP.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
|
||||
* @param ProcessorNumber The handle number of AP. The range is from 0 to
|
||||
* the total number of logical processors minus 1. The total number of
|
||||
* logical processors can be retrieved by
|
||||
* EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
|
||||
* @param EnableAP Specifies the new state for the processor specified by
|
||||
* ProcessorNumber. TRUE for enabled, FALSE for disabled.
|
||||
* @param HealthFlag If not NULL, a pointer to a value that specifies the new
|
||||
* health status of the AP. This flag corresponds to StatusFlag defined in
|
||||
* EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only the
|
||||
* PROCESSOR_HEALTH_STATUS_BIT is used. All other bits are ignored. If it
|
||||
* is NULL, this parameter is ignored.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_MP_SERVICES_ENABLEDISABLEAP)(
|
||||
IN EFI_MP_SERVICES_PROTOCOL *This,
|
||||
IN UINTN ProcessorNumber,
|
||||
IN BOOLEAN EnableAP,
|
||||
IN UINT32 *HealthFlag OPTIONAL);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief This return the handle number for the calling processor. This
|
||||
* service may be called from the BSP and APs.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
|
||||
* @param ProcessorNumber Pointer to the handle number of AP. The range is
|
||||
* from 0 to the total number of logical processors minus 1. The total
|
||||
* number of logical processors can be retrieved by
|
||||
* EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_MP_SERVICES_WHOAMI)(
|
||||
IN EFI_MP_SERVICES_PROTOCOL *This, OUT UINTN *ProcessorNumber);
|
||||
|
||||
/**
|
||||
* @struct EFI_MP_SERVICES_PROTOCOL
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_MP_SERVICES_PROTOCOL struct:
|
||||
* https://uefi.org/sites/default/files/resources/PI_Spec_1_7_A_final_May1.pdf
|
||||
*/
|
||||
typedef struct _EFI_MP_SERVICES_PROTOCOL
|
||||
{
|
||||
/**
|
||||
* @brief Gets the number of logical processors and the number of enabled
|
||||
* logical processors in the system.
|
||||
*/
|
||||
EFI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS GetNumberOfProcessors;
|
||||
|
||||
/**
|
||||
* @brief Gets detailed information on the requested processor at the
|
||||
* instant this call is made.
|
||||
*/
|
||||
EFI_MP_SERVICES_GET_PROCESSOR_INFO GetProcessorInfo;
|
||||
|
||||
/**
|
||||
* @brief Starts up all the enabled APs in the system to run the function
|
||||
* provided by the caller.
|
||||
*/
|
||||
EFI_MP_SERVICES_STARTUP_ALL_APS StartupAllAPs;
|
||||
|
||||
/**
|
||||
* @brief Starts up the requested AP to run the function provided by the
|
||||
* caller.
|
||||
*/
|
||||
EFI_MP_SERVICES_STARTUP_THIS_AP StartupThisAP;
|
||||
|
||||
/**
|
||||
* @brief Switches the requested AP to be the BSP from that point onward.
|
||||
* This service changes the BSP for all purposes.
|
||||
*/
|
||||
EFI_MP_SERVICES_SWITCH_BSP SwitchBSP;
|
||||
|
||||
/**
|
||||
* @brief Enables and disables the given AP from that point onward.
|
||||
*/
|
||||
EFI_MP_SERVICES_ENABLEDISABLEAP EnableDisableAP;
|
||||
|
||||
/**
|
||||
* @brief Gets the handle number of the caller processor.
|
||||
*/
|
||||
EFI_MP_SERVICES_WHOAMI WhoAmI;
|
||||
|
||||
} EFI_MP_SERVICES_PROTOCOL;
|
||||
|
||||
/** @brief defines the global pointer to the EFI_MP_SERVICES_PROTOCOL */
|
||||
extern EFI_MP_SERVICES_PROTOCOL *g_mp_services_protocol;
|
||||
|
||||
#endif
|
||||
63
loader/efi/include/efi/efi_open_protocol_information_entry.h
Normal file
63
loader/efi/include/efi/efi_open_protocol_information_entry.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_OPEN_PROTOCOL_INFORMATION_ENTRY_H
|
||||
#define EFI_OPEN_PROTOCOL_INFORMATION_ENTRY_H
|
||||
|
||||
#include "efi_types.h"
|
||||
|
||||
/**
|
||||
* @struct EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_OPEN_PROTOCOL_INFORMATION_ENTRY struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/**
|
||||
* @brief Defined in EFI_BOOT_SERVICES.OpenProtocolInformation()
|
||||
*/
|
||||
EFI_HANDLE AgentHandle;
|
||||
|
||||
/**
|
||||
* @brief Defined in EFI_BOOT_SERVICES.OpenProtocolInformation()
|
||||
*/
|
||||
EFI_HANDLE ControllerHandle;
|
||||
|
||||
/**
|
||||
* @brief Defined in EFI_BOOT_SERVICES.OpenProtocolInformation()
|
||||
*/
|
||||
UINT32 Attributes;
|
||||
|
||||
/**
|
||||
* @brief Defined in EFI_BOOT_SERVICES.OpenProtocolInformation()
|
||||
*/
|
||||
UINT32 OpenCount;
|
||||
|
||||
} EFI_OPEN_PROTOCOL_INFORMATION_ENTRY;
|
||||
|
||||
#endif
|
||||
90
loader/efi/include/efi/efi_processor_information.h
Normal file
90
loader/efi/include/efi/efi_processor_information.h
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_PROCESSOR_INFORMATION_H
|
||||
#define EFI_PROCESSOR_INFORMATION_H
|
||||
|
||||
#include "efi_cpu_physical_location.h"
|
||||
#include "efi_types.h"
|
||||
#include "extened_processor_information.h"
|
||||
|
||||
/**
|
||||
* @brief This bit indicates whether the processor is playing the role of BSP.
|
||||
* If the bit is 1, then the processor is BSP. Otherwise, it is AP.
|
||||
*/
|
||||
#define PROCESSOR_AS_BSP_BIT 0x00000001
|
||||
|
||||
/**
|
||||
* @brief This bit indicates whether the processor is enabled. If the bit is 1,
|
||||
* then the processor is enabled. Otherwise, it is disabled.
|
||||
*/
|
||||
#define PROCESSOR_ENABLED_BIT 0x00000002
|
||||
|
||||
/**
|
||||
* @brief This bit indicates whether the processor is healthy. If the bit is 1,
|
||||
* then the processor is healthy. Otherwise, some fault has been detected for
|
||||
* the processor.
|
||||
*/
|
||||
#define PROCESSOR_HEALTH_STATUS_BIT 0x00000004
|
||||
|
||||
/**
|
||||
* @struct EFI_PROCESSOR_INFORMATION
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_PROCESSOR_INFORMATION struct:
|
||||
* https://uefi.org/sites/default/files/resources/PI_Spec_1_7_A_final_May1.pdf
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/**
|
||||
* @brief The unique processor ID determined by system hardware. For IPF,
|
||||
* the lower 16 bits contains id/eid, and higher bits are reserved.
|
||||
*/
|
||||
UINT64 ProcessorId;
|
||||
|
||||
/**
|
||||
* @brief Flags indicating if the processor is BSP or AP, if the processor
|
||||
* is enabled or disabled, and if the processor is healthy. The bit
|
||||
* format is defined below.
|
||||
*/
|
||||
UINT32 StatusFlag;
|
||||
|
||||
/**
|
||||
* @brief The physical location of the processor, including the physical
|
||||
* package number that identifies the cartridge, the physical core number
|
||||
* within package, and logical thread number within core.
|
||||
*/
|
||||
EFI_CPU_PHYSICAL_LOCATION Location;
|
||||
|
||||
/**
|
||||
* @brief The extended information of the processor. This field is filled
|
||||
* only when CPU_V2_EXTENDED_TOPOLOGY is set in parameter ProcessorNumber.
|
||||
*/
|
||||
EXTENDED_PROCESSOR_INFORMATION ExtendedInformation;
|
||||
|
||||
} EFI_PROCESSOR_INFORMATION;
|
||||
|
||||
#endif
|
||||
41
loader/efi/include/efi/efi_runtime_services.h
Normal file
41
loader/efi/include/efi/efi_runtime_services.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_RUNTIME_SERVICES_H
|
||||
#define EFI_RUNTIME_SERVICES_H
|
||||
|
||||
/**
|
||||
* @struct EFI_RUNTIME_SERVICES
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_RUNTIME_SERVICES struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
} EFI_RUNTIME_SERVICES;
|
||||
|
||||
#endif
|
||||
91
loader/efi/include/efi/efi_simple_file_system_protocol.h
Normal file
91
loader/efi/include/efi/efi_simple_file_system_protocol.h
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_H
|
||||
#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_H
|
||||
|
||||
#include "efi_file_protocol.h"
|
||||
#include "efi_status.h"
|
||||
#include "efi_types.h"
|
||||
|
||||
/** @brief defines the GUID for EFI_SIMPLE_FILE_SYSTEM_PROTOCOL */
|
||||
#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
|
||||
{ \
|
||||
0x0964e5b22, 0x6459, 0x11d2, \
|
||||
{ \
|
||||
0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b \
|
||||
} \
|
||||
}
|
||||
|
||||
/** @brief defines the Revision Number for EFI_SIMPLE_FILE_SYSTEM_PROTOCOL */
|
||||
#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION 0x00010000
|
||||
|
||||
/** @brief prototype for _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL */
|
||||
struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL;
|
||||
|
||||
/** @brief prototype for EFI_SIMPLE_FILE_SYSTEM_PROTOCOL */
|
||||
typedef struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL EFI_SIMPLE_FILE_SYSTEM_PROTOCOL;
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief The SetMem() function fills a buffer with a specified value.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the volume to open the root directory of. See the type
|
||||
* EFI_SIMPLE_FILE_SYSTEM_PROTOCOL description.
|
||||
* @param Root A pointer to the location to return the opened file handle for
|
||||
* the root directory. See the type EFI_FILE_PROTOCOL description.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME)(
|
||||
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This, OUT EFI_FILE_PROTOCOL **Root);
|
||||
|
||||
/**
|
||||
* @struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
|
||||
{
|
||||
/**
|
||||
* @brief The version of the EFI_FILE_PROTOCOL. The version specified by
|
||||
* this specification is 0x00010000. All future revisions must be
|
||||
* backwards compatible. If a future version is not backwards compatible,
|
||||
* it is not the same GUID.
|
||||
*/
|
||||
UINT64 Revision;
|
||||
|
||||
/**
|
||||
* @brief Opens the volume for file I/O access. See the OpenVolume()
|
||||
* function description.
|
||||
*/
|
||||
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME OpenVolume;
|
||||
|
||||
} EFI_SIMPLE_FILE_SYSTEM_PROTOCOL;
|
||||
|
||||
#endif
|
||||
41
loader/efi/include/efi/efi_simple_text_input_protocol.h
Normal file
41
loader/efi/include/efi/efi_simple_text_input_protocol.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_SIMPLE_TEXT_INPUT_PROTOCOL_H
|
||||
#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_H
|
||||
|
||||
/**
|
||||
* @struct EFI_SIMPLE_TEXT_INPUT_PROTOCOL
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_SIMPLE_TEXT_INPUT_PROTOCOL struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
} EFI_SIMPLE_TEXT_INPUT_PROTOCOL;
|
||||
|
||||
#endif
|
||||
41
loader/efi/include/efi/efi_simple_text_output_mode.h
Normal file
41
loader/efi/include/efi/efi_simple_text_output_mode.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_SIMPLE_TEXT_OUTPUT_MODE_H
|
||||
#define EFI_SIMPLE_TEXT_OUTPUT_MODE_H
|
||||
|
||||
/**
|
||||
* @struct SIMPLE_TEXT_OUTPUT_MODE
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the SIMPLE_TEXT_OUTPUT_MODE struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
} SIMPLE_TEXT_OUTPUT_MODE;
|
||||
|
||||
#endif
|
||||
246
loader/efi/include/efi/efi_simple_text_output_protocol.h
Normal file
246
loader/efi/include/efi/efi_simple_text_output_protocol.h
Normal file
|
|
@ -0,0 +1,246 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_H
|
||||
#define EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_H
|
||||
|
||||
#include "efi_simple_text_output_mode.h"
|
||||
#include "efi_status.h"
|
||||
#include "efi_types.h"
|
||||
|
||||
/** @brief prototype for _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL */
|
||||
struct _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;
|
||||
|
||||
/** @brief prototype for EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL */
|
||||
typedef struct _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief The Reset() function resets the text output device hardware. The
|
||||
* cursor position is set to (0, 0), and the screen is cleared to the
|
||||
* default background color for the output device.
|
||||
*
|
||||
* As part of initialization process, the firmware/device will make a
|
||||
* quick but reasonable attempt to verify that the device is functioning.
|
||||
* If the ExtendedVerification flag is TRUE the firmware may take an
|
||||
* extended amount of time to verify the device is operating on reset.
|
||||
* Otherwise the reset operation is to occur as quickly as possible.
|
||||
*
|
||||
* The hardware verification process is not defined by this specification
|
||||
* and is left up to the platform firmware or driver to implement.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
|
||||
* @param ExtendedVerification Indicates that the driver may perform a more
|
||||
* exhaustive verification operation of the device during reset.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_TEXT_RESET)(
|
||||
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN BOOLEAN ExtendedVerification);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Writes a string to the output device.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
|
||||
* @param String The Null-terminated string to be displayed on the output
|
||||
* device(s). All output devices must also support the Unicode drawing
|
||||
* character codes defined in “Related Definitions.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_TEXT_STRING)(
|
||||
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN CHAR16 *String);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Verifies that all characters in a string can be output to the
|
||||
* target device.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
|
||||
* @param String The Null-terminated string to be examined for the output
|
||||
* device(s).
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_TEXT_TEST_STRING)(
|
||||
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN CHAR16 *String);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Returns information for an available text mode that the output
|
||||
* device(s) supports.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
|
||||
* @param ModeNumber The mode number to return information on.
|
||||
* @param Columns Returns the geometry of the text output device for the
|
||||
* request ModeNumber.
|
||||
* @param Rows Returns the geometry of the text output device for the
|
||||
* request ModeNumber.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_TEXT_QUERY_MODE)(
|
||||
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
|
||||
IN UINTN ModeNumber,
|
||||
OUT UINTN *Columns,
|
||||
OUT UINTN *Rows);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Sets the output device(s) to a specified mode.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
|
||||
* @param ModeNumber The text mode to set.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS (*EFIAPI EFI_TEXT_SET_MODE)(
|
||||
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN UINTN ModeNumber);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Sets the background and foreground colors for theOutputString()
|
||||
* and ClearScreen() functions.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
|
||||
* @param Attribute The attribute to set. Bits 0..3 are the foreground color,
|
||||
* and bits 4..6 are the background color. All other bits are reserved.
|
||||
* See “Related Definitions” below.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_TEXT_SET_ATTRIBUTE)(
|
||||
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN UINTN Attribute);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Clears the output device(s) display to the currently selected
|
||||
* background color.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_TEXT_CLEAR_SCREEN)(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Sets the current coordinates of the cursor position.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
|
||||
* @param Column The position to set the cursor to. Must greater than or
|
||||
* equal to zero and less than the number of columns and rows returned
|
||||
* by QueryMode().
|
||||
* @param Row The position to set the cursor to. Must greater than or
|
||||
* equal to zero and less than the number of columns and rows returned
|
||||
* by QueryMode().
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_TEXT_SET_CURSOR_POSITION)(
|
||||
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN UINTN Column, IN UINTN Row);
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Makes the cursor visible or invisible.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param This A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL instance.
|
||||
* @param Visible If TRUE, the cursor is set to be visible. If FALSE, the
|
||||
* cursor is set to be invisible.
|
||||
* @return Returns an EFI_STATUS
|
||||
*/
|
||||
typedef EFI_STATUS(EFIAPI *EFI_TEXT_ENABLE_CURSOR)(
|
||||
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN BOOLEAN Visible);
|
||||
|
||||
/**
|
||||
* @struct EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef struct _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
|
||||
{
|
||||
/**
|
||||
* @brief Reset the ConsoleOut device. See Reset().
|
||||
*/
|
||||
EFI_TEXT_RESET Reset;
|
||||
|
||||
/**
|
||||
* @brief Displays the string on the device at the current cursor location.
|
||||
* See OutputString().
|
||||
*/
|
||||
EFI_TEXT_STRING OutputString;
|
||||
|
||||
/**
|
||||
* @brief Tests to see if the ConsoleOut device supports this string. See
|
||||
* TestString().
|
||||
*/
|
||||
EFI_TEXT_TEST_STRING TestString;
|
||||
|
||||
/**
|
||||
* @brief Queries information concerning the output device’s supported text
|
||||
* mode. See QueryMode().
|
||||
*/
|
||||
EFI_TEXT_QUERY_MODE QueryMode;
|
||||
|
||||
/**
|
||||
* @brief Sets the current mode of the output device. See SetMode().
|
||||
*/
|
||||
EFI_TEXT_SET_MODE SetMode;
|
||||
|
||||
/**
|
||||
* @brief Sets the foreground and background color of the text that is
|
||||
* output. See SetAttribute().
|
||||
*/
|
||||
EFI_TEXT_SET_ATTRIBUTE SetAttribute;
|
||||
|
||||
/**
|
||||
* @brief Clears the screen with the currently set background color. See
|
||||
* ClearScreen().
|
||||
*/
|
||||
EFI_TEXT_CLEAR_SCREEN ClearScreen;
|
||||
|
||||
/**
|
||||
* @brief Sets the current cursor position. See SetCursorPosition().
|
||||
*/
|
||||
EFI_TEXT_SET_CURSOR_POSITION SetCursorPosition;
|
||||
|
||||
/**
|
||||
* @brief Turns the visibility of the cursor on/off. See EnableCursor().
|
||||
*/
|
||||
EFI_TEXT_ENABLE_CURSOR EnableCursor;
|
||||
|
||||
/**
|
||||
* @brief Pointer to SIMPLE_TEXT_OUTPUT_MODE data.
|
||||
*/
|
||||
SIMPLE_TEXT_OUTPUT_MODE *Mode;
|
||||
|
||||
} EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;
|
||||
|
||||
#endif
|
||||
259
loader/efi/include/efi/efi_status.h
Normal file
259
loader/efi/include/efi/efi_status.h
Normal file
|
|
@ -0,0 +1,259 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_STATUS_CODES_H
|
||||
#define EFI_STATUS_CODES_H
|
||||
|
||||
#include "efi_types.h"
|
||||
|
||||
/** @brief Status code. Type UINTN. */
|
||||
typedef UINTN EFI_STATUS;
|
||||
|
||||
/** used to construct an error code */
|
||||
#define EFIERR(a) (((EFI_STATUS)0x8000000000000000) | ((EFI_STATUS)a))
|
||||
/** used to construct a warning code */
|
||||
#define EFIWRN(a) ((EFI_STATUS)a)
|
||||
|
||||
/**
|
||||
* @brief The operation completed successfully.
|
||||
*/
|
||||
#define EFI_SUCCESS ((EFI_STATUS)0)
|
||||
|
||||
/**
|
||||
* @brief The image failed to load.
|
||||
*/
|
||||
#define EFI_LOAD_ERROR EFIERR(1)
|
||||
|
||||
/**
|
||||
* @brief A parameter was incorrect.
|
||||
*/
|
||||
#define EFI_INVALID_PARAMETER EFIERR(2)
|
||||
|
||||
/**
|
||||
* @brief The operation is not supported.
|
||||
*/
|
||||
#define EFI_UNSUPPORTED EFIERR(3)
|
||||
|
||||
/**
|
||||
* @brief The buffer was not the proper size for the request.
|
||||
*/
|
||||
#define EFI_BAD_BUFFER_SIZE EFIERR(4)
|
||||
|
||||
/**
|
||||
* @brief The buffer is not large enough to hold the requested data. The
|
||||
* required buffer size is returned in the appropriate parameter when this
|
||||
* error occurs.
|
||||
*/
|
||||
#define EFI_BUFFER_TOO_SMALL EFIERR(5)
|
||||
|
||||
/**
|
||||
* @brief There is no data pending upon return.
|
||||
*/
|
||||
#define EFI_NOT_READY EFIERR(6)
|
||||
|
||||
/**
|
||||
* @brief The physical device reported an error while attempting the operation.
|
||||
*/
|
||||
#define EFI_DEVICE_ERROR EFIERR(7)
|
||||
|
||||
/**
|
||||
* @brief The device cannot be written to.
|
||||
*/
|
||||
#define EFI_WRITE_PROTECTED EFIERR(8)
|
||||
|
||||
/**
|
||||
* @brief A resource has run out.
|
||||
*/
|
||||
#define EFI_OUT_OF_RESOURCES EFIERR(9)
|
||||
|
||||
/**
|
||||
* @brief An inconstancy was detected on the file system causing the
|
||||
* operating to fail.
|
||||
*/
|
||||
#define EFI_VOLUME_CORRUPTED EFIERR(10)
|
||||
|
||||
/**
|
||||
* @brief There is no more space on the file system.
|
||||
*/
|
||||
#define EFI_VOLUME_FULL EFIERR(11)
|
||||
|
||||
/**
|
||||
* @brief The device does not contain any medium to perform the operation.
|
||||
*/
|
||||
#define EFI_NO_MEDIA EFIERR(12)
|
||||
|
||||
/**
|
||||
* @brief The medium in the device has changed since the last access.
|
||||
*/
|
||||
#define EFI_MEDIA_CHANGED EFIERR(13)
|
||||
|
||||
/**
|
||||
* @brief The item was not found.
|
||||
*/
|
||||
#define EFI_NOT_FOUND EFIERR(14)
|
||||
|
||||
/**
|
||||
* @brief Access was denied.
|
||||
*/
|
||||
#define EFI_ACCESS_DENIED EFIERR(15)
|
||||
|
||||
/**
|
||||
* @brief The server was not found or did not respond to the request.
|
||||
*/
|
||||
#define EFI_NO_RESPONSE EFIERR(16)
|
||||
|
||||
/**
|
||||
* @brief A mapping to a device does not exist.
|
||||
*/
|
||||
#define EFI_NO_MAPPING EFIERR(17)
|
||||
|
||||
/**
|
||||
* @brief The timeout time expired.
|
||||
*/
|
||||
#define EFI_TIMEOUT EFIERR(18)
|
||||
|
||||
/**
|
||||
* @brief The protocol has not been started.
|
||||
*/
|
||||
#define EFI_NOT_STARTED EFIERR(19)
|
||||
|
||||
/**
|
||||
* @brief The protocol has already been started.
|
||||
*/
|
||||
#define EFI_ALREADY_STARTED EFIERR(20)
|
||||
|
||||
/**
|
||||
* @brief The operation was aborted.
|
||||
*/
|
||||
#define EFI_ABORTED EFIERR(21)
|
||||
|
||||
/**
|
||||
* @brief An ICMP error occurred during the network operation.
|
||||
*/
|
||||
#define EFI_ICMP_ERROR EFIERR(22)
|
||||
|
||||
/**
|
||||
* @brief A TFTP error occurred during the network operation.
|
||||
*/
|
||||
#define EFI_TFTP_ERROR EFIERR(23)
|
||||
|
||||
/**
|
||||
* @brief A protocol error occurred during the network operation.
|
||||
*/
|
||||
#define EFI_PROTOCOL_ERROR EFIERR(24)
|
||||
|
||||
/**
|
||||
* @brief The function encountered an internal version that was incompatible
|
||||
* with a version requested by the caller.
|
||||
*/
|
||||
#define EFI_INCOMPATIBLE_VERSION EFIERR(25)
|
||||
|
||||
/**
|
||||
* @brief The function was not performed due to a security violation.
|
||||
*/
|
||||
#define EFI_SECURITY_VIOLATION EFIERR(26)
|
||||
|
||||
/**
|
||||
* @brief A CRC error was detected.
|
||||
*/
|
||||
#define EFI_CRC_ERROR EFIERR(27)
|
||||
|
||||
/**
|
||||
* @brief Beginning or end of media was reached
|
||||
*/
|
||||
#define EFI_END_OF_MEDIA EFIERR(28)
|
||||
|
||||
/**
|
||||
* @brief The end of the file was reached.
|
||||
*/
|
||||
#define EFI_END_OF_FILE EFIERR(31)
|
||||
|
||||
/**
|
||||
* @brief The language specified was invalid.
|
||||
*/
|
||||
#define EFI_INVALID_LANGUAGE EFIERR(32)
|
||||
|
||||
/**
|
||||
* @brief The security status of the data is unknown or compromised and the
|
||||
* data must be updated or replaced to restore a valid security status.
|
||||
*/
|
||||
#define EFI_COMPROMISED_DATA EFIERR(33)
|
||||
|
||||
/**
|
||||
* @brief There is an address conflict address allocation
|
||||
*/
|
||||
#define EFI_IP_ADDRESS_CONFLICT EFIERR(34)
|
||||
|
||||
/**
|
||||
* @brief A HTTP error occurred during the network operation.
|
||||
*/
|
||||
#define EFI_HTTP_ERROR EFIERR(35)
|
||||
|
||||
/**
|
||||
* @brief The string contained one or more characters that the device could
|
||||
* not render and were skipped.
|
||||
*/
|
||||
#define EFI_WARN_UNKNOWN_GLYPH EFIWRN(1)
|
||||
|
||||
/**
|
||||
* @brief The handle was closed, but the file was not deleted.
|
||||
*/
|
||||
#define EFI_WARN_DELETE_FAILURE EFIWRN(2)
|
||||
|
||||
/**
|
||||
* @brief The handle was closed, but the data to the file was not flushed
|
||||
* properly.
|
||||
*/
|
||||
#define EFI_WARN_WRITE_FAILURE EFIWRN(3)
|
||||
|
||||
/**
|
||||
* @brief The resulting buffer was too small, and the data was truncated
|
||||
* to the buffer size.
|
||||
*/
|
||||
#define EFI_WARN_BUFFER_TOO_SMALL EFIWRN(4)
|
||||
|
||||
/**
|
||||
* @brief The data has not been updated within the timeframe set by local
|
||||
* policy for this type of data
|
||||
*/
|
||||
#define EFI_WARN_STALE_DATA EFIWRN(5)
|
||||
|
||||
/**
|
||||
* @brief The resulting buffer contains UEFI-compliant file system.
|
||||
*/
|
||||
#define EFI_WARN_FILE_SYSTEM EFIWRN(6)
|
||||
|
||||
/**
|
||||
* @brief The operation will be processed across a system reset.
|
||||
*/
|
||||
#define EFI_WARN_RESET_REQUIRED EFIWRN(7)
|
||||
|
||||
/**
|
||||
* @brief used to determine if a function has returned an error
|
||||
*/
|
||||
#define EFI_ERROR(a) (a != EFI_SUCCESS)
|
||||
|
||||
#endif
|
||||
162
loader/efi/include/efi/efi_system_table.h
Normal file
162
loader/efi/include/efi/efi_system_table.h
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_SYSTEM_TABLE_H
|
||||
#define EFI_SYSTEM_TABLE_H
|
||||
|
||||
#include "efi_boot_services.h"
|
||||
#include "efi_configuration_table.h"
|
||||
#include "efi_runtime_services.h"
|
||||
#include "efi_simple_text_input_protocol.h"
|
||||
#include "efi_simple_text_output_protocol.h"
|
||||
#include "efi_table_header.h"
|
||||
#include "efi_types.h"
|
||||
|
||||
/** @brief Defines EFI_SYSTEM_TABLE_SIGNATURE */
|
||||
#define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249
|
||||
/** @brief Defines EFI_2_80_SYSTEM_TABLE_REVISION */
|
||||
#define EFI_2_80_SYSTEM_TABLE_REVISION ((2 << 16) | (80))
|
||||
/** @brief Defines EFI_2_70_SYSTEM_TABLE_REVISION */
|
||||
#define EFI_2_70_SYSTEM_TABLE_REVISION ((2 << 16) | (70))
|
||||
/** @brief Defines EFI_2_60_SYSTEM_TABLE_REVISION */
|
||||
#define EFI_2_60_SYSTEM_TABLE_REVISION ((2 << 16) | (60))
|
||||
/** @brief Defines EFI_2_50_SYSTEM_TABLE_REVISION */
|
||||
#define EFI_2_50_SYSTEM_TABLE_REVISION ((2 << 16) | (50))
|
||||
/** @brief Defines EFI_2_40_SYSTEM_TABLE_REVISION */
|
||||
#define EFI_2_40_SYSTEM_TABLE_REVISION ((2 << 16) | (40))
|
||||
/** @brief Defines EFI_2_31_SYSTEM_TABLE_REVISION */
|
||||
#define EFI_2_31_SYSTEM_TABLE_REVISION ((2 << 16) | (31))
|
||||
/** @brief Defines EFI_2_30_SYSTEM_TABLE_REVISION */
|
||||
#define EFI_2_30_SYSTEM_TABLE_REVISION ((2 << 16) | (30))
|
||||
/** @brief Defines EFI_2_20_SYSTEM_TABLE_REVISION */
|
||||
#define EFI_2_20_SYSTEM_TABLE_REVISION ((2 << 16) | (20))
|
||||
/** @brief Defines EFI_2_10_SYSTEM_TABLE_REVISION */
|
||||
#define EFI_2_10_SYSTEM_TABLE_REVISION ((2 << 16) | (10))
|
||||
/** @brief Defines EFI_2_00_SYSTEM_TABLE_REVISION */
|
||||
#define EFI_2_00_SYSTEM_TABLE_REVISION ((2 << 16) | (00))
|
||||
/** @brief Defines EFI_1_10_SYSTEM_TABLE_REVISION */
|
||||
#define EFI_1_10_SYSTEM_TABLE_REVISION ((1 << 16) | (10))
|
||||
/** @brief Defines EFI_1_02_SYSTEM_TABLE_REVISION */
|
||||
#define EFI_1_02_SYSTEM_TABLE_REVISION ((1 << 16) | (02))
|
||||
/** @brief Defines EFI_SPECIFICATION_VERSION */
|
||||
#define EFI_SPECIFICATION_VERSION EFI_SYSTEM_TABLE_REVISION
|
||||
/** @brief Defines EFI_SYSTEM_TABLE_REVISION */
|
||||
#define EFI_SYSTEM_TABLE_REVISION EFI_2_8_SYSTEM_TABLE_REVISION
|
||||
|
||||
/**
|
||||
* @struct EFI_SYSTEM_TABLE
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_SYSTEM_TABLE struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/**
|
||||
* @brief The table header for the EFI System Table. This header contains
|
||||
* the EFI_SYSTEM_TABLE_SIGNATURE and EFI_SYSTEM_TABLE_REVISION values
|
||||
* along with the size of the EFI_SYSTEM_TABLE structure and a 32-bit
|
||||
* CRC to verify that the contents of the EFI System Table are valid.
|
||||
*/
|
||||
EFI_TABLE_HEADER Hdr;
|
||||
|
||||
/**
|
||||
* @brief A pointer to a null terminated string that identifies the vendor
|
||||
* that produces the system firmware for the platform.
|
||||
*/
|
||||
CHAR16 *FirmwareVendor;
|
||||
|
||||
/**
|
||||
* @brief A firmware vendor specific value that identifies the revision
|
||||
* of the system firmware for the platform.
|
||||
*/
|
||||
UINT32 FirmwareRevision;
|
||||
|
||||
/**
|
||||
* @brief The handle for the active console input device. This handle must
|
||||
* support EFI_SIMPLE_TEXT_INPUT_PROTOCOL and
|
||||
* EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.
|
||||
*/
|
||||
EFI_HANDLE ConsoleInHandle;
|
||||
|
||||
/**
|
||||
* @brief A pointer to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL interface that
|
||||
* is associated with ConsoleInHandle.
|
||||
*/
|
||||
EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
|
||||
|
||||
/**
|
||||
* @brief The handle for the active console output device. This handle
|
||||
* must support the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.
|
||||
*/
|
||||
EFI_HANDLE ConsoleOutHandle;
|
||||
|
||||
/**
|
||||
* @brief A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface that
|
||||
* is associated with ConsoleOutHandle.
|
||||
*/
|
||||
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;
|
||||
|
||||
/**
|
||||
* @brief The handle for the active standard error console device. This
|
||||
* handle must support the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.
|
||||
*/
|
||||
EFI_HANDLE StandardErrorHandle;
|
||||
|
||||
/**
|
||||
* @brief A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface that
|
||||
* is associated with StandardErrorHandle.
|
||||
*/
|
||||
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *StdErr;
|
||||
|
||||
/**
|
||||
* @brief A pointer to the EFI Runtime Services Table.
|
||||
*/
|
||||
EFI_RUNTIME_SERVICES *RuntimeServices;
|
||||
|
||||
/**
|
||||
* @brief A pointer to the EFI Boot Services Table.
|
||||
*/
|
||||
EFI_BOOT_SERVICES *BootServices;
|
||||
|
||||
/**
|
||||
* @brief The number of system configuration tables in the buffer
|
||||
* ConfigurationTable.
|
||||
*/
|
||||
UINTN NumberOfTableEntries;
|
||||
|
||||
/**
|
||||
* @brief A pointer to the system configuration tables. The number of
|
||||
* entries in the table is NumberOfTableEntries.
|
||||
*/
|
||||
EFI_CONFIGURATION_TABLE *ConfigurationTable;
|
||||
|
||||
} EFI_SYSTEM_TABLE;
|
||||
|
||||
/** @brief defines the global pointer to the EFI_SYSTEM_TABLE */
|
||||
extern EFI_SYSTEM_TABLE *g_st;
|
||||
|
||||
#endif
|
||||
89
loader/efi/include/efi/efi_table_header.h
Normal file
89
loader/efi/include/efi/efi_table_header.h
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_TABLE_HEADER_H
|
||||
#define EFI_TABLE_HEADER_H
|
||||
|
||||
#include "efi_types.h"
|
||||
|
||||
/**
|
||||
* @struct EFI_TABLE_HEADER
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_TABLE_HEADER struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/**
|
||||
* @brief A 64-bit signature that identifies the type of table that
|
||||
* follows. Unique signatures have been generated for the EFI System
|
||||
* Table, the EFI Boot Services Table, and the EFI Runtime Services
|
||||
* Table.
|
||||
*/
|
||||
UINT64 Signature;
|
||||
|
||||
/**
|
||||
* @brief The revision of the EFI Specification to which this table
|
||||
* conforms. The upper 16 bits of this field contain the major revision
|
||||
* value, and the lower 16 bits contain the minor revision value. The
|
||||
* minor revision values are binary coded decimals and are limited to
|
||||
* the range of 00..99.
|
||||
*
|
||||
* When printed or displayed UEFI spec revision is referred as (Major
|
||||
* revision).(Minor revision upper decimal).(Minor revision lower
|
||||
* decimal) or (Major revision).(Minor revision upper decimal) in case
|
||||
* Minor revision lower decimal is set to 0. For example:
|
||||
*
|
||||
* A specification with the revision value ((2<<16) | (30)) would be
|
||||
* referred as 2.3;
|
||||
*
|
||||
* A specification with the revision value ((2<<16) | (31)) would be
|
||||
* referred as 2.3.1
|
||||
*/
|
||||
UINT32 Revision;
|
||||
|
||||
/**
|
||||
* @brief The size, in bytes, of the entire table including the
|
||||
* EFI_TABLE_HEADER
|
||||
*/
|
||||
UINT32 HeaderSize;
|
||||
|
||||
/**
|
||||
* @brief The 32-bit CRC for the entire table. This value is computed by
|
||||
* setting this field to 0, and computing the 32-bit CRC for HeaderSize
|
||||
* bytes.
|
||||
*/
|
||||
UINT32 CRC32;
|
||||
|
||||
/**
|
||||
* @brief Reserved field that must be set to 0.
|
||||
*/
|
||||
UINT32 Reserved;
|
||||
|
||||
} EFI_TABLE_HEADER;
|
||||
|
||||
#endif
|
||||
113
loader/efi/include/efi/efi_time.h
Normal file
113
loader/efi/include/efi/efi_time.h
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_TIME_H
|
||||
#define EFI_TIME_H
|
||||
|
||||
/**
|
||||
* @struct EFI_TIME
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_TIME struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/**
|
||||
* @brief The current local date.
|
||||
*/
|
||||
UINT16 Year;
|
||||
|
||||
/**
|
||||
* @brief The current local date.
|
||||
*/
|
||||
UINT8 Month;
|
||||
|
||||
/**
|
||||
* @brief The current local date.
|
||||
*/
|
||||
UINT8 Day;
|
||||
|
||||
/**
|
||||
* @brief The current local time. Nanoseconds report the current
|
||||
* fraction of a second in the device. The format of the time is
|
||||
* hh:mm:ss.nnnnnnnnn. A battery backed real time clock device
|
||||
* maintains the date and time.
|
||||
*/
|
||||
UINT8 Hour;
|
||||
|
||||
/**
|
||||
* @brief The current local time. Nanoseconds report the current
|
||||
* fraction of a second in the device. The format of the time is
|
||||
* hh:mm:ss.nnnnnnnnn. A battery backed real time clock device
|
||||
* maintains the date and time.
|
||||
*/
|
||||
UINT8 Minute;
|
||||
|
||||
/**
|
||||
* @brief The current local time. Nanoseconds report the current
|
||||
* fraction of a second in the device. The format of the time is
|
||||
* hh:mm:ss.nnnnnnnnn. A battery backed real time clock device
|
||||
* maintains the date and time.
|
||||
*/
|
||||
UINT8 Second;
|
||||
|
||||
/**
|
||||
* @brief n/a
|
||||
*/
|
||||
UINT8 Pad1;
|
||||
|
||||
/**
|
||||
* @brief The current local time. Nanoseconds report the current
|
||||
* fraction of a second in the device. The format of the time is
|
||||
* hh:mm:ss.nnnnnnnnn. A battery backed real time clock device
|
||||
* maintains the date and time.
|
||||
*/
|
||||
UINT32 Nanosecond;
|
||||
|
||||
/**
|
||||
* @brief The time's offset in minutes from UTC. If the value is
|
||||
* EFI_UNSPECIFIED_TIMEZONE, then the time is interpreted as a
|
||||
* local time. The TimeZone is the number of minutes that the
|
||||
* local time is relative to UTC. To calculate the TimeZone value,
|
||||
* follow this equation: Localtime = UTC - TimeZone.
|
||||
*/
|
||||
INT16 TimeZone;
|
||||
|
||||
/**
|
||||
* @brief A bitmask containing the daylight savings time information for
|
||||
* the time.
|
||||
*/
|
||||
UINT8 Daylight;
|
||||
|
||||
/**
|
||||
* @brief n/a
|
||||
*/
|
||||
UINT8 Pad2;
|
||||
|
||||
} EFI_TIME;
|
||||
|
||||
#endif
|
||||
60
loader/efi/include/efi/efi_timer_delay.h
Normal file
60
loader/efi/include/efi/efi_timer_delay.h
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_TIMER_DELAY_H
|
||||
#define EFI_TIMER_DELAY_H
|
||||
|
||||
/**
|
||||
* @struct EFI_TIMER_DELAY
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EFI_TIMER_DELAY struct:
|
||||
* https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/**
|
||||
* @brief The event’s timer setting is to be cancelled and no timer
|
||||
* trigger is to be set. TriggerTime is ignored when canceling a timer.
|
||||
*/
|
||||
TimerCancel,
|
||||
|
||||
/**
|
||||
* @brief The event is to be signaled periodically at TriggerTime
|
||||
* intervals from the current time. This is the only timer trigger Type
|
||||
* for which the event timer does not need to be reset for each
|
||||
* notification. All other timer trigger types are “one shot.”
|
||||
*/
|
||||
TimerPeriodic,
|
||||
|
||||
/**
|
||||
* @brief The event is to be signaled in TriggerTime 100ns units.
|
||||
*/
|
||||
TimerRelative
|
||||
|
||||
} EFI_TIMER_DELAY;
|
||||
|
||||
#endif
|
||||
143
loader/efi/include/efi/efi_types.h
Normal file
143
loader/efi/include/efi/efi_types.h
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EFI_TYPES_H
|
||||
#define EFI_TYPES_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
/**
|
||||
* @brief Logical Boolean. 1-byte value containing a 0 for FALSE or a 1 for
|
||||
* TRUE. Other values are undefined.
|
||||
*/
|
||||
typedef uint8_t BOOLEAN;
|
||||
|
||||
/** @brief */
|
||||
#define FALSE ((BOOLEAN)0)
|
||||
/** @brief */
|
||||
#define TRUE ((BOOLEAN)1)
|
||||
|
||||
/**
|
||||
* @brief Signed value of native width. (4 bytes on supported 32-bit
|
||||
* processor instructions, 8 bytes on supported 64-bit processor
|
||||
* instructions, 16 bytes on supported 128-bit processor instructions)
|
||||
*/
|
||||
typedef int64_t INTN;
|
||||
|
||||
/**
|
||||
* @brief Unsigned value of native width. (4 bytes on supported 32-bit
|
||||
* processor instructions, 8 bytes on supported 64-bit processor
|
||||
* instructions, 16 bytes on supported 128-bit processor instructions)
|
||||
*/
|
||||
typedef uint64_t UINTN;
|
||||
|
||||
/** @brief 1-byte signed value. */
|
||||
typedef int8_t INT8;
|
||||
|
||||
/** @brief 1-byte unsigned value. */
|
||||
typedef uint8_t UINT8;
|
||||
|
||||
/** @brief 2-byte signed value. */
|
||||
typedef int16_t INT16;
|
||||
|
||||
/** @brief 2-byte unsigned value. */
|
||||
typedef uint16_t UINT16;
|
||||
|
||||
/** @brief 4-byte signed value. */
|
||||
typedef int32_t INT32;
|
||||
|
||||
/** @brief 4-byte unsigned value. */
|
||||
typedef uint32_t UINT32;
|
||||
|
||||
/** @brief 8-byte signed value. */
|
||||
typedef int64_t INT64;
|
||||
|
||||
/** @brief 8-byte unsigned value. */
|
||||
typedef uint64_t UINT64;
|
||||
|
||||
/** @brief 16-byte signed value. */
|
||||
/** unsupported typedef ??? INT128; */
|
||||
|
||||
/** @brief 16-byte unsigned value. */
|
||||
/** unsupported typedef ??? UINT128; */
|
||||
|
||||
/**
|
||||
* @brief 1-byte character. Unless otherwise specified, all 1-byte or ASCII
|
||||
* characters and strings are stored in 8-bit ASCII encoding format, using
|
||||
* the ISO-Latin-1 character set.
|
||||
*/
|
||||
typedef uint8_t CHAR8;
|
||||
|
||||
/**
|
||||
* @brief 2-byte Character. Unless otherwise specified all characters and
|
||||
* strings are stored in the UCS-2 encoding format as defined by Unicode
|
||||
* 2.1 and ISO/IEC 10646 standards.
|
||||
*/
|
||||
typedef uint16_t CHAR16;
|
||||
|
||||
/** @brief Undeclared type. */
|
||||
typedef void VOID;
|
||||
|
||||
/** @brief NULL type*/
|
||||
#define NULL ((VOID *)0)
|
||||
|
||||
/** @brief A collection of related interfaces. Type VOID *. */
|
||||
typedef VOID *EFI_HANDLE;
|
||||
|
||||
/** @brief Handle to an event structure. Type VOID *. */
|
||||
typedef VOID *EFI_EVENT;
|
||||
|
||||
/** @brief Logical block address. Type UINT64. */
|
||||
typedef UINT64 EFI_LBA;
|
||||
|
||||
/** @brief Task priority level. Type UINTN. */
|
||||
typedef UINTN EFI_TPL;
|
||||
|
||||
/** @brief Datum is passed to the function. */
|
||||
#define IN
|
||||
|
||||
/** @brief Datum is returned from the function. */
|
||||
#define OUT
|
||||
|
||||
/**
|
||||
* @brief Passing the datum to the function is optional, and a NULL may be
|
||||
* passed if the value is not supplied.
|
||||
*/
|
||||
#define OPTIONAL
|
||||
|
||||
/** @brief Datum is read-only. */
|
||||
#define CONST const
|
||||
|
||||
/** @brief Defines the calling convention for UEFI interfaces. */
|
||||
#define EFIAPI
|
||||
|
||||
/** @brief Defined in EFI_BOOT_SERVICES.GetMemoryMap() */
|
||||
typedef UINT64 EFI_VIRTUAL_ADDRESS;
|
||||
|
||||
/** @brief Defined in EFI_BOOT_SERVICES.AllocatePages() */
|
||||
typedef UINT64 EFI_PHYSICAL_ADDRESS;
|
||||
|
||||
#endif
|
||||
55
loader/efi/include/efi/extened_processor_information.h
Normal file
55
loader/efi/include/efi/extened_processor_information.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EXTENDED_PROCESSOR_INFORMATION_H
|
||||
#define EXTENDED_PROCESSOR_INFORMATION_H
|
||||
|
||||
#include "efi_cpu_physical_location2.h"
|
||||
|
||||
/** @brief Defined in EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo() */
|
||||
#define CPU_V2_EXTENDED_TOPOLOGY BIT24
|
||||
|
||||
/**
|
||||
* @struct EXTENDED_PROCESSOR_INFORMATION
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the layout of the EXTENDED_PROCESSOR_INFORMATION struct:
|
||||
* https://uefi.org/sites/default/files/resources/PI_Spec_1_7_A_final_May1.pdf
|
||||
*/
|
||||
typedef union
|
||||
{
|
||||
/**
|
||||
* @brief The 6-level physical location of the processor, including the
|
||||
* physical package number that identifies the cartridge, the physical
|
||||
* module number within package, the physical tile number within the
|
||||
* module, the physical die number within the tile, the physical core
|
||||
* number within package, and logical thread number within core.
|
||||
*/
|
||||
EFI_CPU_PHYSICAL_LOCATION2 Location2;
|
||||
|
||||
} EXTENDED_PROCESSOR_INFORMATION;
|
||||
|
||||
#endif
|
||||
44
loader/efi/include/types.h
Normal file
44
loader/efi/include/types.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief Returned by a loader function when a function succeeds.
|
||||
*/
|
||||
#define LOADER_SUCCESS ((int64_t)0)
|
||||
|
||||
/**
|
||||
* @brief Returned by a loader function when an error occurs. Note that
|
||||
* functions that are responsible for stopping the hypervisor, in general,
|
||||
* should never return an error.
|
||||
*/
|
||||
#define LOADER_FAILURE ((int64_t)-1)
|
||||
|
||||
#endif
|
||||
334
loader/efi/src/entry.c
Normal file
334
loader/efi/src/entry.c
Normal file
|
|
@ -0,0 +1,334 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <debug.h>
|
||||
#include <efi/efi_mp_services_protocol.h>
|
||||
#include <efi/efi_simple_file_system_protocol.h>
|
||||
#include <efi/efi_status.h>
|
||||
#include <efi/efi_system_table.h>
|
||||
#include <efi/efi_types.h>
|
||||
#include <loader_init.h>
|
||||
#include <serial_init.h>
|
||||
#include <span_t.h>
|
||||
#include <start_vmm.h>
|
||||
#include <start_vmm_args_t.h>
|
||||
|
||||
/** @brief defines the global pointer to the EFI_SYSTEM_TABLE */
|
||||
EFI_SYSTEM_TABLE *g_st = NULL;
|
||||
|
||||
/** @brief defines the global pointer to the EFI_MP_SERVICES_PROTOCOL */
|
||||
EFI_MP_SERVICES_PROTOCOL *g_mp_services_protocol = NULL;
|
||||
|
||||
/** @brief defines the global pointer to the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL */
|
||||
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *g_simple_file_system = NULL;
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Returns the size (in bytes) of the provided file
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param file_protocol the file protocol to use to get the file info
|
||||
* @param hndl a handle to the file to query
|
||||
* @param file_size where to return the resulting file size
|
||||
* @return returns EFI_SUCCESS on success, and a non-EFI_SUCCESS value on
|
||||
* failure.
|
||||
*/
|
||||
EFI_STATUS
|
||||
get_file_size(
|
||||
EFI_FILE_PROTOCOL *const file_protocol, EFI_FILE_PROTOCOL *const hndl, UINTN *const file_size)
|
||||
{
|
||||
EFI_STATUS status = EFI_SUCCESS;
|
||||
EFI_GUID efi_file_info_guid = EFI_FILE_INFO_ID;
|
||||
EFI_FILE_INFO *efi_file_info = NULL;
|
||||
UINTN efi_file_info_size = 0;
|
||||
|
||||
/**
|
||||
* NOTE:
|
||||
* - We don't know what the size of the EFI_FILE_INFO is. To get that,
|
||||
* we need to run GetInfo with the size set to 0. It will return the
|
||||
* size that we need, and then from there we have to allocate a buffer,
|
||||
* get the file size, and then free this buffer.
|
||||
*/
|
||||
|
||||
status = file_protocol->GetInfo(hndl, &efi_file_info_guid, &efi_file_info_size, NULL);
|
||||
if (status != EFI_BUFFER_TOO_SMALL) {
|
||||
bferror_x64("GetInfo failed", status);
|
||||
goto get_info_failed_size;
|
||||
}
|
||||
|
||||
status = g_st->BootServices->AllocatePool(
|
||||
EfiLoaderData, efi_file_info_size, ((VOID **)&efi_file_info));
|
||||
if (EFI_ERROR(status)) {
|
||||
bferror_x64("AllocatePool failed", status);
|
||||
goto allocate_pool_failed;
|
||||
}
|
||||
|
||||
status = file_protocol->GetInfo(hndl, &efi_file_info_guid, &efi_file_info_size, efi_file_info);
|
||||
if (EFI_ERROR(status)) {
|
||||
bferror_x64("GetInfo failed", status);
|
||||
goto get_info_failed;
|
||||
}
|
||||
|
||||
*file_size = efi_file_info->FileSize;
|
||||
|
||||
g_st->BootServices->FreePool(efi_file_info);
|
||||
return EFI_SUCCESS;
|
||||
|
||||
get_info_failed:
|
||||
g_st->BootServices->FreePool(efi_file_info);
|
||||
allocate_pool_failed:
|
||||
get_info_failed_size:
|
||||
|
||||
*file_size = 0;
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Allocates a buffer and fills the buffer with the contents of the
|
||||
* provided file.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param file_protocol the file protocol to use to get the file contents
|
||||
* @param filename the file to read
|
||||
* @param file where to store the resulting buffer containing the file
|
||||
* contents. This buffer must be freed by the caller.
|
||||
* @return returns EFI_SUCCESS on success, and a non-EFI_SUCCESS value on
|
||||
* failure.
|
||||
*/
|
||||
EFI_STATUS
|
||||
read_file(EFI_FILE_PROTOCOL *const file_protocol, CHAR16 *const filename, struct span_t *const file)
|
||||
{
|
||||
EFI_STATUS status = EFI_SUCCESS;
|
||||
EFI_FILE_PROTOCOL *hndl = NULL;
|
||||
|
||||
status = file_protocol->Open(file_protocol, &hndl, filename, EFI_FILE_MODE_READ, EFI_FILE_NONE);
|
||||
if (EFI_ERROR(status)) {
|
||||
bferror_x64("Open failed", status);
|
||||
goto open_failed;
|
||||
}
|
||||
|
||||
status = get_file_size(file_protocol, hndl, &file->size);
|
||||
if (EFI_ERROR(status)) {
|
||||
bferror_x64("get_file_size failed", status);
|
||||
goto get_file_size_failed;
|
||||
}
|
||||
|
||||
status =
|
||||
g_st->BootServices->AllocatePool(EfiRuntimeServicesData, file->size, (VOID **)&file->addr);
|
||||
if (EFI_ERROR(status)) {
|
||||
bferror_x64("AllocatePool failed", status);
|
||||
goto allocate_pool_failed;
|
||||
}
|
||||
|
||||
status = file_protocol->Read(hndl, &file->size, (VOID *)file->addr);
|
||||
if (EFI_ERROR(status)) {
|
||||
bferror_x64("Read failed", status);
|
||||
goto read_failed;
|
||||
}
|
||||
|
||||
file_protocol->Close(hndl);
|
||||
return EFI_SUCCESS;
|
||||
|
||||
read_failed:
|
||||
g_st->BootServices->FreePool((VOID *)file->addr);
|
||||
file->addr = NULL;
|
||||
file->size = ((uint64_t)0);
|
||||
allocate_pool_failed:
|
||||
get_file_size_failed:
|
||||
file_protocol->Close(hndl);
|
||||
open_failed:
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Locates all of the protocols that are needed
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @return returns EFI_SUCCESS on success, and a non-EFI_SUCCESS value on
|
||||
* failure.
|
||||
*/
|
||||
EFI_STATUS
|
||||
locate_protocols(void)
|
||||
{
|
||||
EFI_STATUS status = EFI_SUCCESS;
|
||||
EFI_GUID efi_mp_services_protocol_guid = EFI_MP_SERVICES_PROTOCOL_GUID;
|
||||
EFI_GUID efi_simple_file_system_protocol_guid = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID;
|
||||
|
||||
status = g_st->BootServices->LocateProtocol(
|
||||
&efi_mp_services_protocol_guid, NULL, (VOID **)&g_mp_services_protocol);
|
||||
if (EFI_ERROR(status)) {
|
||||
bferror_x64("LocateProtocol EFI_MP_SERVICES_PROTOCOL failed", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
status = g_st->BootServices->LocateProtocol(
|
||||
&efi_simple_file_system_protocol_guid, NULL, (VOID **)&g_simple_file_system);
|
||||
if (EFI_ERROR(status)) {
|
||||
bferror_x64("LocateProtocol EFI_SIMPLE_FILE_SYSTEM_PROTOCOL failed", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Loads the ELF images from the EFI partition and starts the VMM.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @return returns EFI_SUCCESS on success, and a non-EFI_SUCCESS value on
|
||||
* failure.
|
||||
*/
|
||||
EFI_STATUS
|
||||
load_images_and_start(void)
|
||||
{
|
||||
EFI_STATUS status = EFI_SUCCESS;
|
||||
EFI_FILE_PROTOCOL *file_protocol = NULL;
|
||||
struct start_vmm_args_t start_args = {0};
|
||||
|
||||
status = g_simple_file_system->OpenVolume(g_simple_file_system, &file_protocol);
|
||||
if (EFI_ERROR(status)) {
|
||||
bferror_x64("OpenVolume failed", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
status = read_file(file_protocol, L"bareflank_kernel", &start_args.mk_elf_file);
|
||||
if (EFI_ERROR(status)) {
|
||||
bferror_x64("open_kernel failed", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
status = read_file(file_protocol, L"bareflank_extension0", &(start_args.ext_elf_files[0]));
|
||||
if (EFI_ERROR(status)) {
|
||||
bferror_x64("open_extensions failed", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
start_args.ver = ((uint64_t)1);
|
||||
start_args.num_pages_in_page_pool = ((uint32_t)0);
|
||||
|
||||
if (start_vmm(&start_args)) {
|
||||
bferror("start_vmm failed");
|
||||
return EFI_LOAD_ERROR;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Defines the main EFI entry pointer
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param ImageHandle ignored
|
||||
* @param SystemTable stores a pointer to the global EFI stytem table
|
||||
* @return returns EFI_SUCCESS on success, and a non-EFI_SUCCESS value on
|
||||
* failure.
|
||||
*/
|
||||
EFI_STATUS
|
||||
efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
|
||||
{
|
||||
EFI_STATUS status = EFI_SUCCESS;
|
||||
|
||||
/**
|
||||
* NOTE:
|
||||
* - This function needs to be kept pretty simple as if you attempt to
|
||||
* do too much, you might cause memcpy/memset to be called prior to
|
||||
* the system table being saved.
|
||||
*/
|
||||
|
||||
g_st = SystemTable;
|
||||
if (g_st->Hdr.Revision < EFI_1_10_SYSTEM_TABLE_REVISION) {
|
||||
g_st->ConOut->OutputString(g_st->ConOut, L"EFI version not supported\r\n");
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
serial_init();
|
||||
|
||||
/**
|
||||
* TODO:
|
||||
* - Need to process the command line arguments so that we can load
|
||||
* an image that the user provides.
|
||||
* - Also need to add a CMAKE var for where to load the UEFI stuff.
|
||||
*/
|
||||
|
||||
if (loader_init()) {
|
||||
bferror("loader_init failed");
|
||||
return EFI_LOAD_ERROR;
|
||||
}
|
||||
|
||||
status = locate_protocols();
|
||||
if (EFI_ERROR(status)) {
|
||||
bferror_x64("locate_protocols failed", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
status = load_images_and_start();
|
||||
if (EFI_ERROR(status)) {
|
||||
bferror_x64("load_images_and_start failed", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
g_st->ConOut->OutputString(g_st->ConOut, L"bareflank successfully started\r\n");
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Same as std::memcpy.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param dst a pointer to the memory to copy to
|
||||
* @param src a pointer to the memory to copy from
|
||||
* @param count the total number of bytes to copy
|
||||
* @return Returns the same result as std::memcpy.
|
||||
*/
|
||||
void *
|
||||
memcpy(void *const dst, void const *const src, uint64_t const count)
|
||||
{
|
||||
g_st->BootServices->CopyMem(dst, ((VOID *)src), count);
|
||||
return dst;
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Same as std::memset.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param dst a pointer to the memory to set
|
||||
* @param ch the value to set the memory to
|
||||
* @param num the total number of bytes to set
|
||||
* @return Returns the same result as std::memset.
|
||||
*/
|
||||
void *
|
||||
memset(void *const dst, char const ch, uint64_t const num)
|
||||
{
|
||||
g_st->BootServices->SetMem(dst, num, ((UINT8)ch));
|
||||
return dst;
|
||||
}
|
||||
456
loader/efi/src/platform.c
Normal file
456
loader/efi/src/platform.c
Normal file
|
|
@ -0,0 +1,456 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "platform_on_each_cpu_callback_args.h"
|
||||
|
||||
#include <constants.h>
|
||||
#include <debug.h>
|
||||
#include <efi/efi_mp_services_protocol.h>
|
||||
#include <efi/efi_status.h>
|
||||
#include <efi/efi_system_table.h>
|
||||
#include <efi/efi_types.h>
|
||||
#include <platform.h>
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief This function allocates read/write virtual memory from the
|
||||
* kernel. This memory is not physically contiguous. The resulting
|
||||
* pointer is at least 4k aligned, so use this function sparingly
|
||||
* as it will always allocate at least one page. Use platform_free()
|
||||
* to release this memory.
|
||||
*
|
||||
* @note This function must zero the allocated memory
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param size the number of bytes to allocate
|
||||
* @return Returns a pointer to the newly allocated memory on success.
|
||||
* Returns a nullptr on failure.
|
||||
*/
|
||||
void *
|
||||
platform_alloc(uint64_t size)
|
||||
{
|
||||
EFI_STATUS status = EFI_SUCCESS;
|
||||
EFI_PHYSICAL_ADDRESS ret = ((EFI_PHYSICAL_ADDRESS)0);
|
||||
|
||||
if (((uint64_t)0) == size) {
|
||||
bferror("invalid number of bytes (i.e., size)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (((uint64_t)0) != (size & (HYPERVISOR_PAGE_SIZE - ((uint64_t)1)))) {
|
||||
size += HYPERVISOR_PAGE_SIZE;
|
||||
size &= ~(HYPERVISOR_PAGE_SIZE - ((uint64_t)1));
|
||||
}
|
||||
|
||||
status = g_st->BootServices->AllocatePages(
|
||||
AllocateAnyPages, EfiRuntimeServicesData, size / HYPERVISOR_PAGE_SIZE, &ret);
|
||||
if (EFI_ERROR(status)) {
|
||||
bferror_x64("AllocatePages failed", status);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_st->BootServices->SetMem((void *)ret, size, ((UINT8)0));
|
||||
return (void *)ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief This function allocates read/write virtual memory from the
|
||||
* kernel. This memory is physically contiguous. The resulting
|
||||
* pointer is at least 4k aligned, so use this function sparingly
|
||||
* as it will always allocate at least one page. Use
|
||||
* platform_free_contiguous() to release this memory.
|
||||
*
|
||||
* @note This function must zero the allocated memory
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param size the number of bytes to allocate
|
||||
* @return Returns a pointer to the newly allocated memory on success.
|
||||
* Returns a nullptr on failure.
|
||||
*/
|
||||
void *
|
||||
platform_alloc_contiguous(uint64_t size)
|
||||
{
|
||||
EFI_STATUS status = EFI_SUCCESS;
|
||||
EFI_PHYSICAL_ADDRESS ret = ((EFI_PHYSICAL_ADDRESS)0);
|
||||
|
||||
if (((uint64_t)0) == size) {
|
||||
bferror("invalid number of bytes (i.e., size)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (((uint64_t)0) != (size & (HYPERVISOR_PAGE_SIZE - ((uint64_t)1)))) {
|
||||
size += HYPERVISOR_PAGE_SIZE;
|
||||
size &= ~(HYPERVISOR_PAGE_SIZE - ((uint64_t)1));
|
||||
}
|
||||
|
||||
status = g_st->BootServices->AllocatePages(
|
||||
AllocateAnyPages, EfiRuntimeServicesData, size / HYPERVISOR_PAGE_SIZE, &ret);
|
||||
if (EFI_ERROR(status)) {
|
||||
bferror_x64("AllocatePages failed", status);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_st->BootServices->SetMem((void *)ret, size, ((UINT8)0));
|
||||
return (void *)ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief This function frees memory previously allocated using the
|
||||
* platform_alloc() function.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param ptr the pointer returned by platform_alloc(). If ptr is
|
||||
* passed a nullptr, it will be ignored. Attempting to free memory
|
||||
* more than once results in UB.
|
||||
* @param size the number of bytes that were allocated. Note that this
|
||||
* may or may not be ignored depending on the platform.
|
||||
*/
|
||||
void
|
||||
platform_free(void const *const ptr, uint64_t const size)
|
||||
{
|
||||
(void)size;
|
||||
|
||||
if (NULL != ptr) {
|
||||
g_st->BootServices->FreePool((VOID *)ptr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief This function frees memory previously allocated using the
|
||||
* platform_alloc_contiguous() function.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param ptr the pointer returned by platform_alloc_contiguous(). If ptr is
|
||||
* passed a nullptr, it will be ignored. Attempting to free memory
|
||||
* more than once results in UB.
|
||||
* @param size the number of bytes that were allocated. Note that this
|
||||
* may or may not be ignored depending on the platform.
|
||||
*/
|
||||
void
|
||||
platform_free_contiguous(void const *const ptr, uint64_t const size)
|
||||
{
|
||||
(void)size;
|
||||
|
||||
if (NULL != ptr) {
|
||||
g_st->BootServices->FreePool((VOID *)ptr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Given a virtual address, this function returns the virtual
|
||||
* address's physical address. Returns NULL if the conversion failed.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param virt the virtual address to convert to a physical address
|
||||
* @return Given a virtual address, this function returns the virtual
|
||||
* address's physical address. Returns NULL if the conversion failed.
|
||||
*/
|
||||
uintptr_t
|
||||
platform_virt_to_phys(void const *const virt)
|
||||
{
|
||||
return (uintptr_t)virt;
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Sets "num" bytes in the memory pointed to by "ptr" to "val".
|
||||
* If the provided parameters are valid, returns 0, otherwise
|
||||
* returns LOADER_FAILURE.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param ptr a pointer to the memory to set
|
||||
* @param val the value to set each byte to
|
||||
* @param num the number of bytes in "ptr" to set to "val".
|
||||
* @return If the provided parameters are valid, returns 0, otherwise
|
||||
* returns LOADER_FAILURE.
|
||||
*/
|
||||
int64_t
|
||||
platform_memset(void *const ptr, uint8_t const val, uint64_t const num)
|
||||
{
|
||||
if (!ptr) {
|
||||
bferror("invalid ptr");
|
||||
return LOADER_FAILURE;
|
||||
}
|
||||
|
||||
g_st->BootServices->SetMem(ptr, num, val);
|
||||
return LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Copies "num" bytes from "src" to "dst". If "src" or "dst" are
|
||||
* NULL, returns LOADER_FAILURE, otherwise returns 0.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param dst a pointer to the memory to copy to
|
||||
* @param src a pointer to the memory to copy from
|
||||
* @param num the number of bytes to copy
|
||||
* @return If "src" or "dst" are NULL, returns LOADER_FAILURE, otherwise
|
||||
* returns 0.
|
||||
*/
|
||||
int64_t
|
||||
platform_memcpy(void *const dst, void const *const src, uint64_t const num)
|
||||
{
|
||||
if (NULL == dst) {
|
||||
bferror("invalid pointer");
|
||||
return LOADER_FAILURE;
|
||||
}
|
||||
|
||||
if (NULL == src) {
|
||||
bferror("invalid pointer");
|
||||
return LOADER_FAILURE;
|
||||
}
|
||||
|
||||
g_st->BootServices->CopyMem(dst, ((VOID *)src), num);
|
||||
return LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Copies "num" bytes from "src" to "dst". If "src" or "dst" are
|
||||
* NULL, returns FAILURE, otherwise returns 0. Note that this function can
|
||||
* be used to copy memory from userspace via an IOCTL.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param dst a pointer to the memory to copy to
|
||||
* @param src a pointer to the memory to copy from
|
||||
* @param num the number of bytes to copy
|
||||
* @return If "src" or "dst" are NULL, returns FAILURE, otherwise
|
||||
* returns 0.
|
||||
*/
|
||||
int64_t
|
||||
platform_copy_from_user(void *const dst, void const *const src, uint64_t const num)
|
||||
{
|
||||
if (NULL == dst) {
|
||||
bferror("invalid pointer");
|
||||
return LOADER_FAILURE;
|
||||
}
|
||||
|
||||
if (NULL == src) {
|
||||
bferror("invalid pointer");
|
||||
return LOADER_FAILURE;
|
||||
}
|
||||
|
||||
g_st->BootServices->CopyMem(dst, ((VOID *)src), num);
|
||||
return LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Copies "num" bytes from "src" to "dst". If "src" or "dst" are
|
||||
* NULL, returns FAILURE, otherwise returns 0. Note that this function can
|
||||
* be used to copy memory to userspace via an IOCTL.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param dst a pointer to the memory to copy to
|
||||
* @param src a pointer to the memory to copy from
|
||||
* @param num the number of bytes to copy
|
||||
* @return If "src" or "dst" are NULL, returns FAILURE, otherwise
|
||||
* returns 0.
|
||||
*/
|
||||
int64_t
|
||||
platform_copy_to_user(void *const dst, void const *const src, uint64_t const num)
|
||||
{
|
||||
if (NULL == dst) {
|
||||
bferror("invalid pointer");
|
||||
return LOADER_FAILURE;
|
||||
}
|
||||
|
||||
if (NULL == src) {
|
||||
bferror("invalid pointer");
|
||||
return LOADER_FAILURE;
|
||||
}
|
||||
|
||||
g_st->BootServices->CopyMem(dst, ((VOID *)src), num);
|
||||
return LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Returns the total number of online CPUs (i.e. PPs)
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @return Returns the total number of online CPUs (i.e. PPs)
|
||||
*/
|
||||
uint32_t
|
||||
platform_num_online_cpus(void)
|
||||
{
|
||||
EFI_STATUS status = EFI_SUCCESS;
|
||||
UINTN NumberOfProcessors;
|
||||
UINTN NumberOfEnabledProcessors;
|
||||
|
||||
status = g_mp_services_protocol->GetNumberOfProcessors(
|
||||
g_mp_services_protocol, &NumberOfProcessors, &NumberOfEnabledProcessors);
|
||||
if (EFI_ERROR(status)) {
|
||||
bferror_x64("GetNumberOfProcessors failed", status);
|
||||
return ((uint32_t)0);
|
||||
}
|
||||
|
||||
return (uint32_t)NumberOfProcessors;
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief This function is called when the user calls platform_on_each_cpu.
|
||||
* On each iteration of the CPU, this function calls the user provided
|
||||
* callback with the signature that we perfer, providing us with a way
|
||||
* to be compatable with Linux.
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param dummy ignored
|
||||
*/
|
||||
static void
|
||||
platform_on_each_cpu_callback(void *const ProcedureArgument)
|
||||
{
|
||||
struct platform_on_each_cpu_callback_args *args =
|
||||
((struct platform_on_each_cpu_callback_args *)ProcedureArgument);
|
||||
|
||||
args->ret = args->func(args->cpu);
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Calls the user provided callback on each CPU in forward order.
|
||||
* If each callback returns 0, this function returns 0, otherwise this
|
||||
* function returns a non-0 value, even if all callbacks succeed except
|
||||
* for one. If an error occurs, it is possible that this function will
|
||||
* continue to execute the remaining callbacks until all callbacks have
|
||||
* been called (depends on the platform).
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param func the function to call on each cpu
|
||||
* @return If each callback returns 0, this function returns 0, otherwise
|
||||
* this function returns a non-0 value
|
||||
*/
|
||||
static int64_t
|
||||
platform_on_each_cpu_forward(platform_per_cpu_func const func)
|
||||
{
|
||||
EFI_STATUS status = EFI_SUCCESS;
|
||||
uint32_t cpu;
|
||||
|
||||
for (cpu = 0; cpu < platform_num_online_cpus(); ++cpu) {
|
||||
if (cpu == 0U) {
|
||||
if (func(cpu)) {
|
||||
bferror("platform_per_cpu_func failed");
|
||||
return LOADER_FAILURE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
struct platform_on_each_cpu_callback_args args = {func, cpu, 0};
|
||||
|
||||
status = g_mp_services_protocol->StartupThisAP(
|
||||
g_mp_services_protocol, platform_on_each_cpu_callback, cpu, NULL, 0, &args, NULL);
|
||||
if (args.ret) {
|
||||
bferror("platform_per_cpu_func failed");
|
||||
return LOADER_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Calls the user provided callback on each CPU in reverse order.
|
||||
* If each callback returns 0, this function returns 0, otherwise this
|
||||
* function returns a non-0 value, even if all callbacks succeed except
|
||||
* for one. If an error occurs, it is possible that this function will
|
||||
* continue to execute the remaining callbacks until all callbacks have
|
||||
* been called (depends on the platform).
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param func the function to call on each cpu
|
||||
* @return If each callback returns 0, this function returns 0, otherwise
|
||||
* this function returns a non-0 value
|
||||
*/
|
||||
static int64_t
|
||||
platform_on_each_cpu_reverse(platform_per_cpu_func const func)
|
||||
{
|
||||
EFI_STATUS status = EFI_SUCCESS;
|
||||
uint32_t cpu;
|
||||
|
||||
for (cpu = platform_num_online_cpus(); cpu > 0U; --cpu) {
|
||||
if ((cpu - 1U) == 0U) {
|
||||
if (func(cpu - 1U)) {
|
||||
bferror("platform_per_cpu_func failed");
|
||||
return LOADER_FAILURE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
struct platform_on_each_cpu_callback_args args = {func, cpu - 1U, 0};
|
||||
|
||||
status = g_mp_services_protocol->StartupThisAP(
|
||||
g_mp_services_protocol,
|
||||
platform_on_each_cpu_callback,
|
||||
cpu - 1U,
|
||||
NULL,
|
||||
0,
|
||||
&args,
|
||||
NULL);
|
||||
if (args.ret) {
|
||||
bferror("platform_per_cpu_func failed");
|
||||
return LOADER_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- description -->
|
||||
* @brief Calls the user provided callback on each CPU. If each callback
|
||||
* returns 0, this function returns 0, otherwise this function returns
|
||||
* a non-0 value, even if all callbacks succeed except for one. If an
|
||||
* error occurs, it is possible that this function will continue to
|
||||
* execute the remaining callbacks until all callbacks have been called
|
||||
* (depends on the platform).
|
||||
*
|
||||
* <!-- inputs/outputs -->
|
||||
* @param func the function to call on each cpu
|
||||
* @param order sets the order the CPUs are called
|
||||
* @return If each callback returns 0, this function returns 0, otherwise
|
||||
* this function returns a non-0 value
|
||||
*/
|
||||
int64_t
|
||||
platform_on_each_cpu(platform_per_cpu_func const func, uint32_t const order)
|
||||
{
|
||||
int64_t ret;
|
||||
|
||||
if (PLATFORM_FORWARD == order) {
|
||||
ret = platform_on_each_cpu_forward(func);
|
||||
}
|
||||
else {
|
||||
ret = platform_on_each_cpu_reverse(func);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
58
loader/efi/src/platform_on_each_cpu_callback_args.h
Normal file
58
loader/efi/src/platform_on_each_cpu_callback_args.h
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef PLATFORM_ON_EACH_CPU_CALLBACK_ARGS_H
|
||||
#define PLATFORM_ON_EACH_CPU_CALLBACK_ARGS_H
|
||||
|
||||
#include <platform.h>
|
||||
#include <types.h>
|
||||
|
||||
/**
|
||||
* @struct platform_on_each_cpu_callback_args
|
||||
*
|
||||
* <!-- description -->
|
||||
* @brief Defines the args passed to the platform_on_each_cpu_callback
|
||||
* function.
|
||||
*/
|
||||
struct platform_on_each_cpu_callback_args
|
||||
{
|
||||
/**
|
||||
* @brief The fucntion to call from platform_on_each_cpu_callback
|
||||
*/
|
||||
platform_per_cpu_func func;
|
||||
|
||||
/**
|
||||
* @brief The CPU platform_on_each_cpu_callback is called on
|
||||
*/
|
||||
uint32_t cpu;
|
||||
|
||||
/**
|
||||
* @brief The return value of 'func'
|
||||
*/
|
||||
int64_t ret;
|
||||
};
|
||||
|
||||
#endif
|
||||
35
loader/efi/src/x64/amd/disable_interrupts.S
Normal file
35
loader/efi/src/x64/amd/disable_interrupts.S
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl disable_interrupts
|
||||
disable_interrupts:
|
||||
|
||||
clgi
|
||||
ret
|
||||
int 3
|
||||
35
loader/efi/src/x64/amd/enable_interrupts.S
Normal file
35
loader/efi/src/x64/amd/enable_interrupts.S
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl enable_interrupts
|
||||
enable_interrupts:
|
||||
|
||||
stgi
|
||||
ret
|
||||
int 3
|
||||
306
loader/efi/src/x64/demote.S
Normal file
306
loader/efi/src/x64/demote.S
Normal file
|
|
@ -0,0 +1,306 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl demote
|
||||
.align 0x1000
|
||||
demote:
|
||||
|
||||
/**************************************************************************/
|
||||
/* General Purpose Registers */
|
||||
/**************************************************************************/
|
||||
|
||||
mov [r8 + 0x000], rax
|
||||
mov [r8 + 0x008], rbx
|
||||
mov [r8 + 0x010], rcx
|
||||
mov [r8 + 0x018], rdx
|
||||
mov [r8 + 0x020], rbp
|
||||
mov [r8 + 0x028], rsi
|
||||
mov [r8 + 0x030], rdi
|
||||
mov [r8 + 0x038], r8
|
||||
mov [r8 + 0x040], r9
|
||||
mov [r8 + 0x048], r10
|
||||
mov [r8 + 0x050], r11
|
||||
mov [r8 + 0x058], r12
|
||||
mov [r8 + 0x060], r13
|
||||
mov [r8 + 0x068], r14
|
||||
mov [r8 + 0x070], r15
|
||||
|
||||
lea rax, [rip + demotion_success]
|
||||
mov [r8 + 0x078], rax
|
||||
mov [r8 + 0x080], rsp
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* Setup */
|
||||
/**************************************************************************/
|
||||
|
||||
mov r13, rcx /* args */
|
||||
mov r14, rdx /* mk_state */
|
||||
mov r15, r8 /* root_vp_state */
|
||||
|
||||
/**************************************************************************/
|
||||
/* Flags */
|
||||
/**************************************************************************/
|
||||
|
||||
pushf
|
||||
pop qword ptr[r15 + 0x088]
|
||||
push [r14 + 0x088]
|
||||
popf
|
||||
|
||||
/**************************************************************************/
|
||||
/* IDT */
|
||||
/**************************************************************************/
|
||||
|
||||
call disable_interrupts
|
||||
|
||||
sidt [r15 + 0x0B0]
|
||||
lidt [r14 + 0x0B0]
|
||||
|
||||
/**************************************************************************/
|
||||
/* MSRs */
|
||||
/**************************************************************************/
|
||||
|
||||
mov ecx, 0xC0000080 /* EFER */
|
||||
rdmsr
|
||||
mov [r15 + 0x240], eax
|
||||
mov [r15 + 0x244], edx
|
||||
mov eax, [r14 + 0x240]
|
||||
mov edx, [r14 + 0x244]
|
||||
wrmsr
|
||||
|
||||
mov ecx, 0xC0000081 /* STAR */
|
||||
rdmsr
|
||||
mov [r15 + 0x248], eax
|
||||
mov [r15 + 0x24C], edx
|
||||
mov eax, [r14 + 0x248]
|
||||
mov edx, [r14 + 0x24C]
|
||||
wrmsr
|
||||
|
||||
mov ecx, 0xC0000082 /* LSTAR */
|
||||
rdmsr
|
||||
mov [r15 + 0x250], eax
|
||||
mov [r15 + 0x254], edx
|
||||
mov eax, [r14 + 0x250]
|
||||
mov edx, [r14 + 0x254]
|
||||
wrmsr
|
||||
|
||||
mov ecx, 0xC0000083 /* CSTAR */
|
||||
rdmsr
|
||||
mov [r15 + 0x258], eax
|
||||
mov [r15 + 0x25C], edx
|
||||
mov eax, [r14 + 0x258]
|
||||
mov edx, [r14 + 0x25C]
|
||||
wrmsr
|
||||
|
||||
mov ecx, 0xC0000084 /* FMASK */
|
||||
rdmsr
|
||||
mov [r15 + 0x260], eax
|
||||
mov [r15 + 0x264], edx
|
||||
mov eax, [r14 + 0x260]
|
||||
mov edx, [r14 + 0x264]
|
||||
wrmsr
|
||||
|
||||
mov ecx, 0xC0000100 /* FS Base */
|
||||
rdmsr
|
||||
mov [r15 + 0x268], eax
|
||||
mov [r15 + 0x26C], edx
|
||||
mov eax, [r14 + 0x268]
|
||||
mov edx, [r14 + 0x26C]
|
||||
wrmsr
|
||||
|
||||
mov ecx, 0xC0000101 /* GS Base */
|
||||
rdmsr
|
||||
mov [r15 + 0x270], eax
|
||||
mov [r15 + 0x274], edx
|
||||
mov eax, [r14 + 0x270]
|
||||
mov edx, [r14 + 0x274]
|
||||
wrmsr
|
||||
|
||||
mov ecx, 0xC0000102 /* Kernel GS Base */
|
||||
rdmsr
|
||||
mov [r15 + 0x278], eax
|
||||
mov [r15 + 0x27C], edx
|
||||
mov eax, [r14 + 0x278]
|
||||
mov edx, [r14 + 0x27C]
|
||||
wrmsr
|
||||
|
||||
mov ecx, 0x00000174 /* SYSENTER_CS */
|
||||
rdmsr
|
||||
mov [r15 + 0x280], eax
|
||||
mov [r15 + 0x284], edx
|
||||
mov eax, [r14 + 0x280]
|
||||
mov edx, [r14 + 0x284]
|
||||
wrmsr
|
||||
|
||||
mov ecx, 0x00000175 /* SYSENTER_ESP */
|
||||
rdmsr
|
||||
mov [r15 + 0x288], eax
|
||||
mov [r15 + 0x28C], edx
|
||||
mov eax, [r14 + 0x288]
|
||||
mov edx, [r14 + 0x28C]
|
||||
wrmsr
|
||||
|
||||
mov ecx, 0x00000176 /* SYSENTER_EIP */
|
||||
rdmsr
|
||||
mov [r15 + 0x290], eax
|
||||
mov [r15 + 0x294], edx
|
||||
mov eax, [r14 + 0x290]
|
||||
mov edx, [r14 + 0x294]
|
||||
wrmsr
|
||||
|
||||
mov ecx, 0x00000277 /* PAT */
|
||||
rdmsr
|
||||
mov [r15 + 0x298], eax
|
||||
mov [r15 + 0x29C], edx
|
||||
mov eax, [r14 + 0x298]
|
||||
mov edx, [r14 + 0x29C]
|
||||
wrmsr
|
||||
|
||||
mov ecx, 0x000001D9 /* DEBUGCTL */
|
||||
rdmsr
|
||||
mov [r15 + 0x2A0], eax
|
||||
mov [r15 + 0x2A4], edx
|
||||
mov eax, [r14 + 0x2A0]
|
||||
mov edx, [r14 + 0x2A4]
|
||||
wrmsr
|
||||
|
||||
/**************************************************************************/
|
||||
/* GDT */
|
||||
/*************************************************************************/
|
||||
|
||||
sgdt qword ptr [r15 + 0x0A0]
|
||||
lgdt qword ptr [r14 + 0x0A0]
|
||||
|
||||
mov dx, es
|
||||
mov [r15 + 0x0C0], dx
|
||||
mov dx, [r14 + 0x0C0]
|
||||
mov es, dx
|
||||
|
||||
mov dx, cs
|
||||
mov [r15 + 0x0D0], dx
|
||||
mov ax, [r14 + 0x0D0]
|
||||
push rax
|
||||
|
||||
mov dx, ss
|
||||
mov [r15 + 0x0E0], dx
|
||||
mov dx, [r14 + 0x0E0]
|
||||
mov ss, dx
|
||||
|
||||
mov dx, ds
|
||||
mov [r15 + 0x0F0], dx
|
||||
mov dx, [r14 + 0x0F0]
|
||||
mov ds, dx
|
||||
|
||||
mov dx, fs
|
||||
mov [r15 + 0x100], dx
|
||||
mov dx, [r14 + 0x100]
|
||||
mov fs, dx
|
||||
|
||||
mov dx, gs
|
||||
mov [r15 + 0x110], dx
|
||||
mov dx, [r14 + 0x110]
|
||||
mov gs, dx
|
||||
|
||||
mov ecx, 0x000001D9
|
||||
xor rax, rax
|
||||
xor rdx, rdx
|
||||
mov ax, [r14 + 0x110]
|
||||
wrmsr
|
||||
|
||||
sldt dx
|
||||
mov [r15 + 0x120], dx
|
||||
mov dx, [r14 + 0x120]
|
||||
lldt dx
|
||||
|
||||
str dx
|
||||
mov [r15 + 0x130], dx
|
||||
mov dx, [r14 + 0x130]
|
||||
ltr dx
|
||||
|
||||
lea rax, [rip + gdt_and_cs_loaded]
|
||||
push rax
|
||||
|
||||
retfq
|
||||
|
||||
gdt_and_cs_loaded:
|
||||
|
||||
/**************************************************************************/
|
||||
/* Control Registers */
|
||||
/**************************************************************************/
|
||||
|
||||
mov rax, cr0
|
||||
mov [r15 + 0x140], rax
|
||||
mov rax, [r14 + 0x140]
|
||||
mov cr0, rax
|
||||
|
||||
mov rax, cr2
|
||||
mov [r15 + 0x150], rax
|
||||
mov rax, [r14 + 0x150]
|
||||
mov cr2, rax
|
||||
|
||||
mov rax, cr4
|
||||
mov [r15 + 0x160], rax
|
||||
mov rax, [r14 + 0x160]
|
||||
mov cr4, rax
|
||||
|
||||
mov rax, cr3
|
||||
mov [r15 + 0x158], rax
|
||||
mov rax, [r14 + 0x158]
|
||||
mov cr3, rax
|
||||
|
||||
mov rsp, [r14 + 0x080]
|
||||
|
||||
/**************************************************************************/
|
||||
/* Debug Registers */
|
||||
/**************************************************************************/
|
||||
|
||||
mov rax, dr6
|
||||
mov [r15 + 0x1F0], rax
|
||||
mov rax, [r14 + 0x1F0]
|
||||
mov dr6, rax
|
||||
|
||||
mov rax, dr7
|
||||
mov [r15 + 0x1F8], rax
|
||||
mov rax, [r14 + 0x1F8]
|
||||
mov dr7, rax
|
||||
|
||||
/**************************************************************************/
|
||||
/* Call Microkernel */
|
||||
/**************************************************************************/
|
||||
|
||||
mov rdi, r13
|
||||
push [r14 + 0x078]
|
||||
ret
|
||||
int 3
|
||||
|
||||
demotion_success:
|
||||
|
||||
call enable_interrupts
|
||||
ret
|
||||
int 3
|
||||
50
loader/efi/src/x64/esr_default.S
Normal file
50
loader/efi/src/x64/esr_default.S
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl esr_default
|
||||
.align 0x1000
|
||||
esr_default:
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x45
|
||||
out dx, al
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x53
|
||||
out dx, al
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x52
|
||||
out dx, al
|
||||
|
||||
cli
|
||||
hlt
|
||||
|
||||
ret
|
||||
int 3
|
||||
62
loader/efi/src/x64/esr_df.S
Normal file
62
loader/efi/src/x64/esr_df.S
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl esr_df
|
||||
.align 0x1000
|
||||
esr_df:
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x45
|
||||
out dx, al
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x53
|
||||
out dx, al
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x52
|
||||
out dx, al
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x20
|
||||
out dx, al
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x44
|
||||
out dx, al
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x46
|
||||
out dx, al
|
||||
|
||||
cli
|
||||
hlt
|
||||
|
||||
ret
|
||||
int 3
|
||||
66
loader/efi/src/x64/esr_gpf.S
Normal file
66
loader/efi/src/x64/esr_gpf.S
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl esr_gpf
|
||||
.align 0x1000
|
||||
esr_gpf:
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x45
|
||||
out dx, al
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x53
|
||||
out dx, al
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x52
|
||||
out dx, al
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x20
|
||||
out dx, al
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x47
|
||||
out dx, al
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x50
|
||||
out dx, al
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x46
|
||||
out dx, al
|
||||
|
||||
cli
|
||||
hlt
|
||||
|
||||
ret
|
||||
int 3
|
||||
51
loader/efi/src/x64/esr_nmi.S
Normal file
51
loader/efi/src/x64/esr_nmi.S
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl esr_nmi
|
||||
.align 0x1000
|
||||
esr_nmi:
|
||||
|
||||
/**
|
||||
* NOTE (IMPORTANT):
|
||||
* - r15 is dedicated during the demotion process to the root_vp_state.
|
||||
* It cannot be changed from this until the kernel's actual ESRs are
|
||||
* loaded.
|
||||
*/
|
||||
|
||||
push rax
|
||||
push rdx
|
||||
|
||||
mov rax, 0x1
|
||||
mov [r15 + 0x318], rax
|
||||
|
||||
pop rdx
|
||||
pop rax
|
||||
|
||||
iretq
|
||||
int 3
|
||||
59
loader/efi/src/x64/esr_pf.S
Normal file
59
loader/efi/src/x64/esr_pf.S
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl esr_pf
|
||||
.align 0x1000
|
||||
esr_pf:
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x45
|
||||
out dx, al
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x53
|
||||
out dx, al
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x52
|
||||
out dx, al
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x20
|
||||
out dx, al
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x50
|
||||
out dx, al
|
||||
|
||||
mov rdx, 0x03F8
|
||||
mov rax, 0x46
|
||||
out dx, al
|
||||
|
||||
cli
|
||||
hlt
|
||||
35
loader/efi/src/x64/intel/disable_interrupts.S
Normal file
35
loader/efi/src/x64/intel/disable_interrupts.S
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl disable_interrupts
|
||||
disable_interrupts:
|
||||
|
||||
cli
|
||||
ret
|
||||
int 3
|
||||
35
loader/efi/src/x64/intel/enable_interrupts.S
Normal file
35
loader/efi/src/x64/intel/enable_interrupts.S
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl enable_interrupts
|
||||
enable_interrupts:
|
||||
|
||||
sti
|
||||
ret
|
||||
int 3
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
/* SPDX-License-Identifier: SPDX-License-Identifier: GPL-2.0 OR MIT */
|
||||
|
||||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
|
|
@ -26,16 +24,20 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef INTTYPES_H
|
||||
#define INTTYPES_H
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
#include "stdint.h"
|
||||
.globl intrinsic_vmxoff
|
||||
intrinsic_vmxoff:
|
||||
|
||||
#define PRId64 "lld"
|
||||
#define PRIu64 "llu"
|
||||
#define PRIx64 "llx"
|
||||
#define PRIdPTR "ld"
|
||||
#define PRIuPTR "lu"
|
||||
#define PRIxPTR "lx"
|
||||
vmxoff
|
||||
jbe intrinsic_vmxoff_failure
|
||||
|
||||
#endif
|
||||
xor rax, rax
|
||||
ret
|
||||
int 3
|
||||
|
||||
intrinsic_vmxoff_failure:
|
||||
mov rax, 0x1
|
||||
ret
|
||||
int 3
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
/* SPDX-License-Identifier: SPDX-License-Identifier: GPL-2.0 OR MIT */
|
||||
|
||||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
|
|
@ -26,16 +24,20 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef INTTYPES_H
|
||||
#define INTTYPES_H
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
#include "stdint.h"
|
||||
.globl intrinsic_vmxon
|
||||
intrinsic_vmxon:
|
||||
|
||||
#define PRId64 "lld"
|
||||
#define PRIu64 "llu"
|
||||
#define PRIx64 "llx"
|
||||
#define PRIdPTR "ld"
|
||||
#define PRIuPTR "lu"
|
||||
#define PRIxPTR "lx"
|
||||
vmxon [rcx]
|
||||
jbe intrinsic_vmxon_failure
|
||||
|
||||
#endif
|
||||
xor rax, rax
|
||||
ret
|
||||
int 3
|
||||
|
||||
intrinsic_vmxon_failure:
|
||||
mov rax, 0x1
|
||||
ret
|
||||
int 3
|
||||
50
loader/efi/src/x64/intrinsic_cpuid.S
Normal file
50
loader/efi/src/x64/intrinsic_cpuid.S
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl intrinsic_cpuid
|
||||
intrinsic_cpuid:
|
||||
|
||||
push rbx
|
||||
|
||||
mov r10, rcx
|
||||
mov r11, rdx
|
||||
|
||||
mov eax, [r10]
|
||||
mov ebx, [r11]
|
||||
mov ecx, [r8]
|
||||
mov edx, [r9]
|
||||
cpuid
|
||||
mov [r10], eax
|
||||
mov [r11], ebx
|
||||
mov [r8], ecx
|
||||
mov [r9], edx
|
||||
|
||||
pop rbx
|
||||
ret
|
||||
int 3
|
||||
38
loader/efi/src/x64/intrinsic_inb.S
Normal file
38
loader/efi/src/x64/intrinsic_inb.S
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl intrinsic_inb
|
||||
intrinsic_inb:
|
||||
|
||||
xor rax, rax
|
||||
mov rdx, rcx
|
||||
in al, dx
|
||||
|
||||
ret
|
||||
int 3
|
||||
36
loader/efi/src/x64/intrinsic_lcr4.S
Normal file
36
loader/efi/src/x64/intrinsic_lcr4.S
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl intrinsic_lcr4
|
||||
intrinsic_lcr4:
|
||||
|
||||
mov cr4, rcx
|
||||
|
||||
ret
|
||||
int 3
|
||||
39
loader/efi/src/x64/intrinsic_outb.S
Normal file
39
loader/efi/src/x64/intrinsic_outb.S
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl intrinsic_outb
|
||||
intrinsic_outb:
|
||||
|
||||
mov rax, rdx
|
||||
mov rdx, rcx
|
||||
out dx, al
|
||||
xor rax, rax
|
||||
|
||||
ret
|
||||
int 3
|
||||
39
loader/efi/src/x64/intrinsic_rdmsr.S
Normal file
39
loader/efi/src/x64/intrinsic_rdmsr.S
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl intrinsic_rdmsr
|
||||
intrinsic_rdmsr:
|
||||
|
||||
xor rax, rax
|
||||
rdmsr
|
||||
shl rdx, 32
|
||||
or rax, rdx
|
||||
|
||||
ret
|
||||
int 3
|
||||
36
loader/efi/src/x64/intrinsic_scr0.S
Normal file
36
loader/efi/src/x64/intrinsic_scr0.S
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl intrinsic_scr0
|
||||
intrinsic_scr0:
|
||||
|
||||
mov rax, cr0
|
||||
|
||||
ret
|
||||
int 3
|
||||
36
loader/efi/src/x64/intrinsic_scr4.S
Normal file
36
loader/efi/src/x64/intrinsic_scr4.S
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl intrinsic_scr4
|
||||
intrinsic_scr4:
|
||||
|
||||
mov rax, cr4
|
||||
|
||||
ret
|
||||
int 3
|
||||
37
loader/efi/src/x64/intrinsic_scs.S
Normal file
37
loader/efi/src/x64/intrinsic_scs.S
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl intrinsic_scs
|
||||
intrinsic_scs:
|
||||
|
||||
xor rax, rax
|
||||
mov ax, cs
|
||||
|
||||
ret
|
||||
int 3
|
||||
37
loader/efi/src/x64/intrinsic_sds.S
Normal file
37
loader/efi/src/x64/intrinsic_sds.S
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl intrinsic_sds
|
||||
intrinsic_sds:
|
||||
|
||||
xor rax, rax
|
||||
mov ax, ds
|
||||
|
||||
ret
|
||||
int 3
|
||||
37
loader/efi/src/x64/intrinsic_ses.S
Normal file
37
loader/efi/src/x64/intrinsic_ses.S
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl intrinsic_ses
|
||||
intrinsic_ses:
|
||||
|
||||
xor rax, rax
|
||||
mov ax, es
|
||||
|
||||
ret
|
||||
int 3
|
||||
37
loader/efi/src/x64/intrinsic_sfs.S
Normal file
37
loader/efi/src/x64/intrinsic_sfs.S
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl intrinsic_sfs
|
||||
intrinsic_sfs:
|
||||
|
||||
xor rax, rax
|
||||
mov ax, fs
|
||||
|
||||
ret
|
||||
int 3
|
||||
36
loader/efi/src/x64/intrinsic_sgdt.S
Normal file
36
loader/efi/src/x64/intrinsic_sgdt.S
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl intrinsic_sgdt
|
||||
intrinsic_sgdt:
|
||||
|
||||
sgdt [rcx]
|
||||
|
||||
ret
|
||||
int 3
|
||||
37
loader/efi/src/x64/intrinsic_sgs.S
Normal file
37
loader/efi/src/x64/intrinsic_sgs.S
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* @copyright
|
||||
* Copyright (C) 2020 Assured Information Security, Inc.
|
||||
*
|
||||
* @copyright
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* @copyright
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* @copyright
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
.code64
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl intrinsic_sgs
|
||||
intrinsic_sgs:
|
||||
|
||||
xor rax, rax
|
||||
mov ax, gs
|
||||
|
||||
ret
|
||||
int 3
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue