예제 #1
0
        public static unsafe void Init()
        {
            RuntimeMemory.SetupEarlyStartup();
            InitializAssembly();
            //Mosa.Runtime.StartUp.InitializeRuntimeMetadata();
            RuntimeMemory.SetupAllocator();

            ElfSections = *((ElfSections *)SysCalls.GetElfSectionsAddress());
            ElfSections.Init();
        }
예제 #2
0
        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);
        }
예제 #3
0
        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;
        }
예제 #4
0
        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);
        }
예제 #5
0
 internal static void SetupEarlyStartup()
 {
     initialMemoryNextAddr = SysCalls.RequestMemory(3 * 1024 * 1024);
 }
예제 #6
0
 public static void Write(char c)
 {
     SysCalls.WriteDebugChar(c);
 }
예제 #7
0
 public static void WriteLine()
 {
     SysCalls.WriteDebugChar('\n');
 }
예제 #8
0
 public static void WriteLine(string msg)
 {
     SysCalls.WriteDebugMessage(buf, msg);
     SysCalls.WriteDebugChar('\n');
 }
예제 #9
0
 public static void Write(string msg)
 {
     SysCalls.WriteDebugMessage(buf, msg);
 }
예제 #10
0
        static Console()
        {
            var writeDebugMessageProcID = SysCalls.GetProcessIDForCommand(SysCallTarget.WriteDebugMessage);

            buf = SysCalls.RequestMessageBuffer(4096, writeDebugMessageProcID);
        }
예제 #11
0
 public static unsafe void Exit(int exitCode)
 {
     SysCalls.KillProcess(CurrentProcessID);
 }
예제 #12
0
        public static MemoryAllocation RequestMessageBuffer(int size, int targetProcessID)
        {
            var buf = SysCalls.RequestMessageBuffer((uint)size, targetProcessID);

            return(new MemoryAllocation(buf));
        }