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

Method lockReadOnlyMemory

source/kernel/kmemory.cpp:661–679  ·  view source on GitHub ↗

This doesn't mean the data can't be changed by another thread, it just means the pointer will stay valid

Source from the content-addressed store, hash-verified

659
660// This doesn't mean the data can't be changed by another thread, it just means the pointer will stay valid
661U8* KMemory::lockReadOnlyMemory(U32 address, U32 len) {
662 U32 pageIndex = address >> K_PAGE_SHIFT;
663 Page* page = data->getPage(pageIndex);
664 U32 offset = address & K_PAGE_MASK;
665
666 // if we cross a page boundry then we will need to make a copy
667 if (len <= K_PAGE_SIZE - offset) {
668 return page->getRamPtr(&data->mmu[pageIndex], pageIndex, false, true, offset, len);
669 }
670 std::shared_ptr<LockedMemory> p = std::make_shared<LockedMemory>();
671 p->p = new U8[len];
672 p->len = len;
673 p->address = address;
674 p->readOnly = true;
675 memcpy(p->p, address, len);
676 BOXEDWINE_CRITICAL_SECTION_WITH_MUTEX(lockedMemoryMutex);
677 lockedMemory.set(p->p, p);
678 return p->p;
679}
680
681void KMemory::unlockMemory(U8* lockedPointer) {
682 BOXEDWINE_CRITICAL_SECTION_WITH_MUTEX(lockedMemoryMutex);

Callers 15

vk_ResetFencesFunction · 0.80
vk_WaitForFencesFunction · 0.80
vk_MergePipelineCachesFunction · 0.80
vk_FreeDescriptorSetsFunction · 0.80
vk_CmdSetBlendConstantsFunction · 0.80
vk_CmdBindDescriptorSetsFunction · 0.80
vk_CmdBindVertexBuffersFunction · 0.80
vk_CmdUpdateBufferFunction · 0.80
vk_CmdWaitEventsFunction · 0.80
vk_CmdPushConstantsFunction · 0.80

Calls 4

memcpyFunction · 0.85
getPageMethod · 0.45
getRamPtrMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected