Merge branch 'master' into bsd

This commit is contained in:
flerovium^-^
2018-01-18 14:24:11 +01:00
committed by GitHub
33 changed files with 600 additions and 575 deletions

View File

@@ -32,7 +32,7 @@ matrix:
deploy: deploy:
provider: releases provider: releases
api_key: api_key:
secure: IuTT8DjxzNgOtaEsyOpz1JaSmtDtHSsWZnJKmSBwXAzgP2ZU4Ja3/q0z5PwbC5Ql7kuFahuYTE5oi7lbJBuu2P3y1Wj2zvFozGUkA3JUvEXDNOPS9QTJ1EYd6O+wenZoj7d/Pn+ZeIgyEafnnZsGBb8lMQnV9MfIHgYlZQ5EyF3n4XikT2h1UbDBYx74ciXZIxFEulx68kDr9Q4/U+zIYQmYv2N+lgXSLDkFrCJ046gRcujPYGPqE6jVw0kKni80CTTpuDF5prU8yIBeiffjkJ3Qx1a17G07eZ4r83P4XUOlaHbRBmA/8ywZvLF2Gep3wGKfSFgMWbPxBJk5ZSYcOOAgMsEcg0+gBK9gLTwO4pbmc2GvqP21yRQBzgtbFoEtAHLu5lVPBkZU7kZuRMJtRdqvFIwOLhpnRS8IknFOD5vjtaFiNdGWaK9ePdsGvplijnXcPafkumakc4+eVEiXb6/KzdX1zXdur5tuUPFytm0Oy6IJcGIf8FHXGvUlmWsnPzwfusij9JgeQOP+uegc9PdBfL+h7L5rk+ilELt3cXD5K7wgov/4hkl5istNJ2bm0IioIstWss8QQQTkyscGoeh/oXmUpOL4FdsTvsWhDR3QKeq8nSzgDkqLe0iSbplQGnC7o7ytNbldmxJvf3nylwglA8w3HlqLHtZLkUOcuQ0= secure: ElsIAlbvVXBNKsP31nVPysh+mf0GQA4DiL/y5iJeQxKQYR6iRoNo+RfzOBmdswdo0bE/PGeBAlfzCkp15gjhWf6Je0N6dRpczmcmLq6SSQFn1Mpq00xMJB2AgQIlaHs6KFgoUA173EBKbPwgU/NubTFpJFm/Wa+NcSWAHQXKL9KT2M3qKpxNkPl3mKEVsbch4REP+T/46vsa+ikw0VE0kIs6V93LqUQZpI2F0Dhihx8Cxr5iedkE1QsNK+QSX9iItMHbfek9OH980gP7L3lkZltyAA1Pk0c37OAgz2PwczwNKwCT8jg9PMzdcKmWouvLyAkZFuA806ElzwHY3oEd91Zm6+Bk5n24yBKZ9027AZzw38NK2Z2m9Akb8+ar8PdsKU6N5pDutX9qSLayr0oMgJ0s7/xnGBGdL3gfkPCFc50xO/2DxlsOR+zAhPNM9Y76hhGy6A7/40+9uzrJvd4nAuDvIXRzi2Yl2L7mKBE4suMKbFLtk2LlgM0qY5JMVTQ8NliaEtqopfPur2KWFVJUpWDNLtNX8xGqhfwg7cLjIiGmnxSaJBTDuZI6dpEjkWkU0n1xYhGqEqit8DbehYzazozMJ+Vsr8hku7jGlUtlw+U6HG1e19O2y4aGeSwYPROcCNz+BLwmVM8oZE3Roy3qoaa2yiFf+sy6rUHznrhsfEM=
file_glob: true file_glob: true
file: "artifacts/*" file: "artifacts/*"
skip_cleanup: true skip_cleanup: true

View File

@@ -323,12 +323,14 @@ endif()
# This function should be passed a list of all files in a target. It will automatically generate # This function should be passed a list of all files in a target. It will automatically generate
# file groups following the directory hierarchy, so that the layout of the files in IDEs matches the # file groups following the directory hierarchy, so that the layout of the files in IDEs matches the
# one in the filesystem. # one in the filesystem.
function(create_directory_groups) function(create_target_directory_groups target_name)
# Place any files that aren't in the source list in a separate group so that they don't get in # Place any files that aren't in the source list in a separate group so that they don't get in
# the way. # the way.
source_group("Other Files" REGULAR_EXPRESSION ".") source_group("Other Files" REGULAR_EXPRESSION ".")
foreach(file_name ${ARGV}) get_target_property(target_sources "${target_name}" SOURCES)
foreach(file_name IN LISTS target_sources)
get_filename_component(dir_name "${file_name}" PATH) get_filename_component(dir_name "${file_name}" PATH)
# Group names use '\' as a separator even though the entire rest of CMake uses '/'... # Group names use '\' as a separator even though the entire rest of CMake uses '/'...
string(REPLACE "/" "\\" group_name "${dir_name}") string(REPLACE "/" "\\" group_name "${dir_name}")

View File

@@ -163,7 +163,7 @@ deploy:
provider: GitHub provider: GitHub
release: $(appveyor_repo_tag_name) release: $(appveyor_repo_tag_name)
auth_token: auth_token:
secure: "argb6oi2TYLB4wDy+HoCC8PuGAmsnocSk12CQ5614XAPO+NVPndlkLv1utnDFfg2" secure: QqePPnXbkzmXct5c8hZ2X5AbsthbI6cS1Sr+VBzcD8oUOIjfWJJKXVAQGUbQAbb0
artifact: update,build artifact: update,build
draft: false draft: false
prerelease: false prerelease: false

View File

@@ -1,11 +1,9 @@
set(SRCS add_library(getopt
getopt.c getopt.c
) getopt.h
set(HEADERS )
getopt.h
) create_target_directory_groups(getopt)
create_directory_groups(${SRCS} ${HEADERS})
add_library(getopt ${SRCS} ${HEADERS})
target_compile_definitions(getopt PUBLIC STATIC_GETOPT) target_compile_definitions(getopt PUBLIC STATIC_GETOPT)
target_include_directories(getopt INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(getopt INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})

View File

@@ -1,13 +1,10 @@
set(SRCS add_library(glad STATIC
src/glad.c src/glad.c
) include/KHR/khrplatform.h
set(HEADERS include/glad/glad.h
include/KHR/khrplatform.h )
include/glad/glad.h
)
create_directory_groups(${SRCS} ${HEADERS}) create_target_directory_groups(glad)
add_library(glad STATIC ${SRCS} ${HEADERS})
target_include_directories(glad PUBLIC "include/") target_include_directories(glad PUBLIC "include/")
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")

View File

@@ -1,12 +1,9 @@
set(SRCS add_library(inih
inih/ini.c inih/ini.c
inih/cpp/INIReader.cpp inih/ini.h
) inih/cpp/INIReader.cpp
set(HEADERS inih/cpp/INIReader.h
inih/ini.h )
inih/cpp/INIReader.h
)
create_directory_groups(${SRCS} ${HEADERS}) create_target_directory_groups(inih)
add_library(inih ${SRCS} ${HEADERS})
target_include_directories(inih INTERFACE .) target_include_directories(inih INTERFACE .)

View File

@@ -24,78 +24,72 @@ if ($ENV{CI})
endif() endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp.in" "${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp" @ONLY) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp.in" "${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp" @ONLY)
set(SRCS add_library(common STATIC
break_points.cpp alignment.h
file_util.cpp assert.h
hash.cpp bit_field.h
logging/filter.cpp bit_set.h
logging/text_formatter.cpp break_points.cpp
logging/backend.cpp break_points.h
memory_util.cpp chunk_file.h
microprofile.cpp code_block.h
misc.cpp color.h
param_package.cpp common_funcs.h
scm_rev.cpp common_paths.h
string_util.cpp common_types.h
telemetry.cpp file_util.cpp
thread.cpp file_util.h
timer.cpp hash.cpp
) hash.h
linear_disk_cache.h
set(HEADERS logging/backend.cpp
alignment.h logging/backend.h
assert.h logging/filter.cpp
bit_field.h logging/filter.h
bit_set.h logging/log.h
break_points.h logging/text_formatter.cpp
chunk_file.h logging/text_formatter.h
code_block.h math_util.h
color.h memory_util.cpp
common_funcs.h memory_util.h
common_paths.h microprofile.cpp
common_types.h microprofile.h
file_util.h microprofileui.h
hash.h misc.cpp
linear_disk_cache.h param_package.cpp
logging/text_formatter.h param_package.h
logging/filter.h platform.h
logging/log.h quaternion.h
logging/backend.h scm_rev.cpp
math_util.h scm_rev.h
memory_util.h scope_exit.h
microprofile.h string_util.cpp
microprofileui.h string_util.h
param_package.h swap.h
platform.h synchronized_wrapper.h
quaternion.h telemetry.cpp
scm_rev.h telemetry.h
scope_exit.h thread.cpp
string_util.h thread.h
swap.h thread_queue_list.h
synchronized_wrapper.h threadsafe_queue.h
telemetry.h timer.cpp
thread.h timer.h
thread_queue_list.h vector_math.h
threadsafe_queue.h )
timer.h
vector_math.h
)
if(ARCHITECTURE_x86_64) if(ARCHITECTURE_x86_64)
set(SRCS ${SRCS} target_sources(common
PRIVATE
x64/cpu_detect.cpp x64/cpu_detect.cpp
)
set(HEADERS ${HEADERS}
x64/cpu_detect.h x64/cpu_detect.h
x64/xbyak_abi.h x64/xbyak_abi.h
x64/xbyak_util.h x64/xbyak_util.h
) )
endif() endif()
create_directory_groups(${SRCS} ${HEADERS}) create_target_directory_groups(common)
add_library(common STATIC ${SRCS} ${HEADERS})
target_link_libraries(common PUBLIC Boost::boost microprofile) target_link_libraries(common PUBLIC Boost::boost microprofile)
if (ARCHITECTURE_x86_64) if (ARCHITECTURE_x86_64)
target_link_libraries(common PRIVATE xbyak) target_link_libraries(common PRIVATE xbyak)

View File

@@ -53,10 +53,10 @@ template <typename T>
class Field : public FieldInterface { class Field : public FieldInterface {
public: public:
Field(FieldType type, std::string name, const T& value) Field(FieldType type, std::string name, const T& value)
: type(type), name(std::move(name)), value(value) {} : name(std::move(name)), type(type), value(value) {}
Field(FieldType type, std::string name, T&& value) Field(FieldType type, std::string name, T&& value)
: type(type), name(std::move(name)), value(std::move(value)) {} : name(std::move(name)), type(type), value(std::move(value)) {}
Field(const Field& other) : Field(other.type, other.name, other.value) {} Field(const Field& other) : Field(other.type, other.name, other.value) {}

View File

@@ -1,177 +1,176 @@
set(SRCS add_library(core STATIC
arm/dynarmic/arm_dynarmic.cpp arm/arm_interface.h
arm/unicorn/arm_unicorn.cpp arm/dynarmic/arm_dynarmic.cpp
core.cpp arm/dynarmic/arm_dynarmic.h
core_timing.cpp arm/unicorn/arm_unicorn.cpp
file_sys/archive_backend.cpp arm/unicorn/arm_unicorn.h
file_sys/disk_archive.cpp core.cpp
file_sys/ivfc_archive.cpp core.h
file_sys/path_parser.cpp core_timing.cpp
file_sys/savedata_archive.cpp core_timing.h
file_sys/title_metadata.cpp file_sys/archive_backend.cpp
frontend/emu_window.cpp file_sys/archive_backend.h
frontend/framebuffer_layout.cpp file_sys/directory_backend.h
gdbstub/gdbstub.cpp file_sys/disk_archive.cpp
hle/config_mem.cpp file_sys/disk_archive.h
hle/kernel/address_arbiter.cpp file_sys/errors.h
hle/kernel/client_port.cpp file_sys/file_backend.h
hle/kernel/client_session.cpp file_sys/ivfc_archive.cpp
hle/kernel/condition_variable.cpp file_sys/ivfc_archive.h
hle/kernel/domain.cpp file_sys/path_parser.cpp
hle/kernel/event.cpp file_sys/path_parser.h
hle/kernel/handle_table.cpp file_sys/savedata_archive.cpp
hle/kernel/hle_ipc.cpp file_sys/savedata_archive.h
hle/kernel/kernel.cpp file_sys/title_metadata.cpp
hle/kernel/memory.cpp file_sys/title_metadata.h
hle/kernel/mutex.cpp frontend/emu_window.cpp
hle/kernel/object_address_table.cpp frontend/emu_window.h
hle/kernel/process.cpp frontend/framebuffer_layout.cpp
hle/kernel/resource_limit.cpp frontend/framebuffer_layout.h
hle/kernel/server_port.cpp frontend/input.h
hle/kernel/server_session.cpp gdbstub/gdbstub.cpp
hle/kernel/shared_memory.cpp gdbstub/gdbstub.h
hle/kernel/svc.cpp hle/config_mem.cpp
hle/kernel/thread.cpp hle/config_mem.h
hle/kernel/timer.cpp hle/ipc.h
hle/kernel/vm_manager.cpp hle/ipc_helpers.h
hle/kernel/wait_object.cpp hle/kernel/address_arbiter.cpp
hle/lock.cpp hle/kernel/address_arbiter.h
hle/romfs.cpp hle/kernel/client_port.cpp
hle/service/acc/acc.cpp hle/kernel/client_port.h
hle/service/acc/acc_u0.cpp hle/kernel/client_session.cpp
hle/service/am/am.cpp hle/kernel/client_session.h
hle/service/am/applet_oe.cpp hle/kernel/condition_variable.cpp
hle/service/aoc/aoc_u.cpp hle/kernel/condition_variable.h
hle/service/apm/apm.cpp hle/kernel/domain.cpp
hle/service/audio/audio.cpp hle/kernel/domain.h
hle/service/audio/audout_u.cpp hle/kernel/errors.h
hle/service/hid/hid.cpp hle/kernel/event.cpp
hle/service/lm/lm.cpp hle/kernel/event.h
hle/service/nvdrv/devices/nvdisp_disp0.cpp hle/kernel/handle_table.cpp
hle/service/nvdrv/devices/nvhost_as_gpu.cpp hle/kernel/handle_table.h
hle/service/nvdrv/devices/nvmap.cpp hle/kernel/hle_ipc.cpp
hle/service/nvdrv/interface.cpp hle/kernel/hle_ipc.h
hle/service/nvdrv/nvdrv.cpp hle/kernel/kernel.cpp
hle/service/pctl/pctl.cpp hle/kernel/kernel.h
hle/service/pctl/pctl_a.cpp hle/kernel/memory.cpp
hle/service/service.cpp hle/kernel/memory.h
hle/service/sm/controller.cpp hle/kernel/mutex.cpp
hle/service/sm/sm.cpp hle/kernel/mutex.h
hle/service/time/time.cpp hle/kernel/object_address_table.cpp
hle/service/time/time_s.cpp hle/kernel/object_address_table.h
hle/service/vi/vi.cpp hle/kernel/process.cpp
hle/service/vi/vi_m.cpp hle/kernel/process.h
hle/service/sockets/sockets.cpp hle/kernel/resource_limit.cpp
hle/service/sockets/bsd_u.cpp hle/kernel/resource_limit.h
hle/shared_page.cpp hle/kernel/server_port.cpp
hw/hw.cpp hle/kernel/server_port.h
hw/lcd.cpp hle/kernel/server_session.cpp
loader/elf.cpp hle/kernel/server_session.h
loader/linker.cpp hle/kernel/session.h
loader/loader.cpp hle/kernel/shared_memory.cpp
loader/nro.cpp hle/kernel/shared_memory.h
loader/nso.cpp hle/kernel/svc.cpp
tracer/recorder.cpp hle/kernel/svc.h
memory.cpp hle/kernel/svc_wrap.h
perf_stats.cpp hle/kernel/sync_object.h
settings.cpp hle/kernel/thread.cpp
telemetry_session.cpp hle/kernel/thread.h
) hle/kernel/timer.cpp
hle/kernel/timer.h
hle/kernel/vm_manager.cpp
hle/kernel/vm_manager.h
hle/kernel/wait_object.cpp
hle/kernel/wait_object.h
hle/lock.cpp
hle/lock.h
hle/result.h
hle/romfs.cpp
hle/romfs.h
hle/service/acc/acc.cpp
hle/service/acc/acc.h
hle/service/acc/acc_u0.cpp
hle/service/acc/acc_u0.h
hle/service/am/am.cpp
hle/service/am/am.h
hle/service/am/applet_oe.cpp
hle/service/am/applet_oe.h
hle/service/aoc/aoc_u.cpp
hle/service/aoc/aoc_u.h
hle/service/apm/apm.cpp
hle/service/apm/apm.h
hle/service/audio/audio.cpp
hle/service/audio/audio.h
hle/service/audio/audout_u.cpp
hle/service/audio/audout_u.h
hle/service/hid/hid.cpp
hle/service/hid/hid.h
hle/service/lm/lm.cpp
hle/service/lm/lm.h
hle/service/nvdrv/devices/nvdevice.h
hle/service/nvdrv/devices/nvdisp_disp0.cpp
hle/service/nvdrv/devices/nvdisp_disp0.h
hle/service/nvdrv/devices/nvhost_as_gpu.cpp
hle/service/nvdrv/devices/nvhost_as_gpu.h
hle/service/nvdrv/devices/nvmap.cpp
hle/service/nvdrv/devices/nvmap.h
hle/service/nvdrv/interface.cpp
hle/service/nvdrv/interface.h
hle/service/nvdrv/nvdrv.cpp
hle/service/nvdrv/nvdrv.h
hle/service/pctl/pctl.cpp
hle/service/pctl/pctl.h
hle/service/pctl/pctl_a.cpp
hle/service/pctl/pctl_a.h
hle/service/service.cpp
hle/service/service.h
hle/service/sm/controller.cpp
hle/service/sm/controller.h
hle/service/sm/sm.cpp
hle/service/sm/sm.h
hle/service/sockets/bsd_u.cpp
hle/service/sockets/bsd_u.h
hle/service/sockets/sfdnsres.h
hle/service/sockets/sockets.cpp
hle/service/sockets/sockets.h
hle/service/time/time.cpp
hle/service/time/time.h
hle/service/vi/vi.cpp
hle/service/vi/vi.h
hle/service/vi/vi_m.cpp
hle/service/vi/vi_m.h
hle/shared_page.cpp
hle/shared_page.h
hw/hw.cpp
hw/hw.h
hw/lcd.cpp
hw/lcd.h
loader/elf.cpp
loader/elf.h
loader/linker.cpp
loader/linker.h
loader/loader.cpp
loader/loader.h
loader/nro.cpp
loader/nro.h
loader/nso.cpp
loader/nso.h
memory.cpp
memory.h
memory_setup.h
mmio.h
perf_stats.cpp
perf_stats.h
settings.cpp
settings.h
telemetry_session.cpp
telemetry_session.h
tracer/citrace.h
tracer/recorder.cpp
tracer/recorder.h
)
set(HEADERS create_target_directory_groups(core)
arm/arm_interface.h
arm/dynarmic/arm_dynarmic.h
arm/unicorn/arm_unicorn.h
core.h
core_timing.h
file_sys/archive_backend.h
file_sys/directory_backend.h
file_sys/disk_archive.h
file_sys/errors.h
file_sys/file_backend.h
file_sys/ivfc_archive.h
file_sys/path_parser.h
file_sys/savedata_archive.h
frontend/emu_window.h
frontend/framebuffer_layout.h
frontend/input.h
gdbstub/gdbstub.h
hle/config_mem.h
hle/ipc.h
hle/ipc_helpers.h
hle/kernel/address_arbiter.h
hle/kernel/client_port.h
hle/kernel/client_session.h
hle/kernel/condition_variable.h
hle/kernel/domain.h
hle/kernel/errors.h
hle/kernel/event.h
hle/kernel/handle_table.h
hle/kernel/hle_ipc.h
hle/kernel/kernel.h
hle/kernel/memory.h
hle/kernel/mutex.h
hle/kernel/object_address_table.h
hle/kernel/process.h
hle/kernel/resource_limit.h
hle/kernel/server_port.h
hle/kernel/server_session.h
hle/kernel/session.h
hle/kernel/shared_memory.h
hle/kernel/sync_object.h
hle/kernel/svc.h
hle/kernel/svc_wrap.h
hle/kernel/thread.h
hle/kernel/timer.h
hle/kernel/vm_manager.h
hle/kernel/wait_object.h
hle/lock.h
hle/result.h
hle/romfs.h
hle/service/acc/acc.h
hle/service/acc/acc_u0.h
hle/service/am/am.h
hle/service/am/applet_oe.h
hle/service/aoc/aoc_u.h
hle/service/apm/apm.h
hle/service/audio/audio.h
hle/service/audio/audout_u.h
hle/service/hid/hid.h
hle/service/lm/lm.h
hle/service/nvdrv/devices/nvdevice.h
hle/service/nvdrv/devices/nvdisp_disp0.h
hle/service/nvdrv/devices/nvhost_as_gpu.h
hle/service/nvdrv/devices/nvmap.h
hle/service/nvdrv/interface.h
hle/service/nvdrv/nvdrv.h
hle/service/pctl/pctl.h
hle/service/pctl/pctl_a.h
hle/service/service.h
hle/service/sm/controller.h
hle/service/sm/sm.h
hle/service/time/time.h
hle/service/time/time_s.h
hle/service/vi/vi.h
hle/service/vi/vi_m.h
hle/shared_page.h
hw/hw.h
hw/lcd.h
loader/elf.h
loader/linker.h
loader/loader.h
loader/nro.h
loader/nso.h
tracer/recorder.h
tracer/citrace.h
memory.h
memory_setup.h
mmio.h
perf_stats.h
settings.h
telemetry_session.h
)
create_directory_groups(${SRCS} ${HEADERS})
add_library(core STATIC ${SRCS} ${HEADERS})
target_link_libraries(core PUBLIC common PRIVATE dynarmic video_core) target_link_libraries(core PUBLIC common PRIVATE dynarmic video_core)
target_link_libraries(core PUBLIC Boost::boost PRIVATE fmt lz4_static unicorn) target_link_libraries(core PUBLIC Boost::boost PRIVATE fmt lz4_static unicorn)

View File

@@ -4,6 +4,7 @@
#pragma once #pragma once
#include <array>
#include <string> #include <string>
#include <vector> #include <vector>
#include "common/common_types.h" #include "common/common_types.h"

View File

@@ -57,7 +57,7 @@ static ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size) {
} }
/// Connect to an OS service given the port name, returns the handle to the port to out /// Connect to an OS service given the port name, returns the handle to the port to out
static ResultCode ConnectToPort(Handle* out_handle, VAddr port_name_address) { static ResultCode ConnectToNamedPort(Handle* out_handle, VAddr port_name_address) {
if (!Memory::IsValidVirtualAddress(port_name_address)) if (!Memory::IsValidVirtualAddress(port_name_address))
return ERR_NOT_FOUND; return ERR_NOT_FOUND;
@@ -253,8 +253,8 @@ static ResultCode CancelSynchronization(Handle thread_handle) {
} }
/// Attempts to locks a mutex, creating it if it does not already exist /// Attempts to locks a mutex, creating it if it does not already exist
static ResultCode LockMutex(Handle holding_thread_handle, VAddr mutex_addr, static ResultCode ArbitrateLock(Handle holding_thread_handle, VAddr mutex_addr,
Handle requesting_thread_handle) { Handle requesting_thread_handle) {
LOG_TRACE(Kernel_SVC, "called holding_thread_handle=0x%08X, mutex_addr=0x%llx, " LOG_TRACE(Kernel_SVC, "called holding_thread_handle=0x%08X, mutex_addr=0x%llx, "
"requesting_current_thread_handle=0x%08X", "requesting_current_thread_handle=0x%08X",
holding_thread_handle, mutex_addr, requesting_thread_handle); holding_thread_handle, mutex_addr, requesting_thread_handle);
@@ -277,7 +277,7 @@ static ResultCode LockMutex(Handle holding_thread_handle, VAddr mutex_addr,
} }
/// Unlock a mutex /// Unlock a mutex
static ResultCode UnlockMutex(VAddr mutex_addr) { static ResultCode ArbitrateUnlock(VAddr mutex_addr) {
LOG_TRACE(Kernel_SVC, "called mutex_addr=0x%llx", mutex_addr); LOG_TRACE(Kernel_SVC, "called mutex_addr=0x%llx", mutex_addr);
SharedPtr<Mutex> mutex = g_object_address_table.Get<Mutex>(mutex_addr); SharedPtr<Mutex> mutex = g_object_address_table.Get<Mutex>(mutex_addr);
@@ -774,12 +774,12 @@ static const FunctionDef SVC_Table[] = {
{0x17, SvcWrap<ResetSignal>, "ResetSignal"}, {0x17, SvcWrap<ResetSignal>, "ResetSignal"},
{0x18, SvcWrap<WaitSynchronization>, "WaitSynchronization"}, {0x18, SvcWrap<WaitSynchronization>, "WaitSynchronization"},
{0x19, SvcWrap<CancelSynchronization>, "CancelSynchronization"}, {0x19, SvcWrap<CancelSynchronization>, "CancelSynchronization"},
{0x1A, SvcWrap<LockMutex>, "LockMutex"}, {0x1A, SvcWrap<ArbitrateLock>, "ArbitrateLock"},
{0x1B, SvcWrap<UnlockMutex>, "UnlockMutex"}, {0x1B, SvcWrap<ArbitrateUnlock>, "ArbitrateUnlock"},
{0x1C, SvcWrap<WaitProcessWideKeyAtomic>, "WaitProcessWideKeyAtomic"}, {0x1C, SvcWrap<WaitProcessWideKeyAtomic>, "WaitProcessWideKeyAtomic"},
{0x1D, SvcWrap<SignalProcessWideKey>, "SignalProcessWideKey"}, {0x1D, SvcWrap<SignalProcessWideKey>, "SignalProcessWideKey"},
{0x1E, SvcWrap<GetSystemTick>, "GetSystemTick"}, {0x1E, SvcWrap<GetSystemTick>, "GetSystemTick"},
{0x1F, SvcWrap<ConnectToPort>, "ConnectToPort"}, {0x1F, SvcWrap<ConnectToNamedPort>, "ConnectToNamedPort"},
{0x20, nullptr, "SendSyncRequestLight"}, {0x20, nullptr, "SendSyncRequestLight"},
{0x21, SvcWrap<SendSyncRequest>, "SendSyncRequest"}, {0x21, SvcWrap<SendSyncRequest>, "SendSyncRequest"},
{0x22, nullptr, "SendSyncRequestWithUserBuffer"}, {0x22, nullptr, "SendSyncRequestWithUserBuffer"},
@@ -823,8 +823,8 @@ static const FunctionDef SVC_Table[] = {
{0x48, nullptr, "Unknown"}, {0x48, nullptr, "Unknown"},
{0x49, nullptr, "Unknown"}, {0x49, nullptr, "Unknown"},
{0x4A, nullptr, "Unknown"}, {0x4A, nullptr, "Unknown"},
{0x4B, nullptr, "Unknown"}, {0x4B, nullptr, "CreateJitMemory"},
{0x4C, nullptr, "Unknown"}, {0x4C, nullptr, "MapJitMemory"},
{0x4D, nullptr, "SleepSystem"}, {0x4D, nullptr, "SleepSystem"},
{0x4E, nullptr, "ReadWriteRegister"}, {0x4E, nullptr, "ReadWriteRegister"},
{0x4F, nullptr, "SetProcessActivity"}, {0x4F, nullptr, "SetProcessActivity"},

View File

@@ -32,6 +32,12 @@ void Controller::DuplicateSession(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service, "called"); LOG_DEBUG(Service, "called");
} }
void Controller::DuplicateSessionEx(Kernel::HLERequestContext& ctx) {
DuplicateSession(ctx);
LOG_WARNING(Service, "(STUBBED) called, using DuplicateSession");
}
void Controller::QueryPointerBufferSize(Kernel::HLERequestContext& ctx) { void Controller::QueryPointerBufferSize(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb{ctx, 3}; IPC::RequestBuilder rb{ctx, 3};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
@@ -46,7 +52,7 @@ Controller::Controller() : ServiceFramework("IpcController") {
{0x00000001, nullptr, "ConvertDomainToSession"}, {0x00000001, nullptr, "ConvertDomainToSession"},
{0x00000002, &Controller::DuplicateSession, "DuplicateSession"}, {0x00000002, &Controller::DuplicateSession, "DuplicateSession"},
{0x00000003, &Controller::QueryPointerBufferSize, "QueryPointerBufferSize"}, {0x00000003, &Controller::QueryPointerBufferSize, "QueryPointerBufferSize"},
{0x00000004, nullptr, "DuplicateSessionEx"}, {0x00000004, &Controller::DuplicateSessionEx, "DuplicateSessionEx"},
}; };
RegisterHandlers(functions); RegisterHandlers(functions);
} }

View File

@@ -17,6 +17,7 @@ public:
private: private:
void ConvertSessionToDomain(Kernel::HLERequestContext& ctx); void ConvertSessionToDomain(Kernel::HLERequestContext& ctx);
void DuplicateSession(Kernel::HLERequestContext& ctx); void DuplicateSession(Kernel::HLERequestContext& ctx);
void DuplicateSessionEx(Kernel::HLERequestContext& ctx);
void QueryPointerBufferSize(Kernel::HLERequestContext& ctx); void QueryPointerBufferSize(Kernel::HLERequestContext& ctx);
}; };

View File

@@ -2,14 +2,140 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <chrono>
#include "common/logging/log.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/client_port.h"
#include "core/hle/kernel/client_session.h"
#include "core/hle/service/time/time.h" #include "core/hle/service/time/time.h"
#include "core/hle/service/time/time_s.h"
namespace Service { namespace Service {
namespace Time { namespace Time {
class ISystemClock final : public ServiceFramework<ISystemClock> {
public:
ISystemClock() : ServiceFramework("ISystemClock") {
static const FunctionInfo functions[] = {
{0, &ISystemClock::GetCurrentTime, "GetCurrentTime"},
};
RegisterHandlers(functions);
}
private:
void GetCurrentTime(Kernel::HLERequestContext& ctx) {
const s64 time_since_epoch{std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count()};
IPC::RequestBuilder rb{ctx, 4};
rb.Push(RESULT_SUCCESS);
rb.Push<u64>(time_since_epoch);
LOG_DEBUG(Service, "called");
}
};
class ISteadyClock final : public ServiceFramework<ISteadyClock> {
public:
ISteadyClock() : ServiceFramework("ISteadyClock") {}
};
class ITimeZoneService final : public ServiceFramework<ITimeZoneService> {
public:
ITimeZoneService() : ServiceFramework("ITimeZoneService") {
static const FunctionInfo functions[] = {
{0, &ITimeZoneService::GetDeviceLocationName, "GetDeviceLocationName"},
{101, &ITimeZoneService::ToCalendarTimeWithMyRule, "ToCalendarTimeWithMyRule"},
};
RegisterHandlers(functions);
}
private:
void GetDeviceLocationName(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service, "(STUBBED) called");
LocationName name{};
IPC::RequestBuilder rb{ctx, 11};
rb.Push(RESULT_SUCCESS);
rb.PushRaw(name);
}
void ToCalendarTimeWithMyRule(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
u64 posixTime = rp.Pop<u64>();
LOG_WARNING(Service, "(STUBBED) called, posixTime=0x%016llX", posixTime);
CalendarTime calendarTime{2018, 1, 1, 0, 0, 0};
CalendarAdditionalInfo additionalInfo{};
IPC::RequestBuilder rb{ctx, 10};
rb.Push(RESULT_SUCCESS);
rb.PushRaw(calendarTime);
rb.PushRaw(additionalInfo);
}
};
void TIME::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) {
auto client_port = std::make_shared<ISystemClock>()->CreatePort();
auto session = client_port->Connect();
if (session.Succeeded()) {
LOG_DEBUG(Service, "called, initialized ISystemClock -> session=%u",
(*session)->GetObjectId());
IPC::RequestBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS);
rb.PushMoveObjects(std::move(session).Unwrap());
} else {
UNIMPLEMENTED();
}
}
void TIME::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) {
auto client_port = std::make_shared<ISystemClock>()->CreatePort();
auto session = client_port->Connect();
if (session.Succeeded()) {
LOG_DEBUG(Service, "called, initialized ISystemClock -> session=%u",
(*session)->GetObjectId());
IPC::RequestBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS);
rb.PushMoveObjects(std::move(session).Unwrap());
} else {
UNIMPLEMENTED();
}
}
void TIME::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) {
auto client_port = std::make_shared<ISteadyClock>()->CreatePort();
auto session = client_port->Connect();
if (session.Succeeded()) {
LOG_DEBUG(Service, "called, initialized ISteadyClock -> session=%u",
(*session)->GetObjectId());
IPC::RequestBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS);
rb.PushMoveObjects(std::move(session).Unwrap());
} else {
UNIMPLEMENTED();
}
}
void TIME::GetTimeZoneService(Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb{ctx, 2, 0, 0, 1};
rb.Push(RESULT_SUCCESS);
rb.PushIpcInterface<ITimeZoneService>();
LOG_DEBUG(Service, "called");
}
TIME::TIME(const char* name) : ServiceFramework(name) {
static const FunctionInfo functions[] = {
{0x00000000, &TIME::GetStandardUserSystemClock, "GetStandardUserSystemClock"},
{0x00000001, &TIME::GetStandardNetworkSystemClock, "GetStandardNetworkSystemClock"},
{0x00000002, &TIME::GetStandardSteadyClock, "GetStandardSteadyClock"},
{0x00000003, &TIME::GetTimeZoneService, "GetTimeZoneService"},
};
RegisterHandlers(functions);
}
void InstallInterfaces(SM::ServiceManager& service_manager) { void InstallInterfaces(SM::ServiceManager& service_manager) {
std::make_shared<TimeS>()->InstallAsService(service_manager); std::make_shared<TIME>("time:a")->InstallAsService(service_manager);
std::make_shared<TIME>("time:r")->InstallAsService(service_manager);
std::make_shared<TIME>("time:s")->InstallAsService(service_manager);
std::make_shared<TIME>("time:u")->InstallAsService(service_manager);
} }
} // namespace Time } // namespace Time

View File

@@ -9,6 +9,42 @@
namespace Service { namespace Service {
namespace Time { namespace Time {
// TODO(Rozelette) RE this structure
struct LocationName {
INSERT_PADDING_BYTES(0x24);
};
static_assert(sizeof(LocationName) == 0x24, "LocationName structure has incorrect size");
struct CalendarTime {
u16_le year;
u8 month; // Starts at 1
u8 day; // Starts at 1
u8 hour;
u8 minute;
u8 second;
INSERT_PADDING_BYTES(1);
};
static_assert(sizeof(CalendarTime) == 0x8, "CalendarTime structure has incorrect size");
// TODO(Rozelette) RE this structure
struct CalendarAdditionalInfo {
INSERT_PADDING_BYTES(0x18);
};
static_assert(sizeof(CalendarAdditionalInfo) == 0x18,
"CalendarAdditionalInfo structure has incorrect size");
class TIME final : public ServiceFramework<TIME> {
public:
explicit TIME(const char* name);
~TIME() = default;
private:
void GetStandardUserSystemClock(Kernel::HLERequestContext& ctx);
void GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx);
void GetStandardSteadyClock(Kernel::HLERequestContext& ctx);
void GetTimeZoneService(Kernel::HLERequestContext& ctx);
};
/// Registers all Time services with the specified service manager. /// Registers all Time services with the specified service manager.
void InstallInterfaces(SM::ServiceManager& service_manager); void InstallInterfaces(SM::ServiceManager& service_manager);

View File

@@ -1,58 +0,0 @@
// Copyright 2018 yuzu emulator team
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <chrono>
#include "common/logging/log.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/client_port.h"
#include "core/hle/kernel/client_session.h"
#include "core/hle/service/time/time_s.h"
namespace Service {
namespace Time {
class ISystemClock final : public ServiceFramework<ISystemClock> {
public:
ISystemClock() : ServiceFramework("ISystemClock") {
static const FunctionInfo functions[] = {
{0, &ISystemClock::GetCurrentTime, "GetCurrentTime"},
};
RegisterHandlers(functions);
}
private:
void GetCurrentTime(Kernel::HLERequestContext& ctx) {
const s64 time_since_epoch{std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count()};
IPC::RequestBuilder rb{ctx, 4};
rb.Push(RESULT_SUCCESS);
rb.Push<u64>(time_since_epoch);
LOG_DEBUG(Service, "called");
}
};
void TimeS::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) {
auto client_port = std::make_shared<ISystemClock>()->CreatePort();
auto session = client_port->Connect();
if (session.Succeeded()) {
LOG_DEBUG(Service, "called, initialized ISystemClock -> session=%u",
(*session)->GetObjectId());
IPC::RequestBuilder rb{ctx, 2, 0, 1};
rb.Push(RESULT_SUCCESS);
rb.PushMoveObjects(std::move(session).Unwrap());
} else {
UNIMPLEMENTED();
}
}
TimeS::TimeS() : ServiceFramework("time:s") {
static const FunctionInfo functions[] = {
{0x00000000, &TimeS::GetStandardUserSystemClock, "GetStandardUserSystemClock"},
};
RegisterHandlers(functions);
}
} // namespace Time
} // namespace Service

View File

@@ -1,23 +0,0 @@
// Copyright 2018 yuzu emulator team
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include "core/hle/kernel/hle_ipc.h"
#include "core/hle/service/service.h"
namespace Service {
namespace Time {
class TimeS final : public ServiceFramework<TimeS> {
public:
TimeS();
~TimeS() = default;
private:
void GetStandardUserSystemClock(Kernel::HLERequestContext& ctx);
};
} // namespace Time
} // namespace Service

View File

@@ -26,7 +26,7 @@ public:
// This default size was chosen arbitrarily. // This default size was chosen arbitrarily.
static constexpr size_t DefaultBufferSize = 0x40; static constexpr size_t DefaultBufferSize = 0x40;
Parcel() : buffer(DefaultBufferSize) {} Parcel() : buffer(DefaultBufferSize) {}
Parcel(std::vector<u8> data) : buffer(std::move(data)) {} explicit Parcel(std::vector<u8> data) : buffer(std::move(data)) {}
virtual ~Parcel() = default; virtual ~Parcel() = default;
template <typename T> template <typename T>
@@ -47,8 +47,9 @@ public:
} }
std::vector<u8> ReadBlock(size_t length) { std::vector<u8> ReadBlock(size_t length) {
std::vector<u8> data(length); const u8* const begin = buffer.data() + read_index;
std::memcpy(data.data(), buffer.data() + read_index, length); const u8* const end = begin + length;
std::vector<u8> data(begin, end);
read_index += length; read_index += length;
read_index = Common::AlignUp(read_index, 4); read_index = Common::AlignUp(read_index, 4);
return data; return data;
@@ -101,9 +102,9 @@ public:
} }
protected: protected:
virtual void SerializeData(){}; virtual void SerializeData() {}
virtual void DeserializeData(){}; virtual void DeserializeData() {}
private: private:
struct Header { struct Header {
@@ -121,7 +122,7 @@ private:
class NativeWindow : public Parcel { class NativeWindow : public Parcel {
public: public:
NativeWindow(u32 id) : Parcel() { explicit NativeWindow(u32 id) : Parcel() {
data.id = id; data.id = id;
} }
~NativeWindow() override = default; ~NativeWindow() override = default;
@@ -147,12 +148,12 @@ private:
class IGBPConnectRequestParcel : public Parcel { class IGBPConnectRequestParcel : public Parcel {
public: public:
IGBPConnectRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) { explicit IGBPConnectRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) {
Deserialize(); Deserialize();
} }
~IGBPConnectRequestParcel() override = default; ~IGBPConnectRequestParcel() override = default;
void DeserializeData() { void DeserializeData() override {
std::u16string token = ReadInterfaceToken(); std::u16string token = ReadInterfaceToken();
data = Read<Data>(); data = Read<Data>();
} }
@@ -168,7 +169,7 @@ public:
class IGBPConnectResponseParcel : public Parcel { class IGBPConnectResponseParcel : public Parcel {
public: public:
IGBPConnectResponseParcel(u32 width, u32 height) : Parcel() { explicit IGBPConnectResponseParcel(u32 width, u32 height) : Parcel() {
data.width = width; data.width = width;
data.height = height; data.height = height;
} }
@@ -194,12 +195,13 @@ private:
class IGBPSetPreallocatedBufferRequestParcel : public Parcel { class IGBPSetPreallocatedBufferRequestParcel : public Parcel {
public: public:
IGBPSetPreallocatedBufferRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) { explicit IGBPSetPreallocatedBufferRequestParcel(const std::vector<u8>& buffer)
: Parcel(buffer) {
Deserialize(); Deserialize();
} }
~IGBPSetPreallocatedBufferRequestParcel() override = default; ~IGBPSetPreallocatedBufferRequestParcel() override = default;
void DeserializeData() { void DeserializeData() override {
std::u16string token = ReadInterfaceToken(); std::u16string token = ReadInterfaceToken();
data = Read<Data>(); data = Read<Data>();
ASSERT(data.graphic_buffer_length == sizeof(IGBPBuffer)); ASSERT(data.graphic_buffer_length == sizeof(IGBPBuffer));
@@ -231,12 +233,12 @@ protected:
class IGBPDequeueBufferRequestParcel : public Parcel { class IGBPDequeueBufferRequestParcel : public Parcel {
public: public:
IGBPDequeueBufferRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) { explicit IGBPDequeueBufferRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) {
Deserialize(); Deserialize();
} }
~IGBPDequeueBufferRequestParcel() override = default; ~IGBPDequeueBufferRequestParcel() override = default;
void DeserializeData() { void DeserializeData() override {
std::u16string token = ReadInterfaceToken(); std::u16string token = ReadInterfaceToken();
data = Read<Data>(); data = Read<Data>();
} }
@@ -254,7 +256,7 @@ public:
class IGBPDequeueBufferResponseParcel : public Parcel { class IGBPDequeueBufferResponseParcel : public Parcel {
public: public:
IGBPDequeueBufferResponseParcel(u32 slot) : Parcel(), slot(slot) {} explicit IGBPDequeueBufferResponseParcel(u32 slot) : Parcel(), slot(slot) {}
~IGBPDequeueBufferResponseParcel() override = default; ~IGBPDequeueBufferResponseParcel() override = default;
protected: protected:
@@ -271,12 +273,12 @@ protected:
class IGBPRequestBufferRequestParcel : public Parcel { class IGBPRequestBufferRequestParcel : public Parcel {
public: public:
IGBPRequestBufferRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) { explicit IGBPRequestBufferRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) {
Deserialize(); Deserialize();
} }
~IGBPRequestBufferRequestParcel() override = default; ~IGBPRequestBufferRequestParcel() override = default;
void DeserializeData() { void DeserializeData() override {
std::u16string token = ReadInterfaceToken(); std::u16string token = ReadInterfaceToken();
slot = Read<u32_le>(); slot = Read<u32_le>();
} }
@@ -286,7 +288,7 @@ public:
class IGBPRequestBufferResponseParcel : public Parcel { class IGBPRequestBufferResponseParcel : public Parcel {
public: public:
IGBPRequestBufferResponseParcel(IGBPBuffer buffer) : Parcel(), buffer(buffer) {} explicit IGBPRequestBufferResponseParcel(IGBPBuffer buffer) : Parcel(), buffer(buffer) {}
~IGBPRequestBufferResponseParcel() override = default; ~IGBPRequestBufferResponseParcel() override = default;
protected: protected:
@@ -307,12 +309,12 @@ protected:
class IGBPQueueBufferRequestParcel : public Parcel { class IGBPQueueBufferRequestParcel : public Parcel {
public: public:
IGBPQueueBufferRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) { explicit IGBPQueueBufferRequestParcel(const std::vector<u8>& buffer) : Parcel(buffer) {
Deserialize(); Deserialize();
} }
~IGBPQueueBufferRequestParcel() override = default; ~IGBPQueueBufferRequestParcel() override = default;
void DeserializeData() { void DeserializeData() override {
std::u16string token = ReadInterfaceToken(); std::u16string token = ReadInterfaceToken();
data = Read<Data>(); data = Read<Data>();
} }
@@ -330,7 +332,7 @@ public:
class IGBPQueueBufferResponseParcel : public Parcel { class IGBPQueueBufferResponseParcel : public Parcel {
public: public:
IGBPQueueBufferResponseParcel(u32 width, u32 height) : Parcel() { explicit IGBPQueueBufferResponseParcel(u32 width, u32 height) : Parcel() {
data.width = width; data.width = width;
data.height = height; data.height = height;
} }
@@ -356,7 +358,7 @@ private:
class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> { class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> {
public: public:
IHOSBinderDriver(std::shared_ptr<NVFlinger> nv_flinger) explicit IHOSBinderDriver(std::shared_ptr<NVFlinger> nv_flinger)
: ServiceFramework("IHOSBinderDriver"), nv_flinger(std::move(nv_flinger)) { : ServiceFramework("IHOSBinderDriver"), nv_flinger(std::move(nv_flinger)) {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0, &IHOSBinderDriver::TransactParcel, "TransactParcel"}, {0, &IHOSBinderDriver::TransactParcel, "TransactParcel"},
@@ -506,7 +508,7 @@ private:
class IManagerDisplayService final : public ServiceFramework<IManagerDisplayService> { class IManagerDisplayService final : public ServiceFramework<IManagerDisplayService> {
public: public:
IManagerDisplayService(std::shared_ptr<NVFlinger> nv_flinger) explicit IManagerDisplayService(std::shared_ptr<NVFlinger> nv_flinger)
: ServiceFramework("IManagerDisplayService"), nv_flinger(std::move(nv_flinger)) { : ServiceFramework("IManagerDisplayService"), nv_flinger(std::move(nv_flinger)) {
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{1020, &IManagerDisplayService::CloseDisplay, "CloseDisplay"}, {1020, &IManagerDisplayService::CloseDisplay, "CloseDisplay"},

View File

@@ -62,20 +62,6 @@ static constexpr u32 PageAlignSize(u32 size) {
return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK;
} }
static std::vector<u8> ReadSegment(FileUtil::IOFile& file, const NroSegmentHeader& header) {
std::vector<u8> data;
data.resize(header.size);
file.Seek(header.offset + sizeof(NroHeader), SEEK_SET);
size_t bytes_read{file.ReadBytes(data.data(), header.size)};
if (header.size != PageAlignSize(static_cast<u32>(bytes_read))) {
LOG_CRITICAL(Loader, "Failed to read NRO segment bytes", header.size);
return {};
}
return data;
}
bool AppLoader_NRO::LoadNro(const std::string& path, VAddr load_base) { bool AppLoader_NRO::LoadNro(const std::string& path, VAddr load_base) {
FileUtil::IOFile file(path, "rb"); FileUtil::IOFile file(path, "rb");
if (!file.IsOpen()) { if (!file.IsOpen()) {
@@ -95,7 +81,7 @@ bool AppLoader_NRO::LoadNro(const std::string& path, VAddr load_base) {
// Build program image // Build program image
Kernel::SharedPtr<Kernel::CodeSet> codeset = Kernel::CodeSet::Create("", 0); Kernel::SharedPtr<Kernel::CodeSet> codeset = Kernel::CodeSet::Create("", 0);
std::vector<u8> program_image; std::vector<u8> program_image;
program_image.resize(PageAlignSize(nro_header.file_size + nro_header.bss_size)); program_image.resize(PageAlignSize(nro_header.file_size));
file.Seek(0, SEEK_SET); file.Seek(0, SEEK_SET);
file.ReadBytes(program_image.data(), nro_header.file_size); file.ReadBytes(program_image.data(), nro_header.file_size);
@@ -107,24 +93,18 @@ bool AppLoader_NRO::LoadNro(const std::string& path, VAddr load_base) {
// Read MOD header // Read MOD header
ModHeader mod_header{}; ModHeader mod_header{};
u32 bss_size{Memory::PAGE_SIZE}; // Default .bss to page size if MOD0 section doesn't exist // Default .bss to NRO header bss size if MOD0 section doesn't exist
u32 bss_size{PageAlignSize(nro_header.bss_size)};
std::memcpy(&mod_header, program_image.data() + nro_header.module_header_offset, std::memcpy(&mod_header, program_image.data() + nro_header.module_header_offset,
sizeof(ModHeader)); sizeof(ModHeader));
const bool has_mod_header{mod_header.magic == Common::MakeMagic('M', 'O', 'D', '0')}; const bool has_mod_header{mod_header.magic == Common::MakeMagic('M', 'O', 'D', '0')};
if (has_mod_header) { if (has_mod_header) {
// Resize program image to include .bss section and page align each section // Resize program image to include .bss section and page align each section
bss_size = PageAlignSize(mod_header.bss_end_offset - mod_header.bss_start_offset); bss_size = PageAlignSize(mod_header.bss_end_offset - mod_header.bss_start_offset);
codeset->data.size += bss_size;
} }
codeset->data.size += bss_size;
program_image.resize(PageAlignSize(static_cast<u32>(program_image.size()) + bss_size)); program_image.resize(PageAlignSize(static_cast<u32>(program_image.size()) + bss_size));
// Relocate symbols if there was a proper MOD header - This must happen after the image has been
// loaded into memory
if (has_mod_header) {
Relocate(program_image, nro_header.module_header_offset + mod_header.dynamic_offset,
load_base);
}
// Load codeset for current process // Load codeset for current process
codeset->name = path; codeset->name = path;
codeset->memory = std::make_shared<std::vector<u8>>(std::move(program_image)); codeset->memory = std::make_shared<std::vector<u8>>(std::move(program_image));
@@ -141,9 +121,11 @@ ResultStatus AppLoader_NRO::Load(Kernel::SharedPtr<Kernel::Process>& process) {
return ResultStatus::Error; return ResultStatus::Error;
} }
// Load and relocate "main" and "sdk" NSO
static constexpr VAddr base_addr{Memory::PROCESS_IMAGE_VADDR};
process = Kernel::Process::Create("main"); process = Kernel::Process::Create("main");
// Load NRO
static constexpr VAddr base_addr{Memory::PROCESS_IMAGE_VADDR};
if (!LoadNro(filepath, base_addr)) { if (!LoadNro(filepath, base_addr)) {
return ResultStatus::ErrorInvalidFormat; return ResultStatus::ErrorInvalidFormat;
} }
@@ -152,9 +134,7 @@ ResultStatus AppLoader_NRO::Load(Kernel::SharedPtr<Kernel::Process>& process) {
process->address_mappings = default_address_mappings; process->address_mappings = default_address_mappings;
process->resource_limit = process->resource_limit =
Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION); Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
process->Run(base_addr, 48, Kernel::DEFAULT_STACK_SIZE); process->Run(base_addr + sizeof(NroHeader), 48, Kernel::DEFAULT_STACK_SIZE);
ResolveImports();
is_loaded = true; is_loaded = true;
return ResultStatus::Success; return ResultStatus::Success;

View File

@@ -88,7 +88,7 @@ static constexpr u32 PageAlignSize(u32 size) {
return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK;
} }
VAddr AppLoader_NSO::LoadNso(const std::string& path, VAddr load_base, bool relocate) { VAddr AppLoader_NSO::LoadNso(const std::string& path, VAddr load_base) {
FileUtil::IOFile file(path, "rb"); FileUtil::IOFile file(path, "rb");
if (!file.IsOpen()) { if (!file.IsOpen()) {
return {}; return {};
@@ -135,12 +135,6 @@ VAddr AppLoader_NSO::LoadNso(const std::string& path, VAddr load_base, bool relo
const u32 image_size{PageAlignSize(static_cast<u32>(program_image.size()) + bss_size)}; const u32 image_size{PageAlignSize(static_cast<u32>(program_image.size()) + bss_size)};
program_image.resize(image_size); program_image.resize(image_size);
// Relocate symbols if there was a proper MOD header - This must happen after the image has been
// loaded into memory
if (has_mod_header && relocate) {
Relocate(program_image, module_offset + mod_header.dynamic_offset, load_base);
}
// Load codeset for current process // Load codeset for current process
codeset->name = path; codeset->name = path;
codeset->memory = std::make_shared<std::vector<u8>>(std::move(program_image)); codeset->memory = std::make_shared<std::vector<u8>>(std::move(program_image));
@@ -181,8 +175,6 @@ ResultStatus AppLoader_NSO::Load(Kernel::SharedPtr<Kernel::Process>& process) {
Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION); Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
process->Run(Memory::PROCESS_IMAGE_VADDR, 48, Kernel::DEFAULT_STACK_SIZE); process->Run(Memory::PROCESS_IMAGE_VADDR, 48, Kernel::DEFAULT_STACK_SIZE);
ResolveImports();
is_loaded = true; is_loaded = true;
return ResultStatus::Success; return ResultStatus::Success;
} }

View File

@@ -34,7 +34,7 @@ public:
ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override; ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override;
private: private:
VAddr LoadNso(const std::string& path, VAddr load_base, bool relocate = false); VAddr LoadNso(const std::string& path, VAddr load_base);
std::string filepath; std::string filepath;
}; };

View File

@@ -1,25 +1,18 @@
set(SRCS add_library(input_common STATIC
analog_from_button.cpp analog_from_button.cpp
keyboard.cpp analog_from_button.h
main.cpp keyboard.cpp
motion_emu.cpp keyboard.h
) main.cpp
main.h
motion_emu.cpp
motion_emu.h
set(HEADERS $<$<BOOL:${SDL2_FOUND}>:sdl/sdl.cpp sdl/sdl.h>
analog_from_button.h )
keyboard.h
main.h
motion_emu.h
)
if(SDL2_FOUND) create_target_directory_groups(input_common)
set(SRCS ${SRCS} sdl/sdl.cpp)
set(HEADERS ${HEADERS} sdl/sdl.h)
endif()
create_directory_groups(${SRCS} ${HEADERS})
add_library(input_common STATIC ${SRCS} ${HEADERS})
target_link_libraries(input_common PUBLIC core PRIVATE common) target_link_libraries(input_common PUBLIC core PRIVATE common)
if(SDL2_FOUND) if(SDL2_FOUND)

View File

@@ -425,7 +425,7 @@ std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> GetPollers(
pollers.push_back(std::make_unique<SDLButtonPoller>()); pollers.push_back(std::make_unique<SDLButtonPoller>());
break; break;
} }
return std::move(pollers); return pollers;
} }
} // namespace Polling } // namespace Polling
} // namespace SDL } // namespace SDL

View File

@@ -1,20 +1,16 @@
set(SRCS add_executable(tests
common/param_package.cpp common/param_package.cpp
core/arm/arm_test_common.cpp core/arm/arm_test_common.cpp
core/core_timing.cpp core/arm/arm_test_common.h
core/file_sys/path_parser.cpp core/core_timing.cpp
core/memory/memory.cpp core/file_sys/path_parser.cpp
glad.cpp core/memory/memory.cpp
tests.cpp glad.cpp
) tests.cpp
)
set(HEADERS create_target_directory_groups(tests)
core/arm/arm_test_common.h
)
create_directory_groups(${SRCS} ${HEADERS})
add_executable(tests ${SRCS} ${HEADERS})
target_link_libraries(tests PRIVATE common core) target_link_libraries(tests PRIVATE common core)
target_link_libraries(tests PRIVATE glad) # To support linker work-around target_link_libraries(tests PRIVATE glad) # To support linker work-around
target_link_libraries(tests PRIVATE ${PLATFORM_LIBRARIES} catch-single-include Threads::Threads) target_link_libraries(tests PRIVATE ${PLATFORM_LIBRARIES} catch-single-include Threads::Threads)

View File

@@ -1,23 +1,19 @@
set(SRCS add_library(video_core STATIC
renderer_base.cpp renderer_base.cpp
renderer_opengl/gl_shader_util.cpp renderer_base.h
renderer_opengl/gl_state.cpp renderer_opengl/gl_resource_manager.h
renderer_opengl/renderer_opengl.cpp renderer_opengl/gl_shader_util.cpp
video_core.cpp renderer_opengl/gl_shader_util.h
) renderer_opengl/gl_state.cpp
renderer_opengl/gl_state.h
renderer_opengl/renderer_opengl.cpp
renderer_opengl/renderer_opengl.h
utils.h
video_core.cpp
video_core.h
)
set(HEADERS create_target_directory_groups(video_core)
renderer_base.h
renderer_opengl/gl_resource_manager.h
renderer_opengl/gl_shader_util.h
renderer_opengl/gl_state.h
renderer_opengl/renderer_opengl.h
utils.h
video_core.h
)
create_directory_groups(${SRCS} ${HEADERS})
add_library(video_core STATIC ${SRCS} ${HEADERS})
target_link_libraries(video_core PUBLIC common core) target_link_libraries(video_core PUBLIC common core)
target_link_libraries(video_core PRIVATE glad) target_link_libraries(video_core PRIVATE glad)

View File

@@ -3,79 +3,84 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules)
set(SRCS add_executable(yuzu
about_dialog.cpp Info.plist
configuration/config.cpp about_dialog.cpp
configuration/configure_debug.cpp about_dialog.h
configuration/configure_dialog.cpp bootmanager.cpp
configuration/configure_general.cpp bootmanager.h
configuration/configure_graphics.cpp configuration/config.cpp
configuration/configure_input.cpp configuration/config.h
configuration/configure_system.cpp configuration/configure_debug.cpp
debugger/profiler.cpp configuration/configure_debug.h
debugger/registers.cpp configuration/configure_dialog.cpp
debugger/wait_tree.cpp configuration/configure_dialog.h
util/spinbox.cpp configuration/configure_general.cpp
util/util.cpp configuration/configure_general.h
bootmanager.cpp configuration/configure_graphics.cpp
game_list.cpp configuration/configure_graphics.h
hotkeys.cpp configuration/configure_input.cpp
main.cpp configuration/configure_input.h
ui_settings.cpp configuration/configure_system.cpp
yuzu.rc configuration/configure_system.h
Info.plist debugger/profiler.cpp
) debugger/profiler.h
debugger/registers.cpp
set(HEADERS debugger/registers.h
about_dialog.h debugger/wait_tree.cpp
configuration/config.h debugger/wait_tree.h
configuration/configure_debug.h game_list.cpp
configuration/configure_dialog.h game_list.h
configuration/configure_general.h game_list_p.h
configuration/configure_graphics.h hotkeys.cpp
configuration/configure_input.h hotkeys.h
configuration/configure_system.h main.cpp
debugger/profiler.h main.h
debugger/registers.h ui_settings.cpp
debugger/wait_tree.h ui_settings.h
util/spinbox.h util/spinbox.cpp
util/util.h util/spinbox.h
bootmanager.h util/util.cpp
game_list.h util/util.h
game_list_p.h yuzu.rc
hotkeys.h )
main.h
ui_settings.h
)
set(UIS set(UIS
aboutdialog.ui aboutdialog.ui
configuration/configure.ui configuration/configure.ui
configuration/configure_debug.ui configuration/configure_debug.ui
configuration/configure_general.ui configuration/configure_general.ui
configuration/configure_graphics.ui configuration/configure_graphics.ui
configuration/configure_input.ui configuration/configure_input.ui
configuration/configure_system.ui configuration/configure_system.ui
debugger/registers.ui debugger/registers.ui
hotkeys.ui hotkeys.ui
main.ui main.ui
) )
file(GLOB_RECURSE ICONS ${CMAKE_SOURCE_DIR}/dist/icons/*) file(GLOB_RECURSE ICONS ${CMAKE_SOURCE_DIR}/dist/icons/*)
file(GLOB_RECURSE THEMES ${CMAKE_SOURCE_DIR}/dist/qt_themes/*) file(GLOB_RECURSE THEMES ${CMAKE_SOURCE_DIR}/dist/qt_themes/*)
create_directory_groups(${SRCS} ${HEADERS} ${UIS})
qt5_wrap_ui(UI_HDRS ${UIS}) qt5_wrap_ui(UI_HDRS ${UIS})
target_sources(yuzu
PRIVATE
${ICONS}
${THEMES}
${UI_HDRS}
${UIS}
)
if (APPLE) if (APPLE)
set(MACOSX_ICON "../../dist/yuzu.icns") set(MACOSX_ICON "../../dist/yuzu.icns")
set_source_files_properties(${MACOSX_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) set_source_files_properties(${MACOSX_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
add_executable(yuzu MACOSX_BUNDLE ${SRCS} ${HEADERS} ${UI_HDRS} ${MACOSX_ICON} ${ICONS}) target_sources(yuzu PRIVATE ${MACOSX_ICON})
set_target_properties(yuzu PROPERTIES MACOSX_BUNDLE TRUE)
set_target_properties(yuzu PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) set_target_properties(yuzu PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
else()
add_executable(yuzu ${SRCS} ${HEADERS} ${UI_HDRS} ${ICONS})
endif() endif()
create_target_directory_groups(yuzu)
target_link_libraries(yuzu PRIVATE common core input_common video_core) target_link_libraries(yuzu PRIVATE common core input_common video_core)
target_link_libraries(yuzu PRIVATE Boost::boost glad Qt5::OpenGL Qt5::Widgets) target_link_libraries(yuzu PRIVATE Boost::boost glad Qt5::OpenGL Qt5::Widgets)
target_link_libraries(yuzu PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads) target_link_libraries(yuzu PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads)

View File

@@ -1,12 +1,8 @@
#include <QApplication> #include <QApplication>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QKeyEvent> #include <QKeyEvent>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
// Required for screen DPI information
#include <QScreen> #include <QScreen>
#include <QWindow> #include <QWindow>
#endif
#include "common/microprofile.h" #include "common/microprofile.h"
#include "common/scm_rev.h" #include "common/scm_rev.h"
@@ -19,8 +15,7 @@
#include "input_common/motion_emu.h" #include "input_common/motion_emu.h"
#include "yuzu/bootmanager.h" #include "yuzu/bootmanager.h"
EmuThread::EmuThread(GRenderWindow* render_window) EmuThread::EmuThread(GRenderWindow* render_window) : render_window(render_window) {}
: exec_step(false), running(false), stop_run(false), render_window(render_window) {}
void EmuThread::run() { void EmuThread::run() {
render_window->MakeCurrent(); render_window->MakeCurrent();
@@ -120,15 +115,13 @@ GRenderWindow::~GRenderWindow() {
void GRenderWindow::moveContext() { void GRenderWindow::moveContext() {
DoneCurrent(); DoneCurrent();
// We need to move GL context to the swapping thread in Qt5
#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
// If the thread started running, move the GL Context to the new thread. Otherwise, move it // If the thread started running, move the GL Context to the new thread. Otherwise, move it
// back. // back.
auto thread = (QThread::currentThread() == qApp->thread() && emu_thread != nullptr) auto thread = (QThread::currentThread() == qApp->thread() && emu_thread != nullptr)
? emu_thread ? emu_thread
: qApp->thread(); : qApp->thread();
child->context()->moveToThread(thread); child->context()->moveToThread(thread);
#endif
} }
void GRenderWindow::SwapBuffers() { void GRenderWindow::SwapBuffers() {
@@ -191,12 +184,8 @@ QByteArray GRenderWindow::saveGeometry() {
} }
qreal GRenderWindow::windowPixelRatio() { qreal GRenderWindow::windowPixelRatio() {
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
// windowHandle() might not be accessible until the window is displayed to screen. // windowHandle() might not be accessible until the window is displayed to screen.
return windowHandle() ? windowHandle()->screen()->devicePixelRatio() : 1.0f; return windowHandle() ? windowHandle()->screen()->devicePixelRatio() : 1.0f;
#else
return 1.0f;
#endif
} }
void GRenderWindow::closeEvent(QCloseEvent* event) { void GRenderWindow::closeEvent(QCloseEvent* event) {
@@ -299,9 +288,7 @@ void GRenderWindow::OnEmulationStopping() {
void GRenderWindow::showEvent(QShowEvent* event) { void GRenderWindow::showEvent(QShowEvent* event) {
QWidget::showEvent(event); QWidget::showEvent(event);
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
// windowHandle() is not initialized until the Window is shown, so we connect it here. // windowHandle() is not initialized until the Window is shown, so we connect it here.
connect(this->windowHandle(), SIGNAL(screenChanged(QScreen*)), this, connect(this->windowHandle(), SIGNAL(screenChanged(QScreen*)), this,
SLOT(OnFramebufferSizeChanged()), Qt::UniqueConnection); SLOT(OnFramebufferSizeChanged()), Qt::UniqueConnection);
#endif
} }

View File

@@ -58,7 +58,7 @@ public:
* @return True if the emulation thread is running, otherwise false * @return True if the emulation thread is running, otherwise false
* @note This function is thread-safe * @note This function is thread-safe
*/ */
bool IsRunning() { bool IsRunning() const {
return running; return running;
} }
@@ -68,12 +68,12 @@ public:
void RequestStop() { void RequestStop() {
stop_run = true; stop_run = true;
SetRunning(false); SetRunning(false);
}; }
private: private:
bool exec_step; bool exec_step = false;
bool running; bool running = false;
std::atomic<bool> stop_run; std::atomic<bool> stop_run{false};
std::mutex running_mutex; std::mutex running_mutex;
std::condition_variable running_cv; std::condition_variable running_cv;

View File

@@ -137,8 +137,8 @@ GameList::SearchField::SearchField(GameList* parent) : QWidget{parent} {
* Checks if all words separated by spaces are contained in another string * Checks if all words separated by spaces are contained in another string
* This offers a word order insensitive search function * This offers a word order insensitive search function
* *
* @param String that gets checked if it contains all words of the userinput string * @param haystack String that gets checked if it contains all words of the userinput string
* @param String containing all words getting checked * @param userinput String containing all words getting checked
* @return true if the haystack contains all words of userinput * @return true if the haystack contains all words of userinput
*/ */
bool GameList::containsAllWords(QString haystack, QString userinput) { bool GameList::containsAllWords(QString haystack, QString userinput) {

View File

@@ -49,7 +49,7 @@ public:
QString edit_filter_text_old; QString edit_filter_text_old;
protected: protected:
bool eventFilter(QObject* obj, QEvent* event); bool eventFilter(QObject* obj, QEvent* event) override;
}; };
QHBoxLayout* layout_filter = nullptr; QHBoxLayout* layout_filter = nullptr;
QTreeView* tree_view = nullptr; QTreeView* tree_view = nullptr;

View File

@@ -5,6 +5,7 @@
#include <map> #include <map>
#include <QKeySequence> #include <QKeySequence>
#include <QShortcut> #include <QShortcut>
#include <QTreeWidgetItem>
#include <QtGlobal> #include <QtGlobal>
#include "yuzu/hotkeys.h" #include "yuzu/hotkeys.h"
#include "yuzu/ui_settings.h" #include "yuzu/ui_settings.h"

View File

@@ -1,21 +1,18 @@
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules)
set(SRCS add_executable(yuzu-cmd
emu_window/emu_window_sdl2.cpp config.cpp
config.cpp config.h
yuzu.cpp default_ini.h
yuzu.rc emu_window/emu_window_sdl2.cpp
) emu_window/emu_window_sdl2.h
set(HEADERS resource.h
emu_window/emu_window_sdl2.h yuzu.cpp
config.h yuzu.rc
default_ini.h )
resource.h
)
create_directory_groups(${SRCS} ${HEADERS}) create_target_directory_groups(yuzu-cmd)
add_executable(yuzu-cmd ${SRCS} ${HEADERS})
target_link_libraries(yuzu-cmd PRIVATE common core input_common) target_link_libraries(yuzu-cmd PRIVATE common core input_common)
target_link_libraries(yuzu-cmd PRIVATE inih glad) target_link_libraries(yuzu-cmd PRIVATE inih glad)
if (MSVC) if (MSVC)