| 872 | } |
| 873 | |
| 874 | long 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 | |
| 900 | long SysGrantPTY(regs64_t* r){ |
| 901 | if(!SC_ARG0(r)) return 1; |
nothing calls this directly
no test coverage detected