Implement public header files

This commit is contained in:
MerryMage 2016-08-25 18:22:08 +01:00
parent 656d4f7252
commit ed3a686d1d
12 changed files with 100 additions and 47 deletions

View file

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.4.1) cmake_minimum_required(VERSION 3.4.1)
project(dynarmic) project(dynarmic CXX)
# Dynarmic project options # Dynarmic project options
option(DYNARMIC_USE_SYSTEM_BOOST "Use the system boost libraries" ON) option(DYNARMIC_USE_SYSTEM_BOOST "Use the system boost libraries" ON)
@ -13,6 +13,13 @@ set(CMAKE_CXX_EXTENSIONS OFF)
# Warn on CMake API deprecations # Warn on CMake API deprecations
set(CMAKE_WARN_DEPRECATED ON) set(CMAKE_WARN_DEPRECATED ON)
# Disable in-source builds
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(SEND_ERROR "In-source builds are not allowed.")
endif()
# Signify where the module directories are # Signify where the module directories are
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules)

View file

@ -0,0 +1,35 @@
/* This file is part of the dynarmic project.
* Copyright (c) 2016 MerryMage
* This software may be used and distributed according to the terms of the GNU
* General Public License version 2 or any later version.
*/
#pragma once
#include <cstdint>
namespace Dynarmic {
class Jit;
/// These function pointers may be inserted into compiled code.
struct UserCallbacks {
std::uint8_t (*MemoryRead8)(std::uint32_t vaddr);
std::uint16_t (*MemoryRead16)(std::uint32_t vaddr);
std::uint32_t (*MemoryRead32)(std::uint32_t vaddr);
std::uint64_t (*MemoryRead64)(std::uint32_t vaddr);
void (*MemoryWrite8)(std::uint32_t vaddr, std::uint8_t value);
void (*MemoryWrite16)(std::uint32_t vaddr, std::uint16_t value);
void (*MemoryWrite32)(std::uint32_t vaddr, std::uint32_t value);
void (*MemoryWrite64)(std::uint32_t vaddr, std::uint64_t value);
bool (*IsReadOnlyMemory)(std::uint32_t vaddr);
/// The intrepreter must execute only one instruction at PC.
void (*InterpreterFallback)(std::uint32_t pc, Jit* jit);
bool (*CallSVC)(std::uint32_t swi);
};
} // namespace Dynarmic

View file

@ -0,0 +1,19 @@
/* This file is part of the dynarmic project.
* Copyright (c) 2016 MerryMage
* This software may be used and distributed according to the terms of the GNU
* General Public License version 2 or any later version.
*/
#pragma once
#include <cstdint>
#include <string>
namespace Dynarmic {
namespace Arm {
std::string DisassembleArm(std::uint32_t instruction);
std::string DisassembleThumb16(std::uint16_t instruction);
} // namespace Arm
} // namespace Dynarmic

View file

@ -6,9 +6,12 @@
#pragma once #pragma once
#include <cstddef>
#include <cstdint>
#include <string>
#include <memory> #include <memory>
#include "common/common_types.h" #include <dynarmic/callbacks.h>
namespace Dynarmic { namespace Dynarmic {
@ -16,28 +19,6 @@ namespace Arm {
struct LocationDescriptor; struct LocationDescriptor;
} }
class Jit;
/// These function pointers may be inserted into compiled code.
struct UserCallbacks {
u8 (*MemoryRead8)(u32 vaddr);
u16 (*MemoryRead16)(u32 vaddr);
u32 (*MemoryRead32)(u32 vaddr);
u64 (*MemoryRead64)(u32 vaddr);
void (*MemoryWrite8)(u32 vaddr, u8 value);
void (*MemoryWrite16)(u32 vaddr, u16 value);
void (*MemoryWrite32)(u32 vaddr, u32 value);
void (*MemoryWrite64)(u32 vaddr, u64 value);
bool (*IsReadOnlyMemory)(u32 vaddr);
/// The intrepreter must execute only one instruction at PC.
void (*InterpreterFallback)(u32 pc, Jit* jit);
bool (*CallSVC)(u32 swi);
};
class Jit final { class Jit final {
public: public:
explicit Jit(Dynarmic::UserCallbacks callbacks); explicit Jit(Dynarmic::UserCallbacks callbacks);
@ -49,7 +30,7 @@ public:
* @param cycle_count Estimated number of cycles to run the CPU for. * @param cycle_count Estimated number of cycles to run the CPU for.
* @returns Actual cycle count. * @returns Actual cycle count.
*/ */
size_t Run(size_t cycle_count); std::size_t Run(std::size_t cycle_count);
/** /**
* Clears the code cache of all compiled code. * Clears the code cache of all compiled code.
@ -71,18 +52,18 @@ public:
void HaltExecution(); void HaltExecution();
/// View and modify registers. /// View and modify registers.
std::array<u32, 16>& Regs(); std::array<std::uint32_t, 16>& Regs();
const std::array<u32, 16>& Regs() const; const std::array<std::uint32_t, 16>& Regs() const;
std::array<u32, 64>& ExtRegs(); std::array<std::uint32_t, 64>& ExtRegs();
const std::array<u32, 64>& ExtRegs() const; const std::array<std::uint32_t, 64>& ExtRegs() const;
/// View and modify CPSR. /// View and modify CPSR.
u32& Cpsr(); std::uint32_t& Cpsr();
u32 Cpsr() const; std::uint32_t Cpsr() const;
/// View and modify FPSCR. /// View and modify FPSCR.
u32 Fpscr() const; std::uint32_t Fpscr() const;
void SetFpscr(u32 value) const; void SetFpscr(std::uint32_t value) const;
/** /**
* Returns true if Jit::Run was called but hasn't returned yet. * Returns true if Jit::Run was called but hasn't returned yet.

View file

@ -1,6 +1,3 @@
include_directories(.)
include(CreateDirectoryGroups)
set(SRCS set(SRCS
backend_x64/abi.cpp backend_x64/abi.cpp
backend_x64/block_of_code.cpp backend_x64/block_of_code.cpp
@ -39,6 +36,9 @@ set(SRCS
) )
set(HEADERS set(HEADERS
../include/dynarmic/dynarmic.h
../include/dynarmic/callbacks.h
../include/dynarmic/disassembler.h
backend_x64/abi.h backend_x64/abi.h
backend_x64/block_of_code.h backend_x64/block_of_code.h
backend_x64/emit_x64.h backend_x64/emit_x64.h
@ -54,8 +54,8 @@ set(HEADERS
common/mp.h common/mp.h
common/scope_exit.h common/scope_exit.h
common/string_util.h common/string_util.h
frontend/arm_types.h
frontend/arm/FPSCR.h frontend/arm/FPSCR.h
frontend/arm_types.h
frontend/decoder/arm.h frontend/decoder/arm.h
frontend/decoder/decoder_detail.h frontend/decoder/decoder_detail.h
frontend/decoder/thumb16.h frontend/decoder/thumb16.h
@ -70,10 +70,14 @@ set(HEADERS
frontend/ir/value.h frontend/ir/value.h
frontend/translate/translate.h frontend/translate/translate.h
frontend/translate/translate_arm/translate_arm.h frontend/translate/translate_arm/translate_arm.h
interface/interface.h
ir_opt/passes.h ir_opt/passes.h
) )
include(CreateDirectoryGroups)
create_directory_groups(${SRCS} ${HEADERS}) create_directory_groups(${SRCS} ${HEADERS})
add_library(dynarmic STATIC ${SRCS} ${HEADERS}) add_library(dynarmic STATIC ${SRCS} ${HEADERS})
set_target_properties(dynarmic PROPERTIES LINKER_LANGUAGE CXX) set_target_properties(dynarmic PROPERTIES LINKER_LANGUAGE CXX)
target_include_directories(dynarmic
PUBLIC ../include
PRIVATE .)

View file

@ -15,11 +15,11 @@
#include "backend_x64/block_of_code.h" #include "backend_x64/block_of_code.h"
#include "backend_x64/reg_alloc.h" #include "backend_x64/reg_alloc.h"
#include "dynarmic/callbacks.h"
#include "frontend/arm_types.h" #include "frontend/arm_types.h"
#include "frontend/ir/basic_block.h" #include "frontend/ir/basic_block.h"
#include "frontend/ir/microinstruction.h" #include "frontend/ir/microinstruction.h"
#include "frontend/ir/terminal.h" #include "frontend/ir/terminal.h"
#include "interface/interface.h"
namespace Dynarmic { namespace Dynarmic {
namespace BackendX64 { namespace BackendX64 {

View file

@ -19,9 +19,9 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "common/scope_exit.h" #include "common/scope_exit.h"
#include "common/string_util.h" #include "common/string_util.h"
#include "dynarmic/dynarmic.h"
#include "frontend/arm_types.h" #include "frontend/arm_types.h"
#include "frontend/translate/translate.h" #include "frontend/translate/translate.h"
#include "interface/interface.h"
#include "ir_opt/passes.h" #include "ir_opt/passes.h"
namespace Dynarmic { namespace Dynarmic {

View file

@ -1,6 +1,3 @@
include_directories(. ../src)
include(CreateDirectoryGroups)
set(SRCS set(SRCS
arm/fuzz_arm.cpp arm/fuzz_arm.cpp
arm/fuzz_thumb.cpp arm/fuzz_thumb.cpp
@ -34,7 +31,13 @@ set(HEADERS
skyeye_interpreter/skyeye_common/vfp/vfp_helper.h skyeye_interpreter/skyeye_common/vfp/vfp_helper.h
) )
include(CreateDirectoryGroups)
create_directory_groups(${SRCS} ${HEADERS}) create_directory_groups(${SRCS} ${HEADERS})
add_executable(dynarmic_tests ${SRCS}) add_executable(dynarmic_tests ${SRCS})
target_link_libraries(dynarmic_tests dynarmic ${llvm_libs}) target_link_libraries(dynarmic_tests dynarmic ${llvm_libs})
set_target_properties(dynarmic_tests PROPERTIES LINKER_LANGUAGE CXX) set_target_properties(dynarmic_tests PROPERTIES LINKER_LANGUAGE CXX)
target_include_directories(dynarmic_tests
PRIVATE . ../src)
add_test(dynarmic_tests dynarmic_tests)

View file

@ -15,13 +15,14 @@
#include <catch.hpp> #include <catch.hpp>
#include <dynarmic/dynarmic.h>
#include "common/bit_util.h" #include "common/bit_util.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "frontend/arm_types.h" #include "frontend/arm_types.h"
#include "frontend/disassembler/disassembler.h" #include "frontend/disassembler/disassembler.h"
#include "frontend/ir/basic_block.h" #include "frontend/ir/basic_block.h"
#include "frontend/translate/translate.h" #include "frontend/translate/translate.h"
#include "interface/interface.h"
#include "ir_opt/passes.h" #include "ir_opt/passes.h"
#include "rand_int.h" #include "rand_int.h"
#include "skyeye_interpreter/dyncom/arm_dyncom_interpreter.h" #include "skyeye_interpreter/dyncom/arm_dyncom_interpreter.h"

View file

@ -14,12 +14,13 @@
#include <catch.hpp> #include <catch.hpp>
#include <dynarmic/dynarmic.h>
#include "common/bit_util.h" #include "common/bit_util.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "frontend/disassembler/disassembler.h" #include "frontend/disassembler/disassembler.h"
#include "frontend/ir/basic_block.h" #include "frontend/ir/basic_block.h"
#include "frontend/translate/translate.h" #include "frontend/translate/translate.h"
#include "interface/interface.h"
#include "ir_opt/passes.h" #include "ir_opt/passes.h"
#include "rand_int.h" #include "rand_int.h"
#include "skyeye_interpreter/dyncom/arm_dyncom_interpreter.h" #include "skyeye_interpreter/dyncom/arm_dyncom_interpreter.h"

View file

@ -6,8 +6,9 @@
#include <catch.hpp> #include <catch.hpp>
#include <dynarmic/dynarmic.h>
#include "common/common_types.h" #include "common/common_types.h"
#include "interface/interface.h"
#include "skyeye_interpreter/dyncom/arm_dyncom_interpreter.h" #include "skyeye_interpreter/dyncom/arm_dyncom_interpreter.h"
#include "skyeye_interpreter/skyeye_common/armstate.h" #include "skyeye_interpreter/skyeye_common/armstate.h"

View file

@ -20,8 +20,9 @@
#include <array> #include <array>
#include <unordered_map> #include <unordered_map>
#include <dynarmic/dynarmic.h>
#include "common/common_types.h" #include "common/common_types.h"
#include "interface/interface.h"
#include "skyeye_interpreter/skyeye_common/arm_regformat.h" #include "skyeye_interpreter/skyeye_common/arm_regformat.h"
// Signal levels // Signal levels