示例#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));
        }