Remove support for multiple guest processes

This commit removes support for more than one guest processes as it requires a fair bit of extra code to support in addition the HLE service implementations don't support it anyway.
This commit is contained in:
◱ PixelyIon
2020-01-01 18:41:25 +05:30
committed by ◱ PixelyIon
parent 48d47a2b25
commit b84859d352
33 changed files with 457 additions and 459 deletions

View File

@ -21,7 +21,7 @@ namespace skyline::gpu::device {
void NvHostChannel::SetErrorNotifier(skyline::gpu::device::IoctlData &buffer) {}
void NvHostChannel::SetPriority(skyline::gpu::device::IoctlData &buffer) {
auto priority = state.thisProcess->ReadMemory<NvChannelPriority>(buffer.input[0].address);
auto priority = state.process->ReadMemory<NvChannelPriority>(buffer.input[0].address);
switch (priority) {
case NvChannelPriority::Low:
timeslice = 1300;

View File

@ -12,7 +12,7 @@ namespace skyline::gpu::device {
void NvHostCtrlGpu::ZCullGetCtxSize(IoctlData &buffer) {
u32 size = 0x1;
state.thisProcess->WriteMemory(size, buffer.output[0].address);
state.process->WriteMemory(size, buffer.output[0].address);
}
void NvHostCtrlGpu::ZCullGetInfo(skyline::gpu::device::IoctlData &buffer) {
@ -28,7 +28,7 @@ namespace skyline::gpu::device {
u32 subregionHeightAlignPixels{0x40};
u32 subregionCount{0x10};
} zCullInfo;
state.thisProcess->WriteMemory(zCullInfo, buffer.output[0].address);
state.process->WriteMemory(zCullInfo, buffer.output[0].address);
}
void NvHostCtrlGpu::GetCharacteristics(IoctlData &buffer) {
@ -73,7 +73,7 @@ namespace skyline::gpu::device {
u64 gpuCharacteristicsBufSize; // InOut
u64 gpuCharacteristicsBufAddr; // In
GpuCharacteristics gpuCharacteristics; // Out
} data = state.thisProcess->ReadMemory<Data>(buffer.input[0].address);
} data = state.process->ReadMemory<Data>(buffer.input[0].address);
data.gpuCharacteristics = {
.arch = 0x120,
.impl = 0xB,
@ -111,7 +111,7 @@ namespace skyline::gpu::device {
.grCompbitStoreBaseHw = 0x0
};
data.gpuCharacteristicsBufSize = 0xA0;
state.thisProcess->WriteMemory(data, buffer.output[0].address);
state.process->WriteMemory(data, buffer.output[0].address);
}
void NvHostCtrlGpu::GetTpcMasks(IoctlData &buffer) {
@ -119,10 +119,10 @@ namespace skyline::gpu::device {
u32 maskBufSize; // In
u32 reserved[3]; // In
u64 maskBuf; // Out
} data = state.thisProcess->ReadMemory<Data>(buffer.input[0].address);
} data = state.process->ReadMemory<Data>(buffer.input[0].address);
if (data.maskBufSize)
data.maskBuf = 0x3;
state.thisProcess->WriteMemory(data, buffer.output[0].address);
state.process->WriteMemory(data, buffer.output[0].address);
}
void NvHostCtrlGpu::GetActiveSlotMask(IoctlData &buffer) {
@ -133,6 +133,6 @@ namespace skyline::gpu::device {
.slot = 0x07,
.mask = 0x01
};
state.thisProcess->WriteMemory(data, buffer.output[0].address);
state.process->WriteMemory(data, buffer.output[0].address);
}
}

View File

@ -17,10 +17,10 @@ namespace skyline::gpu::device {
struct Data {
u32 size; // In
u32 handle; // Out
} data = state.thisProcess->ReadMemory<Data>(buffer.input[0].address);
} data = state.process->ReadMemory<Data>(buffer.input[0].address);
handleTable[handleIndex] = std::make_shared<NvMapObject>(idIndex++, data.size);
data.handle = handleIndex++;
state.thisProcess->WriteMemory(data, buffer.output[0].address);
state.process->WriteMemory(data, buffer.output[0].address);
state.logger->Debug("Create: Input: Size: 0x{:X}, Output: Handle: 0x{:X}, Status: {}", data.size, data.handle, buffer.status);
}
@ -28,7 +28,7 @@ namespace skyline::gpu::device {
struct Data {
u32 id; // In
u32 handle; // Out
} data = state.thisProcess->ReadMemory<Data>(buffer.input[0].address);
} data = state.process->ReadMemory<Data>(buffer.input[0].address);
bool found{};
for (const auto &object : handleTable) {
if (object.second->id == data.id) {
@ -38,7 +38,7 @@ namespace skyline::gpu::device {
}
}
if (found)
state.thisProcess->WriteMemory(data, buffer.output[0].address);
state.process->WriteMemory(data, buffer.output[0].address);
else
buffer.status = NvStatus::BadValue;
state.logger->Debug("FromId: Input: Handle: 0x{:X}, Output: ID: 0x{:X}, Status: {}", data.handle, data.id, buffer.status);
@ -53,7 +53,7 @@ namespace skyline::gpu::device {
u8 kind; // In
u8 _pad0_[7];
u64 address; // InOut
} data = state.thisProcess->ReadMemory<Data>(buffer.input[0].address);
} data = state.process->ReadMemory<Data>(buffer.input[0].address);
auto &object = handleTable.at(data.handle);
object->heapMask = data.heapMask;
object->flags = data.flags;
@ -71,7 +71,7 @@ namespace skyline::gpu::device {
u32 address; // Out
u32 size; // Out
u64 flags; // Out
} data = state.thisProcess->ReadMemory<Data>(buffer.input[0].address);
} data = state.process->ReadMemory<Data>(buffer.input[0].address);
const auto &object = handleTable.at(data.handle);
if (object.use_count() > 1) {
data.address = static_cast<u32>(object->address);
@ -82,7 +82,7 @@ namespace skyline::gpu::device {
}
data.size = object->size;
handleTable.erase(data.handle);
state.thisProcess->WriteMemory(data, buffer.output[0].address);
state.process->WriteMemory(data, buffer.output[0].address);
}
void NvMap::Param(IoctlData &buffer) {
@ -91,7 +91,7 @@ namespace skyline::gpu::device {
u32 handle; // In
Parameter parameter; // In
u32 result; // Out
} data = state.thisProcess->ReadMemory<Data>(buffer.input[0].address);
} data = state.process->ReadMemory<Data>(buffer.input[0].address);
auto &object = handleTable.at(data.handle);
switch (data.parameter) {
case Parameter::Size:
@ -124,7 +124,7 @@ namespace skyline::gpu::device {
buffer.status = NvStatus::NotImplemented;
break;
}
state.thisProcess->WriteMemory(data, buffer.output[0].address);
state.process->WriteMemory(data, buffer.output[0].address);
state.logger->Debug("Param: Input: Handle: 0x{:X}, Parameter: {}, Output: Result: 0x{:X}, Status: {}", data.handle, data.parameter, data.result, buffer.status);
}
@ -132,9 +132,9 @@ namespace skyline::gpu::device {
struct Data {
u32 id; // Out
u32 handle; // In
} data = state.thisProcess->ReadMemory<Data>(buffer.input[0].address);
} data = state.process->ReadMemory<Data>(buffer.input[0].address);
data.id = handleTable.at(data.handle)->id;
state.thisProcess->WriteMemory(data, buffer.output[0].address);
state.process->WriteMemory(data, buffer.output[0].address);
state.logger->Debug("GetId: Input: Handle: 0x{:X}, Output: ID: 0x{:X}, Status: {}", data.handle, data.id, buffer.status);
}
}

View File

@ -31,7 +31,7 @@ namespace skyline::gpu {
}
void Buffer::UpdateBuffer() {
state.thisProcess->ReadMemory(dataBuffer.data(), nvBuffer->address + gbpBuffer.offset, gbpBuffer.size);
state.process->ReadMemory(dataBuffer.data(), nvBuffer->address + gbpBuffer.offset, gbpBuffer.size);
}
BufferQueue::WaitContext::WaitContext(std::shared_ptr<kernel::type::KThread> thread, DequeueIn input, kernel::ipc::OutputBuffer& buffer) : thread(std::move(thread)), input(input), buffer(buffer) {}
@ -59,8 +59,8 @@ namespace skyline::gpu {
}
}
if (slot == -1) {
state.thisThread->Sleep();
waitVec.emplace_back(state.thisThread, *data, buffer);
state.thread->Sleep();
waitVec.emplace_back(state.thread, *data, buffer);
state.logger->Debug("DequeueBuffer: Width: {}, Height: {}, Format: {}, Usage: {}, Timestamps: {}, No Free Buffers", data->width, data->height, data->format, data->usage, data->timestamps);
return true;
}
@ -135,7 +135,7 @@ namespace skyline::gpu {
gpu::Parcel out(state);
DequeueOut output(slotNo);
out.WriteData(output);
out.WriteParcel(context->buffer, context->thread->pid);
out.WriteParcel(context->buffer);
slot->status = BufferStatus::Dequeued;
waitVec.erase(context);
break;

View File

@ -6,22 +6,22 @@ namespace skyline::gpu {
Parcel::Parcel(kernel::ipc::InputBuffer &buffer, const DeviceState &state) : Parcel(buffer.address, buffer.size, state) {}
Parcel::Parcel(u64 address, u64 size, const DeviceState &state) : state(state) {
state.thisProcess->ReadMemory(&header, address, sizeof(ParcelHeader));
state.process->ReadMemory(&header, address, sizeof(ParcelHeader));
if (size < (sizeof(ParcelHeader) + header.dataSize + header.objectsSize))
throw exception("The size of the parcel according to the header exceeds the specified size");
data.resize(header.dataSize);
state.thisProcess->ReadMemory(data.data(), address + header.dataOffset, header.dataSize);
state.process->ReadMemory(data.data(), address + header.dataOffset, header.dataSize);
objects.resize(header.objectsSize);
state.thisProcess->ReadMemory(objects.data(), address + header.objectsOffset, header.objectsSize);
state.process->ReadMemory(objects.data(), address + header.objectsOffset, header.objectsSize);
}
Parcel::Parcel(const DeviceState &state) : state(state) {}
u64 Parcel::WriteParcel(kernel::ipc::OutputBuffer& buffer, pid_t process) {
return WriteParcel(buffer.address, buffer.size, process);
u64 Parcel::WriteParcel(kernel::ipc::OutputBuffer& buffer) {
return WriteParcel(buffer.address, buffer.size);
}
u64 Parcel::WriteParcel(u64 address, u64 maxSize, pid_t process) {
u64 Parcel::WriteParcel(u64 address, u64 maxSize) {
header.dataSize = static_cast<u32>(data.size());
header.dataOffset = sizeof(ParcelHeader);
header.objectsSize = static_cast<u32>(objects.size());
@ -29,16 +29,9 @@ namespace skyline::gpu {
u64 totalSize = sizeof(ParcelHeader) + header.dataSize + header.objectsSize;
if (maxSize < totalSize)
throw exception("The size of the parcel exceeds maxSize");
if (process) {
auto &object = state.os->processMap.at(process);
object->WriteMemory(header, address);
object->WriteMemory(data.data(), address + header.dataOffset, data.size());
object->WriteMemory(objects.data(), address + header.objectsOffset, objects.size());
} else {
state.thisProcess->WriteMemory(header, address);
state.thisProcess->WriteMemory(data.data(), address + header.dataOffset, data.size());
state.thisProcess->WriteMemory(objects.data(), address + header.objectsOffset, objects.size());
}
state.process->WriteMemory(header, address);
state.process->WriteMemory(data.data(), address + header.dataOffset, data.size());
state.process->WriteMemory(objects.data(), address + header.objectsOffset, objects.size());
return totalSize;
}
}

View File

@ -80,18 +80,16 @@ namespace skyline::gpu {
/**
* @brief Writes the Parcel object into a particular output buffer on a process
* @param buffer The buffer to write into
* @param process The process to write the Parcel to
* @return The total size of the message
*/
u64 WriteParcel(kernel::ipc::OutputBuffer& buffer, pid_t process = 0);
u64 WriteParcel(kernel::ipc::OutputBuffer& buffer);
/**
* @brief Writes the Parcel object into the process's memory
* @param address The address to write the Parcel object to
* @param maxSize The maximum size of the Parcel
* @param process The process to write the Parcel to
* @return The total size of the message
*/
u64 WriteParcel(u64 address, u64 maxSize, pid_t process = 0);
u64 WriteParcel(u64 address, u64 maxSize);
};
}