MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / SysUnmapSharedMemory

Function SysUnmapSharedMemory

Kernel/src/arch/x86_64/syscalls.cpp:1109–1126  ·  view source on GitHub ↗

* SysUnmapSharedMemory (address, key) - Map Shared Memory * address - address of mapped memory * key - Memory key * * On Success - return 0 * On Failure - return -1 */

Source from the content-addressed store, hash-verified

1107 * On Failure - return -1
1108 */
1109long SysUnmapSharedMemory(regs64_t* r){
1110 uint64_t address = SC_ARG0(r);
1111 int64_t key = SC_ARG1(r);
1112
1113 shared_mem_t* sMem = Memory::GetSharedMemory(key);
1114 if(!sMem) return -1;
1115
1116 if(!Memory::CheckRegion(address, sMem->pgCount * PAGE_SIZE_4K, Scheduler::GetCurrentProcess()->addressSpace)) // Make sure the process is not screwing with kernel memory
1117 return -1;
1118
1119 Memory::Free4KPages((void*)address, sMem->pgCount, Scheduler::GetCurrentProcess()->addressSpace);
1120
1121 sMem->mapCount--;
1122
1123 Memory::DestroySharedMemory(key); // Active shared memory will not be destroyed and this will return
1124
1125 return 0;
1126}
1127
1128/*
1129 * SysDestroySharedMemory (key) - Destroy Shared Memory

Callers

nothing calls this directly

Calls 5

GetSharedMemoryFunction · 0.85
CheckRegionFunction · 0.85
GetCurrentProcessFunction · 0.85
Free4KPagesFunction · 0.85
DestroySharedMemoryFunction · 0.50

Tested by

no test coverage detected