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

Function SysMmap

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

Source from the content-addressed store, hash-verified

872}
873
874long SysMmap(regs64_t* r){
875 uint64_t* address = (uint64_t*)SC_ARG0(r);
876 size_t count = SC_ARG1(r);
877 uintptr_t hint = SC_ARG2(r);
878
879 uintptr_t _address;
880 if(hint){
881 if(Memory::CheckRegion(hint, count * PAGE_SIZE_4K, Scheduler::GetCurrentProcess()->addressSpace) /*Check availibilty of the requested map*/){
882 _address = hint;
883 } else {
884 Log::Warning("sys_mmap: Could not map to address %x", hint);
885 *address = 0;
886 return 1;
887 }
888 } else _address = (uintptr_t)Memory::Allocate4KPages(count, Scheduler::GetCurrentProcess()->addressSpace);
889
890 for(size_t i = 0; i < count; i++){
891 Memory::MapVirtualMemory4K(Memory::AllocatePhysicalMemoryBlock(), _address + i * PAGE_SIZE_4K, 1, Scheduler::GetCurrentProcess()->addressSpace);
892 memset((void*)(_address + i * PAGE_SIZE_4K), 0, PAGE_SIZE_4K);
893 }
894
895 *address = _address;
896
897 return 0;
898}
899
900long SysGrantPTY(regs64_t* r){
901 if(!SC_ARG0(r)) return 1;

Callers

nothing calls this directly

Calls 7

CheckRegionFunction · 0.85
GetCurrentProcessFunction · 0.85
WarningFunction · 0.85
Allocate4KPagesFunction · 0.85
MapVirtualMemory4KFunction · 0.85
memsetFunction · 0.85

Tested by

no test coverage detected