Exemple #1
0
        public static int ThreadMain(int threadIndex)
        {
            DebugStub.Print("Hello from NullTest::ThreadMain(threadIndex=");
            DebugStub.Print(threadIndex);
            DebugStub.Print(")\n");
#if TEST_STACK_ABI
            Test1(1);
#endif // TEST_STACK_ABI
            DebugStub.Print("Exiting.\n");
            return(998);
        }
Exemple #2
0
 internal static int Test1(int a)
 {
     DebugStub.Print("[Test1. ");
     DebugStub.Print("("); DebugStub.Print(a);
     DebugStub.Print(")\n");
     a = Test2(a, a + 1) + 1;
     DebugStub.Print(".Test1] = ");
     DebugStub.Print(a);
     DebugStub.Print("\n");
     return(a);
 }
Exemple #3
0
        public static int Main(String[] args)
        {
            int  i = 10;
            long l = 100;
            byte b = 1;

            DebugStub.Print("Hello from TestApp.cs\n");
            DebugStub.Print("byte: {0}, int: {1}, long: {2}\n",
                            __arglist(b, i, l));

            return(999);
        }
Exemple #4
0
 internal static int Test2(int a, int b)
 {
     DebugStub.Print("[Test2. ");
     DebugStub.Print("("); DebugStub.Print(a);
     DebugStub.Print(","); DebugStub.Print(b);
     DebugStub.Print(")\n");
     a = Test3(a, a + 1, a + 2) + 1;
     DebugStub.Print(".Test2] = ");
     DebugStub.Print(a);
     DebugStub.Print("\n");
     return(a);
 }
Exemple #5
0
 internal static int Test3(int a, int b, int c)
 {
     DebugStub.Print("[Test3. ");
     DebugStub.Print("("); DebugStub.Print(a);
     DebugStub.Print(","); DebugStub.Print(b);
     DebugStub.Print(","); DebugStub.Print(c);
     DebugStub.Print(")\n");
     a = Test4(a, a + 1, a + 2, a + 3) + 1;
     DebugStub.Print(".Test3] = ");
     DebugStub.Print(a);
     DebugStub.Print("\n");
     return(a);
 }
Exemple #6
0
        public static int Main()
        {
#if TEST_CONSOLE
            int  i = 10;
            long l = 100;
            byte b = 1;
            bool o = true;
#endif
            DebugStub.Print("Hello from NullTest::Main\n");
#if TEST_CONSOLE
            DebugStub.Print(b);
            DebugStub.Print("\n");
            DebugStub.Print(i);
            DebugStub.Print("\n");
            DebugStub.Print(l);
            DebugStub.Print("\n");
            DebugStub.Print(o);
            DebugStub.Print("\n");
#endif

#if TEST_MEMORY_ABI
            uint tag = PageTableService.GetProcessTag();
            DebugStub.Print("Process Tag: ");
            DebugStub.Print((ulong)tag);
            DebugStub.Print("\n");

            uint pages = PageTableService.GetPageCount();
            DebugStub.Print("Pages:       ");
            DebugStub.Print(pages);
            DebugStub.Print("\n");

            uint addr = PageTableService.Allocate(0x1000);
            DebugStub.Print("Allocation:  ");
            DebugStub.Print((ulong)addr);
            DebugStub.Print("\n");

            Probe(addr);

            addr = 1;
            for (i = 0; i < 20 && addr != 0 && addr < 0xc0000000; i++)
            {
                addr = Probe(addr);
            }
#endif // TEST_MEMORY_ABI
#if TEST_STACK_ABI
            Test1(1);
#endif // TEST_STACK_ABI

            return(0);
        }
Exemple #7
0
 internal static int Test4(int a, int b, int c, int d)
 {
     DebugStub.Print("[Test4. ");
     DebugStub.Print("("); DebugStub.Print(a);
     DebugStub.Print(","); DebugStub.Print(b);
     DebugStub.Print(","); DebugStub.Print(c);
     DebugStub.Print(","); DebugStub.Print(d);
     DebugStub.Print(")\n");
     a = Test5(a, a + 1, a + 2, a + 3, a + 4) + 1;
     DebugStub.Print(".Test4] =");
     DebugStub.Print(a);
     DebugStub.Print("\n");
     return(a);
 }
Exemple #8
0
        internal static int MpMain(int cpu)
        {
            Tracing.Log(Tracing.Audit, "processor");
            Processor processor = Processor.EnableProcessor(cpu);

            // Initialize dispatcher
            Processor.InitializeDispatcher(cpu);

            // Initialize the HAL processor services
            // Note that this must occur after EnableProcessor, as the kernel
            // thread does not get bound until then. (It gets bound much
            // earlier in the boot processor case -- need to decide if this difference is
            // really appropriate.)
            Platform.Cpu(cpu).InitializeServices();

            Platform.InitializeHal(processor);

            Thread.CurrentThread.Affinity = cpu;

            Processor.ActivateTimer(cpu);

#if DEBUG_SYSTEM_LOCKUP
            // Spin one CPU on debugger. For instance with a quad-proc
            // box, spin CPU 3.
            while (cpu == 3)
            {
                if (DebugStub.PollForBreak() == true)
                {
                    DebugStub.Break();
                }
            }
#endif // DEBUG_SYSTEM_LOCKUP

            Processor.RestoreInterrupts(true);

            Tracing.Log(Tracing.Audit,
                        "Looping in processor's kernel thread.");
            //while (cpu > 0) {
            //    Thread.Yield();
            //}

            // This probably won't be the
            // ultimate way of dissociating kernel entry threads
            // from the kernel.
            DebugStub.Print("AP Processor started, about to wait\n");
            mpEndEvent.WaitOne();

            return(0);
        }
Exemple #9
0
 internal static int Test5(int a, int b, int c, int d, int e)
 {
     DebugStub.Print("[Test5. ");
     DebugStub.Print("("); DebugStub.Print(a);
     DebugStub.Print(","); DebugStub.Print(b);
     DebugStub.Print(","); DebugStub.Print(c);
     DebugStub.Print(","); DebugStub.Print(d);
     DebugStub.Print(","); DebugStub.Print(e);
     DebugStub.Print(")\n");
     a = Test6(a, a + 1, a + 2, a + 3, a + 4, a + 5) + 1;
     DebugStub.Print(".Test5] = ");
     DebugStub.Print(a);
     DebugStub.Print("\n");
     return(a);
 }
Exemple #10
0
 internal static int Test6(int a, int b, int c, int d, int e, int f)
 {
     DebugStub.Print("[Test6. ");
     DebugStub.Print("("); DebugStub.Print(a);
     DebugStub.Print(","); DebugStub.Print(b);
     DebugStub.Print(","); DebugStub.Print(c);
     DebugStub.Print(","); DebugStub.Print(d);
     DebugStub.Print(","); DebugStub.Print(e);
     DebugStub.Print(","); DebugStub.Print(f);
     DebugStub.Print(")\n");
     a = a + 100;
     DebugStub.WalkStack();
     DebugStub.Print(".Test6] = ");
     DebugStub.Print(a);
     DebugStub.Print("\n");
     return(a);
 }
Exemple #11
0
        public static uint Probe(uint addr)
        {
            uint begin;
            uint bytes;
            bool used = PageTableService.Query(addr, out begin, out bytes);

            DebugStub.Print("   ");
            DebugStub.Print((ulong)begin);
            DebugStub.Print("..");
            DebugStub.Print((ulong)begin + bytes);
            DebugStub.Print("  ");
            if (used)
            {
                DebugStub.Print("[used]");
            }
            DebugStub.Print("\n");
            return(begin + bytes);
        }
Exemple #12
0
        private static void InitServices()
        {
            InitGCSupport();
            args = GetCommandLine();
            VTable.ParseArgs(args);

            ARM_PROGRESS("Kernel!011");
            InitSchedulerTypes();

            ARM_PROGRESS("Kernel!018");
            Controller.InitializeSystem();
            Tracing.InitializeSystem();

            ARM_PROGRESS("Kernel!019");
            //  Read the profiler settings. The values are assumed in kbytes
            //  convert them to bytes for direct consumption
            ProfilerBufferSize  = (uint)GetIntegerArgument("profiler", 0);
            ProfilerBufferSize *= 1024;

            ARM_PROGRESS("Kernel!020");

            SpinLock.StaticInitialize();

            int cpusLength;
            int cpuCount = GetCpuCount(out cpusLength);

            Processor.InitializeProcessorTable(cpusLength);
            ARM_PROGRESS("Kernel!021");
            Tracing.Log(Tracing.Audit, "processor");
            Processor processor = Processor.EnableProcessor(0);

            PEImage.Initialize();
            ARM_PROGRESS("Kernel!034");

            //  Initialize the sample profiling for the processor
            //  after the initial breakpoint in kd in the call
            //  PEImage.Initialize(). This will allow enabling profiling
            //  from kd, by overwriting the ProfilerBufferSize value
            processor.EnableProfiling();
            ARM_PROGRESS("Kernel!035");
            FlatPages.InitializeMemoryMonitoring();

            // initialize endpoints
            InitType(typeof(Microsoft.Singularity.Channels.EndpointCore));

            // TODO Bug 59: Currently broken, need to review paging build.
//#if PAGING
//            Microsoft.Singularity.Channels.EndpointTrusted.StaticInitialize();
//#endif
            ARM_PROGRESS("Kernel!036");

            // get the system manifest
            IoMemory systemManifest = GetSystemManifest();

            ARM_PROGRESS("Kernel!037");
            XmlReader xmlReader    = new XmlReader(systemManifest);
            XmlNode   xmlData      = xmlReader.Parse();
            XmlNode   manifestRoot = xmlData.GetChild("system");
            XmlNode   initConfig   = manifestRoot.GetChild("initConfig");

            ARM_PROGRESS("Kernel!038");

            PerfCounters.Initialize();
            // need to have processed the manifest before we can call Process initialize
            ARM_PROGRESS("Kernel!039");
            PrincipalImpl.Initialize(initConfig);

            ARM_PROGRESS("Kernel!040");
            Process.Initialize(manifestRoot.GetChild("processConfig"));

            InitIO(processor, initConfig, manifestRoot.GetChild("drivers"));

            InitBootTime();

            ARM_PROGRESS("Kernel!045");
            // From here on, we want lazy type initialization to worry about
            // competing threads.
            VTable.InitializeForMultipleThread();

            ARM_PROGRESS("Kernel!046");
            Console.WriteLine("Running C# Kernel of {0}", GetLinkDate());
            Console.WriteLine();

            // TODO: remove this
            Console.WriteLine("Current time: {0}", SystemClock.GetUtcTime().ToString("r"));
            ARM_PROGRESS("Kernel!047");

            InitScheduling();

            DirectoryService.StartNotificationThread();

            Console.WriteLine("Initializing Shared Heap Walker");
            ProtectionDomain.InitializeSharedHeapWalker();
            ARM_PROGRESS("Kernel!050");

            Console.WriteLine("Initializing Service Thread");
            ServiceThread.Initialize();
            ARM_PROGRESS("Kernel!051");

            GC.EnableHeap();
            GCProfilerLogger.StartProfiling();
            ARM_PROGRESS("Kernel!052");

            Tracing.Log(Tracing.Audit, "Waypoints init");
            Waypoints   = new long[2048];
            WaypointSeq = new int[2048];
            WaypointThd = new int[2048];

            Tracing.Log(Tracing.Audit, "Interrupts ON.");
            Processor.RestoreInterrupts(true);
            ARM_PROGRESS("Kernel!053");

#if ISA_ARM && TEST_GC
            for (int i = 0; i < 1000; i++)
            {
                DebugStub.WriteLine("Iteration {0}", __arglist(i));
                ArrayList a = new ArrayList();
                for (int j = 0; j < 128; j++)
                {
                    int size = 1024 * 1024;
                    a.Add(new byte [size]);
                }
            }
#endif // ISA_ARM

            ARM_PROGRESS("Kernel!054");

            Tracing.Log(Tracing.Audit, "Binder");
            Binder.Initialize(manifestRoot.GetChild("namingConventions"));

#if ISA_ARM
            DebugStub.WriteLine("Exporting local namespace to BSP\n");
            DirectoryService.ExportArmNamespace();
            DebugStub.WriteLine("Export complete...redirecting binder\n");
            Binder.RedirectRootRef();
            DebugStub.WriteLine("Binder redirect complete\n");
#endif

#if false
            Tracing.Log(Tracing.Audit, "Starting Security Service channels");
            PrincipalImpl.Export();
            ARM_PROGRESS("Kernel!055");
#endif
            Tracing.Log(Tracing.Audit, "Creating Root Directory.");

            //This can be moved below
            IoSystem.InitializeDirectoryService();
            ARM_PROGRESS("Kernel!055");

#if false
            // Start User space namespace manager
            Console.WriteLine("Starting Directory Service SIP");
            DirectoryService.StartUserSpaceDirectoryService();
#endif
            ARM_PROGRESS("Kernel!055.5");

#if !ISA_ARM
            Tracing.Log(Tracing.Audit, "Starting Security Service channels");
            PrincipalImpl.Export();
#endif

            ARM_PROGRESS("Kernel!056");

            Console.WriteLine("Initializing system channels");

            // starting channels services
            DebugStub.Print("Initializing Channel Services\n");
            ChannelDeliveryImplService.Initialize();

            ARM_PROGRESS("Kernel!057");
            ConsoleOutput.Initialize();

            ARM_PROGRESS("Kernel!058");

            // Initialize MP after Binder and ConsoleOutput
            // are initialized so there are no
            // initialization races if the additional
            // threads try to use them.
            Tracing.Log(Tracing.Audit, "Starting additional processors");

            // For ABI to ARM support
            MpExecution.Initialize();
            ARM_PROGRESS("Kernel!059");

            mpEndEvent = new ManualResetEvent(false);

            Tracing.Log(Tracing.Audit, "Initializing Volume Manager.");

#if !ISA_ARM
            IoSystem.InitializeVolumeManager();
#endif // ISA_ARM
            ARM_PROGRESS("Kernel!060");

            InitDrivers();

            if (cpuCount > 1)
            {
                unsafe {
                    Console.WriteLine("Enabling {0} cpus out of {1} real cpus\n", cpuCount, Platform.ThePlatform.CpuRealCount);
                }
                Processor.EnableMoreProcessors(cpuCount);
                ARM_PROGRESS("Kernel!064");
            }

            Tracing.Log(Tracing.Audit, "Initializing Service Manager.");
            IoSystem.InitializeServiceManager(manifestRoot.GetChild("serviceConfig"));
            ARM_PROGRESS("Kernel!065");

            InitDiagnostics();

#if !ISA_ARM
            // At this point consider kernel finshed booting
            hasBooted = true;
#endif // ISA_ARM

            Processor.StartSampling();
            ARM_PROGRESS("Kernel!069");

            Microsoft.Singularity.KernelDebugger.KdFilesNamespace.StartNamespaceThread();
            ARM_PROGRESS("Kernel!070");
        }