Merge pull request #296 from bunnei/misc-mem-fsp-fixes
Fix stack region, implement FSP GetSize/SetSize, and some stubs
This commit is contained in:
commit
f92594d744
|
@ -174,8 +174,9 @@ u64 Disk_Storage::GetSize() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Disk_Storage::SetSize(const u64 size) const {
|
bool Disk_Storage::SetSize(const u64 size) const {
|
||||||
LOG_WARNING(Service_FS, "(STUBBED) called");
|
file->Resize(size);
|
||||||
return false;
|
file->Flush();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Disk_Directory::Disk_Directory(const std::string& path) : directory() {
|
Disk_Directory::Disk_Directory(const std::string& path) : directory() {
|
||||||
|
|
|
@ -268,8 +268,11 @@ std::vector<u8> HLERequestContext::ReadBuffer() const {
|
||||||
|
|
||||||
size_t HLERequestContext::WriteBuffer(const void* buffer, size_t size) const {
|
size_t HLERequestContext::WriteBuffer(const void* buffer, size_t size) const {
|
||||||
const bool is_buffer_b{BufferDescriptorB().size() && BufferDescriptorB()[0].Size()};
|
const bool is_buffer_b{BufferDescriptorB().size() && BufferDescriptorB()[0].Size()};
|
||||||
|
const size_t buffer_size{GetWriteBufferSize()};
|
||||||
ASSERT_MSG(size <= GetWriteBufferSize(), "Size %lx is too big", size);
|
if (size > buffer_size) {
|
||||||
|
LOG_CRITICAL(Core, "size (%016zx) is greater than buffer_size (%016zx)", size, buffer_size);
|
||||||
|
size = buffer_size; // TODO(bunnei): This needs to be HW tested
|
||||||
|
}
|
||||||
|
|
||||||
if (is_buffer_b) {
|
if (is_buffer_b) {
|
||||||
Memory::WriteBlock(BufferDescriptorB()[0].Address(), buffer, size);
|
Memory::WriteBlock(BufferDescriptorB()[0].Address(), buffer, size);
|
||||||
|
|
|
@ -121,8 +121,9 @@ void Process::Run(VAddr entry_point, s32 main_thread_priority, u32 stack_size) {
|
||||||
// TODO(bunnei): This is heap area that should be allocated by the kernel and not mapped as part
|
// TODO(bunnei): This is heap area that should be allocated by the kernel and not mapped as part
|
||||||
// of the user address space.
|
// of the user address space.
|
||||||
vm_manager
|
vm_manager
|
||||||
.MapMemoryBlock(Memory::STACK_VADDR, std::make_shared<std::vector<u8>>(stack_size, 0), 0,
|
.MapMemoryBlock(Memory::STACK_AREA_VADDR_END - stack_size,
|
||||||
stack_size, MemoryState::Mapped)
|
std::make_shared<std::vector<u8>>(stack_size, 0), 0, stack_size,
|
||||||
|
MemoryState::Mapped)
|
||||||
.Unwrap();
|
.Unwrap();
|
||||||
misc_memory_used += stack_size;
|
misc_memory_used += stack_size;
|
||||||
memory_region->used += stack_size;
|
memory_region->used += stack_size;
|
||||||
|
|
|
@ -342,7 +342,7 @@ SharedPtr<Thread> SetupMainThread(VAddr entry_point, u32 priority,
|
||||||
|
|
||||||
// Initialize new "main" thread
|
// Initialize new "main" thread
|
||||||
auto thread_res = Thread::Create("main", entry_point, priority, 0, THREADPROCESSORID_0,
|
auto thread_res = Thread::Create("main", entry_point, priority, 0, THREADPROCESSORID_0,
|
||||||
Memory::STACK_VADDR_END, owner_process);
|
Memory::STACK_AREA_VADDR_END, owner_process);
|
||||||
|
|
||||||
SharedPtr<Thread> thread = std::move(thread_res).Unwrap();
|
SharedPtr<Thread> thread = std::move(thread_res).Unwrap();
|
||||||
|
|
||||||
|
|
|
@ -72,8 +72,8 @@ public:
|
||||||
explicit IFile(std::unique_ptr<FileSys::StorageBackend>&& backend)
|
explicit IFile(std::unique_ptr<FileSys::StorageBackend>&& backend)
|
||||||
: ServiceFramework("IFile"), backend(std::move(backend)) {
|
: ServiceFramework("IFile"), backend(std::move(backend)) {
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &IFile::Read, "Read"}, {1, &IFile::Write, "Write"}, {2, nullptr, "Flush"},
|
{0, &IFile::Read, "Read"}, {1, &IFile::Write, "Write"}, {2, nullptr, "Flush"},
|
||||||
{3, nullptr, "SetSize"}, {4, nullptr, "GetSize"},
|
{3, &IFile::SetSize, "SetSize"}, {4, &IFile::GetSize, "GetSize"},
|
||||||
};
|
};
|
||||||
RegisterHandlers(functions);
|
RegisterHandlers(functions);
|
||||||
}
|
}
|
||||||
|
@ -150,6 +150,25 @@ private:
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetSize(Kernel::HLERequestContext& ctx) {
|
||||||
|
IPC::RequestParser rp{ctx};
|
||||||
|
const u64 size = rp.Pop<u64>();
|
||||||
|
backend->SetSize(size);
|
||||||
|
LOG_DEBUG(Service_FS, "called, size=%" PRIu64, size);
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetSize(Kernel::HLERequestContext& ctx) {
|
||||||
|
const u64 size = backend->GetSize();
|
||||||
|
LOG_DEBUG(Service_FS, "called, size=%" PRIu64, size);
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 4};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
rb.Push<u64>(size);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class IDirectory final : public ServiceFramework<IDirectory> {
|
class IDirectory final : public ServiceFramework<IDirectory> {
|
||||||
|
|
|
@ -185,6 +185,7 @@ public:
|
||||||
{66, &Hid::StartSixAxisSensor, "StartSixAxisSensor"},
|
{66, &Hid::StartSixAxisSensor, "StartSixAxisSensor"},
|
||||||
{79, &Hid::SetGyroscopeZeroDriftMode, "SetGyroscopeZeroDriftMode"},
|
{79, &Hid::SetGyroscopeZeroDriftMode, "SetGyroscopeZeroDriftMode"},
|
||||||
{100, &Hid::SetSupportedNpadStyleSet, "SetSupportedNpadStyleSet"},
|
{100, &Hid::SetSupportedNpadStyleSet, "SetSupportedNpadStyleSet"},
|
||||||
|
{101, &Hid::GetSupportedNpadStyleSet, "GetSupportedNpadStyleSet"},
|
||||||
{102, &Hid::SetSupportedNpadIdType, "SetSupportedNpadIdType"},
|
{102, &Hid::SetSupportedNpadIdType, "SetSupportedNpadIdType"},
|
||||||
{103, &Hid::ActivateNpad, "ActivateNpad"},
|
{103, &Hid::ActivateNpad, "ActivateNpad"},
|
||||||
{106, &Hid::AcquireNpadStyleSetUpdateEventHandle,
|
{106, &Hid::AcquireNpadStyleSetUpdateEventHandle,
|
||||||
|
@ -265,6 +266,13 @@ private:
|
||||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx) {
|
||||||
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
rb.Push<u32>(0);
|
||||||
|
LOG_WARNING(Service_HID, "(STUBBED) called");
|
||||||
|
}
|
||||||
|
|
||||||
void SetSupportedNpadIdType(Kernel::HLERequestContext& ctx) {
|
void SetSupportedNpadIdType(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
|
|
@ -414,7 +414,7 @@ ResultStatus AppLoader_ELF::Load(Kernel::SharedPtr<Kernel::Process>& process) {
|
||||||
process->resource_limit =
|
process->resource_limit =
|
||||||
Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
|
Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
|
||||||
|
|
||||||
process->Run(codeset->entrypoint, 48, Memory::STACK_SIZE);
|
process->Run(codeset->entrypoint, 48, Memory::DEFAULT_STACK_SIZE);
|
||||||
|
|
||||||
is_loaded = true;
|
is_loaded = true;
|
||||||
return ResultStatus::Success;
|
return ResultStatus::Success;
|
||||||
|
|
|
@ -137,7 +137,7 @@ ResultStatus AppLoader_NRO::Load(Kernel::SharedPtr<Kernel::Process>& process) {
|
||||||
process->address_mappings = default_address_mappings;
|
process->address_mappings = default_address_mappings;
|
||||||
process->resource_limit =
|
process->resource_limit =
|
||||||
Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
|
Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
|
||||||
process->Run(base_addr, 48, Memory::STACK_SIZE);
|
process->Run(base_addr, 48, Memory::DEFAULT_STACK_SIZE);
|
||||||
|
|
||||||
is_loaded = true;
|
is_loaded = true;
|
||||||
return ResultStatus::Success;
|
return ResultStatus::Success;
|
||||||
|
|
|
@ -165,7 +165,7 @@ ResultStatus AppLoader_NSO::Load(Kernel::SharedPtr<Kernel::Process>& process) {
|
||||||
process->address_mappings = default_address_mappings;
|
process->address_mappings = default_address_mappings;
|
||||||
process->resource_limit =
|
process->resource_limit =
|
||||||
Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
|
Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
|
||||||
process->Run(Memory::PROCESS_IMAGE_VADDR, 48, Memory::STACK_SIZE);
|
process->Run(Memory::PROCESS_IMAGE_VADDR, 48, Memory::DEFAULT_STACK_SIZE);
|
||||||
|
|
||||||
is_loaded = true;
|
is_loaded = true;
|
||||||
return ResultStatus::Success;
|
return ResultStatus::Success;
|
||||||
|
|
|
@ -162,12 +162,13 @@ enum : VAddr {
|
||||||
TLS_AREA_VADDR = NEW_LINEAR_HEAP_VADDR_END,
|
TLS_AREA_VADDR = NEW_LINEAR_HEAP_VADDR_END,
|
||||||
TLS_ENTRY_SIZE = 0x200,
|
TLS_ENTRY_SIZE = 0x200,
|
||||||
TLS_AREA_SIZE = 0x10000000,
|
TLS_AREA_SIZE = 0x10000000,
|
||||||
TLS_ADREA_VADDR_END = TLS_AREA_VADDR + TLS_AREA_SIZE,
|
TLS_AREA_VADDR_END = TLS_AREA_VADDR + TLS_AREA_SIZE,
|
||||||
|
|
||||||
/// Application stack
|
/// Application stack
|
||||||
STACK_VADDR = TLS_ADREA_VADDR_END,
|
STACK_AREA_VADDR = TLS_AREA_VADDR_END,
|
||||||
STACK_SIZE = 0x10000,
|
STACK_AREA_SIZE = 0x10000000,
|
||||||
STACK_VADDR_END = STACK_VADDR + STACK_SIZE,
|
STACK_AREA_VADDR_END = STACK_AREA_VADDR + STACK_AREA_SIZE,
|
||||||
|
DEFAULT_STACK_SIZE = 0x100000,
|
||||||
|
|
||||||
/// Application heap
|
/// Application heap
|
||||||
/// Size is confirmed to be a static value on fw 3.0.0
|
/// Size is confirmed to be a static value on fw 3.0.0
|
||||||
|
|
Reference in New Issue