Compare commits
50 Commits
__refs_pul
...
__refs_pul
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
91e19deb39 | ||
|
|
a9e4e8294a | ||
|
|
4f969e2271 | ||
|
|
0a87eb71ba | ||
|
|
6085d32cf5 | ||
|
|
ce8006e851 | ||
|
|
3160f83607 | ||
|
|
be5ba4d952 | ||
|
|
6cddf9d88e | ||
|
|
e01a8f2187 | ||
|
|
890e98a33e | ||
|
|
ba2426aa3f | ||
|
|
deadcb39c2 | ||
|
|
6fce1414c3 | ||
|
|
068744db1b | ||
|
|
b26cdf1fe5 | ||
|
|
8e7da73214 | ||
|
|
0532de6559 | ||
|
|
c83a1b2320 | ||
|
|
725304094e | ||
|
|
63de56ee0f | ||
|
|
309276a317 | ||
|
|
1add3b20c4 | ||
|
|
3b35202280 | ||
|
|
45e5a67676 | ||
|
|
22caeee64f | ||
|
|
576f0cf027 | ||
|
|
ca99063600 | ||
|
|
205daab50d | ||
|
|
d3bbed5e78 | ||
|
|
dc0a137e5b | ||
|
|
db11c9a0b9 | ||
|
|
a39a65cbe0 | ||
|
|
c711253798 | ||
|
|
196f8dff08 | ||
|
|
703880c9ab | ||
|
|
869d65e923 | ||
|
|
335096e19a | ||
|
|
2b75b52489 | ||
|
|
8d300b2d7e | ||
|
|
1cd9438945 | ||
|
|
903beb43a8 | ||
|
|
1963222933 | ||
|
|
d129905a66 | ||
|
|
c83f69841f | ||
|
|
294b2b2c17 | ||
|
|
e33117c00a | ||
|
|
22bc951d7e | ||
|
|
f9ba5a7e11 | ||
|
|
35517ca92c |
@@ -2,7 +2,7 @@
|
||||
|
||||
set -o pipefail
|
||||
|
||||
export MACOSX_DEPLOYMENT_TARGET=10.9
|
||||
export MACOSX_DEPLOYMENT_TARGET=10.12
|
||||
export Qt5_DIR=$(brew --prefix)/opt/qt5
|
||||
export UNICORNDIR=$(pwd)/externals/unicorn
|
||||
|
||||
|
||||
2
externals/catch
vendored
2
externals/catch
vendored
Submodule externals/catch updated: 62dae592c3...cd76f5730c
2
externals/dynarmic
vendored
2
externals/dynarmic
vendored
Submodule externals/dynarmic updated: a6d17e6bb0...d7323d6799
2
externals/xbyak
vendored
2
externals/xbyak
vendored
Submodule externals/xbyak updated: d512551e91...2794cde79e
@@ -92,6 +92,8 @@ add_library(core STATIC
|
||||
hle/service/aoc/aoc_u.h
|
||||
hle/service/apm/apm.cpp
|
||||
hle/service/apm/apm.h
|
||||
hle/service/apm/interface.cpp
|
||||
hle/service/apm/interface.h
|
||||
hle/service/audio/audio.cpp
|
||||
hle/service/audio/audio.h
|
||||
hle/service/audio/audin_u.cpp
|
||||
@@ -129,6 +131,10 @@ add_library(core STATIC
|
||||
hle/service/nvdrv/devices/nvhost_as_gpu.h
|
||||
hle/service/nvdrv/devices/nvhost_ctrl.cpp
|
||||
hle/service/nvdrv/devices/nvhost_ctrl.h
|
||||
hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp
|
||||
hle/service/nvdrv/devices/nvhost_ctrl_gpu.h
|
||||
hle/service/nvdrv/devices/nvhost_gpu.cpp
|
||||
hle/service/nvdrv/devices/nvhost_gpu.h
|
||||
hle/service/nvdrv/devices/nvmap.cpp
|
||||
hle/service/nvdrv/devices/nvmap.h
|
||||
hle/service/nvdrv/interface.cpp
|
||||
|
||||
@@ -8,9 +8,12 @@
|
||||
#include <dynarmic/A64/config.h>
|
||||
#include "core/arm/dynarmic/arm_dynarmic.h"
|
||||
#include "core/core_timing.h"
|
||||
#include "core/hle/kernel/memory.h"
|
||||
#include "core/hle/kernel/svc.h"
|
||||
#include "core/memory.h"
|
||||
|
||||
using Vector = Dynarmic::A64::Vector;
|
||||
|
||||
class ARM_Dynarmic_Callbacks : public Dynarmic::A64::UserCallbacks {
|
||||
public:
|
||||
explicit ARM_Dynarmic_Callbacks(ARM_Dynarmic& parent) : parent(parent) {}
|
||||
@@ -28,6 +31,9 @@ public:
|
||||
u64 MemoryRead64(u64 vaddr) override {
|
||||
return Memory::Read64(vaddr);
|
||||
}
|
||||
Vector MemoryRead128(u64 vaddr) override {
|
||||
return {Memory::Read64(vaddr), Memory::Read64(vaddr + 8)};
|
||||
}
|
||||
|
||||
void MemoryWrite8(u64 vaddr, u8 value) override {
|
||||
Memory::Write8(vaddr, value);
|
||||
@@ -41,6 +47,10 @@ public:
|
||||
void MemoryWrite64(u64 vaddr, u64 value) override {
|
||||
Memory::Write64(vaddr, value);
|
||||
}
|
||||
void MemoryWrite128(u64 vaddr, Vector value) override {
|
||||
Memory::Write64(vaddr, value[0]);
|
||||
Memory::Write64(vaddr + 8, value[1]);
|
||||
}
|
||||
|
||||
void InterpreterFallback(u64 pc, size_t num_instructions) override {
|
||||
ARM_Interface::ThreadContext ctx;
|
||||
@@ -52,12 +62,12 @@ public:
|
||||
num_interpreted_instructions += num_instructions;
|
||||
}
|
||||
|
||||
void ExceptionRaised(u64 pc, Dynarmic::A64::Exception /*exception*/) override {
|
||||
ASSERT_MSG(false, "ExceptionRaised(%" PRIx64 ")", pc);
|
||||
void ExceptionRaised(u64 pc, Dynarmic::A64::Exception exception) override {
|
||||
ASSERT_MSG(false, "ExceptionRaised(exception = %zu, pc = %" PRIx64 ")",
|
||||
static_cast<size_t>(exception), pc);
|
||||
}
|
||||
|
||||
void CallSVC(u32 swi) override {
|
||||
printf("svc %x\n", swi);
|
||||
Kernel::CallSVC(swi);
|
||||
}
|
||||
|
||||
@@ -75,12 +85,24 @@ public:
|
||||
ARM_Dynarmic& parent;
|
||||
size_t ticks_remaining = 0;
|
||||
size_t num_interpreted_instructions = 0;
|
||||
u64 tpidrr0_el0 = 0;
|
||||
u64 tpidrro_el0 = 0;
|
||||
};
|
||||
|
||||
std::unique_ptr<Dynarmic::A64::Jit> MakeJit(const std::unique_ptr<ARM_Dynarmic_Callbacks>& cb) {
|
||||
const auto page_table = Kernel::g_current_process->vm_manager.page_table.pointers.data();
|
||||
|
||||
Dynarmic::A64::UserConfig config;
|
||||
config.callbacks = cb.get();
|
||||
config.tpidrro_el0 = &cb->tpidrro_el0;
|
||||
config.dczid_el0 = 4;
|
||||
config.page_table = reinterpret_cast<void**>(page_table);
|
||||
config.page_table_address_space_bits = Memory::ADDRESS_SPACE_BITS;
|
||||
config.silently_mirror_page_table = false;
|
||||
return std::make_unique<Dynarmic::A64::Jit>(config);
|
||||
}
|
||||
|
||||
ARM_Dynarmic::ARM_Dynarmic()
|
||||
: cb(std::make_unique<ARM_Dynarmic_Callbacks>(*this)),
|
||||
jit(Dynarmic::A64::UserConfig{cb.get()}) {
|
||||
: cb(std::make_unique<ARM_Dynarmic_Callbacks>(*this)), jit(MakeJit(cb)) {
|
||||
ARM_Interface::ThreadContext ctx;
|
||||
inner_unicorn.SaveContext(ctx);
|
||||
LoadContext(ctx);
|
||||
@@ -94,27 +116,27 @@ void ARM_Dynarmic::MapBackingMemory(u64 address, size_t size, u8* memory,
|
||||
}
|
||||
|
||||
void ARM_Dynarmic::SetPC(u64 pc) {
|
||||
jit.SetPC(pc);
|
||||
jit->SetPC(pc);
|
||||
}
|
||||
|
||||
u64 ARM_Dynarmic::GetPC() const {
|
||||
return jit.GetPC();
|
||||
return jit->GetPC();
|
||||
}
|
||||
|
||||
u64 ARM_Dynarmic::GetReg(int index) const {
|
||||
return jit.GetRegister(index);
|
||||
return jit->GetRegister(index);
|
||||
}
|
||||
|
||||
void ARM_Dynarmic::SetReg(int index, u64 value) {
|
||||
jit.SetRegister(index, value);
|
||||
jit->SetRegister(index, value);
|
||||
}
|
||||
|
||||
u128 ARM_Dynarmic::GetExtReg(int index) const {
|
||||
return jit.GetVector(index);
|
||||
return jit->GetVector(index);
|
||||
}
|
||||
|
||||
void ARM_Dynarmic::SetExtReg(int index, u128 value) {
|
||||
jit.SetVector(index, value);
|
||||
jit->SetVector(index, value);
|
||||
}
|
||||
|
||||
u32 ARM_Dynarmic::GetVFPReg(int /*index*/) const {
|
||||
@@ -127,58 +149,58 @@ void ARM_Dynarmic::SetVFPReg(int /*index*/, u32 /*value*/) {
|
||||
}
|
||||
|
||||
u32 ARM_Dynarmic::GetCPSR() const {
|
||||
return jit.GetPstate();
|
||||
return jit->GetPstate();
|
||||
}
|
||||
|
||||
void ARM_Dynarmic::SetCPSR(u32 cpsr) {
|
||||
jit.SetPstate(cpsr);
|
||||
jit->SetPstate(cpsr);
|
||||
}
|
||||
|
||||
u64 ARM_Dynarmic::GetTlsAddress() const {
|
||||
return cb->tpidrr0_el0;
|
||||
return cb->tpidrro_el0;
|
||||
}
|
||||
|
||||
void ARM_Dynarmic::SetTlsAddress(u64 address) {
|
||||
cb->tpidrr0_el0 = address;
|
||||
cb->tpidrro_el0 = address;
|
||||
}
|
||||
|
||||
void ARM_Dynarmic::ExecuteInstructions(int num_instructions) {
|
||||
cb->ticks_remaining = num_instructions;
|
||||
jit.Run();
|
||||
jit->Run();
|
||||
CoreTiming::AddTicks(num_instructions - cb->num_interpreted_instructions);
|
||||
cb->num_interpreted_instructions = 0;
|
||||
}
|
||||
|
||||
void ARM_Dynarmic::SaveContext(ARM_Interface::ThreadContext& ctx) {
|
||||
ctx.cpu_registers = jit.GetRegisters();
|
||||
ctx.sp = jit.GetSP();
|
||||
ctx.pc = jit.GetPC();
|
||||
ctx.cpsr = jit.GetPstate();
|
||||
ctx.fpu_registers = jit.GetVectors();
|
||||
ctx.fpscr = jit.GetFpcr();
|
||||
ctx.tls_address = cb->tpidrr0_el0;
|
||||
ctx.cpu_registers = jit->GetRegisters();
|
||||
ctx.sp = jit->GetSP();
|
||||
ctx.pc = jit->GetPC();
|
||||
ctx.cpsr = jit->GetPstate();
|
||||
ctx.fpu_registers = jit->GetVectors();
|
||||
ctx.fpscr = jit->GetFpcr();
|
||||
ctx.tls_address = cb->tpidrro_el0;
|
||||
}
|
||||
|
||||
void ARM_Dynarmic::LoadContext(const ARM_Interface::ThreadContext& ctx) {
|
||||
jit.SetRegisters(ctx.cpu_registers);
|
||||
jit.SetSP(ctx.sp);
|
||||
jit.SetPC(ctx.pc);
|
||||
jit.SetPstate(static_cast<u32>(ctx.cpsr));
|
||||
jit.SetVectors(ctx.fpu_registers);
|
||||
jit.SetFpcr(static_cast<u32>(ctx.fpscr));
|
||||
cb->tpidrr0_el0 = ctx.tls_address;
|
||||
jit->SetRegisters(ctx.cpu_registers);
|
||||
jit->SetSP(ctx.sp);
|
||||
jit->SetPC(ctx.pc);
|
||||
jit->SetPstate(static_cast<u32>(ctx.cpsr));
|
||||
jit->SetVectors(ctx.fpu_registers);
|
||||
jit->SetFpcr(static_cast<u32>(ctx.fpscr));
|
||||
cb->tpidrro_el0 = ctx.tls_address;
|
||||
}
|
||||
|
||||
void ARM_Dynarmic::PrepareReschedule() {
|
||||
if (jit.IsExecuting()) {
|
||||
jit.HaltExecution();
|
||||
if (jit->IsExecuting()) {
|
||||
jit->HaltExecution();
|
||||
}
|
||||
}
|
||||
|
||||
void ARM_Dynarmic::ClearInstructionCache() {
|
||||
jit.ClearCache();
|
||||
jit->ClearCache();
|
||||
}
|
||||
|
||||
void ARM_Dynarmic::PageTableChanged() {
|
||||
UNIMPLEMENTED();
|
||||
jit = MakeJit(cb);
|
||||
}
|
||||
|
||||
@@ -45,6 +45,6 @@ public:
|
||||
private:
|
||||
friend class ARM_Dynarmic_Callbacks;
|
||||
std::unique_ptr<ARM_Dynarmic_Callbacks> cb;
|
||||
Dynarmic::A64::Jit jit;
|
||||
std::unique_ptr<Dynarmic::A64::Jit> jit;
|
||||
ARM_Unicorn inner_unicorn;
|
||||
};
|
||||
|
||||
@@ -154,6 +154,8 @@ System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) {
|
||||
break;
|
||||
}
|
||||
|
||||
gpu_core = std::make_unique<Tegra::GPU>();
|
||||
|
||||
telemetry_session = std::make_unique<Core::TelemetrySession>();
|
||||
|
||||
CoreTiming::Init();
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "core/memory.h"
|
||||
#include "core/perf_stats.h"
|
||||
#include "core/telemetry_session.h"
|
||||
#include "video_core/gpu.h"
|
||||
|
||||
class EmuWindow;
|
||||
class ARM_Interface;
|
||||
@@ -102,6 +103,10 @@ public:
|
||||
return *cpu_core;
|
||||
}
|
||||
|
||||
Tegra::GPU& GPU() {
|
||||
return *gpu_core;
|
||||
}
|
||||
|
||||
PerfStats perf_stats;
|
||||
FrameLimiter frame_limiter;
|
||||
|
||||
@@ -138,6 +143,8 @@ private:
|
||||
///< ARM11 CPU core
|
||||
std::unique_ptr<ARM_Interface> cpu_core;
|
||||
|
||||
std::unique_ptr<Tegra::GPU> gpu_core;
|
||||
|
||||
/// When true, signals that a reschedule should happen
|
||||
bool reschedule_pending{};
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ ResultCode Mutex::Release(Thread* thread) {
|
||||
holding_thread->held_mutexes.erase(this);
|
||||
holding_thread->UpdatePriority();
|
||||
SetHoldingThread(nullptr);
|
||||
SetHasWaiters(!GetWaitingThreads().empty());
|
||||
WakeupAllWaitingThreads();
|
||||
Core::System::GetInstance().PrepareReschedule();
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
namespace Service {
|
||||
namespace Account {
|
||||
|
||||
using Uid = std::array<u64, 2>;
|
||||
static constexpr Uid DEFAULT_USER_ID{0x10ull, 0x20ull};
|
||||
|
||||
class IProfile final : public ServiceFramework<IProfile> {
|
||||
public:
|
||||
IProfile() : ServiceFramework("IProfile") {
|
||||
@@ -61,6 +64,15 @@ void ACC_U0::GetUserExistence(Kernel::HLERequestContext& ctx) {
|
||||
rb.Push(true); // TODO: Check when this is supposed to return true and when not
|
||||
}
|
||||
|
||||
void ACC_U0::ListAllUsers(Kernel::HLERequestContext& ctx) {
|
||||
constexpr std::array<u128, 10> user_ids{DEFAULT_USER_ID};
|
||||
const auto& output_buffer = ctx.BufferDescriptorC()[0];
|
||||
Memory::WriteBlock(output_buffer.Address(), user_ids.data(), user_ids.size());
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
LOG_DEBUG(Service_ACC, "called");
|
||||
}
|
||||
|
||||
void ACC_U0::GetProfile(Kernel::HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
@@ -85,13 +97,13 @@ void ACC_U0::GetLastOpenedUser(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_ACC, "(STUBBED) called");
|
||||
IPC::ResponseBuilder rb{ctx, 6};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.Push<u64>(0x0);
|
||||
rb.Push<u64>(0x0);
|
||||
rb.PushRaw(DEFAULT_USER_ID);
|
||||
}
|
||||
|
||||
ACC_U0::ACC_U0() : ServiceFramework("acc:u0") {
|
||||
static const FunctionInfo functions[] = {
|
||||
{1, &ACC_U0::GetUserExistence, "GetUserExistence"},
|
||||
{2, &ACC_U0::ListAllUsers, "ListAllUsers"},
|
||||
{4, &ACC_U0::GetLastOpenedUser, "GetLastOpenedUser"},
|
||||
{5, &ACC_U0::GetProfile, "GetProfile"},
|
||||
{100, &ACC_U0::InitializeApplicationInfo, "InitializeApplicationInfo"},
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
|
||||
private:
|
||||
void GetUserExistence(Kernel::HLERequestContext& ctx);
|
||||
void ListAllUsers(Kernel::HLERequestContext& ctx);
|
||||
void GetLastOpenedUser(Kernel::HLERequestContext& ctx);
|
||||
void GetProfile(Kernel::HLERequestContext& ctx);
|
||||
void InitializeApplicationInfo(Kernel::HLERequestContext& ctx);
|
||||
|
||||
@@ -45,6 +45,7 @@ ISelfController::ISelfController(std::shared_ptr<NVFlinger::NVFlinger> nvflinger
|
||||
static const FunctionInfo functions[] = {
|
||||
{1, &ISelfController::LockExit, "LockExit"},
|
||||
{2, &ISelfController::UnlockExit, "UnlockExit"},
|
||||
{9, &ISelfController::GetLibraryAppletLaunchableEvent, "GetLibraryAppletLaunchableEvent"},
|
||||
{11, &ISelfController::SetOperationModeChangedNotification,
|
||||
"SetOperationModeChangedNotification"},
|
||||
{12, &ISelfController::SetPerformanceModeChangedNotification,
|
||||
@@ -55,6 +56,9 @@ ISelfController::ISelfController(std::shared_ptr<NVFlinger::NVFlinger> nvflinger
|
||||
{40, &ISelfController::CreateManagedDisplayLayer, "CreateManagedDisplayLayer"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
|
||||
launchable_event =
|
||||
Kernel::Event::Create(Kernel::ResetType::OneShot, "ISelfController:LaunchableEvent");
|
||||
}
|
||||
|
||||
void ISelfController::SetFocusHandlingMode(Kernel::HLERequestContext& ctx) {
|
||||
@@ -132,6 +136,16 @@ void ISelfController::UnlockExit(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_AM, "(STUBBED) called");
|
||||
}
|
||||
|
||||
void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) {
|
||||
launchable_event->Signal();
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushCopyObjects(launchable_event);
|
||||
|
||||
LOG_WARNING(Service_AM, "(STUBBED) called");
|
||||
}
|
||||
|
||||
void ISelfController::CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx) {
|
||||
// TODO(Subv): Find out how AM determines the display to use, for now just create the layer
|
||||
// in the Default display.
|
||||
@@ -200,7 +214,69 @@ void ICommonStateGetter::GetPerformanceMode(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_AM, "(STUBBED) called");
|
||||
}
|
||||
|
||||
ILibraryAppletCreator::ILibraryAppletCreator() : ServiceFramework("ILibraryAppletCreator") {}
|
||||
class ILibraryAppletAccessor final : public ServiceFramework<ILibraryAppletAccessor> {
|
||||
public:
|
||||
explicit ILibraryAppletAccessor() : ServiceFramework("ILibraryAppletAccessor") {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &ILibraryAppletAccessor::GetAppletStateChangedEvent, "GetAppletStateChangedEvent"},
|
||||
{1, nullptr, "IsCompleted"},
|
||||
{10, nullptr, "Start"},
|
||||
{20, nullptr, "RequestExit"},
|
||||
{25, nullptr, "Terminate"},
|
||||
{30, nullptr, "GetResult"},
|
||||
{50, nullptr, "SetOutOfFocusApplicationSuspendingEnabled"},
|
||||
{100, nullptr, "PushInData"},
|
||||
{101, nullptr, "PopOutData"},
|
||||
{102, nullptr, "PushExtraStorage"},
|
||||
{103, nullptr, "PushInteractiveInData"},
|
||||
{104, nullptr, "PopInteractiveOutData"},
|
||||
{105, nullptr, "GetPopOutDataEvent"},
|
||||
{106, nullptr, "GetPopInteractiveOutDataEvent"},
|
||||
{120, nullptr, "NeedsToExitProcess"},
|
||||
{120, nullptr, "GetLibraryAppletInfo"},
|
||||
{150, nullptr, "RequestForAppletToGetForeground"},
|
||||
{160, nullptr, "GetIndirectLayerConsumerHandle"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
|
||||
state_changed_event = Kernel::Event::Create(Kernel::ResetType::OneShot,
|
||||
"ILibraryAppletAccessor:StateChangedEvent");
|
||||
}
|
||||
|
||||
private:
|
||||
void GetAppletStateChangedEvent(Kernel::HLERequestContext& ctx) {
|
||||
state_changed_event->Signal();
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushCopyObjects(state_changed_event);
|
||||
|
||||
LOG_WARNING(Service_AM, "(STUBBED) called");
|
||||
}
|
||||
|
||||
Kernel::SharedPtr<Kernel::Event> state_changed_event;
|
||||
};
|
||||
|
||||
ILibraryAppletCreator::ILibraryAppletCreator() : ServiceFramework("ILibraryAppletCreator") {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &ILibraryAppletCreator::CreateLibraryApplet, "CreateLibraryApplet"},
|
||||
{1, nullptr, "TerminateAllLibraryApplets"},
|
||||
{2, nullptr, "AreAnyLibraryAppletsLeft"},
|
||||
{10, nullptr, "CreateStorage"},
|
||||
{11, nullptr, "CreateTransferMemoryStorage"},
|
||||
{12, nullptr, "CreateHandleStorage"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
void ILibraryAppletCreator::CreateLibraryApplet(Kernel::HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<AM::ILibraryAppletAccessor>();
|
||||
|
||||
LOG_DEBUG(Service_AM, "called");
|
||||
}
|
||||
|
||||
class IStorageAccessor final : public ServiceFramework<IStorageAccessor> {
|
||||
public:
|
||||
@@ -270,6 +346,7 @@ private:
|
||||
IApplicationFunctions::IApplicationFunctions() : ServiceFramework("IApplicationFunctions") {
|
||||
static const FunctionInfo functions[] = {
|
||||
{1, &IApplicationFunctions::PopLaunchParameter, "PopLaunchParameter"},
|
||||
{20, &IApplicationFunctions::EnsureSaveData, "EnsureSaveData"},
|
||||
{21, &IApplicationFunctions::GetDesiredLanguage, "GetDesiredLanguage"},
|
||||
{22, &IApplicationFunctions::SetTerminateResult, "SetTerminateResult"},
|
||||
{66, &IApplicationFunctions::InitializeGamePlayRecording, "InitializeGamePlayRecording"},
|
||||
@@ -299,6 +376,12 @@ void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_AM, "called");
|
||||
}
|
||||
|
||||
void IApplicationFunctions::EnsureSaveData(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service, "(STUBBED) called");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
void IApplicationFunctions::SetTerminateResult(Kernel::HLERequestContext& ctx) {
|
||||
// Takes an input u32 Result, no output.
|
||||
// For example, in some cases official apps use this with error 0x2A2 then uses svcBreak.
|
||||
|
||||
@@ -60,9 +60,11 @@ private:
|
||||
void SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext& ctx);
|
||||
void LockExit(Kernel::HLERequestContext& ctx);
|
||||
void UnlockExit(Kernel::HLERequestContext& ctx);
|
||||
void GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx);
|
||||
void CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx);
|
||||
|
||||
std::shared_ptr<NVFlinger::NVFlinger> nvflinger;
|
||||
Kernel::SharedPtr<Kernel::Event> launchable_event;
|
||||
};
|
||||
|
||||
class ICommonStateGetter final : public ServiceFramework<ICommonStateGetter> {
|
||||
@@ -92,6 +94,9 @@ private:
|
||||
class ILibraryAppletCreator final : public ServiceFramework<ILibraryAppletCreator> {
|
||||
public:
|
||||
ILibraryAppletCreator();
|
||||
|
||||
private:
|
||||
void CreateLibraryApplet(Kernel::HLERequestContext& ctx);
|
||||
};
|
||||
|
||||
class IApplicationFunctions final : public ServiceFramework<IApplicationFunctions> {
|
||||
@@ -100,6 +105,7 @@ public:
|
||||
|
||||
private:
|
||||
void PopLaunchParameter(Kernel::HLERequestContext& ctx);
|
||||
void EnsureSaveData(Kernel::HLERequestContext& ctx);
|
||||
void SetTerminateResult(Kernel::HLERequestContext& ctx);
|
||||
void GetDesiredLanguage(Kernel::HLERequestContext& ctx);
|
||||
void InitializeGamePlayRecording(Kernel::HLERequestContext& ctx);
|
||||
|
||||
@@ -5,63 +5,15 @@
|
||||
#include "common/logging/log.h"
|
||||
#include "core/hle/ipc_helpers.h"
|
||||
#include "core/hle/service/apm/apm.h"
|
||||
#include "core/hle/service/apm/interface.h"
|
||||
|
||||
namespace Service {
|
||||
namespace APM {
|
||||
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
||||
std::make_shared<APM>()->InstallAsService(service_manager);
|
||||
}
|
||||
|
||||
class ISession final : public ServiceFramework<ISession> {
|
||||
public:
|
||||
ISession() : ServiceFramework("ISession") {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &ISession::SetPerformanceConfiguration, "SetPerformanceConfiguration"},
|
||||
{1, &ISession::GetPerformanceConfiguration, "GetPerformanceConfiguration"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
private:
|
||||
void SetPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
|
||||
auto mode = static_cast<PerformanceMode>(rp.Pop<u32>());
|
||||
u32 config = rp.Pop<u32>();
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
|
||||
LOG_WARNING(Service_APM, "(STUBBED) called mode=%u config=%u", static_cast<u32>(mode),
|
||||
config);
|
||||
}
|
||||
|
||||
void GetPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
|
||||
auto mode = static_cast<PerformanceMode>(rp.Pop<u32>());
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.Push<u32>(0); // Performance configuration
|
||||
|
||||
LOG_WARNING(Service_APM, "(STUBBED) called mode=%u", static_cast<u32>(mode));
|
||||
}
|
||||
};
|
||||
|
||||
APM::APM() : ServiceFramework("apm") {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0x00000000, &APM::OpenSession, "OpenSession"},
|
||||
{0x00000001, nullptr, "GetPerformanceMode"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
void APM::OpenSession(Kernel::HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<ISession>();
|
||||
auto module_ = std::make_shared<Module>();
|
||||
std::make_shared<APM>(module_, "apm")->InstallAsService(service_manager);
|
||||
std::make_shared<APM>(module_, "apm:p")->InstallAsService(service_manager);
|
||||
}
|
||||
|
||||
} // namespace APM
|
||||
|
||||
@@ -14,13 +14,10 @@ enum class PerformanceMode : u8 {
|
||||
Docked = 1,
|
||||
};
|
||||
|
||||
class APM final : public ServiceFramework<APM> {
|
||||
class Module final {
|
||||
public:
|
||||
APM();
|
||||
~APM() = default;
|
||||
|
||||
private:
|
||||
void OpenSession(Kernel::HLERequestContext& ctx);
|
||||
Module() = default;
|
||||
~Module() = default;
|
||||
};
|
||||
|
||||
/// Registers all AM services with the specified service manager.
|
||||
|
||||
66
src/core/hle/service/apm/interface.cpp
Normal file
66
src/core/hle/service/apm/interface.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
// Copyright 2018 yuzu emulator team
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "common/logging/log.h"
|
||||
#include "core/hle/ipc_helpers.h"
|
||||
#include "core/hle/service/apm/apm.h"
|
||||
#include "core/hle/service/apm/interface.h"
|
||||
|
||||
namespace Service {
|
||||
namespace APM {
|
||||
|
||||
class ISession final : public ServiceFramework<ISession> {
|
||||
public:
|
||||
ISession() : ServiceFramework("ISession") {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &ISession::SetPerformanceConfiguration, "SetPerformanceConfiguration"},
|
||||
{1, &ISession::GetPerformanceConfiguration, "GetPerformanceConfiguration"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
private:
|
||||
void SetPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
|
||||
auto mode = static_cast<PerformanceMode>(rp.Pop<u32>());
|
||||
u32 config = rp.Pop<u32>();
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
|
||||
LOG_WARNING(Service_APM, "(STUBBED) called mode=%u config=%u", static_cast<u32>(mode),
|
||||
config);
|
||||
}
|
||||
|
||||
void GetPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
|
||||
auto mode = static_cast<PerformanceMode>(rp.Pop<u32>());
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.Push<u32>(0); // Performance configuration
|
||||
|
||||
LOG_WARNING(Service_APM, "(STUBBED) called mode=%u", static_cast<u32>(mode));
|
||||
}
|
||||
};
|
||||
|
||||
APM::APM(std::shared_ptr<Module> apm, const char* name)
|
||||
: ServiceFramework(name), apm(std::move(apm)) {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &APM::OpenSession, "OpenSession"},
|
||||
{1, nullptr, "GetPerformanceMode"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
void APM::OpenSession(Kernel::HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<ISession>();
|
||||
}
|
||||
|
||||
} // namespace APM
|
||||
} // namespace Service
|
||||
27
src/core/hle/service/apm/interface.h
Normal file
27
src/core/hle/service/apm/interface.h
Normal file
@@ -0,0 +1,27 @@
|
||||
// Copyright 2018 yuzu emulator team
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Service {
|
||||
namespace APM {
|
||||
|
||||
class APM final : public ServiceFramework<APM> {
|
||||
public:
|
||||
APM(std::shared_ptr<Module> apm, const char* name);
|
||||
~APM() = default;
|
||||
|
||||
private:
|
||||
void OpenSession(Kernel::HLERequestContext& ctx);
|
||||
|
||||
std::shared_ptr<Module> apm;
|
||||
};
|
||||
|
||||
/// Registers all AM services with the specified service manager.
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager);
|
||||
|
||||
} // namespace APM
|
||||
} // namespace Service
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "common/logging/log.h"
|
||||
#include "core/hle/ipc_helpers.h"
|
||||
#include "core/hle/kernel/event.h"
|
||||
#include "core/hle/kernel/hle_ipc.h"
|
||||
#include "core/hle/service/audio/audren_u.h"
|
||||
|
||||
@@ -18,27 +19,143 @@ public:
|
||||
{0x1, nullptr, "GetAudioRendererSampleCount"},
|
||||
{0x2, nullptr, "GetAudioRendererMixBufferCount"},
|
||||
{0x3, nullptr, "GetAudioRendererState"},
|
||||
{0x4, nullptr, "RequestUpdateAudioRenderer"},
|
||||
{0x5, nullptr, "StartAudioRenderer"},
|
||||
{0x6, nullptr, "StopAudioRenderer"},
|
||||
{0x7, nullptr, "QuerySystemEvent"},
|
||||
{0x4, &IAudioRenderer::RequestUpdateAudioRenderer, "RequestUpdateAudioRenderer"},
|
||||
{0x5, &IAudioRenderer::StartAudioRenderer, "StartAudioRenderer"},
|
||||
{0x6, &IAudioRenderer::StopAudioRenderer, "StopAudioRenderer"},
|
||||
{0x7, &IAudioRenderer::QuerySystemEvent, "QuerySystemEvent"},
|
||||
{0x8, nullptr, "SetAudioRendererRenderingTimeLimit"},
|
||||
{0x9, nullptr, "GetAudioRendererRenderingTimeLimit"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
|
||||
system_event =
|
||||
Kernel::Event::Create(Kernel::ResetType::OneShot, "IAudioRenderer:SystemEvent");
|
||||
}
|
||||
~IAudioRenderer() = default;
|
||||
|
||||
private:
|
||||
void RequestUpdateAudioRenderer(Kernel::HLERequestContext& ctx) {
|
||||
AudioRendererResponseData response_data = {0};
|
||||
|
||||
response_data.section_0_size =
|
||||
response_data.state_entries.size() * sizeof(AudioRendererStateEntry);
|
||||
response_data.section_1_size = response_data.section_1.size();
|
||||
response_data.section_2_size = response_data.section_2.size();
|
||||
response_data.section_3_size = response_data.section_3.size();
|
||||
response_data.section_4_size = response_data.section_4.size();
|
||||
response_data.section_5_size = response_data.section_5.size();
|
||||
response_data.total_size = sizeof(AudioRendererResponseData);
|
||||
|
||||
for (unsigned i = 0; i < response_data.state_entries.size(); i++) {
|
||||
// 4 = Busy and 5 = Ready?
|
||||
response_data.state_entries[i].state = 5;
|
||||
}
|
||||
|
||||
auto& buffer = ctx.BufferDescriptorB()[0];
|
||||
|
||||
Memory::WriteBlock(buffer.Address(), &response_data, response_data.total_size);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
|
||||
LOG_WARNING(Service_Audio, "(STUBBED) called");
|
||||
}
|
||||
|
||||
void StartAudioRenderer(Kernel::HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
|
||||
LOG_WARNING(Service_Audio, "(STUBBED) called");
|
||||
}
|
||||
|
||||
void StopAudioRenderer(Kernel::HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
|
||||
LOG_WARNING(Service_Audio, "(STUBBED) called");
|
||||
}
|
||||
|
||||
void QuerySystemEvent(Kernel::HLERequestContext& ctx) {
|
||||
// system_event->Signal();
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushCopyObjects(system_event);
|
||||
|
||||
LOG_WARNING(Service_Audio, "(STUBBED) called");
|
||||
}
|
||||
|
||||
struct AudioRendererStateEntry {
|
||||
u32_le state;
|
||||
u32_le unknown_4;
|
||||
u32_le unknown_8;
|
||||
u32_le unknown_c;
|
||||
};
|
||||
static_assert(sizeof(AudioRendererStateEntry) == 0x10,
|
||||
"AudioRendererStateEntry has wrong size");
|
||||
|
||||
struct AudioRendererResponseData {
|
||||
u32_le unknown_0;
|
||||
u32_le section_5_size;
|
||||
u32_le section_0_size;
|
||||
u32_le section_1_size;
|
||||
u32_le unknown_10;
|
||||
u32_le section_2_size;
|
||||
u32_le unknown_18;
|
||||
u32_le section_3_size;
|
||||
u32_le section_4_size;
|
||||
u32_le unknown_24;
|
||||
u32_le unknown_28;
|
||||
u32_le unknown_2c;
|
||||
u32_le unknown_30;
|
||||
u32_le unknown_34;
|
||||
u32_le unknown_38;
|
||||
u32_le total_size;
|
||||
|
||||
std::array<AudioRendererStateEntry, 0x18e> state_entries;
|
||||
|
||||
std::array<u8, 0x600> section_1;
|
||||
std::array<u8, 0xe0> section_2;
|
||||
std::array<u8, 0x20> section_3;
|
||||
std::array<u8, 0x10> section_4;
|
||||
std::array<u8, 0xb0> section_5;
|
||||
};
|
||||
static_assert(sizeof(AudioRendererResponseData) == 0x20e0,
|
||||
"AudioRendererResponseData has wrong size");
|
||||
|
||||
Kernel::SharedPtr<Kernel::Event> system_event;
|
||||
};
|
||||
|
||||
AudRenU::AudRenU() : ServiceFramework("audren:u") {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0x00000000, nullptr, "OpenAudioRenderer"},
|
||||
{0x00000001, nullptr, "GetAudioRendererWorkBufferSize"},
|
||||
{0x00000000, &AudRenU::OpenAudioRenderer, "OpenAudioRenderer"},
|
||||
{0x00000001, &AudRenU::GetAudioRendererWorkBufferSize, "GetAudioRendererWorkBufferSize"},
|
||||
{0x00000002, nullptr, "GetAudioRenderersProcessMasterVolume"},
|
||||
{0x00000003, nullptr, "SetAudioRenderersProcessMasterVolume"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
void AudRenU::OpenAudioRenderer(Kernel::HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<Audio::IAudioRenderer>();
|
||||
|
||||
LOG_DEBUG(Service_Audio, "called");
|
||||
}
|
||||
|
||||
void AudRenU::GetAudioRendererWorkBufferSize(Kernel::HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.Push<u64>(0x1000);
|
||||
|
||||
LOG_WARNING(Service_Audio, "called");
|
||||
}
|
||||
|
||||
} // namespace Audio
|
||||
} // namespace Service
|
||||
|
||||
@@ -17,6 +17,10 @@ class AudRenU final : public ServiceFramework<AudRenU> {
|
||||
public:
|
||||
explicit AudRenU();
|
||||
~AudRenU() = default;
|
||||
|
||||
private:
|
||||
void OpenAudioRenderer(Kernel::HLERequestContext& ctx);
|
||||
void GetAudioRendererWorkBufferSize(Kernel::HLERequestContext& ctx);
|
||||
};
|
||||
|
||||
} // namespace Audio
|
||||
|
||||
@@ -70,7 +70,9 @@ private:
|
||||
FSP_SRV::FSP_SRV() : ServiceFramework("fsp-srv") {
|
||||
static const FunctionInfo functions[] = {
|
||||
{1, &FSP_SRV::Initalize, "Initalize"},
|
||||
{18, &FSP_SRV::MountSdCard, "MountSdCard"},
|
||||
{200, &FSP_SRV::OpenDataStorageByCurrentProcess, "OpenDataStorageByCurrentProcess"},
|
||||
{202, nullptr, "OpenDataStorageByDataId"},
|
||||
{203, &FSP_SRV::OpenRomStorage, "OpenRomStorage"},
|
||||
{1005, &FSP_SRV::GetGlobalAccessLogMode, "GetGlobalAccessLogMode"},
|
||||
};
|
||||
@@ -95,6 +97,13 @@ void FSP_SRV::Initalize(Kernel::HLERequestContext& ctx) {
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
void FSP_SRV::MountSdCard(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_FS, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
void FSP_SRV::GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_FS, "(STUBBED) called");
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ private:
|
||||
void TryLoadRomFS();
|
||||
|
||||
void Initalize(Kernel::HLERequestContext& ctx);
|
||||
void MountSdCard(Kernel::HLERequestContext& ctx);
|
||||
void GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx);
|
||||
void OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx);
|
||||
void OpenRomStorage(Kernel::HLERequestContext& ctx);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "core/hle/ipc_helpers.h"
|
||||
#include "core/hle/kernel/client_port.h"
|
||||
#include "core/hle/kernel/client_session.h"
|
||||
#include "core/hle/kernel/event.h"
|
||||
#include "core/hle/kernel/shared_memory.h"
|
||||
#include "core/hle/service/hid/hid.h"
|
||||
#include "core/hle/service/service.h"
|
||||
@@ -174,21 +175,29 @@ public:
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &Hid::CreateAppletResource, "CreateAppletResource"},
|
||||
{1, &Hid::ActivateDebugPad, "ActivateDebugPad"},
|
||||
{11, nullptr, "ActivateTouchScreen"},
|
||||
{11, &Hid::ActivateTouchScreen, "ActivateTouchScreen"},
|
||||
{66, &Hid::StartSixAxisSensor, "StartSixAxisSensor"},
|
||||
{100, &Hid::SetSupportedNpadStyleSet, "SetSupportedNpadStyleSet"},
|
||||
{102, &Hid::SetSupportedNpadIdType, "SetSupportedNpadIdType"},
|
||||
{103, &Hid::ActivateNpad, "ActivateNpad"},
|
||||
{120, nullptr, "SetNpadJoyHoldType"},
|
||||
{106, &Hid::AcquireNpadStyleSetUpdateEventHandle,
|
||||
"AcquireNpadStyleSetUpdateEventHandle"},
|
||||
{120, &Hid::SetNpadJoyHoldType, "SetNpadJoyHoldType"},
|
||||
{121, &Hid::GetNpadJoyHoldType, "GetNpadJoyHoldType"},
|
||||
{124, nullptr, "SetNpadJoyAssignmentModeDual"},
|
||||
{128, &Hid::SetNpadHandheldActivationMode, "SetNpadHandheldActivationMode"},
|
||||
{203, &Hid::CreateActiveVibrationDeviceList, "CreateActiveVibrationDeviceList"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
|
||||
event = Kernel::Event::Create(Kernel::ResetType::OneShot, "hid:EventHandle");
|
||||
}
|
||||
~Hid() = default;
|
||||
|
||||
private:
|
||||
std::shared_ptr<IAppletResource> applet_resource;
|
||||
u32 joy_hold_type{0};
|
||||
Kernel::SharedPtr<Kernel::Event> event;
|
||||
|
||||
void CreateAppletResource(Kernel::HLERequestContext& ctx) {
|
||||
if (applet_resource == nullptr) {
|
||||
@@ -207,6 +216,12 @@ private:
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||
}
|
||||
|
||||
void ActivateTouchScreen(Kernel::HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||
}
|
||||
|
||||
void StartSixAxisSensor(Kernel::HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
@@ -231,6 +246,32 @@ private:
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||
}
|
||||
|
||||
void AcquireNpadStyleSetUpdateEventHandle(Kernel::HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushCopyObjects(event);
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||
}
|
||||
|
||||
void SetNpadJoyHoldType(Kernel::HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||
}
|
||||
|
||||
void GetNpadJoyHoldType(Kernel::HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.Push(joy_hold_type);
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||
}
|
||||
|
||||
void SetNpadHandheldActivationMode(Kernel::HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||
}
|
||||
|
||||
void CreateActiveVibrationDeviceList(Kernel::HLERequestContext& ctx) {
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/swap.h"
|
||||
|
||||
namespace Service {
|
||||
namespace Nvidia {
|
||||
@@ -17,6 +19,14 @@ class nvdevice {
|
||||
public:
|
||||
nvdevice() = default;
|
||||
virtual ~nvdevice() = default;
|
||||
union Ioctl {
|
||||
u32_le raw;
|
||||
BitField<0, 8, u32_le> cmd;
|
||||
BitField<8, 8, u32_le> group;
|
||||
BitField<16, 14, u32_le> length;
|
||||
BitField<30, 1, u32_le> is_in;
|
||||
BitField<31, 1, u32_le> is_out;
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles an ioctl request.
|
||||
@@ -25,7 +35,7 @@ public:
|
||||
* @param output A buffer where the output data will be written to.
|
||||
* @returns The result code of the ioctl.
|
||||
*/
|
||||
virtual u32 ioctl(u32 command, const std::vector<u8>& input, std::vector<u8>& output) = 0;
|
||||
virtual u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) = 0;
|
||||
};
|
||||
|
||||
} // namespace Devices
|
||||
|
||||
@@ -14,21 +14,23 @@ namespace Service {
|
||||
namespace Nvidia {
|
||||
namespace Devices {
|
||||
|
||||
u32 nvdisp_disp0::ioctl(u32 command, const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
u32 nvdisp_disp0::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u32 height,
|
||||
u32 stride) {
|
||||
u32 stride, NVFlinger::BufferQueue::BufferTransformFlags transform) {
|
||||
VAddr addr = nvmap_dev->GetObjectAddress(buffer_handle);
|
||||
LOG_WARNING(Service,
|
||||
"Drawing from address %llx offset %08X Width %u Height %u Stride %u Format %u",
|
||||
addr, offset, width, height, stride, format);
|
||||
|
||||
using PixelFormat = RendererBase::FramebufferInfo::PixelFormat;
|
||||
using Flags = NVFlinger::BufferQueue::BufferTransformFlags;
|
||||
const bool flip_vertical = static_cast<u32>(transform) & static_cast<u32>(Flags::FlipV);
|
||||
const RendererBase::FramebufferInfo framebuffer_info{
|
||||
addr, offset, width, height, stride, static_cast<PixelFormat>(format)};
|
||||
addr, offset, width, height, stride, static_cast<PixelFormat>(format), flip_vertical};
|
||||
|
||||
Core::System::GetInstance().perf_stats.EndGameFrame();
|
||||
VideoCore::g_renderer->SwapBuffers(framebuffer_info);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <vector>
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvdevice.h"
|
||||
#include "core/hle/service/nvflinger/buffer_queue.h"
|
||||
|
||||
namespace Service {
|
||||
namespace Nvidia {
|
||||
@@ -20,10 +21,11 @@ public:
|
||||
nvdisp_disp0(std::shared_ptr<nvmap> nvmap_dev) : nvdevice(), nvmap_dev(std::move(nvmap_dev)) {}
|
||||
~nvdisp_disp0() = default;
|
||||
|
||||
u32 ioctl(u32 command, const std::vector<u8>& input, std::vector<u8>& output) override;
|
||||
u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override;
|
||||
|
||||
/// Performs a screen flip, drawing the buffer pointed to by the handle.
|
||||
void flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u32 height, u32 stride);
|
||||
void flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u32 height, u32 stride,
|
||||
NVFlinger::BufferQueue::BufferTransformFlags transform);
|
||||
|
||||
private:
|
||||
std::shared_ptr<nvmap> nvmap_dev;
|
||||
|
||||
@@ -4,14 +4,112 @@
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvhost_as_gpu.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvmap.h"
|
||||
|
||||
namespace Service {
|
||||
namespace Nvidia {
|
||||
namespace Devices {
|
||||
|
||||
u32 nvhost_as_gpu::ioctl(u32 command, const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
UNIMPLEMENTED();
|
||||
u32 nvhost_as_gpu::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
LOG_DEBUG(Service_NVDRV, "called, command=0x%08x, input_size=0x%llx, output_size=0x%llx",
|
||||
command, input.size(), output.size());
|
||||
|
||||
switch (static_cast<IoctlCommand>(command.raw)) {
|
||||
case IoctlCommand::IocInitalizeExCommand:
|
||||
return InitalizeEx(input, output);
|
||||
case IoctlCommand::IocAllocateSpaceCommand:
|
||||
return AllocateSpace(input, output);
|
||||
case IoctlCommand::IocMapBufferExCommand:
|
||||
return MapBufferEx(input, output);
|
||||
case IoctlCommand::IocBindChannelCommand:
|
||||
return BindChannel(input, output);
|
||||
case IoctlCommand::IocGetVaRegionsCommand:
|
||||
return GetVARegions(input, output);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 nvhost_as_gpu::InitalizeEx(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
IoctlInitalizeEx params{};
|
||||
std::memcpy(¶ms, input.data(), input.size());
|
||||
LOG_WARNING(Service_NVDRV, "(STUBBED) called, big_page_size=0x%x", params.big_page_size);
|
||||
std::memcpy(output.data(), ¶ms, output.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 nvhost_as_gpu::AllocateSpace(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
IoctlAllocSpace params{};
|
||||
std::memcpy(¶ms, input.data(), input.size());
|
||||
LOG_DEBUG(Service_NVDRV, "called, pages=%x, page_size=%x, flags=%x", params.pages,
|
||||
params.page_size, params.flags);
|
||||
|
||||
auto& gpu = Core::System::GetInstance().GPU();
|
||||
const u64 size{static_cast<u64>(params.pages) * static_cast<u64>(params.page_size)};
|
||||
if (params.flags & 1) {
|
||||
params.offset = gpu.memory_manager->AllocateSpace(params.offset, size, 1);
|
||||
} else {
|
||||
params.offset = gpu.memory_manager->AllocateSpace(size, params.align);
|
||||
}
|
||||
|
||||
std::memcpy(output.data(), ¶ms, output.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 nvhost_as_gpu::MapBufferEx(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
IoctlMapBufferEx params{};
|
||||
std::memcpy(¶ms, input.data(), input.size());
|
||||
|
||||
LOG_DEBUG(Service_NVDRV,
|
||||
"called, flags=%x, nvmap_handle=%x, buffer_offset=%lx, mapping_size=%lx, offset=%lx",
|
||||
params.flags, params.nvmap_handle, params.buffer_offset, params.mapping_size,
|
||||
params.offset);
|
||||
|
||||
if (!params.nvmap_handle) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto object = nvmap_dev->GetObject(params.nvmap_handle);
|
||||
ASSERT(object);
|
||||
|
||||
auto& gpu = Core::System::GetInstance().GPU();
|
||||
|
||||
if (params.flags & 1) {
|
||||
params.offset = gpu.memory_manager->MapBufferEx(object->addr, params.offset, object->size);
|
||||
} else {
|
||||
params.offset = gpu.memory_manager->MapBufferEx(object->addr, object->size);
|
||||
}
|
||||
|
||||
std::memcpy(output.data(), ¶ms, output.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 nvhost_as_gpu::BindChannel(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
IoctlBindChannel params{};
|
||||
std::memcpy(¶ms, input.data(), input.size());
|
||||
LOG_DEBUG(Service_NVDRV, "called, fd=%x", params.fd);
|
||||
channel = params.fd;
|
||||
std::memcpy(output.data(), ¶ms, output.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 nvhost_as_gpu::GetVARegions(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
IoctlGetVaRegions params{};
|
||||
std::memcpy(¶ms, input.data(), input.size());
|
||||
LOG_WARNING(Service_NVDRV, "(STUBBED) called, buf_addr=%lx, buf_size=%x", params.buf_addr,
|
||||
params.buf_size);
|
||||
|
||||
params.buf_size = 0x30;
|
||||
params.regions[0].offset = 0x04000000;
|
||||
params.regions[0].page_size = 0x1000;
|
||||
params.regions[0].pages = 0x3fbfff;
|
||||
|
||||
params.regions[1].offset = 0x04000000;
|
||||
params.regions[1].page_size = 0x10000;
|
||||
params.regions[1].pages = 0x1bffff;
|
||||
// TODO(ogniK): This probably can stay stubbed but should add support way way later
|
||||
std::memcpy(output.data(), ¶ms, output.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,20 +4,100 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include "common/common_types.h"
|
||||
#include "common/swap.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvdevice.h"
|
||||
|
||||
namespace Service {
|
||||
namespace Nvidia {
|
||||
namespace Devices {
|
||||
|
||||
class nvmap;
|
||||
|
||||
class nvhost_as_gpu final : public nvdevice {
|
||||
public:
|
||||
nvhost_as_gpu() = default;
|
||||
nvhost_as_gpu(std::shared_ptr<nvmap> nvmap_dev) : nvmap_dev(std::move(nvmap_dev)) {}
|
||||
~nvhost_as_gpu() override = default;
|
||||
|
||||
u32 ioctl(u32 command, const std::vector<u8>& input, std::vector<u8>& output) override;
|
||||
u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override;
|
||||
|
||||
private:
|
||||
enum class IoctlCommand : u32_le {
|
||||
IocInitalizeExCommand = 0x40284109,
|
||||
IocAllocateSpaceCommand = 0xC0184102,
|
||||
IocMapBufferExCommand = 0xC0284106,
|
||||
IocBindChannelCommand = 0x40044101,
|
||||
IocGetVaRegionsCommand = 0xC0404108,
|
||||
};
|
||||
|
||||
struct IoctlInitalizeEx {
|
||||
u32_le big_page_size; // depends on GPU's available_big_page_sizes; 0=default
|
||||
s32_le as_fd; // ignored; passes 0
|
||||
u32_le flags; // passes 0
|
||||
u32_le reserved; // ignored; passes 0
|
||||
u64_le unk0;
|
||||
u64_le unk1;
|
||||
u64_le unk2;
|
||||
};
|
||||
static_assert(sizeof(IoctlInitalizeEx) == 40, "IoctlInitalizeEx is incorrect size");
|
||||
|
||||
struct IoctlAllocSpace {
|
||||
u32_le pages;
|
||||
u32_le page_size;
|
||||
u32_le flags;
|
||||
INSERT_PADDING_WORDS(1);
|
||||
union {
|
||||
u64_le offset;
|
||||
u64_le align;
|
||||
};
|
||||
};
|
||||
static_assert(sizeof(IoctlAllocSpace) == 24, "IoctlInitalizeEx is incorrect size");
|
||||
|
||||
struct IoctlMapBufferEx {
|
||||
u32_le flags; // bit0: fixed_offset, bit2: cacheable
|
||||
u32_le kind; // -1 is default
|
||||
u32_le nvmap_handle;
|
||||
u32_le page_size; // 0 means don't care
|
||||
u64_le buffer_offset;
|
||||
u64_le mapping_size;
|
||||
u64_le offset;
|
||||
};
|
||||
static_assert(sizeof(IoctlMapBufferEx) == 40, "IoctlMapBufferEx is incorrect size");
|
||||
|
||||
struct IoctlBindChannel {
|
||||
u32_le fd;
|
||||
};
|
||||
static_assert(sizeof(IoctlBindChannel) == 4, "IoctlBindChannel is incorrect size");
|
||||
|
||||
struct IoctlVaRegion {
|
||||
u64_le offset;
|
||||
u32_le page_size;
|
||||
INSERT_PADDING_WORDS(1);
|
||||
u64_le pages;
|
||||
};
|
||||
static_assert(sizeof(IoctlVaRegion) == 24, "IoctlVaRegion is incorrect size");
|
||||
|
||||
struct IoctlGetVaRegions {
|
||||
u64_le buf_addr; // (contained output user ptr on linux, ignored)
|
||||
u32_le buf_size; // forced to 2*sizeof(struct va_region)
|
||||
u32_le reserved;
|
||||
IoctlVaRegion regions[2];
|
||||
};
|
||||
static_assert(sizeof(IoctlGetVaRegions) == 16 + sizeof(IoctlVaRegion) * 2,
|
||||
"IoctlGetVaRegions is incorrect size");
|
||||
|
||||
u32 channel{};
|
||||
|
||||
u32 InitalizeEx(const std::vector<u8>& input, std::vector<u8>& output);
|
||||
u32 AllocateSpace(const std::vector<u8>& input, std::vector<u8>& output);
|
||||
u32 MapBufferEx(const std::vector<u8>& input, std::vector<u8>& output);
|
||||
u32 BindChannel(const std::vector<u8>& input, std::vector<u8>& output);
|
||||
u32 GetVARegions(const std::vector<u8>& input, std::vector<u8>& output);
|
||||
|
||||
std::shared_ptr<nvmap> nvmap_dev;
|
||||
};
|
||||
|
||||
} // namespace Devices
|
||||
|
||||
@@ -10,12 +10,12 @@ namespace Service {
|
||||
namespace Nvidia {
|
||||
namespace Devices {
|
||||
|
||||
u32 nvhost_ctrl::ioctl(u32 command, const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
u32 nvhost_ctrl::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
LOG_DEBUG(Service_NVDRV, "called, command=0x%08x, input_size=0x%lx, output_size=0x%lx", command,
|
||||
input.size(), output.size());
|
||||
|
||||
switch (command) {
|
||||
case IocGetConfigCommand:
|
||||
switch (static_cast<IoctlCommand>(command.raw)) {
|
||||
case IoctlCommand::IocGetConfigCommand:
|
||||
return NvOsGetConfigU32(input, output);
|
||||
}
|
||||
UNIMPLEMENTED();
|
||||
@@ -23,19 +23,23 @@ u32 nvhost_ctrl::ioctl(u32 command, const std::vector<u8>& input, std::vector<u8
|
||||
}
|
||||
|
||||
u32 nvhost_ctrl::NvOsGetConfigU32(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
IocGetConfigParams params;
|
||||
IocGetConfigParams params{};
|
||||
std::memcpy(¶ms, input.data(), sizeof(params));
|
||||
LOG_DEBUG(Service_NVDRV, "called, setting=%s!%s", params.domain_str.data(),
|
||||
params.param_str.data());
|
||||
|
||||
if (!strcmp(params.domain_str.data(), "nv")) {
|
||||
if (!strcmp(params.param_str.data(), "NV_MEMORY_PROFILER")) {
|
||||
params.config_str[0] = '1';
|
||||
params.config_str[0] = '0';
|
||||
} else if (!strcmp(params.param_str.data(), "NVN_THROUGH_OPENGL")) {
|
||||
params.config_str[0] = '0';
|
||||
} else if (!strcmp(params.param_str.data(), "NVRM_GPU_PREVENT_USE")) {
|
||||
params.config_str[0] = '0';
|
||||
} else {
|
||||
UNIMPLEMENTED();
|
||||
params.config_str[0] = '0';
|
||||
}
|
||||
} else {
|
||||
UNIMPLEMENTED();
|
||||
UNIMPLEMENTED(); // unknown domain? Only nv has been seen so far on hardware
|
||||
}
|
||||
std::memcpy(output.data(), ¶ms, sizeof(params));
|
||||
return 0;
|
||||
|
||||
@@ -20,10 +20,10 @@ public:
|
||||
nvhost_ctrl() = default;
|
||||
~nvhost_ctrl() override = default;
|
||||
|
||||
u32 ioctl(u32 command, const std::vector<u8>& input, std::vector<u8>& output) override;
|
||||
u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override;
|
||||
|
||||
private:
|
||||
enum IoctlCommands {
|
||||
enum class IoctlCommand : u32_le {
|
||||
IocSyncptReadCommand = 0xC0080014,
|
||||
IocSyncptIncrCommand = 0x40040015,
|
||||
IocSyncptWaitCommand = 0xC00C0016,
|
||||
@@ -39,6 +39,7 @@ private:
|
||||
std::array<char, 0x41> param_str;
|
||||
std::array<char, 0x101> config_str;
|
||||
};
|
||||
static_assert(sizeof(IocGetConfigParams) == 387, "IocGetConfigParams is incorrect size");
|
||||
|
||||
u32 NvOsGetConfigU32(const std::vector<u8>& input, std::vector<u8>& output);
|
||||
};
|
||||
|
||||
126
src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp
Normal file
126
src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp
Normal file
@@ -0,0 +1,126 @@
|
||||
// Copyright 2018 yuzu emulator team
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h"
|
||||
|
||||
namespace Service {
|
||||
namespace Nvidia {
|
||||
namespace Devices {
|
||||
|
||||
u32 nvhost_ctrl_gpu::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
LOG_DEBUG(Service_NVDRV, "called, command=0x%08x, input_size=0x%llx, output_size=0x%llx",
|
||||
command, input.size(), output.size());
|
||||
|
||||
switch (static_cast<IoctlCommand>(command.raw)) {
|
||||
case IoctlCommand::IocGetCharacteristicsCommand:
|
||||
return GetCharacteristics(input, output);
|
||||
case IoctlCommand::IocGetTPCMasksCommand:
|
||||
return GetTPCMasks(input, output);
|
||||
case IoctlCommand::IocGetActiveSlotMaskCommand:
|
||||
return GetActiveSlotMask(input, output);
|
||||
case IoctlCommand::IocZcullGetCtxSizeCommand:
|
||||
return ZCullGetCtxSize(input, output);
|
||||
case IoctlCommand::IocZcullGetInfo:
|
||||
return ZCullGetInfo(input, output);
|
||||
}
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 nvhost_ctrl_gpu::GetCharacteristics(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
LOG_DEBUG(Service_NVDRV, "called");
|
||||
IoctlCharacteristics params{};
|
||||
std::memcpy(¶ms, input.data(), input.size());
|
||||
params.gc.arch = 0x120;
|
||||
params.gc.impl = 0xb;
|
||||
params.gc.rev = 0xa1;
|
||||
params.gc.num_gpc = 0x1;
|
||||
params.gc.l2_cache_size = 0x40000;
|
||||
params.gc.on_board_video_memory_size = 0x0;
|
||||
params.gc.num_tpc_per_gpc = 0x2;
|
||||
params.gc.bus_type = 0x20;
|
||||
params.gc.big_page_size = 0x20000;
|
||||
params.gc.compression_page_size = 0x20000;
|
||||
params.gc.pde_coverage_bit_count = 0x1B;
|
||||
params.gc.available_big_page_sizes = 0x30000;
|
||||
params.gc.gpc_mask = 0x1;
|
||||
params.gc.sm_arch_sm_version = 0x503;
|
||||
params.gc.sm_arch_spa_version = 0x503;
|
||||
params.gc.sm_arch_warp_count = 0x80;
|
||||
params.gc.gpu_va_bit_count = 0x28;
|
||||
params.gc.reserved = 0x0;
|
||||
params.gc.flags = 0x55;
|
||||
params.gc.twod_class = 0x902D;
|
||||
params.gc.threed_class = 0xB197;
|
||||
params.gc.compute_class = 0xB1C0;
|
||||
params.gc.gpfifo_class = 0xB06F;
|
||||
params.gc.inline_to_memory_class = 0xA140;
|
||||
params.gc.dma_copy_class = 0xB0B5;
|
||||
params.gc.max_fbps_count = 0x1;
|
||||
params.gc.fbp_en_mask = 0x0;
|
||||
params.gc.max_ltc_per_fbp = 0x2;
|
||||
params.gc.max_lts_per_ltc = 0x1;
|
||||
params.gc.max_tex_per_tpc = 0x0;
|
||||
params.gc.max_gpc_count = 0x1;
|
||||
params.gc.rop_l2_en_mask_0 = 0x21D70;
|
||||
params.gc.rop_l2_en_mask_1 = 0x0;
|
||||
params.gc.chipname = 0x6230326D67;
|
||||
params.gc.gr_compbit_store_base_hw = 0x0;
|
||||
params.gpu_characteristics_buf_size = 0xA0;
|
||||
params.gpu_characteristics_buf_addr = 0xdeadbeef; // Cannot be 0 (UNUSED)
|
||||
std::memcpy(output.data(), ¶ms, output.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 nvhost_ctrl_gpu::GetTPCMasks(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
IoctlGpuGetTpcMasksArgs params{};
|
||||
std::memcpy(¶ms, input.data(), input.size());
|
||||
LOG_WARNING(Service_NVDRV, "(STUBBED) called, mask=0x%x, mask_buf_addr=0x%lx",
|
||||
params.mask_buf_size, params.mask_buf_addr);
|
||||
std::memcpy(output.data(), ¶ms, sizeof(params));
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 nvhost_ctrl_gpu::GetActiveSlotMask(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
LOG_DEBUG(Service_NVDRV, "called");
|
||||
IoctlActiveSlotMask params{};
|
||||
std::memcpy(¶ms, input.data(), input.size());
|
||||
params.slot = 0x07;
|
||||
params.mask = 0x01;
|
||||
std::memcpy(output.data(), ¶ms, output.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 nvhost_ctrl_gpu::ZCullGetCtxSize(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
LOG_DEBUG(Service_NVDRV, "called");
|
||||
IoctlZcullGetCtxSize params{};
|
||||
std::memcpy(¶ms, input.data(), input.size());
|
||||
params.size = 0x1;
|
||||
std::memcpy(output.data(), ¶ms, output.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 nvhost_ctrl_gpu::ZCullGetInfo(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
LOG_DEBUG(Service_NVDRV, "called");
|
||||
IoctlNvgpuGpuZcullGetInfoArgs params{};
|
||||
std::memcpy(¶ms, input.data(), input.size());
|
||||
params.width_align_pixels = 0x20;
|
||||
params.height_align_pixels = 0x20;
|
||||
params.pixel_squares_by_aliquots = 0x400;
|
||||
params.aliquot_total = 0x800;
|
||||
params.region_byte_multiplier = 0x20;
|
||||
params.region_header_size = 0x20;
|
||||
params.subregion_header_size = 0xc0;
|
||||
params.subregion_width_align_pixels = 0x20;
|
||||
params.subregion_height_align_pixels = 0x40;
|
||||
params.subregion_count = 0x10;
|
||||
std::memcpy(output.data(), ¶ms, output.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace Devices
|
||||
} // namespace Nvidia
|
||||
} // namespace Service
|
||||
130
src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h
Normal file
130
src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h
Normal file
@@ -0,0 +1,130 @@
|
||||
// Copyright 2018 yuzu emulator team
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "common/common_types.h"
|
||||
#include "common/swap.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvdevice.h"
|
||||
|
||||
namespace Service {
|
||||
namespace Nvidia {
|
||||
namespace Devices {
|
||||
|
||||
class nvhost_ctrl_gpu final : public nvdevice {
|
||||
public:
|
||||
nvhost_ctrl_gpu() = default;
|
||||
~nvhost_ctrl_gpu() override = default;
|
||||
|
||||
u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override;
|
||||
|
||||
private:
|
||||
enum class IoctlCommand : u32_le {
|
||||
IocGetCharacteristicsCommand = 0xC0B04705,
|
||||
IocGetTPCMasksCommand = 0xC0184706,
|
||||
IocGetActiveSlotMaskCommand = 0x80084714,
|
||||
IocZcullGetCtxSizeCommand = 0x80044701,
|
||||
IocZcullGetInfo = 0x80284702,
|
||||
};
|
||||
|
||||
struct IoctlGpuCharacteristics {
|
||||
u32_le arch; // 0x120 (NVGPU_GPU_ARCH_GM200)
|
||||
u32_le impl; // 0xB (NVGPU_GPU_IMPL_GM20B)
|
||||
u32_le rev; // 0xA1 (Revision A1)
|
||||
u32_le num_gpc; // 0x1
|
||||
u64_le l2_cache_size; // 0x40000
|
||||
u64_le on_board_video_memory_size; // 0x0 (not used)
|
||||
u32_le num_tpc_per_gpc; // 0x2
|
||||
u32_le bus_type; // 0x20 (NVGPU_GPU_BUS_TYPE_AXI)
|
||||
u32_le big_page_size; // 0x20000
|
||||
u32_le compression_page_size; // 0x20000
|
||||
u32_le pde_coverage_bit_count; // 0x1B
|
||||
u32_le available_big_page_sizes; // 0x30000
|
||||
u32_le gpc_mask; // 0x1
|
||||
u32_le sm_arch_sm_version; // 0x503 (Maxwell Generation 5.0.3?)
|
||||
u32_le sm_arch_spa_version; // 0x503 (Maxwell Generation 5.0.3?)
|
||||
u32_le sm_arch_warp_count; // 0x80
|
||||
u32_le gpu_va_bit_count; // 0x28
|
||||
u32_le reserved; // NULL
|
||||
u64_le flags; // 0x55
|
||||
u32_le twod_class; // 0x902D (FERMI_TWOD_A)
|
||||
u32_le threed_class; // 0xB197 (MAXWELL_B)
|
||||
u32_le compute_class; // 0xB1C0 (MAXWELL_COMPUTE_B)
|
||||
u32_le gpfifo_class; // 0xB06F (MAXWELL_CHANNEL_GPFIFO_A)
|
||||
u32_le inline_to_memory_class; // 0xA140 (KEPLER_INLINE_TO_MEMORY_B)
|
||||
u32_le dma_copy_class; // 0xB0B5 (MAXWELL_DMA_COPY_A)
|
||||
u32_le max_fbps_count; // 0x1
|
||||
u32_le fbp_en_mask; // 0x0 (disabled)
|
||||
u32_le max_ltc_per_fbp; // 0x2
|
||||
u32_le max_lts_per_ltc; // 0x1
|
||||
u32_le max_tex_per_tpc; // 0x0 (not supported)
|
||||
u32_le max_gpc_count; // 0x1
|
||||
u32_le rop_l2_en_mask_0; // 0x21D70 (fuse_status_opt_rop_l2_fbp_r)
|
||||
u32_le rop_l2_en_mask_1; // 0x0
|
||||
u64_le chipname; // 0x6230326D67 ("gm20b")
|
||||
u64_le gr_compbit_store_base_hw; // 0x0 (not supported)
|
||||
};
|
||||
static_assert(sizeof(IoctlGpuCharacteristics) == 160,
|
||||
"IoctlGpuCharacteristics is incorrect size");
|
||||
|
||||
struct IoctlCharacteristics {
|
||||
u64_le gpu_characteristics_buf_size; // must not be NULL, but gets overwritten with
|
||||
// 0xA0=max_size
|
||||
u64_le gpu_characteristics_buf_addr; // ignored, but must not be NULL
|
||||
IoctlGpuCharacteristics gc;
|
||||
};
|
||||
static_assert(sizeof(IoctlCharacteristics) == 16 + sizeof(IoctlGpuCharacteristics),
|
||||
"IoctlCharacteristics is incorrect size");
|
||||
|
||||
struct IoctlGpuGetTpcMasksArgs {
|
||||
/// [in] TPC mask buffer size reserved by userspace. Should be at least
|
||||
/// sizeof(__u32) * fls(gpc_mask) to receive TPC mask for each GPC.
|
||||
/// [out] full kernel buffer size
|
||||
u32_le mask_buf_size;
|
||||
u32_le reserved;
|
||||
|
||||
/// [in] pointer to TPC mask buffer. It will receive one 32-bit TPC mask per GPC or 0 if
|
||||
/// GPC is not enabled or not present. This parameter is ignored if mask_buf_size is 0.
|
||||
u64_le mask_buf_addr;
|
||||
u64_le unk; // Nintendo add this?
|
||||
};
|
||||
static_assert(sizeof(IoctlGpuGetTpcMasksArgs) == 24,
|
||||
"IoctlGpuGetTpcMasksArgs is incorrect size");
|
||||
|
||||
struct IoctlActiveSlotMask {
|
||||
u32_le slot; // always 0x07
|
||||
u32_le mask;
|
||||
};
|
||||
static_assert(sizeof(IoctlActiveSlotMask) == 8, "IoctlActiveSlotMask is incorrect size");
|
||||
|
||||
struct IoctlZcullGetCtxSize {
|
||||
u32_le size;
|
||||
};
|
||||
static_assert(sizeof(IoctlZcullGetCtxSize) == 4, "IoctlZcullGetCtxSize is incorrect size");
|
||||
|
||||
struct IoctlNvgpuGpuZcullGetInfoArgs {
|
||||
u32_le width_align_pixels;
|
||||
u32_le height_align_pixels;
|
||||
u32_le pixel_squares_by_aliquots;
|
||||
u32_le aliquot_total;
|
||||
u32_le region_byte_multiplier;
|
||||
u32_le region_header_size;
|
||||
u32_le subregion_header_size;
|
||||
u32_le subregion_width_align_pixels;
|
||||
u32_le subregion_height_align_pixels;
|
||||
u32_le subregion_count;
|
||||
};
|
||||
static_assert(sizeof(IoctlNvgpuGpuZcullGetInfoArgs) == 40,
|
||||
"IoctlNvgpuGpuZcullGetInfoArgs is incorrect size");
|
||||
|
||||
u32 GetCharacteristics(const std::vector<u8>& input, std::vector<u8>& output);
|
||||
u32 GetTPCMasks(const std::vector<u8>& input, std::vector<u8>& output);
|
||||
u32 GetActiveSlotMask(const std::vector<u8>& input, std::vector<u8>& output);
|
||||
u32 ZCullGetCtxSize(const std::vector<u8>& input, std::vector<u8>& output);
|
||||
u32 ZCullGetInfo(const std::vector<u8>& input, std::vector<u8>& output);
|
||||
};
|
||||
} // namespace Devices
|
||||
} // namespace Nvidia
|
||||
} // namespace Service
|
||||
145
src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
Normal file
145
src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
Normal file
@@ -0,0 +1,145 @@
|
||||
// Copyright 2018 yuzu emulator team
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <map>
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvhost_gpu.h"
|
||||
|
||||
namespace Service {
|
||||
namespace Nvidia {
|
||||
namespace Devices {
|
||||
|
||||
u32 nvhost_gpu::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
LOG_DEBUG(Service_NVDRV, "called, command=0x%08x, input_size=0x%llx, output_size=0x%llx",
|
||||
command, input.size(), output.size());
|
||||
|
||||
switch (static_cast<IoctlCommand>(command.raw)) {
|
||||
case IoctlCommand::IocSetNVMAPfdCommand:
|
||||
return SetNVMAPfd(input, output);
|
||||
case IoctlCommand::IocSetClientDataCommand:
|
||||
return SetClientData(input, output);
|
||||
case IoctlCommand::IocGetClientDataCommand:
|
||||
return GetClientData(input, output);
|
||||
case IoctlCommand::IocZCullBind:
|
||||
return ZCullBind(input, output);
|
||||
case IoctlCommand::IocSetErrorNotifierCommand:
|
||||
return SetErrorNotifier(input, output);
|
||||
case IoctlCommand::IocChannelSetPriorityCommand:
|
||||
return SetChannelPriority(input, output);
|
||||
case IoctlCommand::IocAllocGPFIFOEx2Command:
|
||||
return AllocGPFIFOEx2(input, output);
|
||||
case IoctlCommand::IocAllocObjCtxCommand:
|
||||
return AllocateObjectContext(input, output);
|
||||
}
|
||||
|
||||
if (command.group == NVGPU_IOCTL_MAGIC) {
|
||||
if (command.cmd == NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO) {
|
||||
return SubmitGPFIFO(input, output);
|
||||
}
|
||||
}
|
||||
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
};
|
||||
|
||||
u32 nvhost_gpu::SetNVMAPfd(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
IoctlSetNvmapFD params{};
|
||||
std::memcpy(¶ms, input.data(), input.size());
|
||||
LOG_DEBUG(Service_NVDRV, "called, fd=%x", params.nvmap_fd);
|
||||
nvmap_fd = params.nvmap_fd;
|
||||
std::memcpy(output.data(), ¶ms, output.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 nvhost_gpu::SetClientData(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
LOG_DEBUG(Service_NVDRV, "called");
|
||||
IoctlClientData params{};
|
||||
std::memcpy(¶ms, input.data(), input.size());
|
||||
user_data = params.data;
|
||||
std::memcpy(output.data(), ¶ms, output.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 nvhost_gpu::GetClientData(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
LOG_DEBUG(Service_NVDRV, "called");
|
||||
IoctlClientData params{};
|
||||
std::memcpy(¶ms, input.data(), input.size());
|
||||
params.data = user_data;
|
||||
std::memcpy(output.data(), ¶ms, output.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 nvhost_gpu::ZCullBind(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
std::memcpy(&zcull_params, input.data(), input.size());
|
||||
LOG_DEBUG(Service_NVDRV, "called, gpu_va=%lx, mode=%x", zcull_params.gpu_va, zcull_params.mode);
|
||||
std::memcpy(output.data(), &zcull_params, output.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 nvhost_gpu::SetErrorNotifier(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
IoctlSetErrorNotifier params{};
|
||||
std::memcpy(¶ms, input.data(), input.size());
|
||||
LOG_WARNING(Service_NVDRV, "(STUBBED) called, offset=%lx, size=%lx, mem=%x", params.offset,
|
||||
params.size, params.mem);
|
||||
std::memcpy(output.data(), ¶ms, output.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 nvhost_gpu::SetChannelPriority(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
std::memcpy(&channel_priority, input.data(), input.size());
|
||||
LOG_DEBUG(Service_NVDRV, "(STUBBED) called, priority=%x", channel_priority);
|
||||
std::memcpy(output.data(), &channel_priority, output.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 nvhost_gpu::AllocGPFIFOEx2(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
IoctlAllocGpfifoEx2 params{};
|
||||
std::memcpy(¶ms, input.data(), input.size());
|
||||
LOG_WARNING(Service_NVDRV,
|
||||
"(STUBBED) called, num_entries=%x, flags=%x, unk0=%x, unk1=%x, unk2=%x, unk3=%x",
|
||||
params.num_entries, params.flags, params.unk0, params.unk1, params.unk2,
|
||||
params.unk3);
|
||||
params.fence_out.id = 0;
|
||||
params.fence_out.value = 0;
|
||||
std::memcpy(output.data(), ¶ms, output.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 nvhost_gpu::AllocateObjectContext(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
IoctlAllocObjCtx params{};
|
||||
std::memcpy(¶ms, input.data(), input.size());
|
||||
LOG_WARNING(Service_NVDRV, "(STUBBED) called, class_num=%x, flags=%x", params.class_num,
|
||||
params.flags);
|
||||
params.obj_id = 0x0;
|
||||
std::memcpy(output.data(), ¶ms, output.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 nvhost_gpu::SubmitGPFIFO(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
if (input.size() < sizeof(IoctlSubmitGpfifo))
|
||||
UNIMPLEMENTED();
|
||||
IoctlSubmitGpfifo params{};
|
||||
std::memcpy(¶ms, input.data(), sizeof(IoctlSubmitGpfifo));
|
||||
LOG_WARNING(Service_NVDRV, "(STUBBED) called, gpfifo=%lx, num_entries=%x, flags=%x",
|
||||
params.gpfifo, params.num_entries, params.flags);
|
||||
|
||||
auto entries = std::vector<IoctlGpfifoEntry>();
|
||||
entries.resize(params.num_entries);
|
||||
std::memcpy(&entries[0], &input.data()[sizeof(IoctlSubmitGpfifo)],
|
||||
params.num_entries * sizeof(IoctlGpfifoEntry));
|
||||
for (auto entry : entries) {
|
||||
VAddr va_addr = entry.Address();
|
||||
Core::System::GetInstance().GPU().ProcessCommandList(va_addr, entry.sz);
|
||||
}
|
||||
params.fence_out.id = 0;
|
||||
params.fence_out.value = 0;
|
||||
std::memcpy(output.data(), ¶ms, output.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace Devices
|
||||
} // namespace Nvidia
|
||||
} // namespace Service
|
||||
144
src/core/hle/service/nvdrv/devices/nvhost_gpu.h
Normal file
144
src/core/hle/service/nvdrv/devices/nvhost_gpu.h
Normal file
@@ -0,0 +1,144 @@
|
||||
// Copyright 2018 yuzu emulator team
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "common/common_types.h"
|
||||
#include "common/swap.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvdevice.h"
|
||||
|
||||
namespace Service {
|
||||
namespace Nvidia {
|
||||
namespace Devices {
|
||||
|
||||
class nvmap;
|
||||
constexpr u32 NVGPU_IOCTL_MAGIC('H');
|
||||
constexpr u32 NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO(0x8);
|
||||
|
||||
class nvhost_gpu final : public nvdevice {
|
||||
public:
|
||||
nvhost_gpu(std::shared_ptr<nvmap> nvmap_dev) : nvmap_dev(std::move(nvmap_dev)) {}
|
||||
~nvhost_gpu() override = default;
|
||||
|
||||
u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override;
|
||||
|
||||
private:
|
||||
enum class IoctlCommand : u32_le {
|
||||
IocSetNVMAPfdCommand = 0x40044801,
|
||||
IocSetClientDataCommand = 0x40084714,
|
||||
IocGetClientDataCommand = 0x80084715,
|
||||
IocZCullBind = 0xc010480b,
|
||||
IocSetErrorNotifierCommand = 0xC018480C,
|
||||
IocChannelSetPriorityCommand = 0x4004480D,
|
||||
IocAllocGPFIFOEx2Command = 0xC020481A,
|
||||
IocAllocObjCtxCommand = 0xC0104809,
|
||||
};
|
||||
|
||||
enum class CtxObjects : u32_le {
|
||||
Ctx2D = 0x902D,
|
||||
Ctx3D = 0xB197,
|
||||
CtxCompute = 0xB1C0,
|
||||
CtxKepler = 0xA140,
|
||||
CtxDMA = 0xB0B5,
|
||||
CtxChannelGPFIFO = 0xB06F,
|
||||
};
|
||||
|
||||
struct IoctlSetNvmapFD {
|
||||
u32_le nvmap_fd;
|
||||
};
|
||||
static_assert(sizeof(IoctlSetNvmapFD) == 4, "IoctlSetNvmapFD is incorrect size");
|
||||
|
||||
struct IoctlClientData {
|
||||
u64_le data;
|
||||
};
|
||||
static_assert(sizeof(IoctlClientData) == 8, "IoctlClientData is incorrect size");
|
||||
|
||||
struct IoctlZCullBind {
|
||||
u64_le gpu_va;
|
||||
u32_le mode; // 0=global, 1=no_ctxsw, 2=separate_buffer, 3=part_of_regular_buf
|
||||
INSERT_PADDING_WORDS(1);
|
||||
};
|
||||
static_assert(sizeof(IoctlZCullBind) == 16, "IoctlZCullBind is incorrect size");
|
||||
|
||||
struct IoctlSetErrorNotifier {
|
||||
u64_le offset;
|
||||
u64_le size;
|
||||
u32_le mem; // nvmap object handle
|
||||
INSERT_PADDING_WORDS(1);
|
||||
};
|
||||
static_assert(sizeof(IoctlSetErrorNotifier) == 24, "IoctlSetErrorNotifier is incorrect size");
|
||||
|
||||
struct IoctlFence {
|
||||
u32_le id;
|
||||
u32_le value;
|
||||
};
|
||||
static_assert(sizeof(IoctlFence) == 8, "IoctlFence is incorrect size");
|
||||
|
||||
struct IoctlAllocGpfifoEx2 {
|
||||
u32_le num_entries; // in
|
||||
u32_le flags; // in
|
||||
u32_le unk0; // in (1 works)
|
||||
IoctlFence fence_out; // out
|
||||
u32_le unk1; // in
|
||||
u32_le unk2; // in
|
||||
u32_le unk3; // in
|
||||
};
|
||||
static_assert(sizeof(IoctlAllocGpfifoEx2) == 32, "IoctlAllocGpfifoEx2 is incorrect size");
|
||||
|
||||
struct IoctlAllocObjCtx {
|
||||
u32_le class_num; // 0x902D=2d, 0xB197=3d, 0xB1C0=compute, 0xA140=kepler, 0xB0B5=DMA,
|
||||
// 0xB06F=channel_gpfifo
|
||||
u32_le flags;
|
||||
u64_le obj_id; // (ignored) used for FREE_OBJ_CTX ioctl, which is not supported
|
||||
};
|
||||
static_assert(sizeof(IoctlAllocObjCtx) == 16, "IoctlAllocObjCtx is incorrect size");
|
||||
|
||||
struct IoctlGpfifoEntry {
|
||||
u32_le entry0; // gpu_va_lo
|
||||
union {
|
||||
u32_le entry1; // gpu_va_hi | (unk_0x02 << 0x08) | (size << 0x0A) | (unk_0x01 << 0x1F)
|
||||
BitField<0, 8, u32_le> gpu_va_hi;
|
||||
BitField<8, 2, u32_le> unk1;
|
||||
BitField<10, 21, u32_le> sz;
|
||||
BitField<31, 1, u32_le> unk2;
|
||||
};
|
||||
|
||||
VAddr Address() const {
|
||||
return (static_cast<VAddr>(gpu_va_hi) << 32) | entry0;
|
||||
}
|
||||
};
|
||||
static_assert(sizeof(IoctlGpfifoEntry) == 8, "IoctlGpfifoEntry is incorrect size");
|
||||
|
||||
struct IoctlSubmitGpfifo {
|
||||
u64_le gpfifo; // (ignored) pointer to gpfifo fence structs
|
||||
u32_le num_entries; // number of fence objects being submitted
|
||||
u32_le flags;
|
||||
IoctlFence fence_out; // returned new fence object for others to wait on
|
||||
};
|
||||
static_assert(sizeof(IoctlSubmitGpfifo) == 16 + sizeof(IoctlFence),
|
||||
"submit_gpfifo is incorrect size");
|
||||
|
||||
u32_le nvmap_fd{};
|
||||
u64_le user_data{};
|
||||
IoctlZCullBind zcull_params{};
|
||||
u32_le channel_priority{};
|
||||
|
||||
u32 SetNVMAPfd(const std::vector<u8>& input, std::vector<u8>& output);
|
||||
u32 SetClientData(const std::vector<u8>& input, std::vector<u8>& output);
|
||||
u32 GetClientData(const std::vector<u8>& input, std::vector<u8>& output);
|
||||
u32 ZCullBind(const std::vector<u8>& input, std::vector<u8>& output);
|
||||
u32 SetErrorNotifier(const std::vector<u8>& input, std::vector<u8>& output);
|
||||
u32 SetChannelPriority(const std::vector<u8>& input, std::vector<u8>& output);
|
||||
u32 AllocGPFIFOEx2(const std::vector<u8>& input, std::vector<u8>& output);
|
||||
u32 AllocateObjectContext(const std::vector<u8>& input, std::vector<u8>& output);
|
||||
u32 SubmitGPFIFO(const std::vector<u8>& input, std::vector<u8>& output);
|
||||
|
||||
std::shared_ptr<nvmap> nvmap_dev;
|
||||
};
|
||||
|
||||
} // namespace Devices
|
||||
} // namespace Nvidia
|
||||
} // namespace Service
|
||||
@@ -13,16 +13,14 @@ namespace Nvidia {
|
||||
namespace Devices {
|
||||
|
||||
VAddr nvmap::GetObjectAddress(u32 handle) const {
|
||||
auto itr = handles.find(handle);
|
||||
ASSERT(itr != handles.end());
|
||||
|
||||
auto object = itr->second;
|
||||
auto object = GetObject(handle);
|
||||
ASSERT(object);
|
||||
ASSERT(object->status == Object::Status::Allocated);
|
||||
return object->addr;
|
||||
}
|
||||
|
||||
u32 nvmap::ioctl(u32 command, const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
switch (static_cast<IoctlCommand>(command)) {
|
||||
u32 nvmap::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
switch (static_cast<IoctlCommand>(command.raw)) {
|
||||
case IoctlCommand::Create:
|
||||
return IocCreate(input, output);
|
||||
case IoctlCommand::Alloc:
|
||||
@@ -52,7 +50,7 @@ u32 nvmap::IocCreate(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
u32 handle = next_handle++;
|
||||
handles[handle] = std::move(object);
|
||||
|
||||
LOG_WARNING(Service_NVDRV, "(STUBBED) size 0x%08X", params.size);
|
||||
LOG_DEBUG(Service_NVDRV, "size=0x%08X", params.size);
|
||||
|
||||
params.handle = handle;
|
||||
|
||||
@@ -64,17 +62,16 @@ u32 nvmap::IocAlloc(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
IocAllocParams params;
|
||||
std::memcpy(¶ms, input.data(), sizeof(params));
|
||||
|
||||
auto itr = handles.find(params.handle);
|
||||
ASSERT(itr != handles.end());
|
||||
auto object = GetObject(params.handle);
|
||||
ASSERT(object);
|
||||
|
||||
auto object = itr->second;
|
||||
object->flags = params.flags;
|
||||
object->align = params.align;
|
||||
object->kind = params.kind;
|
||||
object->addr = params.addr;
|
||||
object->status = Object::Status::Allocated;
|
||||
|
||||
LOG_WARNING(Service_NVDRV, "(STUBBED) Allocated address 0x%llx", params.addr);
|
||||
LOG_DEBUG(Service_NVDRV, "called, addr=0x%llx", params.addr);
|
||||
|
||||
std::memcpy(output.data(), ¶ms, sizeof(params));
|
||||
return 0;
|
||||
@@ -86,10 +83,10 @@ u32 nvmap::IocGetId(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
|
||||
LOG_WARNING(Service_NVDRV, "called");
|
||||
|
||||
auto itr = handles.find(params.handle);
|
||||
ASSERT(itr != handles.end());
|
||||
auto object = GetObject(params.handle);
|
||||
ASSERT(object);
|
||||
|
||||
params.id = itr->second->id;
|
||||
params.id = object->id;
|
||||
|
||||
std::memcpy(output.data(), ¶ms, sizeof(params));
|
||||
return 0;
|
||||
@@ -123,10 +120,8 @@ u32 nvmap::IocParam(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
|
||||
LOG_WARNING(Service_NVDRV, "(STUBBED) called type=%u", params.type);
|
||||
|
||||
auto itr = handles.find(params.handle);
|
||||
ASSERT(itr != handles.end());
|
||||
|
||||
auto object = itr->second;
|
||||
auto object = GetObject(params.handle);
|
||||
ASSERT(object);
|
||||
ASSERT(object->status == Object::Status::Allocated);
|
||||
|
||||
switch (static_cast<ParamTypes>(params.type)) {
|
||||
|
||||
@@ -24,10 +24,9 @@ public:
|
||||
/// Returns the allocated address of an nvmap object given its handle.
|
||||
VAddr GetObjectAddress(u32 handle) const;
|
||||
|
||||
u32 ioctl(u32 command, const std::vector<u8>& input, std::vector<u8>& output) override;
|
||||
u32 ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) override;
|
||||
|
||||
private:
|
||||
// Represents an nvmap object.
|
||||
/// Represents an nvmap object.
|
||||
struct Object {
|
||||
enum class Status { Created, Allocated };
|
||||
u32 id;
|
||||
@@ -39,10 +38,19 @@ private:
|
||||
Status status;
|
||||
};
|
||||
|
||||
std::shared_ptr<Object> GetObject(u32 handle) const {
|
||||
auto itr = handles.find(handle);
|
||||
if (itr != handles.end()) {
|
||||
return itr->second;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
private:
|
||||
/// Id to use for the next handle that is created.
|
||||
u32 next_handle = 1;
|
||||
|
||||
// Id to use for the next object that is created.
|
||||
/// Id to use for the next object that is created.
|
||||
u32 next_id = 1;
|
||||
|
||||
/// Mapping of currently allocated handles to the objects they represent.
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "common/logging/log.h"
|
||||
#include "core/hle/ipc_helpers.h"
|
||||
#include "core/hle/kernel/event.h"
|
||||
#include "core/hle/service/nvdrv/interface.h"
|
||||
#include "core/hle/service/nvdrv/nvdrv.h"
|
||||
|
||||
@@ -11,7 +12,7 @@ namespace Service {
|
||||
namespace Nvidia {
|
||||
|
||||
void NVDRV::Open(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_NVDRV, "(STUBBED) called");
|
||||
LOG_DEBUG(Service_NVDRV, "called");
|
||||
|
||||
auto buffer = ctx.BufferDescriptorA()[0];
|
||||
|
||||
@@ -25,31 +26,35 @@ void NVDRV::Open(Kernel::HLERequestContext& ctx) {
|
||||
}
|
||||
|
||||
void NVDRV::Ioctl(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_NVDRV, "(STUBBED) called");
|
||||
LOG_DEBUG(Service_NVDRV, "called");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
u32 fd = rp.Pop<u32>();
|
||||
u32 command = rp.Pop<u32>();
|
||||
|
||||
auto input_buffer = ctx.BufferDescriptorA()[0];
|
||||
auto output_buffer = ctx.BufferDescriptorB()[0];
|
||||
|
||||
std::vector<u8> input(input_buffer.Size());
|
||||
std::vector<u8> output(output_buffer.Size());
|
||||
|
||||
Memory::ReadBlock(input_buffer.Address(), input.data(), input_buffer.Size());
|
||||
|
||||
u32 nv_result = nvdrv->Ioctl(fd, command, input, output);
|
||||
|
||||
Memory::WriteBlock(output_buffer.Address(), output.data(), output_buffer.Size());
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.Push(nv_result);
|
||||
if (ctx.BufferDescriptorA()[0].Size() != 0) {
|
||||
auto input_buffer = ctx.BufferDescriptorA()[0];
|
||||
auto output_buffer = ctx.BufferDescriptorB()[0];
|
||||
std::vector<u8> input(input_buffer.Size());
|
||||
std::vector<u8> output(output_buffer.Size());
|
||||
Memory::ReadBlock(input_buffer.Address(), input.data(), input_buffer.Size());
|
||||
rb.Push(nvdrv->Ioctl(fd, command, input, output));
|
||||
Memory::WriteBlock(output_buffer.Address(), output.data(), output_buffer.Size());
|
||||
} else {
|
||||
auto input_buffer = ctx.BufferDescriptorX()[0];
|
||||
auto output_buffer = ctx.BufferDescriptorC()[0];
|
||||
std::vector<u8> input(input_buffer.size);
|
||||
std::vector<u8> output(output_buffer.size);
|
||||
Memory::ReadBlock(input_buffer.Address(), input.data(), input_buffer.size);
|
||||
rb.Push(nvdrv->Ioctl(fd, command, input, output));
|
||||
Memory::WriteBlock(output_buffer.Address(), output.data(), output_buffer.size);
|
||||
}
|
||||
}
|
||||
|
||||
void NVDRV::Close(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_NVDRV, "(STUBBED) called");
|
||||
LOG_DEBUG(Service_NVDRV, "called");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
u32 fd = rp.Pop<u32>();
|
||||
@@ -67,16 +72,34 @@ void NVDRV::Initialize(Kernel::HLERequestContext& ctx) {
|
||||
rb.Push<u32>(0);
|
||||
}
|
||||
|
||||
void NVDRV::QueryEvent(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
u32 fd = rp.Pop<u32>();
|
||||
u32 event_id = rp.Pop<u32>();
|
||||
LOG_WARNING(Service_NVDRV, "(STUBBED) called, fd=%x, event_id=%x", fd, event_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushCopyObjects(query_event);
|
||||
rb.Push<u32>(0);
|
||||
}
|
||||
|
||||
void NVDRV::SetClientPID(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
pid = rp.Pop<u64>();
|
||||
|
||||
LOG_INFO(Service_NVDRV, "called, pid=0x%lx", pid);
|
||||
LOG_WARNING(Service_NVDRV, "(STUBBED) called, pid=0x%lx", pid);
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.Push<u32>(0);
|
||||
}
|
||||
|
||||
void NVDRV::FinishInitialize(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_NVDRV, "(STUBBED) called");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
NVDRV::NVDRV(std::shared_ptr<Module> nvdrv, const char* name)
|
||||
: ServiceFramework(name), nvdrv(std::move(nvdrv)) {
|
||||
static const FunctionInfo functions[] = {
|
||||
@@ -84,9 +107,13 @@ NVDRV::NVDRV(std::shared_ptr<Module> nvdrv, const char* name)
|
||||
{1, &NVDRV::Ioctl, "Ioctl"},
|
||||
{2, &NVDRV::Close, "Close"},
|
||||
{3, &NVDRV::Initialize, "Initialize"},
|
||||
{4, &NVDRV::QueryEvent, "QueryEvent"},
|
||||
{8, &NVDRV::SetClientPID, "SetClientPID"},
|
||||
{13, &NVDRV::FinishInitialize, "FinishInitialize"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
|
||||
query_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "NVDRV::query_event");
|
||||
}
|
||||
|
||||
} // namespace Nvidia
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "core/hle/kernel/event.h"
|
||||
#include "core/hle/service/nvdrv/nvdrv.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
@@ -22,11 +23,15 @@ private:
|
||||
void Ioctl(Kernel::HLERequestContext& ctx);
|
||||
void Close(Kernel::HLERequestContext& ctx);
|
||||
void Initialize(Kernel::HLERequestContext& ctx);
|
||||
void QueryEvent(Kernel::HLERequestContext& ctx);
|
||||
void SetClientPID(Kernel::HLERequestContext& ctx);
|
||||
void FinishInitialize(Kernel::HLERequestContext& ctx);
|
||||
|
||||
std::shared_ptr<Module> nvdrv;
|
||||
|
||||
u64 pid{};
|
||||
|
||||
Kernel::SharedPtr<Kernel::Event> query_event;
|
||||
};
|
||||
|
||||
} // namespace Nvidia
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "core/hle/service/nvdrv/devices/nvdisp_disp0.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvhost_as_gpu.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvhost_ctrl.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvhost_gpu.h"
|
||||
#include "core/hle/service/nvdrv/devices/nvmap.h"
|
||||
#include "core/hle/service/nvdrv/interface.h"
|
||||
#include "core/hle/service/nvdrv/nvdrv.h"
|
||||
@@ -21,13 +23,17 @@ void InstallInterfaces(SM::ServiceManager& service_manager) {
|
||||
auto module_ = std::make_shared<Module>();
|
||||
std::make_shared<NVDRV>(module_, "nvdrv")->InstallAsService(service_manager);
|
||||
std::make_shared<NVDRV>(module_, "nvdrv:a")->InstallAsService(service_manager);
|
||||
std::make_shared<NVDRV>(module_, "nvdrv:s")->InstallAsService(service_manager);
|
||||
std::make_shared<NVDRV>(module_, "nvdrv:t")->InstallAsService(service_manager);
|
||||
std::make_shared<NVMEMP>()->InstallAsService(service_manager);
|
||||
nvdrv = module_;
|
||||
}
|
||||
|
||||
Module::Module() {
|
||||
auto nvmap_dev = std::make_shared<Devices::nvmap>();
|
||||
devices["/dev/nvhost-as-gpu"] = std::make_shared<Devices::nvhost_as_gpu>();
|
||||
devices["/dev/nvhost-as-gpu"] = std::make_shared<Devices::nvhost_as_gpu>(nvmap_dev);
|
||||
devices["/dev/nvhost-gpu"] = std::make_shared<Devices::nvhost_gpu>(nvmap_dev);
|
||||
devices["/dev/nvhost-ctrl-gpu"] = std::make_shared<Devices::nvhost_ctrl_gpu>();
|
||||
devices["/dev/nvmap"] = nvmap_dev;
|
||||
devices["/dev/nvdisp_disp0"] = std::make_shared<Devices::nvdisp_disp0>(nvmap_dev);
|
||||
devices["/dev/nvhost-ctrl"] = std::make_shared<Devices::nvhost_ctrl>();
|
||||
@@ -45,12 +51,12 @@ u32 Module::Open(std::string device_name) {
|
||||
return fd;
|
||||
}
|
||||
|
||||
u32 Module::Ioctl(u32 fd, u32 command, const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
u32 Module::Ioctl(u32 fd, u32_le command, const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
auto itr = open_files.find(fd);
|
||||
ASSERT_MSG(itr != open_files.end(), "Tried to talk to an invalid device");
|
||||
|
||||
auto device = itr->second;
|
||||
return device->ioctl(command, input, output);
|
||||
return device->ioctl({command}, input, output);
|
||||
}
|
||||
|
||||
ResultCode Module::Close(u32 fd) {
|
||||
|
||||
@@ -40,7 +40,11 @@ u32 BufferQueue::DequeueBuffer(u32 pixel_format, u32 width, u32 height) {
|
||||
return igbp_buffer.format == pixel_format && igbp_buffer.width == width &&
|
||||
igbp_buffer.height == height;
|
||||
});
|
||||
ASSERT(itr != queue.end());
|
||||
if (itr == queue.end()) {
|
||||
LOG_CRITICAL(Service_NVDRV, "no free buffers for pixel_format=%d, width=%d, height=%d",
|
||||
pixel_format, width, height);
|
||||
itr = queue.begin();
|
||||
}
|
||||
|
||||
itr->status = Buffer::Status::Dequeued;
|
||||
return itr->slot;
|
||||
@@ -54,12 +58,13 @@ const IGBPBuffer& BufferQueue::RequestBuffer(u32 slot) const {
|
||||
return itr->igbp_buffer;
|
||||
}
|
||||
|
||||
void BufferQueue::QueueBuffer(u32 slot) {
|
||||
void BufferQueue::QueueBuffer(u32 slot, BufferTransformFlags transform) {
|
||||
auto itr = std::find_if(queue.begin(), queue.end(),
|
||||
[&](const Buffer& buffer) { return buffer.slot == slot; });
|
||||
ASSERT(itr != queue.end());
|
||||
ASSERT(itr->status == Buffer::Status::Dequeued);
|
||||
itr->status = Buffer::Status::Queued;
|
||||
itr->transform = transform;
|
||||
}
|
||||
|
||||
boost::optional<const BufferQueue::Buffer&> BufferQueue::AcquireBuffer() {
|
||||
|
||||
@@ -46,18 +46,32 @@ public:
|
||||
BufferQueue(u32 id, u64 layer_id);
|
||||
~BufferQueue() = default;
|
||||
|
||||
enum class BufferTransformFlags : u32 {
|
||||
/// Flip source image horizontally (around the vertical axis)
|
||||
FlipH = 0x01,
|
||||
/// Flip source image vertically (around the horizontal axis)
|
||||
FlipV = 0x02,
|
||||
/// Rotate source image 90 degrees clockwise
|
||||
Rotate90 = 0x04,
|
||||
/// Rotate source image 180 degrees
|
||||
Roate180 = 0x03,
|
||||
/// Rotate source image 270 degrees clockwise
|
||||
Roate270 = 0x07,
|
||||
};
|
||||
|
||||
struct Buffer {
|
||||
enum class Status { Free = 0, Queued = 1, Dequeued = 2, Acquired = 3 };
|
||||
|
||||
u32 slot;
|
||||
Status status = Status::Free;
|
||||
IGBPBuffer igbp_buffer;
|
||||
BufferTransformFlags transform;
|
||||
};
|
||||
|
||||
void SetPreallocatedBuffer(u32 slot, IGBPBuffer& buffer);
|
||||
u32 DequeueBuffer(u32 pixel_format, u32 width, u32 height);
|
||||
const IGBPBuffer& RequestBuffer(u32 slot) const;
|
||||
void QueueBuffer(u32 slot);
|
||||
void QueueBuffer(u32 slot, BufferTransformFlags transform);
|
||||
boost::optional<const Buffer&> AcquireBuffer();
|
||||
void ReleaseBuffer(u32 slot);
|
||||
u32 Query(QueryType type);
|
||||
|
||||
@@ -145,7 +145,7 @@ void NVFlinger::Compose() {
|
||||
ASSERT(nvdisp);
|
||||
|
||||
nvdisp->flip(igbp_buffer.gpu_buffer_id, igbp_buffer.offset, igbp_buffer.format,
|
||||
igbp_buffer.width, igbp_buffer.height, igbp_buffer.stride);
|
||||
igbp_buffer.width, igbp_buffer.height, igbp_buffer.stride, buffer->transform);
|
||||
|
||||
buffer_queue->ReleaseBuffer(buffer->slot);
|
||||
}
|
||||
|
||||
@@ -103,6 +103,8 @@ void SM::GetService(Kernel::HLERequestContext& ctx) {
|
||||
rb.Push(client_port.Code());
|
||||
LOG_ERROR(Service_SM, "called service=%s -> error 0x%08X", name.c_str(),
|
||||
client_port.Code().raw);
|
||||
if (name.length() == 0)
|
||||
return; // LibNX Fix
|
||||
UNIMPLEMENTED();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -68,8 +68,15 @@ public:
|
||||
ITimeZoneService() : ServiceFramework("ITimeZoneService") {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &ITimeZoneService::GetDeviceLocationName, "GetDeviceLocationName"},
|
||||
{1, nullptr, "SetDeviceLocationName"},
|
||||
{2, &ITimeZoneService::GetTotalLocationNameCount, "GetTotalLocationNameCount"},
|
||||
{3, nullptr, "LoadLocationNameList"},
|
||||
{4, &ITimeZoneService::LoadTimeZoneRule, "LoadTimeZoneRule"},
|
||||
{5, nullptr, "GetTimeZoneRuleVersion"},
|
||||
{100, nullptr, "ToCalendarTime"},
|
||||
{101, &ITimeZoneService::ToCalendarTimeWithMyRule, "ToCalendarTimeWithMyRule"},
|
||||
{200, nullptr, "ToPosixTime"},
|
||||
{201, nullptr, "ToPosixTimeWithMyRule"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
@@ -90,6 +97,12 @@ private:
|
||||
rb.Push<u32>(0);
|
||||
}
|
||||
|
||||
void LoadTimeZoneRule(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_Time, "(STUBBED) called");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
void ToCalendarTimeWithMyRule(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
u64 posix_time = rp.Pop<u64>();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <array>
|
||||
#include "common/alignment.h"
|
||||
#include "common/scope_exit.h"
|
||||
#include "core/core_timing.h"
|
||||
@@ -19,6 +19,15 @@
|
||||
namespace Service {
|
||||
namespace VI {
|
||||
|
||||
struct DisplayInfo {
|
||||
char display_name[0x40]{"Default"};
|
||||
u64 unknown_1{1};
|
||||
u64 unknown_2{1};
|
||||
u64 width{1920};
|
||||
u64 height{1080};
|
||||
};
|
||||
static_assert(sizeof(DisplayInfo) == 0x60, "DisplayInfo has wrong size");
|
||||
|
||||
class Parcel {
|
||||
public:
|
||||
// This default size was chosen arbitrarily.
|
||||
@@ -92,8 +101,10 @@ public:
|
||||
SerializeData();
|
||||
|
||||
Header header{};
|
||||
header.data_offset = sizeof(Header);
|
||||
header.data_size = static_cast<u32_le>(write_index - sizeof(Header));
|
||||
header.data_offset = sizeof(Header);
|
||||
header.objects_size = 4;
|
||||
header.objects_offset = sizeof(Header) + header.data_size;
|
||||
std::memcpy(buffer.data(), &header, sizeof(Header));
|
||||
|
||||
return buffer;
|
||||
@@ -133,11 +144,11 @@ protected:
|
||||
private:
|
||||
struct Data {
|
||||
u32_le magic = 2;
|
||||
u32_le process_id;
|
||||
u32_le process_id = 1;
|
||||
u32_le id;
|
||||
INSERT_PADDING_BYTES(0xC);
|
||||
INSERT_PADDING_WORDS(3);
|
||||
std::array<u8, 8> dispdrv = {'d', 'i', 's', 'p', 'd', 'r', 'v', '\0'};
|
||||
INSERT_PADDING_BYTES(8);
|
||||
INSERT_PADDING_WORDS(2);
|
||||
};
|
||||
static_assert(sizeof(Data) == 0x28, "ParcelData has wrong size");
|
||||
|
||||
@@ -202,7 +213,6 @@ public:
|
||||
void DeserializeData() override {
|
||||
std::u16string token = ReadInterfaceToken();
|
||||
data = Read<Data>();
|
||||
ASSERT(data.graphic_buffer_length == sizeof(NVFlinger::IGBPBuffer));
|
||||
buffer = Read<NVFlinger::IGBPBuffer>();
|
||||
}
|
||||
|
||||
@@ -252,6 +262,11 @@ public:
|
||||
Data data;
|
||||
};
|
||||
|
||||
// TODO(bunnei): Remove this. When set to 1, games will think a fence is valid and boot further.
|
||||
// This will break libnx and potentially other apps that more stringently check this. This is here
|
||||
// purely as a convenience, and should go away once we implement fences.
|
||||
static constexpr u32 FENCE_HACK = 0;
|
||||
|
||||
class IGBPDequeueBufferResponseParcel : public Parcel {
|
||||
public:
|
||||
explicit IGBPDequeueBufferResponseParcel(u32 slot) : Parcel(), slot(slot) {}
|
||||
@@ -259,11 +274,20 @@ public:
|
||||
|
||||
protected:
|
||||
void SerializeData() override {
|
||||
Write(slot);
|
||||
// TODO(Subv): Find out how this Fence is used.
|
||||
std::array<u32_le, 11> fence = {};
|
||||
Write(fence);
|
||||
Write<u32_le>(0);
|
||||
// TODO(bunnei): Find out what this all means. Writing anything non-zero here breaks libnx.
|
||||
Write<u32>(0);
|
||||
Write<u32>(FENCE_HACK);
|
||||
Write<u32>(0);
|
||||
Write<u32>(0);
|
||||
Write<u32>(0);
|
||||
Write<u32>(0);
|
||||
Write<u32>(0);
|
||||
Write<u32>(0);
|
||||
Write<u32>(0);
|
||||
Write<u32>(0);
|
||||
Write<u32>(0);
|
||||
Write<u32>(0);
|
||||
Write<u32>(0);
|
||||
}
|
||||
|
||||
u32_le slot;
|
||||
@@ -292,14 +316,11 @@ public:
|
||||
|
||||
protected:
|
||||
void SerializeData() override {
|
||||
// TODO(Subv): Find out what this all means
|
||||
Write<u32_le>(1);
|
||||
|
||||
Write<u32_le>(sizeof(NVFlinger::IGBPBuffer));
|
||||
Write<u32_le>(0); // Unknown
|
||||
|
||||
// TODO(bunnei): Find out what this all means. Writing anything non-zero here breaks libnx.
|
||||
Write<u32_le>(0);
|
||||
Write<u32_le>(FENCE_HACK);
|
||||
Write<u32_le>(0);
|
||||
Write(buffer);
|
||||
|
||||
Write<u32_le>(0);
|
||||
}
|
||||
|
||||
@@ -318,13 +339,29 @@ public:
|
||||
data = Read<Data>();
|
||||
}
|
||||
|
||||
struct Fence {
|
||||
u32_le id;
|
||||
u32_le value;
|
||||
};
|
||||
static_assert(sizeof(Fence) == 8, "Fence has wrong size");
|
||||
|
||||
struct Data {
|
||||
u32_le slot;
|
||||
INSERT_PADDING_WORDS(2);
|
||||
INSERT_PADDING_WORDS(3);
|
||||
u32_le timestamp;
|
||||
INSERT_PADDING_WORDS(20);
|
||||
s32_le is_auto_timestamp;
|
||||
s32_le crop_left;
|
||||
s32_le crop_top;
|
||||
s32_le crop_right;
|
||||
s32_le crop_bottom;
|
||||
s32_le scaling_mode;
|
||||
NVFlinger::BufferQueue::BufferTransformFlags transform;
|
||||
u32_le sticky_transform;
|
||||
INSERT_PADDING_WORDS(2);
|
||||
u32_le fence_is_valid;
|
||||
std::array<Fence, 2> fences;
|
||||
};
|
||||
static_assert(sizeof(Data) == 96, "ParcelData has wrong size");
|
||||
static_assert(sizeof(Data) == 80, "ParcelData has wrong size");
|
||||
|
||||
Data data;
|
||||
};
|
||||
@@ -392,7 +429,7 @@ public:
|
||||
{0, &IHOSBinderDriver::TransactParcel, "TransactParcel"},
|
||||
{1, &IHOSBinderDriver::AdjustRefcount, "AdjustRefcount"},
|
||||
{2, &IHOSBinderDriver::GetNativeHandle, "GetNativeHandle"},
|
||||
{3, nullptr, "TransactParcelAuto"},
|
||||
{3, &IHOSBinderDriver::TransactParcelAuto, "TransactParcelAuto"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
@@ -416,35 +453,23 @@ private:
|
||||
SetPreallocatedBuffer = 14
|
||||
};
|
||||
|
||||
void TransactParcel(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
u32 id = rp.Pop<u32>();
|
||||
auto transaction = static_cast<TransactionId>(rp.Pop<u32>());
|
||||
u32 flags = rp.Pop<u32>();
|
||||
|
||||
auto& input_buffer = ctx.BufferDescriptorA()[0];
|
||||
std::vector<u8> input_data(input_buffer.Size());
|
||||
Memory::ReadBlock(input_buffer.Address(), input_data.data(), input_buffer.Size());
|
||||
|
||||
auto& output_buffer = ctx.BufferDescriptorB()[0];
|
||||
|
||||
void TransactParcel(u32 id, TransactionId transaction, const std::vector<u8>& input_data,
|
||||
VAddr output_addr, u64 output_size) {
|
||||
auto buffer_queue = nv_flinger->GetBufferQueue(id);
|
||||
LOG_WARNING(Service_VI, "(STUBBED) called, transaction=%x", transaction);
|
||||
|
||||
if (transaction == TransactionId::Connect) {
|
||||
IGBPConnectRequestParcel request{input_data};
|
||||
IGBPConnectResponseParcel response{1280, 720};
|
||||
auto response_buffer = response.Serialize();
|
||||
Memory::WriteBlock(output_buffer.Address(), response_buffer.data(),
|
||||
output_buffer.Size());
|
||||
std::vector<u8> response_buffer = response.Serialize();
|
||||
Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size());
|
||||
} else if (transaction == TransactionId::SetPreallocatedBuffer) {
|
||||
IGBPSetPreallocatedBufferRequestParcel request{input_data};
|
||||
|
||||
buffer_queue->SetPreallocatedBuffer(request.data.slot, request.buffer);
|
||||
|
||||
IGBPSetPreallocatedBufferResponseParcel response{};
|
||||
auto response_buffer = response.Serialize();
|
||||
Memory::WriteBlock(output_buffer.Address(), response_buffer.data(),
|
||||
output_buffer.Size());
|
||||
std::vector<u8> response_buffer = response.Serialize();
|
||||
Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size());
|
||||
} else if (transaction == TransactionId::DequeueBuffer) {
|
||||
IGBPDequeueBufferRequestParcel request{input_data};
|
||||
|
||||
@@ -452,27 +477,24 @@ private:
|
||||
request.data.height);
|
||||
|
||||
IGBPDequeueBufferResponseParcel response{slot};
|
||||
auto response_buffer = response.Serialize();
|
||||
Memory::WriteBlock(output_buffer.Address(), response_buffer.data(),
|
||||
output_buffer.Size());
|
||||
std::vector<u8> response_buffer = response.Serialize();
|
||||
Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size());
|
||||
} else if (transaction == TransactionId::RequestBuffer) {
|
||||
IGBPRequestBufferRequestParcel request{input_data};
|
||||
|
||||
auto& buffer = buffer_queue->RequestBuffer(request.slot);
|
||||
|
||||
IGBPRequestBufferResponseParcel response{buffer};
|
||||
auto response_buffer = response.Serialize();
|
||||
Memory::WriteBlock(output_buffer.Address(), response_buffer.data(),
|
||||
output_buffer.Size());
|
||||
std::vector<u8> response_buffer = response.Serialize();
|
||||
Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size());
|
||||
} else if (transaction == TransactionId::QueueBuffer) {
|
||||
IGBPQueueBufferRequestParcel request{input_data};
|
||||
|
||||
buffer_queue->QueueBuffer(request.data.slot);
|
||||
buffer_queue->QueueBuffer(request.data.slot, request.data.transform);
|
||||
|
||||
IGBPQueueBufferResponseParcel response{1280, 720};
|
||||
auto response_buffer = response.Serialize();
|
||||
Memory::WriteBlock(output_buffer.Address(), response_buffer.data(),
|
||||
output_buffer.Size());
|
||||
std::vector<u8> response_buffer = response.Serialize();
|
||||
Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size());
|
||||
} else if (transaction == TransactionId::Query) {
|
||||
IGBPQueryRequestParcel request{input_data};
|
||||
|
||||
@@ -480,12 +502,46 @@ private:
|
||||
buffer_queue->Query(static_cast<NVFlinger::BufferQueue::QueryType>(request.type));
|
||||
|
||||
IGBPQueryResponseParcel response{value};
|
||||
auto response_buffer = response.Serialize();
|
||||
Memory::WriteBlock(output_buffer.Address(), response_buffer.data(),
|
||||
output_buffer.Size());
|
||||
std::vector<u8> response_buffer = response.Serialize();
|
||||
Memory::WriteBlock(output_addr, response_buffer.data(), response_buffer.size());
|
||||
} else if (transaction == TransactionId::CancelBuffer) {
|
||||
LOG_WARNING(Service_VI, "(STUBBED) called, transaction=CancelBuffer");
|
||||
} else {
|
||||
ASSERT_MSG(false, "Unimplemented");
|
||||
}
|
||||
}
|
||||
|
||||
void TransactParcel(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
u32 id = rp.Pop<u32>();
|
||||
auto transaction = static_cast<TransactionId>(rp.Pop<u32>());
|
||||
u32 flags = rp.Pop<u32>();
|
||||
LOG_DEBUG(Service_VI, "called, transaction=%x", transaction);
|
||||
|
||||
auto& input_buffer = ctx.BufferDescriptorA()[0];
|
||||
auto& output_buffer = ctx.BufferDescriptorB()[0];
|
||||
std::vector<u8> input_data(input_buffer.Size());
|
||||
Memory::ReadBlock(input_buffer.Address(), input_data.data(), input_buffer.Size());
|
||||
|
||||
TransactParcel(id, transaction, input_data, output_buffer.Address(), output_buffer.Size());
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
void TransactParcelAuto(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
u32 id = rp.Pop<u32>();
|
||||
auto transaction = static_cast<TransactionId>(rp.Pop<u32>());
|
||||
u32 flags = rp.Pop<u32>();
|
||||
LOG_DEBUG(Service_VI, "called, transaction=%x", transaction);
|
||||
|
||||
auto& input_buffer = ctx.BufferDescriptorX()[0];
|
||||
auto& output_buffer = ctx.BufferDescriptorC()[0];
|
||||
std::vector<u8> input_data(input_buffer.size);
|
||||
Memory::ReadBlock(input_buffer.Address(), input_data.data(), input_buffer.size);
|
||||
|
||||
TransactParcel(id, transaction, input_data, output_buffer.Address(), output_buffer.Size());
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
@@ -518,7 +574,7 @@ private:
|
||||
}
|
||||
|
||||
std::shared_ptr<NVFlinger::NVFlinger> nv_flinger;
|
||||
};
|
||||
}; // namespace VI
|
||||
|
||||
class ISystemDisplayService final : public ServiceFramework<ISystemDisplayService> {
|
||||
public:
|
||||
@@ -648,12 +704,12 @@ void IApplicationDisplayService::CloseDisplay(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
u64 display_id = rp.Pop<u64>();
|
||||
|
||||
IPC::ResponseBuilder rb = rp.MakeBuilder(4, 0, 0);
|
||||
IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0);
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
void IApplicationDisplayService::OpenLayer(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_VI, "(STUBBED) called");
|
||||
LOG_DEBUG(Service_VI, "called");
|
||||
IPC::RequestParser rp{ctx};
|
||||
auto name_buf = rp.PopRaw<std::array<u8, 0x40>>();
|
||||
auto end = std::find(name_buf.begin(), name_buf.end(), '\0');
|
||||
@@ -678,7 +734,7 @@ void IApplicationDisplayService::OpenLayer(Kernel::HLERequestContext& ctx) {
|
||||
}
|
||||
|
||||
void IApplicationDisplayService::CreateStrayLayer(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service, "(STUBBED) called");
|
||||
LOG_DEBUG(Service_VI, "called");
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
u32 flags = rp.Pop<u32>();
|
||||
@@ -722,6 +778,17 @@ void IApplicationDisplayService::SetLayerScalingMode(Kernel::HLERequestContext&
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
void IApplicationDisplayService::ListDisplays(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
DisplayInfo display_info;
|
||||
auto& buffer = ctx.BufferDescriptorB()[0];
|
||||
Memory::WriteBlock(buffer.Address(), &display_info, sizeof(DisplayInfo));
|
||||
IPC::ResponseBuilder rb = rp.MakeBuilder(4, 0, 0);
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.Push<u64>(1);
|
||||
LOG_WARNING(Service_VI, "(STUBBED) called");
|
||||
}
|
||||
|
||||
void IApplicationDisplayService::GetDisplayVsyncEvent(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_VI, "(STUBBED) called");
|
||||
IPC::RequestParser rp{ctx};
|
||||
@@ -743,7 +810,7 @@ IApplicationDisplayService::IApplicationDisplayService(
|
||||
{102, &IApplicationDisplayService::GetManagerDisplayService, "GetManagerDisplayService"},
|
||||
{103, &IApplicationDisplayService::GetIndirectDisplayTransactionService,
|
||||
"GetIndirectDisplayTransactionService"},
|
||||
{1000, nullptr, "ListDisplays"},
|
||||
{1000, &IApplicationDisplayService::ListDisplays, "ListDisplays"},
|
||||
{1010, &IApplicationDisplayService::OpenDisplay, "OpenDisplay"},
|
||||
{1020, &IApplicationDisplayService::CloseDisplay, "CloseDisplay"},
|
||||
{2101, &IApplicationDisplayService::SetLayerScalingMode, "SetLayerScalingMode"},
|
||||
|
||||
@@ -30,6 +30,7 @@ private:
|
||||
void OpenDisplay(Kernel::HLERequestContext& ctx);
|
||||
void CloseDisplay(Kernel::HLERequestContext& ctx);
|
||||
void SetLayerScalingMode(Kernel::HLERequestContext& ctx);
|
||||
void ListDisplays(Kernel::HLERequestContext& ctx);
|
||||
void OpenLayer(Kernel::HLERequestContext& ctx);
|
||||
void CreateStrayLayer(Kernel::HLERequestContext& ctx);
|
||||
void DestroyStrayLayer(Kernel::HLERequestContext& ctx);
|
||||
|
||||
@@ -29,7 +29,7 @@ static std::string FindRomFS(const std::string& directory) {
|
||||
|
||||
// Verify extension
|
||||
const std::string extension = physical_name.substr(physical_name.find_last_of(".") + 1);
|
||||
if (Common::ToLower(extension) != "istorage") {
|
||||
if (Common::ToLower(extension) != "romfs") {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ static std::string FindRomFS(const std::string& directory) {
|
||||
return false;
|
||||
};
|
||||
|
||||
// Search the specified directory recursively, looking for the first .istorage file, which will
|
||||
// Search the specified directory recursively, looking for the first .romfs file, which will
|
||||
// be used for the RomFS
|
||||
FileUtil::ForeachDirectoryEntry(nullptr, directory, callback);
|
||||
|
||||
@@ -128,10 +128,10 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(
|
||||
Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
|
||||
process->Run(Memory::PROCESS_IMAGE_VADDR, 48, Kernel::DEFAULT_STACK_SIZE);
|
||||
|
||||
// Find the RomFS by searching for a ".istorage" file in this directory
|
||||
// Find the RomFS by searching for a ".romfs" file in this directory
|
||||
filepath_romfs = FindRomFS(directory);
|
||||
|
||||
// Register the RomFS if a ".istorage" file was found
|
||||
// Register the RomFS if a ".romfs" file was found
|
||||
if (!filepath_romfs.empty()) {
|
||||
Service::FileSystem::RegisterFileSystem(std::make_unique<FileSys::RomFS_Factory>(*this),
|
||||
Service::FileSystem::Type::RomFS);
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Loader {
|
||||
* This class loads a "deconstructed ROM directory", which are the typical format we see for Switch
|
||||
* game dumps. The path should be a "main" NSO, which must be in a directory that contains the other
|
||||
* standard ExeFS NSOs (e.g. rtld, sdk, etc.). It will automatically find and load these.
|
||||
* Furthermore, it will look for the first .istorage file (optionally) and use this for the RomFS.
|
||||
* Furthermore, it will look for the first .romfs file (optionally) and use this for the RomFS.
|
||||
*/
|
||||
class AppLoader_DeconstructedRomDirectory final : public AppLoader {
|
||||
public:
|
||||
|
||||
@@ -25,10 +25,11 @@ namespace Memory {
|
||||
* Page size used by the ARM architecture. This is the smallest granularity with which memory can
|
||||
* be mapped.
|
||||
*/
|
||||
const int PAGE_BITS = 12;
|
||||
const u64 PAGE_SIZE = 1 << PAGE_BITS;
|
||||
const u64 PAGE_MASK = PAGE_SIZE - 1;
|
||||
const size_t PAGE_TABLE_NUM_ENTRIES = 1ULL << (36 - PAGE_BITS);
|
||||
constexpr size_t PAGE_BITS = 12;
|
||||
constexpr u64 PAGE_SIZE = 1 << PAGE_BITS;
|
||||
constexpr u64 PAGE_MASK = PAGE_SIZE - 1;
|
||||
constexpr size_t ADDRESS_SPACE_BITS = 36;
|
||||
constexpr size_t PAGE_TABLE_NUM_ENTRIES = 1ULL << (ADDRESS_SPACE_BITS - PAGE_BITS);
|
||||
|
||||
enum class PageType : u8 {
|
||||
/// Page is unmapped and should cause an access error.
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
add_library(video_core STATIC
|
||||
command_processor.cpp
|
||||
command_processor.h
|
||||
engines/fermi_2d.cpp
|
||||
engines/fermi_2d.h
|
||||
engines/maxwell_3d.cpp
|
||||
engines/maxwell_3d.h
|
||||
engines/maxwell_compute.cpp
|
||||
engines/maxwell_compute.h
|
||||
gpu.h
|
||||
memory_manager.cpp
|
||||
memory_manager.h
|
||||
renderer_base.cpp
|
||||
renderer_base.h
|
||||
renderer_opengl/gl_resource_manager.h
|
||||
|
||||
119
src/video_core/command_processor.cpp
Normal file
119
src/video_core/command_processor.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
// Copyright 2018 yuzu Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/microprofile.h"
|
||||
#include "common/vector_math.h"
|
||||
#include "core/memory.h"
|
||||
#include "core/tracer/recorder.h"
|
||||
#include "video_core/command_processor.h"
|
||||
#include "video_core/engines/fermi_2d.h"
|
||||
#include "video_core/engines/maxwell_3d.h"
|
||||
#include "video_core/engines/maxwell_compute.h"
|
||||
#include "video_core/gpu.h"
|
||||
#include "video_core/renderer_base.h"
|
||||
#include "video_core/video_core.h"
|
||||
|
||||
namespace Tegra {
|
||||
|
||||
enum class BufferMethods {
|
||||
BindObject = 0,
|
||||
CountBufferMethods = 0x100,
|
||||
};
|
||||
|
||||
void GPU::WriteReg(u32 method, u32 subchannel, u32 value) {
|
||||
LOG_WARNING(HW_GPU, "Processing method %08X on subchannel %u value %08X", method, subchannel,
|
||||
value);
|
||||
|
||||
if (method == static_cast<u32>(BufferMethods::BindObject)) {
|
||||
// Bind the current subchannel to the desired engine id.
|
||||
LOG_DEBUG(HW_GPU, "Binding subchannel %u to engine %u", subchannel, value);
|
||||
ASSERT(bound_engines.find(subchannel) == bound_engines.end());
|
||||
bound_engines[subchannel] = static_cast<EngineID>(value);
|
||||
return;
|
||||
}
|
||||
|
||||
if (method < static_cast<u32>(BufferMethods::CountBufferMethods)) {
|
||||
// TODO(Subv): Research and implement these methods.
|
||||
LOG_ERROR(HW_GPU, "Special buffer methods other than Bind are not implemented");
|
||||
return;
|
||||
}
|
||||
|
||||
ASSERT(bound_engines.find(subchannel) != bound_engines.end());
|
||||
|
||||
const EngineID engine = bound_engines[subchannel];
|
||||
|
||||
switch (engine) {
|
||||
case EngineID::FERMI_TWOD_A:
|
||||
fermi_2d->WriteReg(method, value);
|
||||
break;
|
||||
case EngineID::MAXWELL_B:
|
||||
maxwell_3d->WriteReg(method, value);
|
||||
break;
|
||||
case EngineID::MAXWELL_COMPUTE_B:
|
||||
maxwell_compute->WriteReg(method, value);
|
||||
break;
|
||||
default:
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
}
|
||||
|
||||
void GPU::ProcessCommandList(GPUVAddr address, u32 size) {
|
||||
// TODO(Subv): PhysicalToVirtualAddress is a misnomer, it converts a GPU VAddr into an
|
||||
// application VAddr.
|
||||
const VAddr head_address = memory_manager->PhysicalToVirtualAddress(address);
|
||||
VAddr current_addr = head_address;
|
||||
while (current_addr < head_address + size * sizeof(CommandHeader)) {
|
||||
const CommandHeader header = {Memory::Read32(current_addr)};
|
||||
current_addr += sizeof(u32);
|
||||
|
||||
switch (header.mode.Value()) {
|
||||
case SubmissionMode::IncreasingOld:
|
||||
case SubmissionMode::Increasing: {
|
||||
// Increase the method value with each argument.
|
||||
for (unsigned i = 0; i < header.arg_count; ++i) {
|
||||
WriteReg(header.method + i, header.subchannel, Memory::Read32(current_addr));
|
||||
current_addr += sizeof(u32);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SubmissionMode::NonIncreasingOld:
|
||||
case SubmissionMode::NonIncreasing: {
|
||||
// Use the same method value for all arguments.
|
||||
for (unsigned i = 0; i < header.arg_count; ++i) {
|
||||
WriteReg(header.method, header.subchannel, Memory::Read32(current_addr));
|
||||
current_addr += sizeof(u32);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SubmissionMode::IncreaseOnce: {
|
||||
ASSERT(header.arg_count.Value() >= 1);
|
||||
// Use the original method for the first argument and then the next method for all other
|
||||
// arguments.
|
||||
WriteReg(header.method, header.subchannel, Memory::Read32(current_addr));
|
||||
current_addr += sizeof(u32);
|
||||
// Use the same method value for all arguments.
|
||||
for (unsigned i = 1; i < header.arg_count; ++i) {
|
||||
WriteReg(header.method + 1, header.subchannel, Memory::Read32(current_addr));
|
||||
current_addr += sizeof(u32);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SubmissionMode::Inline: {
|
||||
// The register value is stored in the bits 16-28 as an immediate
|
||||
WriteReg(header.method, header.subchannel, header.inline_data);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Tegra
|
||||
39
src/video_core/command_processor.h
Normal file
39
src/video_core/command_processor.h
Normal file
@@ -0,0 +1,39 @@
|
||||
// Copyright 2018 yuzu Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace Tegra {
|
||||
|
||||
enum class SubmissionMode : u32 {
|
||||
IncreasingOld = 0,
|
||||
Increasing = 1,
|
||||
NonIncreasingOld = 2,
|
||||
NonIncreasing = 3,
|
||||
Inline = 4,
|
||||
IncreaseOnce = 5
|
||||
};
|
||||
|
||||
union CommandHeader {
|
||||
u32 hex;
|
||||
|
||||
BitField<0, 13, u32> method;
|
||||
BitField<13, 3, u32> subchannel;
|
||||
|
||||
BitField<16, 13, u32> arg_count;
|
||||
BitField<16, 13, u32> inline_data;
|
||||
|
||||
BitField<29, 3, SubmissionMode> mode;
|
||||
};
|
||||
static_assert(std::is_standard_layout<CommandHeader>::value == true,
|
||||
"CommandHeader does not use standard layout");
|
||||
static_assert(sizeof(CommandHeader) == sizeof(u32), "CommandHeader has incorrect size!");
|
||||
|
||||
void ProcessCommandList(VAddr address, u32 size);
|
||||
|
||||
} // namespace Tegra
|
||||
13
src/video_core/engines/fermi_2d.cpp
Normal file
13
src/video_core/engines/fermi_2d.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
// Copyright 2018 yuzu Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "video_core/engines/fermi_2d.h"
|
||||
|
||||
namespace Tegra {
|
||||
namespace Engines {
|
||||
|
||||
void Fermi2D::WriteReg(u32 method, u32 value) {}
|
||||
|
||||
} // namespace Engines
|
||||
} // namespace Tegra
|
||||
22
src/video_core/engines/fermi_2d.h
Normal file
22
src/video_core/engines/fermi_2d.h
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright 2018 yuzu Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace Tegra {
|
||||
namespace Engines {
|
||||
|
||||
class Fermi2D final {
|
||||
public:
|
||||
Fermi2D() = default;
|
||||
~Fermi2D() = default;
|
||||
|
||||
/// Write the value to the register identified by method.
|
||||
void WriteReg(u32 method, u32 value);
|
||||
};
|
||||
|
||||
} // namespace Engines
|
||||
} // namespace Tegra
|
||||
13
src/video_core/engines/maxwell_3d.cpp
Normal file
13
src/video_core/engines/maxwell_3d.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
// Copyright 2018 yuzu Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "video_core/engines/maxwell_3d.h"
|
||||
|
||||
namespace Tegra {
|
||||
namespace Engines {
|
||||
|
||||
void Maxwell3D::WriteReg(u32 method, u32 value) {}
|
||||
|
||||
} // namespace Engines
|
||||
} // namespace Tegra
|
||||
22
src/video_core/engines/maxwell_3d.h
Normal file
22
src/video_core/engines/maxwell_3d.h
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright 2018 yuzu Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace Tegra {
|
||||
namespace Engines {
|
||||
|
||||
class Maxwell3D final {
|
||||
public:
|
||||
Maxwell3D() = default;
|
||||
~Maxwell3D() = default;
|
||||
|
||||
/// Write the value to the register identified by method.
|
||||
void WriteReg(u32 method, u32 value);
|
||||
};
|
||||
|
||||
} // namespace Engines
|
||||
} // namespace Tegra
|
||||
13
src/video_core/engines/maxwell_compute.cpp
Normal file
13
src/video_core/engines/maxwell_compute.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
// Copyright 2018 yuzu Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "video_core/engines/maxwell_compute.h"
|
||||
|
||||
namespace Tegra {
|
||||
namespace Engines {
|
||||
|
||||
void MaxwellCompute::WriteReg(u32 method, u32 value) {}
|
||||
|
||||
} // namespace Engines
|
||||
} // namespace Tegra
|
||||
22
src/video_core/engines/maxwell_compute.h
Normal file
22
src/video_core/engines/maxwell_compute.h
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright 2018 yuzu Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace Tegra {
|
||||
namespace Engines {
|
||||
|
||||
class MaxwellCompute final {
|
||||
public:
|
||||
MaxwellCompute() = default;
|
||||
~MaxwellCompute() = default;
|
||||
|
||||
/// Write the value to the register identified by method.
|
||||
void WriteReg(u32 method, u32 value);
|
||||
};
|
||||
|
||||
} // namespace Engines
|
||||
} // namespace Tegra
|
||||
55
src/video_core/gpu.h
Normal file
55
src/video_core/gpu.h
Normal file
@@ -0,0 +1,55 @@
|
||||
// Copyright 2018 yuzu Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include "common/common_types.h"
|
||||
#include "video_core/engines/fermi_2d.h"
|
||||
#include "video_core/engines/maxwell_3d.h"
|
||||
#include "video_core/engines/maxwell_compute.h"
|
||||
#include "video_core/memory_manager.h"
|
||||
|
||||
namespace Tegra {
|
||||
|
||||
enum class EngineID {
|
||||
FERMI_TWOD_A = 0x902D, // 2D Engine
|
||||
MAXWELL_B = 0xB197, // 3D Engine
|
||||
MAXWELL_COMPUTE_B = 0xB1C0,
|
||||
KEPLER_INLINE_TO_MEMORY_B = 0xA140,
|
||||
MAXWELL_DMA_COPY_A = 0xB0B5,
|
||||
};
|
||||
|
||||
class GPU final {
|
||||
public:
|
||||
GPU() {
|
||||
memory_manager = std::make_unique<MemoryManager>();
|
||||
maxwell_3d = std::make_unique<Engines::Maxwell3D>();
|
||||
fermi_2d = std::make_unique<Engines::Fermi2D>();
|
||||
maxwell_compute = std::make_unique<Engines::MaxwellCompute>();
|
||||
}
|
||||
~GPU() = default;
|
||||
|
||||
/// Processes a command list stored at the specified address in GPU memory.
|
||||
void ProcessCommandList(GPUVAddr address, u32 size);
|
||||
|
||||
std::unique_ptr<MemoryManager> memory_manager;
|
||||
|
||||
private:
|
||||
/// Writes a single register in the engine bound to the specified subchannel
|
||||
void WriteReg(u32 method, u32 subchannel, u32 value);
|
||||
|
||||
/// Mapping of command subchannels to their bound engine ids.
|
||||
std::unordered_map<u32, EngineID> bound_engines;
|
||||
|
||||
/// 3D engine
|
||||
std::unique_ptr<Engines::Maxwell3D> maxwell_3d;
|
||||
/// 2D engine
|
||||
std::unique_ptr<Engines::Fermi2D> fermi_2d;
|
||||
/// Compute engine
|
||||
std::unique_ptr<Engines::MaxwellCompute> maxwell_compute;
|
||||
};
|
||||
|
||||
} // namespace Tegra
|
||||
110
src/video_core/memory_manager.cpp
Normal file
110
src/video_core/memory_manager.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
// Copyright 2018 yuzu emulator team
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "video_core/memory_manager.h"
|
||||
|
||||
namespace Tegra {
|
||||
|
||||
PAddr MemoryManager::AllocateSpace(u64 size, u64 align) {
|
||||
boost::optional<PAddr> paddr = FindFreeBlock(size, align);
|
||||
ASSERT(paddr);
|
||||
|
||||
for (u64 offset = 0; offset < size; offset += Memory::PAGE_SIZE) {
|
||||
PageSlot(*paddr + offset) = static_cast<u64>(PageStatus::Allocated);
|
||||
}
|
||||
|
||||
return *paddr;
|
||||
}
|
||||
|
||||
PAddr MemoryManager::AllocateSpace(PAddr paddr, u64 size, u64 align) {
|
||||
for (u64 offset = 0; offset < size; offset += Memory::PAGE_SIZE) {
|
||||
if (IsPageMapped(paddr + offset)) {
|
||||
return AllocateSpace(size, align);
|
||||
}
|
||||
}
|
||||
|
||||
for (u64 offset = 0; offset < size; offset += Memory::PAGE_SIZE) {
|
||||
PageSlot(paddr + offset) = static_cast<u64>(PageStatus::Allocated);
|
||||
}
|
||||
|
||||
return paddr;
|
||||
}
|
||||
|
||||
PAddr MemoryManager::MapBufferEx(VAddr vaddr, u64 size) {
|
||||
vaddr &= ~Memory::PAGE_MASK;
|
||||
|
||||
boost::optional<PAddr> paddr = FindFreeBlock(size);
|
||||
ASSERT(paddr);
|
||||
|
||||
for (u64 offset = 0; offset < size; offset += Memory::PAGE_SIZE) {
|
||||
PageSlot(*paddr + offset) = vaddr + offset;
|
||||
}
|
||||
|
||||
return *paddr;
|
||||
}
|
||||
|
||||
PAddr MemoryManager::MapBufferEx(VAddr vaddr, PAddr paddr, u64 size) {
|
||||
vaddr &= ~Memory::PAGE_MASK;
|
||||
paddr &= ~Memory::PAGE_MASK;
|
||||
|
||||
for (u64 offset = 0; offset < size; offset += Memory::PAGE_SIZE) {
|
||||
if (PageSlot(paddr + offset) != static_cast<u64>(PageStatus::Allocated)) {
|
||||
return MapBufferEx(vaddr, size);
|
||||
}
|
||||
}
|
||||
|
||||
for (u64 offset = 0; offset < size; offset += Memory::PAGE_SIZE) {
|
||||
PageSlot(paddr + offset) = vaddr + offset;
|
||||
}
|
||||
|
||||
return paddr;
|
||||
}
|
||||
|
||||
boost::optional<PAddr> MemoryManager::FindFreeBlock(u64 size, u64 align) {
|
||||
PAddr paddr{};
|
||||
u64 free_space{};
|
||||
align = (align + Memory::PAGE_MASK) & ~Memory::PAGE_MASK;
|
||||
|
||||
while (paddr + free_space < MAX_ADDRESS) {
|
||||
if (!IsPageMapped(paddr + free_space)) {
|
||||
free_space += Memory::PAGE_SIZE;
|
||||
if (free_space >= size) {
|
||||
return paddr;
|
||||
}
|
||||
} else {
|
||||
paddr += free_space + Memory::PAGE_SIZE;
|
||||
free_space = 0;
|
||||
const u64 remainder{paddr % align};
|
||||
if (!remainder) {
|
||||
paddr = (paddr - remainder) + align;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
VAddr MemoryManager::PhysicalToVirtualAddress(PAddr paddr) {
|
||||
VAddr base_addr = PageSlot(paddr);
|
||||
ASSERT(base_addr != static_cast<u64>(PageStatus::Unmapped));
|
||||
return base_addr + (paddr & Memory::PAGE_MASK);
|
||||
}
|
||||
|
||||
bool MemoryManager::IsPageMapped(PAddr paddr) {
|
||||
return PageSlot(paddr) != static_cast<u64>(PageStatus::Unmapped);
|
||||
}
|
||||
|
||||
VAddr& MemoryManager::PageSlot(PAddr paddr) {
|
||||
auto& block = page_table[(paddr >> (Memory::PAGE_BITS + PAGE_TABLE_BITS)) & PAGE_TABLE_MASK];
|
||||
if (!block) {
|
||||
block = std::make_unique<PageBlock>();
|
||||
for (unsigned index = 0; index < PAGE_BLOCK_SIZE; index++) {
|
||||
(*block)[index] = static_cast<u64>(PageStatus::Unmapped);
|
||||
}
|
||||
}
|
||||
return (*block)[(paddr >> Memory::PAGE_BITS) & PAGE_BLOCK_MASK];
|
||||
}
|
||||
|
||||
} // namespace Tegra
|
||||
49
src/video_core/memory_manager.h
Normal file
49
src/video_core/memory_manager.h
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright 2018 yuzu emulator team
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include "common/common_types.h"
|
||||
#include "core/memory.h"
|
||||
|
||||
namespace Tegra {
|
||||
|
||||
/// Virtual addresses in the GPU's memory map are 64 bit.
|
||||
using GPUVAddr = u64;
|
||||
|
||||
class MemoryManager final {
|
||||
public:
|
||||
MemoryManager() = default;
|
||||
|
||||
PAddr AllocateSpace(u64 size, u64 align);
|
||||
PAddr AllocateSpace(PAddr paddr, u64 size, u64 align);
|
||||
PAddr MapBufferEx(VAddr vaddr, u64 size);
|
||||
PAddr MapBufferEx(VAddr vaddr, PAddr paddr, u64 size);
|
||||
VAddr PhysicalToVirtualAddress(PAddr paddr);
|
||||
|
||||
private:
|
||||
boost::optional<PAddr> FindFreeBlock(u64 size, u64 align = 1);
|
||||
bool IsPageMapped(PAddr paddr);
|
||||
VAddr& PageSlot(PAddr paddr);
|
||||
|
||||
enum class PageStatus : u64 {
|
||||
Unmapped = 0xFFFFFFFFFFFFFFFFULL,
|
||||
Allocated = 0xFFFFFFFFFFFFFFFEULL,
|
||||
};
|
||||
|
||||
static constexpr u64 MAX_ADDRESS{0x10000000000ULL};
|
||||
static constexpr u64 PAGE_TABLE_BITS{14};
|
||||
static constexpr u64 PAGE_TABLE_SIZE{1 << PAGE_TABLE_BITS};
|
||||
static constexpr u64 PAGE_TABLE_MASK{PAGE_TABLE_SIZE - 1};
|
||||
static constexpr u64 PAGE_BLOCK_BITS{14};
|
||||
static constexpr u64 PAGE_BLOCK_SIZE{1 << PAGE_BLOCK_BITS};
|
||||
static constexpr u64 PAGE_BLOCK_MASK{PAGE_BLOCK_SIZE - 1};
|
||||
|
||||
using PageBlock = std::array<VAddr, PAGE_BLOCK_SIZE>;
|
||||
std::array<std::unique_ptr<PageBlock>, PAGE_TABLE_SIZE> page_table{};
|
||||
};
|
||||
|
||||
} // namespace Tegra
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
u32 height;
|
||||
u32 stride;
|
||||
PixelFormat pixel_format;
|
||||
bool flip_vertical;
|
||||
};
|
||||
|
||||
virtual ~RendererBase() {}
|
||||
|
||||
@@ -262,6 +262,8 @@ void RendererOpenGL::LoadFBToScreenInfo(const FramebufferInfo& framebuffer_info,
|
||||
// only allows rows to have a memory alignement of 4.
|
||||
ASSERT(framebuffer_info.stride % 4 == 0);
|
||||
|
||||
framebuffer_flip_vertical = framebuffer_info.flip_vertical;
|
||||
|
||||
// Reset the screen info's display texture to its own permanent texture
|
||||
screen_info.display_texture = screen_info.texture.resource.handle;
|
||||
screen_info.display_texcoords = MathUtil::Rectangle<float>(0.f, 0.f, 1.f, 1.f);
|
||||
@@ -401,13 +403,15 @@ void RendererOpenGL::ConfigureFramebufferTexture(TextureInfo& texture,
|
||||
|
||||
void RendererOpenGL::DrawSingleScreen(const ScreenInfo& screen_info, float x, float y, float w,
|
||||
float h) {
|
||||
auto& texcoords = screen_info.display_texcoords;
|
||||
const auto& texcoords = screen_info.display_texcoords;
|
||||
const auto& left = framebuffer_flip_vertical ? texcoords.right : texcoords.left;
|
||||
const auto& right = framebuffer_flip_vertical ? texcoords.left : texcoords.right;
|
||||
|
||||
std::array<ScreenRectVertex, 4> vertices = {{
|
||||
ScreenRectVertex(x, y, texcoords.top, texcoords.right),
|
||||
ScreenRectVertex(x + w, y, texcoords.bottom, texcoords.right),
|
||||
ScreenRectVertex(x, y + h, texcoords.top, texcoords.left),
|
||||
ScreenRectVertex(x + w, y + h, texcoords.bottom, texcoords.left),
|
||||
ScreenRectVertex(x, y, texcoords.top, right),
|
||||
ScreenRectVertex(x + w, y, texcoords.bottom, right),
|
||||
ScreenRectVertex(x, y + h, texcoords.top, left),
|
||||
ScreenRectVertex(x + w, y + h, texcoords.bottom, left),
|
||||
}};
|
||||
|
||||
state.texture_units[0].texture_2d = screen_info.display_texture;
|
||||
|
||||
@@ -86,4 +86,7 @@ private:
|
||||
// Shader attribute input indices
|
||||
GLuint attrib_position;
|
||||
GLuint attrib_tex_coord;
|
||||
|
||||
/// Flips the framebuffer vertically when true
|
||||
bool framebuffer_flip_vertical;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user