public static unsafe void Init() { RuntimeMemory.SetupEarlyStartup(); InitializAssembly(); //Mosa.Runtime.StartUp.InitializeRuntimeMetadata(); RuntimeMemory.SetupAllocator(); ElfSections = *((ElfSections *)SysCalls.GetElfSectionsAddress()); ElfSections.Init(); }
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); }
public static void Write(char c) { SysCalls.WriteDebugChar(c); }
public static void WriteLine() { SysCalls.WriteDebugChar('\n'); }
public static void WriteLine(string msg) { SysCalls.WriteDebugMessage(buf, msg); SysCalls.WriteDebugChar('\n'); }
public static void Write(string msg) { SysCalls.WriteDebugMessage(buf, msg); }
static Console() { var writeDebugMessageProcID = SysCalls.GetProcessIDForCommand(SysCallTarget.WriteDebugMessage); buf = SysCalls.RequestMessageBuffer(4096, writeDebugMessageProcID); }
public static unsafe void Exit(int exitCode) { SysCalls.KillProcess(CurrentProcessID); }
public static MemoryAllocation RequestMessageBuffer(int size, int targetProcessID) { var buf = SysCalls.RequestMessageBuffer((uint)size, targetProcessID); return(new MemoryAllocation(buf)); }