mirror of
https://github.com/StrikerX3/StrikeBox.git
synced 2024-06-15 10:57:50 -04:00
Replace CPU modules with virt86
Restructure CMake projects
This commit is contained in:
parent
359bb7792c
commit
3ef26120ee
46
.gitignore
vendored
46
.gitignore
vendored
|
@ -1,5 +1,41 @@
|
|||
*.pyc
|
||||
.DS_Store
|
||||
build
|
||||
.vs
|
||||
cmake-build-debug
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
# Visual Studio files
|
||||
.vs/
|
||||
|
||||
# CMake build folder
|
||||
build/
|
||||
|
||||
# CLion project metadata
|
||||
.idea/
|
||||
|
|
|
@ -1,55 +1,56 @@
|
|||
if(MSVC)
|
||||
cmake_minimum_required (VERSION 3.8)
|
||||
else()
|
||||
cmake_minimum_required (VERSION 3.1)
|
||||
endif()
|
||||
# Top-level CMake project definitions.
|
||||
# -------------------------------------------------------------------------------
|
||||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2019 Ivan Roberto de Oliveira
|
||||
#
|
||||
# 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.8)
|
||||
|
||||
project(vixen VERSION 1.0.0)
|
||||
|
||||
# Differentiate between Linux and macOS
|
||||
if(UNIX AND NOT APPLE)
|
||||
set(LINUX TRUE)
|
||||
set(LINUX TRUE)
|
||||
endif()
|
||||
|
||||
project (vixen)
|
||||
|
||||
# Define properties and include helpers for Visual Studio
|
||||
if(MSVC)
|
||||
# Set platform names
|
||||
if("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)")
|
||||
set(BUILD_PLATFORM win64)
|
||||
else()
|
||||
set(BUILD_PLATFORM win32)
|
||||
endif()
|
||||
include(cmake/VSHelpers.cmake)
|
||||
|
||||
# Use folders and set the startup project
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT cli)
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
# Configure startup project
|
||||
set_property(DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" PROPERTY VS_STARTUP_PROJECT vixen-cli)
|
||||
endif()
|
||||
|
||||
|
||||
include("${CMAKE_SOURCE_DIR}/cmake/VSHelpers.cmake")
|
||||
include(cmake/PrecompiledHeader.cmake)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
||||
|
||||
# Require C++17 features
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
# Set compiler and linker flags except on MSVC
|
||||
if(NOT MSVC)
|
||||
add_definitions("-Wall -Werror -O0 -g")
|
||||
endif()
|
||||
|
||||
# Add viXen projects
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/src/common")
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/src/module-common")
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/src/cpu-module")
|
||||
if(WIN32)
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/src/cpu-module-haxm")
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/src/cpu-module-whvp")
|
||||
endif()
|
||||
if(LINUX)
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/src/cpu-module-kvm")
|
||||
endif()
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/src/core")
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/src/cli")
|
||||
set(CMAKE_CXX_EXTENSIONS ON)
|
||||
|
||||
# Add modules and apps
|
||||
add_subdirectory(modules)
|
||||
add_subdirectory(apps)
|
||||
|
|
51
README.md
51
README.md
|
@ -12,8 +12,9 @@ will come later in viXen.
|
|||
|
||||
The current state of this thing is just a tad bit more tangible than vaporware.
|
||||
Essentially right now it just initializes an x86 system (courtesy of one of the
|
||||
various virtualization platforms supported by the emulator) and runs whatever
|
||||
is in ROM, which is provided by the user.
|
||||
various virtualization platforms supported by
|
||||
[virt86](https://github.com/StrikerX3/virt86)) and runs whatever is in ROM,
|
||||
which is provided by the user.
|
||||
|
||||
If provided with a particular BIOS ROM and a raw hard disk image containing the
|
||||
Microsoft Xbox Dashboard, it will load the Dashboard software succesfully. It
|
||||
|
@ -33,65 +34,33 @@ incomplete, incorrect or straight up copies of illegally obtained code.
|
|||
How to Build
|
||||
------------
|
||||
viXen uses [CMake](https://cmake.org/) build files to generate projects for
|
||||
your preferred development platform. viXen contains multiple modules, as
|
||||
described in the [Project Structure](#project-structure) section below.
|
||||
|
||||
You will need to specify a CPU module for viXen to run. The CMake option
|
||||
`CPU_MODULE` gives you a choice of default modules bundled with viXen that
|
||||
can be used for development and release builds.
|
||||
your preferred development platform. You'll need CMake 3.8 or later.
|
||||
|
||||
### Windows
|
||||
You'll need CMake 3.8 or later and [Visual Studio Community 2017](https://www.visualstudio.com/downloads/).
|
||||
|
||||
Your choices of CPU modules for this platform are:
|
||||
- `haxm`: [Intel HAXM](https://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager-intel-haxm).
|
||||
Requires an Intel processor with VT-x and runs on any version of Windows.
|
||||
- `whvp`: [Windows Hypervisor Platform](https://docs.microsoft.com/en-us/virtualization/api/).
|
||||
Requires Windows 10 Pro with the [April 2018 Update](https://support.microsoft.com/en-us/help/4028685/windows-10-get-the-update)
|
||||
or later. You'll also need to go to the Windows Features panel and enable the
|
||||
Windows Hypervisor Platform feature. Note that in doing so, you'll be unable to
|
||||
use any other virtualization platform (such as VirtualBox, VMware Player or
|
||||
HAXM). Disable the feature if you wish to continue using those platforms. Note
|
||||
that WHPX still doesn't work correctly, see issue [#2](https://github.com/StrikerX3/viXen/issues/2).
|
||||
To make a [Visual Studio 2017](https://www.visualstudio.com/downloads/)
|
||||
project:
|
||||
|
||||
```
|
||||
> mkdir build
|
||||
> cd build
|
||||
> cmake -G "Visual Studio 15 2017" .. -DCPU_MODULE=<cpu module> # for 32-bit builds
|
||||
> cmake -G "Visual Studio 15 2017 Win64" .. -DCPU_MODULE=<cpu module> # for 64-bit builds
|
||||
> cmake -G "Visual Studio 15 2017" -A Win32 .. # for 32-bit builds
|
||||
> cmake -G "Visual Studio 15 2017" -A x64 .. # for 64-bit builds
|
||||
```
|
||||
The .sln file will be generated in the build folder, ready to build.
|
||||
|
||||
### Linux
|
||||
You'll need CMake 3.1 or later. The Linux build uses [KVM](https://www.linux-kvm.org/page/Main_Page).
|
||||
|
||||
```
|
||||
$ sudo apt-get install cmake
|
||||
$ mkdir build; cd build
|
||||
$ cmake .. -DCPU_MODULE=kvm && make
|
||||
$ cmake .. && make
|
||||
$ cd src/cli
|
||||
$ ./vixen-cli -m <path-to-MCPX-ROM> -b <path-to-BIOS-ROM> -d <path-to-XBE> -r [debug|retail]
|
||||
```
|
||||
|
||||
### macOS
|
||||
macOS is currently unsupported. Feel free to submit a pull request to add
|
||||
support for this platform! (See issue [#3](https://github.com/StrikerX3/viXen/issues/3)
|
||||
for the Hypervisor.Framework or issue [#17](https://github.com/StrikerX3/viXen/issues/17)
|
||||
for HAXM)
|
||||
|
||||
Project Structure
|
||||
-----------------
|
||||
viXen is split into multiple modules:
|
||||
- `core`: the core of the emulator, providing basic emulation logic and a
|
||||
module interface for the various pieces of hardware that composes the Xbox.
|
||||
This is a static library meant to be used by front-end engines.
|
||||
- `cli`: a command line front-end for viXen.
|
||||
- `common`: common code shared across all modules.
|
||||
- `module-common`: contains common definitions and types for viXen modules.
|
||||
- `cpu-module`: defines the interface and basic types for CPU modules.
|
||||
- `cpu-module-haxm`: Windows-only CPU module implementation using [Intel HAXM](https://github.com/intel/haxm).
|
||||
- `cpu-module-whvp`: Windows-only CPU module implementation using the [Windows Hypervisor Platform](https://docs.microsoft.com/en-us/virtualization/api/).
|
||||
- `cpu-module-kvm`: Linux-only CPU module implementation using [KVM](https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt)
|
||||
support for this platform!
|
||||
|
||||
Debugging Guest Code
|
||||
--------------------
|
||||
|
|
2
apps/CMakeLists.txt
Normal file
2
apps/CMakeLists.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Add apps
|
||||
add_subdirectory(cli)
|
54
apps/cli/CMakeLists.txt
Normal file
54
apps/cli/CMakeLists.txt
Normal file
|
@ -0,0 +1,54 @@
|
|||
project(vixen-cli VERSION 1.0.0 LANGUAGES CXX)
|
||||
|
||||
##############################
|
||||
# Source files
|
||||
#
|
||||
file(GLOB_RECURSE sources
|
||||
src/*.cpp
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE private_headers
|
||||
src/*.hpp
|
||||
src/*.h
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE public_headers
|
||||
include/*.hpp
|
||||
include/*.h
|
||||
)
|
||||
|
||||
##############################
|
||||
# Project structure
|
||||
#
|
||||
add_executable(vixen-cli ${sources} ${private_headers} ${public_headers})
|
||||
|
||||
target_include_directories(vixen-cli
|
||||
PUBLIC
|
||||
$<INSTALL_INTERFACE:include>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
)
|
||||
target_link_libraries(vixen-cli vixen-core)
|
||||
|
||||
if(MSVC)
|
||||
add_precompiled_header(vixen-cli pch.hpp SOURCE_CXX "${CMAKE_CURRENT_SOURCE_DIR}/src/pch.cpp" FORCEINCLUDE)
|
||||
|
||||
vs_set_filters(BASE_DIR src FILTER_ROOT "Sources" SOURCES ${sources})
|
||||
vs_set_filters(BASE_DIR src FILTER_ROOT "Private Headers" SOURCES ${private_headers})
|
||||
vs_set_filters(BASE_DIR include FILTER_ROOT "Public Headers" SOURCES ${public_headers})
|
||||
|
||||
vs_use_edit_and_continue()
|
||||
|
||||
set_target_properties(vixen-cli PROPERTIES FOLDER Applications)
|
||||
else()
|
||||
add_precompiled_header(vixen-cli src/pch.hpp PCH_PATH pch.hpp SOURCE_CXX "${CMAKE_CURRENT_SOURCE_DIR}/src/pch.cpp" FORCEINCLUDE)
|
||||
endif()
|
||||
|
||||
##############################
|
||||
# Installation
|
||||
#
|
||||
install(TARGETS vixen-cli
|
||||
EXPORT platform-check
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
)
|
|
@ -2,12 +2,15 @@
|
|||
#include <string.h>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include "lib/cxxopts.hpp"
|
||||
|
||||
#include "vixen/core.h"
|
||||
#include "vixen/settings.h"
|
||||
#include "vixen/thread.h"
|
||||
|
||||
using namespace virt86;
|
||||
|
||||
#ifdef _WIN32
|
||||
char *basename(char *path)
|
||||
{
|
||||
|
@ -73,31 +76,29 @@ int main(int argc, const char *argv[]) {
|
|||
vdvd_path = args["xgd-image"].as<std::string>().c_str();
|
||||
}
|
||||
|
||||
// Locate and instantiate modules
|
||||
ModuleRepository moduleRepo;
|
||||
moduleRepo.Enumerate();
|
||||
// Pick the first hypervisor platform that is available and properly initialized on this system.
|
||||
printf("Loading virtualization platforms... ");
|
||||
|
||||
// Search for CPU modules
|
||||
auto cpuModules = moduleRepo.GetCPUModules();
|
||||
if (cpuModules.size() == 0) {
|
||||
log_fatal("No CPU modules found\n");
|
||||
bool foundPlatform = false;
|
||||
size_t platformIndex = 0;
|
||||
for (size_t i = 0; i < ARRAYSIZE(PlatformFactories); i++) {
|
||||
Platform& platform = PlatformFactories[i]();
|
||||
if (platform.GetInitStatus() == PlatformInitStatus::OK) {
|
||||
printf("%s loaded successfully\n", platform.GetName().c_str());
|
||||
foundPlatform = true;
|
||||
platformIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundPlatform) {
|
||||
printf("none found\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Load first CPU module found
|
||||
auto cpuModuleInfo = cpuModules[0];
|
||||
Platform& platform = PlatformFactories[platformIndex]();
|
||||
|
||||
// Instantiate CPU module
|
||||
log_info("Loading CPU module: %s %s... ", cpuModuleInfo.moduleName.c_str(), cpuModuleInfo.moduleVersion.c_str());
|
||||
CPUModuleInstance cpuModuleInstance;
|
||||
auto cpuModuleResult = LoadCPUModule(cpuModuleInfo.libraryPath, &cpuModuleInstance);
|
||||
if (cpuModuleResult != kModuleLoadSuccess) {
|
||||
log_fatal("instantiation failed; result code 0x%x\n", cpuModuleResult);
|
||||
return -1;
|
||||
}
|
||||
log_info("success\n");
|
||||
|
||||
Xbox *xbox = new Xbox(cpuModuleInstance.cpuModule);
|
||||
Xbox *xbox = new Xbox(platform);
|
||||
|
||||
auto& settings = xbox->GetSettings();
|
||||
settings.cpu_singleStep = false;
|
||||
|
@ -158,7 +159,7 @@ int main(int argc, const char *argv[]) {
|
|||
log_fatal("Emulator exited with error: ");
|
||||
switch (status) {
|
||||
case EMUS_INIT_INVALID_REVISION: log_fatal("Invalid revision specified\n"); break;
|
||||
case EMUS_INIT_ALLOC_MEM_RGN_FAILED: log_fatal("Could not allocate memory for the global memory region\n"); break;
|
||||
case EMUS_INIT_VM_INIT_FAILED: log_fatal("Failed to initialize virtual machine\n"); break;
|
||||
case EMUS_INIT_ALLOC_RAM_FAILED: log_fatal("Could not allocate memory for the guest RAM\n"); break;
|
||||
case EMUS_INIT_ALLOC_RAM_RGN_FAILED: log_fatal("Could not allocate memory for the RAM region"); break;
|
||||
case EMUS_INIT_ALLOC_ROM_FAILED: log_fatal("Could not allocate memory for the guest ROM"); break;
|
||||
|
@ -167,10 +168,6 @@ int main(int argc, const char *argv[]) {
|
|||
case EMUS_INIT_MCPX_ROM_INVALID_SIZE: log_fatal("MCPX ROM provided has incorrect size (must be 512 bytes)"); break;
|
||||
case EMUS_INIT_BIOS_ROM_NOT_FOUND: log_fatal("BIOS ROM file not found"); break;
|
||||
case EMUS_INIT_BIOS_ROM_INVALID_SIZE: log_fatal("BIOS ROM provided has incorrect size (must be 256 KiB or 1 MiB)"); break;
|
||||
case EMUS_INIT_NO_CPU_MODULE: log_fatal("No CPU module specified"); break;
|
||||
case EMUS_INIT_CPU_CREATE_FAILED: log_fatal("CPU instantiation failed"); break;
|
||||
case EMUS_INIT_CPU_INIT_FAILED: log_fatal("CPU initialization failed"); break;
|
||||
case EMUS_INIT_CPU_MEM_MAP_FAILED: log_fatal("Memory mapping failed"); break;
|
||||
case EMUS_INIT_INVALID_HARD_DRIVE_TYPE: log_fatal("Invalid virtual hard drive type specified"); break;
|
||||
case EMUS_INIT_HARD_DRIVE_INIT_FAILED: log_fatal("Failed to initialize virtual hard drive"); break;
|
||||
case EMUS_INIT_INVALID_DVD_DRIVE_TYPE: log_fatal("Invalid virtual DVD drive type specified"); break;
|
26
apps/cli/src/pch.cpp
Normal file
26
apps/cli/src/pch.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
This file is required by Visual Studio in order to compile pch.hpp.
|
||||
-------------------------------------------------------------------------------
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Ivan Roberto de Oliveira
|
||||
|
||||
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 "pch.hpp"
|
29
apps/cli/src/pch.hpp
Normal file
29
apps/cli/src/pch.hpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
Precompiled header for the Platform Checker application.
|
||||
-------------------------------------------------------------------------------
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Ivan Roberto de Oliveira
|
||||
|
||||
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 <cstdio>
|
||||
#include <cinttypes>
|
||||
|
||||
#include "virt86/virt86.hpp"
|
|
@ -63,20 +63,136 @@ macro(combine_arguments _variable)
|
|||
set(${_variable} "${_result}")
|
||||
endmacro()
|
||||
|
||||
function(export_all_flags _filename)
|
||||
function(export_all_flags _filename mode)
|
||||
get_target_property(_target_type ${_target} TYPE)
|
||||
if(_target_type STREQUAL "EXECUTABLE")
|
||||
set(_pic "$<$<BOOL:$<TARGET_PROPERTY:${_target},POSITION_INDEPENDENT_CODE>>:-fPIE\n>")
|
||||
else()
|
||||
set(_pic "$<$<BOOL:$<TARGET_PROPERTY:${_target},POSITION_INDEPENDENT_CODE>>:-fPIC\n>")
|
||||
endif()
|
||||
|
||||
set(_include_directories "$<TARGET_PROPERTY:${_target},INCLUDE_DIRECTORIES>")
|
||||
set(_compile_definitions "$<TARGET_PROPERTY:${_target},COMPILE_DEFINITIONS>")
|
||||
set(_compile_flags "$<TARGET_PROPERTY:${_target},COMPILE_FLAGS>")
|
||||
set(_compile_options "$<TARGET_PROPERTY:${_target},COMPILE_OPTIONS>")
|
||||
set(_include_directories "$<$<BOOL:${_include_directories}>:-I$<JOIN:${_include_directories},\n-I>\n>")
|
||||
set(_include_directories "$<$<BOOL:${_include_directories}>:-I\"$<JOIN:${_include_directories},\"\n-I\">\"\n>")
|
||||
set(_compile_definitions "$<$<BOOL:${_compile_definitions}>:-D$<JOIN:${_compile_definitions},\n-D>\n>")
|
||||
set(_compile_flags "$<$<BOOL:${_compile_flags}>:$<JOIN:${_compile_flags},\n>\n>")
|
||||
set(_compile_options "$<$<BOOL:${_compile_options}>:$<JOIN:${_compile_options},\n>\n>")
|
||||
file(GENERATE OUTPUT "${_filename}" CONTENT "${_compile_definitions}${_include_directories}${_compile_flags}${_compile_options}\n")
|
||||
|
||||
set(_standard_check "")
|
||||
if("${mode}" STREQUAL "CXX")
|
||||
set(_cxx_standard "$<TARGET_PROPERTY:${_target},CXX_STANDARD>")
|
||||
set(_cxx_extensions "$<TARGET_PROPERTY:${_target},CXX_EXTENSIONS>")
|
||||
set(_has_extensions "$<OR:$<STREQUAL:${_cxx_extensions},>,$<BOOL:${_cxx_extensions}>>") # CXX_EXTENSIONS defaults to true
|
||||
set(_standard_check "${_standard_check}$<$<AND:$<STREQUAL:${_cxx_standard},17>,$<NOT:${_has_extensions}>>:${CMAKE_CXX17_STANDARD_COMPILE_OPTION}>")
|
||||
set(_standard_check "${_standard_check}$<$<AND:$<STREQUAL:${_cxx_standard},14>,$<NOT:${_has_extensions}>>:${CMAKE_CXX14_STANDARD_COMPILE_OPTION}>")
|
||||
set(_standard_check "${_standard_check}$<$<AND:$<STREQUAL:${_cxx_standard},11>,$<NOT:${_has_extensions}>>:${CMAKE_CXX11_STANDARD_COMPILE_OPTION}>")
|
||||
set(_standard_check "${_standard_check}$<$<AND:$<STREQUAL:${_cxx_standard},98>,$<NOT:${_has_extensions}>>:${CMAKE_CXX98_STANDARD_COMPILE_OPTION}>")
|
||||
set(_standard_check "${_standard_check}$<$<AND:$<STREQUAL:${_cxx_standard},17>,${_has_extensions}>:${CMAKE_CXX17_EXTENSION_COMPILE_OPTION}>")
|
||||
set(_standard_check "${_standard_check}$<$<AND:$<STREQUAL:${_cxx_standard},14>,${_has_extensions}>:${CMAKE_CXX14_EXTENSION_COMPILE_OPTION}>")
|
||||
set(_standard_check "${_standard_check}$<$<AND:$<STREQUAL:${_cxx_standard},11>,${_has_extensions}>:${CMAKE_CXX11_EXTENSION_COMPILE_OPTION}>")
|
||||
set(_standard_check "${_standard_check}$<$<AND:$<STREQUAL:${_cxx_standard},98>,${_has_extensions}>:${CMAKE_CXX98_EXTENSION_COMPILE_OPTION}>")
|
||||
endif()
|
||||
if("${mode}" STREQUAL "C")
|
||||
set(_c_standard "$<TARGET_PROPERTY:${_target},C_STANDARD>")
|
||||
set(_c_extensions "$<TARGET_PROPERTY:${_target},C_EXTENSIONS>")
|
||||
set(_has_extensions "$<OR:$<STREQUAL:${_c_extensions},>,$<BOOL:${_c_extensions}>>") # C_EXTENSIONS defaults to true
|
||||
set(_standard_check "${_standard_check}$<$<AND:$<STREQUAL:${_c_standard},11>,$<NOT:${_has_extensions}>>:${CMAKE_C11_STANDARD_COMPILE_OPTION}>")
|
||||
set(_standard_check "${_standard_check}$<$<AND:$<STREQUAL:${_c_standard},99>,$<NOT:${_has_extensions}>>:${CMAKE_C99_STANDARD_COMPILE_OPTION}>")
|
||||
set(_standard_check "${_standard_check}$<$<AND:$<STREQUAL:${_c_standard},90>,$<NOT:${_has_extensions}>>:${CMAKE_C90_STANDARD_COMPILE_OPTION}>")
|
||||
set(_standard_check "${_standard_check}$<$<AND:$<STREQUAL:${_c_standard},11>,${_has_extensions}>:${CMAKE_C11_EXTENSION_COMPILE_OPTION}>")
|
||||
set(_standard_check "${_standard_check}$<$<AND:$<STREQUAL:${_c_standard},99>,${_has_extensions}>:${CMAKE_C99_EXTENSION_COMPILE_OPTION}>")
|
||||
set(_standard_check "${_standard_check}$<$<AND:$<STREQUAL:${_c_standard},90>,${_has_extensions}>:${CMAKE_C90_EXTENSION_COMPILE_OPTION}>")
|
||||
endif()
|
||||
set(_standard_check "${_standard_check}\n")
|
||||
|
||||
file(GENERATE OUTPUT "${_filename}" CONTENT "${_compile_definitions}${_include_directories}${_compile_flags}${_compile_options}${_standard_check}${_pic}\n")
|
||||
endfunction()
|
||||
|
||||
function (gcc_pch_targets_for_mode _input _pch_path mode)
|
||||
get_filename_component(_name ${_input} NAME)
|
||||
set(_pch_header "${CMAKE_CURRENT_SOURCE_DIR}/${_input}")
|
||||
set(_pch_binary_dir "${CMAKE_CURRENT_BINARY_DIR}/${_target}_${mode}_pch")
|
||||
set(_pchfile "${_pch_binary_dir}/${_input}")
|
||||
|
||||
string(REGEX MATCH "\.\.[/\\]" _has_parent_access "${_input}")
|
||||
if( "${_pch_path}" STREQUAL "" AND _has_parent_access)
|
||||
message(FATAL_ERROR "Precompiled header name contains ../, please specify an outputh path with the PCH_PATH option")
|
||||
endif()
|
||||
|
||||
if( NOT "${_pch_path}" STREQUAL "" )
|
||||
set(_pchfile "${_pch_binary_dir}/${_pch_path}")
|
||||
endif()
|
||||
set(_output "${_pch_binary_dir}/${_input}.gch")
|
||||
if( NOT "${_pch_path}" STREQUAL "" )
|
||||
set(_output "${_pch_binary_dir}/${_pch_path}.gch")
|
||||
endif()
|
||||
|
||||
set(_pch_flags_file "${_pch_binary_dir}/compile_flags.rsp")
|
||||
export_all_flags("${_pch_flags_file}" ${mode})
|
||||
set(_compiler_FLAGS "@${_pch_flags_file}")
|
||||
add_custom_command(
|
||||
OUTPUT "${_pchfile}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy "${_pch_header}" "${_pchfile}"
|
||||
DEPENDS "${_pch_header}"
|
||||
COMMENT "Updating ${_name} (${mode})")
|
||||
if("${mode}" STREQUAL "CXX")
|
||||
add_custom_command(
|
||||
OUTPUT "${_output}"
|
||||
COMMAND "${CMAKE_CXX_COMPILER}" ${_compiler_FLAGS} -x c++-header -o "${_output}" "${_pchfile}"
|
||||
DEPENDS "${_pchfile}" "${_pch_flags_file}"
|
||||
COMMENT "Precompiling ${_name} for ${_target} (C++)")
|
||||
endif()
|
||||
if("${mode}" STREQUAL "C")
|
||||
add_custom_command(
|
||||
OUTPUT "${_output}"
|
||||
COMMAND "${CMAKE_C_COMPILER}" ${_compiler_FLAGS_c} -x c-header -o "${_output}" "${_pchfile}"
|
||||
DEPENDS "${_pchfile}" "${_pch_flags_file}"
|
||||
COMMENT "Precompiling ${_name} for ${_target} (C)")
|
||||
endif()
|
||||
|
||||
set(_extensions "")
|
||||
if("${mode}" STREQUAL "CXX")
|
||||
set(_extensions "cc|cxx|cpp")
|
||||
endif()
|
||||
if("${mode}" STREQUAL "C")
|
||||
set(_extensions "c")
|
||||
endif()
|
||||
|
||||
get_property(_sources TARGET ${_target} PROPERTY SOURCES)
|
||||
foreach(_source ${_sources})
|
||||
set(_pch_compile_flags "")
|
||||
if(_source MATCHES \\.\(${_extensions}\)$)
|
||||
get_source_file_property(_pch_compile_flags "${_source}" COMPILE_FLAGS)
|
||||
if(NOT _pch_compile_flags)
|
||||
set(_pch_compile_flags)
|
||||
endif()
|
||||
separate_arguments(_pch_compile_flags)
|
||||
list(APPEND _pch_compile_flags -Winvalid-pch)
|
||||
if(_PCH_FORCEINCLUDE)
|
||||
list(APPEND _pch_compile_flags -include "${_pchfile}")
|
||||
else(_PCH_FORCEINCLUDE)
|
||||
list(APPEND _pch_compile_flags "-I${_pch_binary_dir}")
|
||||
endif(_PCH_FORCEINCLUDE)
|
||||
|
||||
get_source_file_property(_object_depends "${_source}" OBJECT_DEPENDS)
|
||||
if(NOT _object_depends)
|
||||
set(_object_depends)
|
||||
endif()
|
||||
list(APPEND _object_depends "${_pchfile}")
|
||||
list(APPEND _object_depends "${_output}")
|
||||
|
||||
combine_arguments(_pch_compile_flags)
|
||||
set_source_files_properties(${_source} PROPERTIES
|
||||
COMPILE_FLAGS "${_pch_compile_flags}"
|
||||
OBJECT_DEPENDS "${_object_depends}")
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(add_precompiled_header _target _input)
|
||||
cmake_parse_arguments(_PCH "FORCEINCLUDE" "SOURCE_CXX;SOURCE_C" "" ${ARGN})
|
||||
cmake_parse_arguments(_PCH "FORCEINCLUDE" "SOURCE_CXX;SOURCE_C;PCH_PATH" "" ${ARGN})
|
||||
|
||||
get_filename_component(_input_we ${_input} NAME_WE)
|
||||
if(NOT _PCH_SOURCE_CXX)
|
||||
|
@ -147,77 +263,17 @@ function(add_precompiled_header _target _input)
|
|||
endif()
|
||||
endif(MSVC)
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
get_filename_component(_name ${_input} NAME)
|
||||
set(_pch_header "${CMAKE_CURRENT_SOURCE_DIR}/${_input}")
|
||||
set(_pch_binary_dir "${CMAKE_CURRENT_BINARY_DIR}/${_target}_pch")
|
||||
set(_pchfile "${_pch_binary_dir}/${_input}")
|
||||
set(_outdir "${CMAKE_CURRENT_BINARY_DIR}/${_target}_pch/${_name}.gch")
|
||||
file(MAKE_DIRECTORY "${_outdir}")
|
||||
set(_output_cxx "${_outdir}/.c++")
|
||||
set(_output_c "${_outdir}/.c")
|
||||
|
||||
set(_pch_flags_file "${_pch_binary_dir}/compile_flags.rsp")
|
||||
export_all_flags("${_pch_flags_file}")
|
||||
set(_compiler_FLAGS "@${_pch_flags_file}")
|
||||
if(CMAKE_CXX_STANDARD STREQUAL 11)
|
||||
set(_compiler_FLAGS "${_compiler_FLAGS}" "-std=c++11")
|
||||
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
|
||||
# Clang only uses PCHs when using the -include option
|
||||
# See: https://clang.llvm.org/docs/UsersManual.html#using-a-pch-file
|
||||
if(NOT _PCH_FORCEINCLUDE)
|
||||
message(WARNING "Clang requires the FORCEINCLUDE option to use PCHs, turning it on")
|
||||
endif()
|
||||
if(CMAKE_CXX_STANDARD STREQUAL 14)
|
||||
set(_compiler_FLAGS "${_compiler_FLAGS}" "-std=c++14")
|
||||
endif()
|
||||
if(CMAKE_CXX_STANDARD STREQUAL 17)
|
||||
set(_compiler_FLAGS "${_compiler_FLAGS}" "-std=c++17")
|
||||
endif()
|
||||
add_custom_command(
|
||||
OUTPUT "${_pchfile}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy "${_pch_header}" "${_pchfile}"
|
||||
DEPENDS "${_pch_header}"
|
||||
COMMENT "Updating ${_name}")
|
||||
add_custom_command(
|
||||
OUTPUT "${_output_cxx}"
|
||||
COMMAND "${CMAKE_CXX_COMPILER}" ${_compiler_FLAGS} -x c++-header -o "${_output_cxx}" "${_pchfile}"
|
||||
DEPENDS "${_pchfile}" "${_pch_flags_file}"
|
||||
COMMENT "Precompiling ${_name} for ${_target} (C++)")
|
||||
add_custom_command(
|
||||
OUTPUT "${_output_c}"
|
||||
COMMAND "${CMAKE_C_COMPILER}" ${_compiler_FLAGS} -x c-header -o "${_output_c}" "${_pchfile}"
|
||||
DEPENDS "${_pchfile}" "${_pch_flags_file}"
|
||||
COMMENT "Precompiling ${_name} for ${_target} (C)")
|
||||
set(_PCH_FORCEINCLUDE ON)
|
||||
endif()
|
||||
|
||||
get_property(_sources TARGET ${_target} PROPERTY SOURCES)
|
||||
foreach(_source ${_sources})
|
||||
set(_pch_compile_flags "")
|
||||
|
||||
if(_source MATCHES \\.\(cc|cxx|cpp|c\)$)
|
||||
get_source_file_property(_pch_compile_flags "${_source}" COMPILE_FLAGS)
|
||||
if(NOT _pch_compile_flags)
|
||||
set(_pch_compile_flags)
|
||||
endif()
|
||||
separate_arguments(_pch_compile_flags)
|
||||
list(APPEND _pch_compile_flags -Winvalid-pch)
|
||||
if(_PCH_FORCEINCLUDE)
|
||||
list(APPEND _pch_compile_flags -include "${_pchfile}")
|
||||
else(_PCH_FORCEINCLUDE)
|
||||
list(APPEND _pch_compile_flags "-I${_pch_binary_dir}")
|
||||
endif(_PCH_FORCEINCLUDE)
|
||||
|
||||
get_source_file_property(_object_depends "${_source}" OBJECT_DEPENDS)
|
||||
if(NOT _object_depends)
|
||||
set(_object_depends)
|
||||
endif()
|
||||
list(APPEND _object_depends "${_pchfile}")
|
||||
if(_source MATCHES \\.\(cc|cxx|cpp\)$)
|
||||
list(APPEND _object_depends "${_output_cxx}")
|
||||
else()
|
||||
list(APPEND _object_depends "${_output_c}")
|
||||
endif()
|
||||
|
||||
combine_arguments(_pch_compile_flags)
|
||||
set_source_files_properties(${_source} PROPERTIES
|
||||
COMPILE_FLAGS "${_pch_compile_flags}"
|
||||
OBJECT_DEPENDS "${_object_depends}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU|Clang")
|
||||
gcc_pch_targets_for_mode("${_input}" "${_PCH_PCH_PATH}" "C")
|
||||
gcc_pch_targets_for_mode("${_input}" "${_PCH_PCH_PATH}" "CXX")
|
||||
endif(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU|Clang")
|
||||
endfunction()
|
||||
|
|
|
@ -1,16 +1,8 @@
|
|||
# Add Visual Studio filters to better organize the code
|
||||
function(vs_set_filters SOURCES)
|
||||
function(vs_set_filters)
|
||||
cmake_parse_arguments(VS_SET_FILTERS "" "FILTER_ROOT;BASE_DIR" "SOURCES" ${ARGN})
|
||||
if(MSVC)
|
||||
set(extra_macro_args ${ARGN})
|
||||
list(LENGTH extra_macro_args num_extra_args)
|
||||
if(${num_extra_args} GREATER 0)
|
||||
list(GET extra_macro_args 0 optional_arg)
|
||||
set(BASE_DIR "${optional_arg}")
|
||||
else()
|
||||
set(BASE_DIR "")
|
||||
endif()
|
||||
|
||||
foreach(FILE ${SOURCES})
|
||||
foreach(FILE IN ITEMS ${VS_SET_FILTERS_SOURCES})
|
||||
# Get the directory of the source file
|
||||
get_filename_component(PARENT_DIR "${FILE}" DIRECTORY)
|
||||
|
||||
|
@ -18,20 +10,14 @@ function(vs_set_filters SOURCES)
|
|||
if(BASE_DIR STREQUAL "")
|
||||
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}" "" GROUP "${PARENT_DIR}")
|
||||
else()
|
||||
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/${BASE_DIR}" "" GROUP "${PARENT_DIR}")
|
||||
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/${VS_SET_FILTERS_BASE_DIR}" "" GROUP "${PARENT_DIR}")
|
||||
endif()
|
||||
|
||||
# Make sure we are using windows slashes
|
||||
# Use Windows path separators
|
||||
string(REPLACE "/" "\\" GROUP "${GROUP}")
|
||||
|
||||
# Group into "Source Files" and "Header Files"
|
||||
if("${FILE}" MATCHES ".*\\.c(pp)?")
|
||||
set(GROUP "Source Files${GROUP}")
|
||||
elseif("${FILE}" MATCHES ".*\\.h")
|
||||
set(GROUP "Header Files${GROUP}")
|
||||
endif()
|
||||
|
||||
source_group("${GROUP}" FILES "${FILE}")
|
||||
# Add to filter
|
||||
source_group("${VS_SET_FILTERS_FILTER_ROOT}${GROUP}" FILES "${FILE}")
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction()
|
||||
|
|
2
modules/CMakeLists.txt
Normal file
2
modules/CMakeLists.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Add modules
|
||||
add_subdirectory(core)
|
173
modules/core/CMakeLists.txt
Normal file
173
modules/core/CMakeLists.txt
Normal file
|
@ -0,0 +1,173 @@
|
|||
# The core of the viXen emulator.
|
||||
# -------------------------------------------------------------------------------
|
||||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2019 Ivan Roberto de Oliveira
|
||||
#
|
||||
# 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.
|
||||
project(vixen-core VERSION 1.0.0 LANGUAGES CXX)
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
##############################
|
||||
# Source files
|
||||
#
|
||||
if(WIN32)
|
||||
set(platform_path windows)
|
||||
elseif(LINUX)
|
||||
set(platform_path linux)
|
||||
elseif(APPLE)
|
||||
set(platform_path darwin)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported platform")
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE sources
|
||||
src/common/*.cpp
|
||||
src/${platform_path}/*.cpp
|
||||
src/pch.cpp
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE private_headers
|
||||
src/common/*.hpp
|
||||
src/common/*.h
|
||||
src/${platform_path}/*.hpp
|
||||
src/${platform_path}/*.h
|
||||
src/pch.hpp
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE public_headers
|
||||
include/*.hpp
|
||||
include/*.h
|
||||
)
|
||||
|
||||
##############################
|
||||
# Project structure
|
||||
#
|
||||
|
||||
add_library(vixen-core OBJECT ${sources} ${private_headers} ${public_headers})
|
||||
|
||||
set_target_properties(vixen-core PROPERTIES DEBUG_POSTFIX "-debug")
|
||||
|
||||
target_include_directories(vixen-core
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/common
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/${platform_path}
|
||||
)
|
||||
|
||||
# Include virt86
|
||||
find_package(virt86 CONFIG REQUIRED)
|
||||
target_link_libraries(vixen-core PUBLIC virt86::virt86)
|
||||
|
||||
# TODO: Include Zydis
|
||||
# add_definitions(-DZYDIS_STATIC_DEFINE)
|
||||
# ExternalProject_Add(
|
||||
# Zydis
|
||||
# GIT_REPOSITORY "https://github.com/zyantific/zydis"
|
||||
# GIT_TAG "v2.0.0"
|
||||
# UPDATE_COMMAND ""
|
||||
# INSTALL_COMMAND "")
|
||||
# ExternalProject_Get_Property(Zydis install_dir)
|
||||
# target_include_directories(vixen-core PUBLIC ${install_dir}/src/Zydis/include ${install_dir}/src/Zydis-build)
|
||||
# add_dependencies(vixen-core Zydis)
|
||||
#
|
||||
# if(WIN32)
|
||||
# target_link_libraries(vixen-core PUBLIC ${install_dir}/src/Zydis-build/${CMAKE_CFG_INTDIR}/Zydis.lib)
|
||||
# else()
|
||||
# target_link_libraries(vixen-core PUBLIC ${install_dir}/src/Zydis-build/libZydis.a)
|
||||
# endif()
|
||||
#
|
||||
# target_include_directories(vixen-core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${install_dir}/src/Zydis/include)
|
||||
|
||||
if(MSVC)
|
||||
add_precompiled_header(vixen-core pch.hpp SOURCE_CXX "${CMAKE_CURRENT_SOURCE_DIR}/src/common/pch.cpp" FORCEINCLUDE)
|
||||
|
||||
vs_set_filters(BASE_DIR src FILTER_ROOT "Sources" SOURCES ${sources})
|
||||
vs_set_filters(BASE_DIR src FILTER_ROOT "Private Headers" SOURCES ${private_headers})
|
||||
vs_set_filters(BASE_DIR include FILTER_ROOT "Public Headers" SOURCES ${public_headers})
|
||||
|
||||
vs_use_edit_and_continue()
|
||||
|
||||
set_target_properties(vixen-core PROPERTIES FOLDER Libraries)
|
||||
else()
|
||||
add_precompiled_header(vixen-core src/common/pch.hpp PCH_PATH pch.hpp SOURCE_CXX "${CMAKE_CURRENT_SOURCE_DIR}/src/common/pch.cpp" FORCEINCLUDE)
|
||||
endif()
|
||||
|
||||
##############################
|
||||
# Installation
|
||||
#
|
||||
|
||||
# Configuration
|
||||
set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
||||
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||
set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
|
||||
set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
|
||||
set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
|
||||
set(namespace "vixen::")
|
||||
|
||||
# Include module with function 'write_basic_package_version_file'
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
# Configure '<PROJECT-NAME>ConfigVersion.cmake'
|
||||
# Use:
|
||||
# * PROJECT_VERSION
|
||||
write_basic_package_version_file(
|
||||
"${version_config}" COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
|
||||
# Configure '<PROJECT-NAME>Config.cmake'
|
||||
# Use variables:
|
||||
# * TARGETS_EXPORT_NAME
|
||||
# * PROJECT_NAME
|
||||
configure_package_config_file(
|
||||
"cmake/Config.cmake.in"
|
||||
"${project_config}"
|
||||
INSTALL_DESTINATION "${config_install_dir}"
|
||||
)
|
||||
|
||||
# Install target library
|
||||
install(TARGETS vixen-core
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
)
|
||||
|
||||
# Install public headers
|
||||
install(DIRECTORY "include/"
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
)
|
||||
|
||||
# Install CMake Config modules
|
||||
# * <prefix>/lib/cmake/<PROJECT-NAME>/<PROJECT-NAME>Config.cmake
|
||||
# * <prefix>/lib/cmake/<PROJECT-NAME>/<PROJECT-NAME>ConfigVersion.cmake
|
||||
install(FILES "${project_config}" "${version_config}"
|
||||
DESTINATION "${config_install_dir}"
|
||||
)
|
||||
|
||||
# Install CMake Target module
|
||||
# * <prefix>/lib/cmake/<PROJECT-NAME>/<PROJECT-NAME>Targets.cmake
|
||||
install(EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
NAMESPACE "${namespace}"
|
||||
DESTINATION "${config_install_dir}"
|
||||
)
|
27
modules/core/cmake/Config.cmake.in
Normal file
27
modules/core/cmake/Config.cmake.in
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Template for CMake Config module.
|
||||
# -------------------------------------------------------------------------------
|
||||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2019 Ivan Roberto de Oliveira
|
||||
#
|
||||
# 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.
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
|
||||
check_required_components("@PROJECT_NAME@")
|
|
@ -1,7 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "vixen/xbox.h"
|
||||
#include "vixen/module.h"
|
||||
|
||||
namespace vixen {
|
||||
|
29
modules/core/include/vixen/debug.h
Normal file
29
modules/core/include/vixen/debug.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
|
||||
#include "virt86/virt86.hpp"
|
||||
|
||||
#include "vixen/log.h"
|
||||
|
||||
namespace vixen {
|
||||
|
||||
/*!
|
||||
* Print the CPU registers
|
||||
*/
|
||||
void DumpCPURegisters(virt86::VirtualProcessor& vp);
|
||||
|
||||
/*!
|
||||
* Dump CPU stack
|
||||
*/
|
||||
void DumpCPUStack(virt86::VirtualProcessor& vp, int32_t offsetStart = -0x20, int32_t offsetEnd = 0x10);
|
||||
|
||||
/*!
|
||||
* Dump memory
|
||||
*/
|
||||
void DumpCPUMemory(virt86::VirtualProcessor& vp, uint32_t address, uint32_t size, bool physical);
|
||||
|
||||
/*!
|
||||
* Disassemble memory region
|
||||
*/
|
||||
void DumpCPUDisassembly(virt86::VirtualProcessor& vp, uint32_t address, uint32_t size, bool physical);
|
||||
|
||||
}
|
|
@ -20,7 +20,7 @@
|
|||
#include <sys/types.h>
|
||||
#ifdef _WIN32
|
||||
# define _WIN32_LEAN_AND_MEAN
|
||||
# include <WinSock2.h>
|
||||
//# include <WinSock2.h>
|
||||
# include <Ws2tcpip.h>
|
||||
# pragma comment (lib, "ws2_32.lib")
|
||||
#else
|
||||
|
@ -36,12 +36,11 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "vixen/cpu.h"
|
||||
|
||||
#include "virt86/virt86.hpp"
|
||||
|
||||
namespace vixen {
|
||||
|
||||
using namespace vixen::cpu;
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef int socklen_t;
|
||||
typedef int ssize_t;
|
||||
|
@ -86,7 +85,7 @@ typedef int (*dbg_dec_func)(const char *buf, size_t buf_len, char *data, size_t
|
|||
|
||||
class GdbServer {
|
||||
protected:
|
||||
Cpu *m_cpu;
|
||||
virt86::VirtualProcessor& m_vp;
|
||||
const char *m_bind_host;
|
||||
int m_bind_port;
|
||||
struct sockaddr_in m_bind_addr;
|
||||
|
@ -137,7 +136,7 @@ protected:
|
|||
int dbg_main();
|
||||
|
||||
public:
|
||||
GdbServer(Cpu *cpu, const char *bind_host, int bind_port);
|
||||
GdbServer(virt86::VirtualProcessor& vp, const char *bind_host, int bind_port);
|
||||
~GdbServer();
|
||||
int Initialize();
|
||||
int WaitForConnection();
|
|
@ -13,9 +13,9 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#include "vixen/cpu.h"
|
||||
#include "../basic/irq.h"
|
||||
#include "../ata/ata_defs.h"
|
||||
#include "vixen/io.h"
|
||||
#include "ata_defs.h"
|
||||
#include "ata_channel.h"
|
||||
|
||||
namespace vixen {
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
#include <mutex>
|
||||
|
||||
#include "vixen/cpu.h"
|
||||
#include "vixen/dynamic_variant.h"
|
||||
#include "../basic/irq.h"
|
||||
#include "../basic/interrupt.h"
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#include "vixen/cpu.h"
|
||||
#include "vixen/util/fifo.h"
|
||||
|
||||
namespace vixen {
|
|
@ -1,10 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include "vixen/io.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <chrono>
|
||||
|
||||
#include "vixen/cpu.h"
|
||||
|
||||
namespace vixen {
|
||||
|
||||
#define CMOS_IRQ 8
|
|
@ -1,15 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "vixen/cpu.h"
|
||||
#include "irq.h"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace vixen {
|
||||
#include "virt86/virt86.hpp"
|
||||
|
||||
using namespace vixen::cpu;
|
||||
#include "vixen/io.h"
|
||||
#include "irq.h"
|
||||
|
||||
namespace vixen {
|
||||
|
||||
#define PORT_PIC_MASTER_COMMAND 0x20
|
||||
#define PORT_PIC_MASTER_DATA 0x21
|
||||
|
@ -28,7 +27,7 @@ using namespace vixen::cpu;
|
|||
|
||||
class i8259 : public IODevice, public IRQHandler {
|
||||
public:
|
||||
i8259(Cpu& cpu);
|
||||
i8259(virt86::VirtualProcessor& cpu);
|
||||
virtual ~i8259();
|
||||
void Reset();
|
||||
|
||||
|
@ -41,7 +40,7 @@ public:
|
|||
|
||||
int GetCurrentIRQ();
|
||||
private:
|
||||
Cpu& m_cpu;
|
||||
virt86::VirtualProcessor& m_vp;
|
||||
|
||||
uint8_t m_PreviousIRR[2]; // used for edge-detection
|
||||
uint8_t m_IRR[2];
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#include "vixen/cpu.h"
|
||||
#include "vixen/io.h"
|
||||
#include "vixen/util/fifo.h"
|
||||
#include "vixen/util/invoke_later.h"
|
||||
#include "char.h"
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#include "vixen/cpu.h"
|
||||
#include "serial.h"
|
||||
|
||||
namespace vixen {
|
|
@ -40,14 +40,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "virt86/virt86.hpp"
|
||||
|
||||
#include "../pci/usb_pci.h"
|
||||
#include "vixen/cxbxtimer.h"
|
||||
#include "vixen/cpu.h"
|
||||
|
||||
namespace vixen {
|
||||
|
||||
using namespace vixen::cpu;
|
||||
|
||||
// Abbreviations used:
|
||||
// OHCI: Open Host Controller Interface; the standard used on the Xbox to comunicate with the usb devices
|
||||
// HC: Host Controller; the hardware which interfaces with the usb device and the usb driver
|
||||
|
@ -148,7 +147,7 @@ public:
|
|||
std::atomic_bool m_bFrameTime;
|
||||
|
||||
// constructor
|
||||
OHCI(Cpu& cpu, int Irqn, USBPCIDevice* UsbObj);
|
||||
OHCI(virt86::VirtualProcessor& vp, int Irqn, USBPCIDevice* UsbObj);
|
||||
// destructor
|
||||
~OHCI() {}
|
||||
// read a register
|
||||
|
@ -157,7 +156,7 @@ public:
|
|||
void OHCI_WriteRegister(uint32_t Addr, uint32_t Value);
|
||||
|
||||
private:
|
||||
Cpu& m_cpu;
|
||||
virt86::VirtualProcessor& m_vp;
|
||||
// pointer to g_USB0 or g_USB1
|
||||
USBPCIDevice* m_UsbDevice = nullptr;
|
||||
// all the registers available in the OHCI standard
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include "../defs.h"
|
||||
#include "pci.h"
|
||||
#include "bmide/bmide_defs.h"
|
||||
#include "bmide_defs.h"
|
||||
#include "bmide_channel.h"
|
||||
#include "vixen/hw/ata/ata.h"
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
#include <cstdint>
|
||||
#include <mutex>
|
||||
|
||||
#include "bmide/bmide_defs.h"
|
||||
#include "vixen/hw/pci/bmide_defs.h"
|
||||
#include "vixen/hw/ata/ata_common.h"
|
||||
#include "vixen/hw/ata/ata.h"
|
||||
|
|
@ -42,15 +42,14 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#include "virt86/virt86.hpp"
|
||||
|
||||
#include "../defs.h"
|
||||
#include "pci.h"
|
||||
#include "../ohci/ohci_common.h"
|
||||
#include "vixen/cpu.h"
|
||||
|
||||
namespace vixen {
|
||||
|
||||
using namespace vixen::cpu;
|
||||
|
||||
typedef enum USBDeviceFlags {
|
||||
USB_DEV_FLAG_FULL_PATH,
|
||||
USB_DEV_FLAG_IS_HOST,
|
||||
|
@ -66,7 +65,7 @@ class OHCI;
|
|||
class USBPCIDevice : public PCIDevice {
|
||||
public:
|
||||
// constructor
|
||||
USBPCIDevice(uint8_t irqn, Cpu& cpu);
|
||||
USBPCIDevice(uint8_t irqn, virt86::VirtualProcessor& vp);
|
||||
virtual ~USBPCIDevice();
|
||||
|
||||
// PCI Device functions
|
||||
|
@ -207,7 +206,7 @@ public:
|
|||
const char* USBDesc_GetString(XboxDeviceState* dev, int index);
|
||||
private:
|
||||
uint8_t m_irqn;
|
||||
Cpu& m_cpu;
|
||||
virt86::VirtualProcessor& m_vp;
|
||||
};
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue