private static unsafe void InitCurrentThread() { var tls = (ThreadLocalStorageBlock *)SysCalls.RequestMemory(4096); tls->ThreadID = SysCalls.GetCurrentThreadID(); var th = new Thread(tls); tls->ThreadPtr = (uint)(void *)Intrinsic.GetObjectAddress(th); SysCalls.SetThreadStorageSegmentBase(tls->ThreadPtr); }
internal static unsafe void SetupAllocator() { Allocator = new RuntimeAllocator(); var ptr = (byte *)SysCalls.RequestMemory(KMath.AlignValueCeil(Allocator.headSize, 4096)); for (var i = 0; i < Allocator.headSize; i++) { *(ptr + i) = 0; // TODO: Optimize } Allocator.List_heads = (malloc_meta **)ptr; AllocatorInitialized = true; }
protected override void *mmap(uint unknown, uint flags, size_t pages) { var bytes = pages * 4096; var ptr = (byte *)SysCalls.RequestMemory(bytes); //KernelMessage.WriteLine("mmap: Pages: {0}, Addr: {1:X8}", pages, (uint)ptr); for (var i = 0; i < bytes; i++) { *(ptr + i) = 0; } return(ptr); }
internal static void SetupEarlyStartup() { initialMemoryNextAddr = SysCalls.RequestMemory(3 * 1024 * 1024); }