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

Function SysAlloc

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

Source from the content-addressed store, hash-verified

505}
506
507long SysAlloc(regs64_t* r){
508 uint64_t pageCount = SC_ARG0(r);
509 uintptr_t* addressPointer = (uintptr_t*)SC_ARG1(r);
510
511 uintptr_t address = (uintptr_t)Memory::Allocate4KPages(pageCount, Scheduler::GetCurrentProcess()->addressSpace);
512
513 assert(address);
514
515 for(unsigned i = 0; i < pageCount; i++){
516 Memory::MapVirtualMemory4K(Memory::AllocatePhysicalMemoryBlock(),address + i * PAGE_SIZE_4K,1,Scheduler::GetCurrentProcess()->addressSpace);
517 memset((void*)(address + i * PAGE_SIZE_4K), 0, PAGE_SIZE_4K);
518 }
519
520 *addressPointer = address;
521
522 return 0;
523}
524
525long SysChmod(regs64_t* r){
526 return 0;

Callers

nothing calls this directly

Calls 5

Allocate4KPagesFunction · 0.85
GetCurrentProcessFunction · 0.85
MapVirtualMemory4KFunction · 0.85
memsetFunction · 0.85

Tested by

no test coverage detected