summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar bunnei2018-04-02 13:05:25 -0400
committerGravatar GitHub2018-04-02 13:05:25 -0400
commitf92594d744eedc6f8b01c5d5f761b55b7035be1f (patch)
tree487a643bbd523b37e95ba1fc1bd3baa576831485 /src/core
parentMerge pull request #288 from Subv/macro_interpreter (diff)
parenthle_ipc, fsp_srv: Cleanup logging. (diff)
downloadyuzu-f92594d744eedc6f8b01c5d5f761b55b7035be1f.tar.gz
yuzu-f92594d744eedc6f8b01c5d5f761b55b7035be1f.tar.xz
yuzu-f92594d744eedc6f8b01c5d5f761b55b7035be1f.zip
Merge pull request #296 from bunnei/misc-mem-fsp-fixes
Fix stack region, implement FSP GetSize/SetSize, and some stubs
Diffstat (limited to 'src/core')
-rw-r--r--src/core/file_sys/disk_filesystem.cpp5
-rw-r--r--src/core/hle/kernel/hle_ipc.cpp7
-rw-r--r--src/core/hle/kernel/process.cpp5
-rw-r--r--src/core/hle/kernel/thread.cpp2
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.cpp23
-rw-r--r--src/core/hle/service/hid/hid.cpp8
-rw-r--r--src/core/loader/elf.cpp2
-rw-r--r--src/core/loader/nro.cpp2
-rw-r--r--src/core/loader/nso.cpp2
-rw-r--r--src/core/memory.h9
10 files changed, 49 insertions, 16 deletions
diff --git a/src/core/file_sys/disk_filesystem.cpp b/src/core/file_sys/disk_filesystem.cpp
index 3a4b45721..4235f3935 100644
--- a/src/core/file_sys/disk_filesystem.cpp
+++ b/src/core/file_sys/disk_filesystem.cpp
@@ -174,8 +174,9 @@ u64 Disk_Storage::GetSize() const {
174} 174}
175 175
176bool Disk_Storage::SetSize(const u64 size) const { 176bool Disk_Storage::SetSize(const u64 size) const {
177 LOG_WARNING(Service_FS, "(STUBBED) called"); 177 file->Resize(size);
178 return false; 178 file->Flush();
179 return true;
179} 180}
180 181
181Disk_Directory::Disk_Directory(const std::string& path) : directory() { 182Disk_Directory::Disk_Directory(const std::string& path) : directory() {
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp
index ffcbfe64f..bef4f15f5 100644
--- a/src/core/hle/kernel/hle_ipc.cpp
+++ b/src/core/hle/kernel/hle_ipc.cpp
@@ -268,8 +268,11 @@ std::vector<u8> HLERequestContext::ReadBuffer() const {
268 268
269size_t HLERequestContext::WriteBuffer(const void* buffer, size_t size) const { 269size_t HLERequestContext::WriteBuffer(const void* buffer, size_t size) const {
270 const bool is_buffer_b{BufferDescriptorB().size() && BufferDescriptorB()[0].Size()}; 270 const bool is_buffer_b{BufferDescriptorB().size() && BufferDescriptorB()[0].Size()};
271 271 const size_t buffer_size{GetWriteBufferSize()};
272 ASSERT_MSG(size <= GetWriteBufferSize(), "Size %lx is too big", size); 272 if (size > buffer_size) {
273 LOG_CRITICAL(Core, "size (%016zx) is greater than buffer_size (%016zx)", size, buffer_size);
274 size = buffer_size; // TODO(bunnei): This needs to be HW tested
275 }
273 276
274 if (is_buffer_b) { 277 if (is_buffer_b) {
275 Memory::WriteBlock(BufferDescriptorB()[0].Address(), buffer, size); 278 Memory::WriteBlock(BufferDescriptorB()[0].Address(), buffer, size);
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp
index 3694afc60..2cffec198 100644
--- a/src/core/hle/kernel/process.cpp
+++ b/src/core/hle/kernel/process.cpp
@@ -121,8 +121,9 @@ void Process::Run(VAddr entry_point, s32 main_thread_priority, u32 stack_size) {
121 // TODO(bunnei): This is heap area that should be allocated by the kernel and not mapped as part 121 // TODO(bunnei): This is heap area that should be allocated by the kernel and not mapped as part
122 // of the user address space. 122 // of the user address space.
123 vm_manager 123 vm_manager
124 .MapMemoryBlock(Memory::STACK_VADDR, std::make_shared<std::vector<u8>>(stack_size, 0), 0, 124 .MapMemoryBlock(Memory::STACK_AREA_VADDR_END - stack_size,
125 stack_size, MemoryState::Mapped) 125 std::make_shared<std::vector<u8>>(stack_size, 0), 0, stack_size,
126 MemoryState::Mapped)
126 .Unwrap(); 127 .Unwrap();
127 misc_memory_used += stack_size; 128 misc_memory_used += stack_size;
128 memory_region->used += stack_size; 129 memory_region->used += stack_size;
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 145f50887..f3a8aa4aa 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -342,7 +342,7 @@ SharedPtr<Thread> SetupMainThread(VAddr entry_point, u32 priority,
342 342
343 // Initialize new "main" thread 343 // Initialize new "main" thread
344 auto thread_res = Thread::Create("main", entry_point, priority, 0, THREADPROCESSORID_0, 344 auto thread_res = Thread::Create("main", entry_point, priority, 0, THREADPROCESSORID_0,
345 Memory::STACK_VADDR_END, owner_process); 345 Memory::STACK_AREA_VADDR_END, owner_process);
346 346
347 SharedPtr<Thread> thread = std::move(thread_res).Unwrap(); 347 SharedPtr<Thread> thread = std::move(thread_res).Unwrap();
348 348
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp
index 41b8cbfd2..89fa70ae6 100644
--- a/src/core/hle/service/filesystem/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp_srv.cpp
@@ -72,8 +72,8 @@ public:
72 explicit IFile(std::unique_ptr<FileSys::StorageBackend>&& backend) 72 explicit IFile(std::unique_ptr<FileSys::StorageBackend>&& backend)
73 : ServiceFramework("IFile"), backend(std::move(backend)) { 73 : ServiceFramework("IFile"), backend(std::move(backend)) {
74 static const FunctionInfo functions[] = { 74 static const FunctionInfo functions[] = {
75 {0, &IFile::Read, "Read"}, {1, &IFile::Write, "Write"}, {2, nullptr, "Flush"}, 75 {0, &IFile::Read, "Read"}, {1, &IFile::Write, "Write"}, {2, nullptr, "Flush"},
76 {3, nullptr, "SetSize"}, {4, nullptr, "GetSize"}, 76 {3, &IFile::SetSize, "SetSize"}, {4, &IFile::GetSize, "GetSize"},
77 }; 77 };
78 RegisterHandlers(functions); 78 RegisterHandlers(functions);
79 } 79 }
@@ -150,6 +150,25 @@ private:
150 IPC::ResponseBuilder rb{ctx, 2}; 150 IPC::ResponseBuilder rb{ctx, 2};
151 rb.Push(RESULT_SUCCESS); 151 rb.Push(RESULT_SUCCESS);
152 } 152 }
153
154 void SetSize(Kernel::HLERequestContext& ctx) {
155 IPC::RequestParser rp{ctx};
156 const u64 size = rp.Pop<u64>();
157 backend->SetSize(size);
158 LOG_DEBUG(Service_FS, "called, size=%" PRIu64, size);
159
160 IPC::ResponseBuilder rb{ctx, 2};
161 rb.Push(RESULT_SUCCESS);
162 }
163
164 void GetSize(Kernel::HLERequestContext& ctx) {
165 const u64 size = backend->GetSize();
166 LOG_DEBUG(Service_FS, "called, size=%" PRIu64, size);
167
168 IPC::ResponseBuilder rb{ctx, 4};
169 rb.Push(RESULT_SUCCESS);
170 rb.Push<u64>(size);
171 }
153}; 172};
154 173
155class IDirectory final : public ServiceFramework<IDirectory> { 174class IDirectory final : public ServiceFramework<IDirectory> {
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index a0b8c6243..f1936991c 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -185,6 +185,7 @@ public:
185 {66, &Hid::StartSixAxisSensor, "StartSixAxisSensor"}, 185 {66, &Hid::StartSixAxisSensor, "StartSixAxisSensor"},
186 {79, &Hid::SetGyroscopeZeroDriftMode, "SetGyroscopeZeroDriftMode"}, 186 {79, &Hid::SetGyroscopeZeroDriftMode, "SetGyroscopeZeroDriftMode"},
187 {100, &Hid::SetSupportedNpadStyleSet, "SetSupportedNpadStyleSet"}, 187 {100, &Hid::SetSupportedNpadStyleSet, "SetSupportedNpadStyleSet"},
188 {101, &Hid::GetSupportedNpadStyleSet, "GetSupportedNpadStyleSet"},
188 {102, &Hid::SetSupportedNpadIdType, "SetSupportedNpadIdType"}, 189 {102, &Hid::SetSupportedNpadIdType, "SetSupportedNpadIdType"},
189 {103, &Hid::ActivateNpad, "ActivateNpad"}, 190 {103, &Hid::ActivateNpad, "ActivateNpad"},
190 {106, &Hid::AcquireNpadStyleSetUpdateEventHandle, 191 {106, &Hid::AcquireNpadStyleSetUpdateEventHandle,
@@ -265,6 +266,13 @@ private:
265 LOG_WARNING(Service_HID, "(STUBBED) called"); 266 LOG_WARNING(Service_HID, "(STUBBED) called");
266 } 267 }
267 268
269 void GetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx) {
270 IPC::ResponseBuilder rb{ctx, 3};
271 rb.Push(RESULT_SUCCESS);
272 rb.Push<u32>(0);
273 LOG_WARNING(Service_HID, "(STUBBED) called");
274 }
275
268 void SetSupportedNpadIdType(Kernel::HLERequestContext& ctx) { 276 void SetSupportedNpadIdType(Kernel::HLERequestContext& ctx) {
269 IPC::ResponseBuilder rb{ctx, 2}; 277 IPC::ResponseBuilder rb{ctx, 2};
270 rb.Push(RESULT_SUCCESS); 278 rb.Push(RESULT_SUCCESS);
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp
index 0ba8c6fd2..e9f462196 100644
--- a/src/core/loader/elf.cpp
+++ b/src/core/loader/elf.cpp
@@ -414,7 +414,7 @@ ResultStatus AppLoader_ELF::Load(Kernel::SharedPtr<Kernel::Process>& process) {
414 process->resource_limit = 414 process->resource_limit =
415 Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION); 415 Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
416 416
417 process->Run(codeset->entrypoint, 48, Memory::STACK_SIZE); 417 process->Run(codeset->entrypoint, 48, Memory::DEFAULT_STACK_SIZE);
418 418
419 is_loaded = true; 419 is_loaded = true;
420 return ResultStatus::Success; 420 return ResultStatus::Success;
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp
index 6dcd1ce48..b5133e4d6 100644
--- a/src/core/loader/nro.cpp
+++ b/src/core/loader/nro.cpp
@@ -137,7 +137,7 @@ ResultStatus AppLoader_NRO::Load(Kernel::SharedPtr<Kernel::Process>& process) {
137 process->address_mappings = default_address_mappings; 137 process->address_mappings = default_address_mappings;
138 process->resource_limit = 138 process->resource_limit =
139 Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION); 139 Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
140 process->Run(base_addr, 48, Memory::STACK_SIZE); 140 process->Run(base_addr, 48, Memory::DEFAULT_STACK_SIZE);
141 141
142 is_loaded = true; 142 is_loaded = true;
143 return ResultStatus::Success; 143 return ResultStatus::Success;
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp
index 100aa022e..3bc10ed0d 100644
--- a/src/core/loader/nso.cpp
+++ b/src/core/loader/nso.cpp
@@ -165,7 +165,7 @@ ResultStatus AppLoader_NSO::Load(Kernel::SharedPtr<Kernel::Process>& process) {
165 process->address_mappings = default_address_mappings; 165 process->address_mappings = default_address_mappings;
166 process->resource_limit = 166 process->resource_limit =
167 Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION); 167 Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
168 process->Run(Memory::PROCESS_IMAGE_VADDR, 48, Memory::STACK_SIZE); 168 process->Run(Memory::PROCESS_IMAGE_VADDR, 48, Memory::DEFAULT_STACK_SIZE);
169 169
170 is_loaded = true; 170 is_loaded = true;
171 return ResultStatus::Success; 171 return ResultStatus::Success;
diff --git a/src/core/memory.h b/src/core/memory.h
index 413a7b4e8..e9b8ca873 100644
--- a/src/core/memory.h
+++ b/src/core/memory.h
@@ -162,12 +162,13 @@ enum : VAddr {
162 TLS_AREA_VADDR = NEW_LINEAR_HEAP_VADDR_END, 162 TLS_AREA_VADDR = NEW_LINEAR_HEAP_VADDR_END,
163 TLS_ENTRY_SIZE = 0x200, 163 TLS_ENTRY_SIZE = 0x200,
164 TLS_AREA_SIZE = 0x10000000, 164 TLS_AREA_SIZE = 0x10000000,
165 TLS_ADREA_VADDR_END = TLS_AREA_VADDR + TLS_AREA_SIZE, 165 TLS_AREA_VADDR_END = TLS_AREA_VADDR + TLS_AREA_SIZE,
166 166
167 /// Application stack 167 /// Application stack
168 STACK_VADDR = TLS_ADREA_VADDR_END, 168 STACK_AREA_VADDR = TLS_AREA_VADDR_END,
169 STACK_SIZE = 0x10000, 169 STACK_AREA_SIZE = 0x10000000,
170 STACK_VADDR_END = STACK_VADDR + STACK_SIZE, 170 STACK_AREA_VADDR_END = STACK_AREA_VADDR + STACK_AREA_SIZE,
171 DEFAULT_STACK_SIZE = 0x100000,
171 172
172 /// Application heap 173 /// Application heap
173 /// Size is confirmed to be a static value on fw 3.0.0 174 /// Size is confirmed to be a static value on fw 3.0.0