Commit graph

82 commits

Author SHA1 Message Date
Weiyi Wang
7308b8d294 Memory: remove IsValidVirtualAddress with current process 2018-11-19 11:16:55 -05:00
Weiyi Wang
36cf104a02 Memory: replace GetPointerFromVMA with GetPointerForRasterizerCache
All usage of GetPointerFromVMA is to recover the pointer that is nulled by changing page type to RasterizerCachedMemory. Our rasterizer cache only works on linear heap and vram, so we can recover the pointer directly by address computation, instead of going through VMA table. Also removed a sanity check pointer!=nullptr in RasterizerMarkRegionCached(RasterizerCachedMemory=>Memory), as now the pointer is never null. The sanity check was added in f2a5a77 (#2797), which was originally necessary during VMA unmapping process, because the function is invloked by VMA after unmapping the page, which in turn invokes back to query the memory, forming a circular dependency. Now the dependency is resolved so the check is not necessary
2018-11-19 11:16:55 -05:00
Weiyi Wang
2b768da531
Merge pull request #4433 from wwylele/vmmanager-simple
VMManager: remove shared_ptr<vector> backing type
2018-11-19 11:13:22 -05:00
Weiyi Wang
471b4cf44f
Merge pull request #4436 from wwylele/p2ptr-boundary
Memory: GetPhysicalPointer should accept right open bound address
2018-11-19 11:05:42 -05:00
Weiyi Wang
365eeb889f Memory: GetPhysicalPointer should accept right open bound address
Also removed IO region check in GetPhysicalPointer as it doesn't make sense to get a pointer to MMIO
2018-11-16 10:27:30 -05:00
Weiyi Wang
b6ab4e466b VMManager: remove all backing block related functions
The shared_ptr<vector> type backing memory is unused now, and is not expected to be used in the future
2018-11-16 00:16:13 -05:00
Weiyi Wang
9e8d149ca7 Memory: remove unused VirtualToPhysical 2018-11-13 11:56:05 -05:00
Weiyi Wang
12daaeedf1 Memory: Use the fixed PAddr directly in RasterizerFlushVirtualRegion 2018-11-13 11:24:46 -05:00
Weiyi Wang
d0edb81182 Memory: convert PAddr for N3DS FCRAM extension 2018-11-09 10:40:04 -05:00
Weiyi Wang
2654a679b3 Memory: replace PhysicalToVirtualAddress with a more dedicated function
There is no external use of PhysicalToVirtualAddress any more, so it there is no need to have a generic function that handles all physical regions. Also, the previous APT change makes it possible that linear heap has some regions mapped to old and new VAddr regions at the same time, so we need to check both region and mark cached for the mapped one. RasterizerMarkRegionCached would skip the unmapped one in its loop
2018-11-08 00:19:57 -05:00
Weiyi Wang
2067946f59
Kernel: reimplement memory management on physical FCRAM (#4392)
* Kernel: reimplement memory management on physical FCRAM

* Kernel/Process: Unmap does not care the source memory permission

What game usually does is after mapping the memory, they reprotect the source memory as no permission to avoid modification there

* Kernel/SharedMemory: zero initialize new-allocated memory

* Process/Thread: zero new TLS entry

* Kernel: fix a bug where code segments memory usage are accumulated twice

It is added to both misc and heap (done inside HeapAlloc), which results a doubled number reported by svcGetProcessInfo. While we are on it, we just merge the three number misc, heap and linear heap usage together, as there is no where they are distinguished.

Question: is TLS page also added to this number?

* Kernel/SharedMemory: add more object info on mapping error

* Process: lower log level; SharedMemory: store phys offset

* VMManager: add helper function to retrieve backing block list for a range
2018-11-06 15:00:47 -05:00
Weiyi Wang
ece96807c4 Kernel: move memory_regions into Kernel instance 2018-11-01 12:56:40 -04:00
Weiyi Wang
a753b9c6cc
Merge pull request #4228 from NarcolepticK/lle-mapped-buffer
LLE Mapped Buffer: Add unmapping of write buffer, zero-size, and multiple page handling
2018-10-30 19:18:11 -04:00
Weiyi Wang
8fb3d8ff38 kernel/process: move current process to kernel instance
Two functional change:
QueryProcessMemory uses the process passed from handle instead current_process
Thread::Stop() uses TLS from owner_process instead of current_process
2018-10-22 21:32:34 -04:00
B3n30
2306af3600 Handle cases when std::optional does not contain a value 2018-10-05 16:51:33 +02:00
B3n30
d37a2270d6 Replace boost::optional with std::optional where possible 2018-10-05 13:51:09 +02:00
NarcolepticK
51d53a6281 LLE Mapped Buffer: addressed comments 2018-09-30 23:23:21 -04:00
Weiyi Wang
7d8f115185 Prefix all size_t with std::
done automatically by executing regex replace `([^:0-9a-zA-Z_])size_t([^0-9a-zA-Z_])` -> `$1std::size_t$2`
2018-09-06 16:03:28 -04:00
wwylele
0eab948728 reformat all files with clang-format 2018-06-29 16:56:12 +03:00
wwylele
7c5a76e58b log: replace all NGLOG with LOG 2018-06-29 14:18:07 +03:00
Daniel Lim Wee Soong
4d2cbf271c Fix wrongly replaced arguments 2018-06-09 16:35:37 +08:00
Daniel Lim Wee Soong
e633d744eb core/memory: Replace logging macros 2018-06-07 23:07:15 +08:00
Daniel Lim Wee Soong
20776b37be Fix wrongly converted specifiers
Sorry that was a lot in one go so some of them had some mistakes
2018-03-27 23:37:36 +08:00
Daniel Lim Wee Soong
968569aa61 Replace format specifiers for all usages of ASSERT_MSG 2018-03-27 23:28:42 +08:00
wwylele
672fbcf37d Memory: remove RasterizerCachedSpecial page type 2018-03-10 01:14:38 +02:00
Weiyi Wang
4befbddc34
Merge pull request #3281 from jroweboy/texcache-pt2
Texture Cache Rework
2018-03-05 11:57:25 +02:00
MerryMage
ab3d53131a audio_core: Remove global state 2018-02-03 15:15:17 +00:00
James Rowe
1c4d1d1ace Move trasnfer_framebuffer to a member of RasterCache. Address review comments 2017-12-23 16:10:32 -07:00
James Rowe
13606a6d0b Memory: Remove count of cached pages and add InvalidateRegion
In a future commit, the count of cached pages will be reintroduced in
the actual surface cache. Also adds an Invalidate only to the cache
which marks a region as invalid in order to try to avoid a costly flush
from 3ds memory
2017-12-23 16:10:25 -07:00
wwylele
8e4e663113 memory: add overload with process parameter for ZeroBlock and CopyBlock 2017-12-07 15:59:54 +02:00
Alexandre Paré
d65983515f Correcting word order of a comment in memory.cpp 2017-10-28 13:23:58 -04:00
Subv
1f2de7501b Memory: Make WriteBlock take a Process parameter on which to operate 2017-10-01 14:18:36 -05:00
Subv
811c01e5fe Memory: Make ReadBlock take a Process parameter on which to operate 2017-10-01 14:18:36 -05:00
Huw Pascoe
a13ab958cb Fixed type conversion ambiguity 2017-09-30 09:34:35 +01:00
bunnei
b07af7dda8 Merge pull request #2961 from Subv/load_titles
Loaders: Don't automatically set the current process every time we load an application.
2017-09-29 14:58:42 -04:00
James Rowe
5620327e03 Merge pull request #2954 from Subv/cache_unmapped_mem
Memory/RasterizerCache: Ignore unmapped memory regions when caching physical regions
2017-09-26 16:55:47 -06:00
Subv
35da7f57ef Memory: Allow IsValidVirtualAddress to be called with a specific process parameter.
There is still an overload of IsValidVirtualAddress that only takes the VAddr and will default to the current process.
2017-09-26 17:27:44 -05:00
Subv
41f6c9f87f Memory/RasterizerCache: Ignore unmapped memory regions when caching physical regions.
Not all physical regions need to be mapped into the address space of every process, for example, system modules do not have a VRAM mapping.

This fixes a crash when loading applets and system modules.
2017-09-25 19:37:45 -05:00
MerryMage
67a70bd9e1 ARM_Interface: Implement PageTableChanged 2017-09-24 23:08:25 +01:00
MerryMage
4e5eb2044a memory: Remove GetCurrentPageTablePointers 2017-09-24 22:43:28 +01:00
MerryMage
c02bbb7030 memory: Add GetCurrentPageTable/SetCurrentPageTable
Don't expose Memory::current_page_table as a global.
2017-09-24 22:42:42 +01:00
B3n30
813837c5cf Merge pull request #2842 from Subv/switchable_page_table
Kernel/Memory: Give each process its own page table and allow switching the current page table upon reschedule
2017-09-15 22:41:45 +02:00
Subv
f18a176b60 Kernel/Memory: Make IsValidPhysicalAddress not go through the current process' virtual memory mapping. 2017-09-15 14:26:18 -05:00
Subv
214150f00c Kernel/Memory: Changed GetPhysicalPointer so that it doesn't go through the current process' page table to obtain a pointer. 2017-09-15 14:26:13 -05:00
Subv
6d2734a074 Kernel/Memory: Give each Process its own page table.
The loader is in charge of setting the newly created process's page table as the main one during the loading process.
2017-09-10 15:13:41 -05:00
danzel
8266064796 Use recursive_mutex instead of mutex to fix #2902 2017-08-29 20:39:55 +12:00
James Rowe
61442d6afb Merge pull request #2839 from Subv/global_kernel_lock
Kernel/HLE: Use a mutex  to synchronize access to the HLE kernel state between the cpu thread and any other possible threads that might touch the kernel (network thread, etc).
2017-08-23 18:17:44 -06:00
Subv
f484927ed0 Kernel/Memory: Acquire the global HLE lock when a memory read/write operation falls outside of the fast path, for it might perform an MMIO operation. 2017-08-22 09:30:58 -05:00
Weiyi Wang
045d0b5bbd Merge pull request #2799 from yuriks/virtual-cached-range-flush
Add address conversion functions returning optional, Add function to flush virtual region from rasterizer cache
2017-07-22 10:15:52 +03:00
Yuri Kunde Schlesner
d553135748 Memory: Add function to flush a virtual range from the rasterizer cache
This is slightly more ergonomic to use, correctly handles virtual
regions which are disjoint in physical addressing space, and checks only
regions which can be cached by the rasterizer.
2017-06-21 22:57:12 -07:00