MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / allocPages

Method allocPages

source/emulation/softmmu/kmemory_soft.cpp:126–158  ·  view source on GitHub ↗

don't need to add a mutex, memory->mutex should be locked when call except for construction and execv (which should only have 1 thread)

Source from the content-addressed store, hash-verified

124
125// don't need to add a mutex, memory->mutex should be locked when call except for construction and execv (which should only have 1 thread)
126void KMemoryData::allocPages(KThread* thread, U32 page, U32 pageCount, U8 permissions, FD fd, U64 offset, const std::shared_ptr<MappedFile>& mappedFile, const RamPage* ramPages) {
127#ifdef _DEBUG
128 if (page + pageCount >= K_NUMBER_OF_PAGES) {
129 kpanic("KMemoryData::allocPages page out of bound");
130 }
131 if (mappedFile && ramPages) {
132 kpanic("KMemoryData::allocPages mapped files should not contain ramPages");
133 }
134#endif
135 if (ramPages) {
136 for (U32 i = 0; i < pageCount; i++) {
137 mmu[page + i].setFlags(permissions);
138 this->mmu[page + i].setPage(memory, page + i, PageType::Ram, ramPages[i]);
139 onPageChanged(page + i);
140 }
141 } else if (mappedFile) {
142 if (offset & K_PAGE_MASK) {
143 kpanic("mmap: wasn't expecting the offset to be in the middle of a page");
144 }
145
146 for (U32 i = 0; i < pageCount; i++) {
147 mmu[page + i].setFlags(permissions);
148 this->mmu[page + i].setPage(memory, page + i, PageType::File, (RamPage)mappedFile->key);
149 onPageChanged(page + i);
150 }
151 } else {
152 for (U32 i = 0; i < pageCount; i++) {
153 mmu[page + i].setFlags(permissions);
154 this->mmu[page + i].setPage(memory, page + i, PageType::Ram, (RamPage)0);
155 onPageChanged(page + i);
156 }
157 }
158}
159
160bool isAlignedNativePage(U32 page) {
161 U32 gran = Platform::getPageAllocationGranularity();

Callers 4

KMemoryDataMethod · 0.95
execvResetMethod · 0.95
mmapMethod · 0.80
mapPagesMethod · 0.80

Calls 3

kpanicFunction · 0.85
setPageMethod · 0.80
setFlagsMethod · 0.45

Tested by

no test coverage detected