Exemple #1
0
        public void TotalStorage_0_Users()
        {
            A.CallTo(() => _pcRep.GetAllUserPCs(A <int> .Ignored)).Returns(
                new List <PC> ()
                );

            var pcService = new PCService(_pcRep);

            Assert.AreEqual(0, pcService.GetTotalStorage(1));
        }
Exemple #2
0
 private void tsmPCService_Click(object sender, EventArgs e)
 {
     if (!CheckExistForm("PCService"))
     {
         PCService frmPCService = new PCService();
         frmPCService.MdiParent = this;
         frmPCService.Show();
     }
     else
     {
         ActiveChildForm("PCService");
     }
 }
Exemple #3
0
        public void TotalStorage_1_User_100_GB()
        {
            var userPcs = new List <PC>();

            userPcs.Add(new PC {
                GB_Storage = 100
            });

            A.CallTo(() => _pcRep.GetAllUserPCs(A <int> .Ignored)).Returns(
                userPcs
                );

            var pcService = new PCService(_pcRep);

            Assert.AreEqual(100, pcService.GetTotalStorage(1));
        }
Exemple #4
0
        /// <summary>
        /// Main
        /// </summary>
        public static void Main()
        {
            Kernel.x86.Kernel.Setup();

            Console = ConsoleManager.Controller.Boot;

            Console.Clear();
            Console.Goto(0, 0);
            Console.ScrollRow       = 23;
            Console.Color           = ScreenColor.White;
            Console.BackgroundColor = ScreenColor.Green;

            Debug = ConsoleManager.Controller.Debug;

            Console.Write("                   MOSA OS Version 2.2 - Compiler Version 2.2");
            FillLine();
            Console.Color           = ScreenColor.White;
            Console.BackgroundColor = ScreenColor.Black;

            Console.WriteLine("> Initializing services...");

            // Create Service manager and basic services
            var serviceManager = new ServiceManager();

            DeviceService = new DeviceService();

            var diskDeviceService    = new DiskDeviceService();
            var partitionService     = new PartitionService();
            var pciControllerService = new PCIControllerService();
            var pciDeviceService     = new PCIDeviceService();
            var pcService            = new PCService();

            serviceManager.AddService(DeviceService);
            serviceManager.AddService(diskDeviceService);
            serviceManager.AddService(partitionService);
            serviceManager.AddService(pciControllerService);
            serviceManager.AddService(pciDeviceService);
            serviceManager.AddService(pcService);

            Console.WriteLine("> Initializing hardware abstraction layer...");

            // Set device driver system with the hardware HAL
            var hardware = new HAL.Hardware();

            DeviceSystem.Setup.Initialize(hardware, DeviceService.ProcessInterrupt);

            Console.WriteLine("> Registering device drivers...");
            DeviceService.RegisterDeviceDriver(DeviceDriver.Setup.GetDeviceDriverRegistryEntries());

            Console.WriteLine("> Starting devices...");

            DeviceService.Initialize(new X86System(), null);

            var acpi = DeviceService.GetFirstDevice <IACPI>().DeviceDriver as IACPI;

            // Setup APIC
            var localApic = Mosa.DeviceSystem.HAL.GetPhysicalMemory((Pointer)acpi.LocalApicAddress, 0xFFFF).Address;
            var ioApic    = Mosa.DeviceSystem.HAL.GetPhysicalMemory((Pointer)acpi.IOApicAddress, 0xFFFF).Address;

            APIC.Setup(localApic, ioApic);

            Console.Write("> Probing for ISA devices...");
            var isaDevices = DeviceService.GetChildrenOf(DeviceService.GetFirstDevice <ISABus>());

            Console.WriteLine("[Completed: " + isaDevices.Count.ToString() + " found]");

            foreach (var device in isaDevices)
            {
                Console.Write("  ");
                Bullet(ScreenColor.Yellow);
                Console.Write(" ");
                InBrackets(device.Name, ScreenColor.White, ScreenColor.Green);
                Console.WriteLine();
            }

            Console.Write("> Probing for PCI devices...");
            var devices = DeviceService.GetDevices <PCIDevice>();

            Console.WriteLine("[Completed: " + devices.Count.ToString() + " found]");

            foreach (var device in devices)
            {
                Console.Write("  ");
                Bullet(ScreenColor.Yellow);
                Console.Write(" ");

                var pciDevice = device.DeviceDriver as PCIDevice;
                InBrackets(device.Name + ": " + pciDevice.VendorID.ToString("x") + ":" + pciDevice.DeviceID.ToString("x") + " " + pciDevice.SubSystemID.ToString("x") + ":" + pciDevice.SubSystemVendorID.ToString("x") + " (" + pciDevice.ClassCode.ToString("x") + ":" + pciDevice.SubClassCode.ToString("x") + ":" + pciDevice.ProgIF.ToString("x") + ":" + pciDevice.RevisionID.ToString("x") + ")", ScreenColor.White, ScreenColor.Green);

                var children = DeviceService.GetChildrenOf(device);

                if (children.Count != 0)
                {
                    var child = children[0];

                    Console.WriteLine();
                    Console.Write("    ");

                    var pciDevice2 = child.DeviceDriver as PCIDevice;
                    InBrackets(child.Name, ScreenColor.White, ScreenColor.Green);
                }

                Console.WriteLine();
            }

            Console.Write("> Probing for disk controllers...");
            var diskcontrollers = DeviceService.GetDevices <IDiskControllerDevice>();

            Console.WriteLine("[Completed: " + diskcontrollers.Count.ToString() + " found]");

            foreach (var device in diskcontrollers)
            {
                Console.Write("  ");
                Bullet(ScreenColor.Yellow);
                Console.Write(" ");
                InBrackets(device.Name, ScreenColor.White, ScreenColor.Green);
                Console.WriteLine();
            }

            Console.Write("> Probing for disks...");
            var disks = DeviceService.GetDevices <IDiskDevice>();

            Console.WriteLine("[Completed: " + disks.Count.ToString() + " found]");

            foreach (var disk in disks)
            {
                Console.Write("  ");
                Bullet(ScreenColor.Yellow);
                Console.Write(" ");
                InBrackets(disk.Name, ScreenColor.White, ScreenColor.Green);
                Console.Write(" " + (disk.DeviceDriver as IDiskDevice).TotalBlocks.ToString() + " blocks");
                Console.WriteLine();
            }

            partitionService.CreatePartitionDevices();

            Console.Write("> Finding partitions...");
            var partitions = DeviceService.GetDevices <IPartitionDevice>();

            Console.WriteLine("[Completed: " + partitions.Count.ToString() + " found]");

            //foreach (var partition in partitions)
            //{
            //	Console.Write("  ");
            //	Bullet(ScreenColor.Yellow);
            //	Console.Write(" ");
            //	InBrackets(partition.Name, ScreenColor.White, ScreenColor.Green);
            //	Console.Write(" " + (partition.DeviceDriver as IPartitionDevice).BlockCount.ToString() + " blocks");
            //	Console.WriteLine();
            //}

            Console.Write("> Finding file systems...");

            foreach (var partition in partitions)
            {
                var fat = new FatFileSystem(partition.DeviceDriver as IPartitionDevice);

                if (fat.IsValid)
                {
                    Console.WriteLine("Found a FAT file system!");

                    const string filename = "TEST.TXT";

                    var location = fat.FindEntry(filename);

                    if (location.IsValid)
                    {
                        Console.Write("Found: " + filename);

                        var fatFileStream = new FatFileStream(fat, location);

                        uint len = (uint)fatFileStream.Length;

                        Console.WriteLine(" - Length: " + len.ToString() + " bytes");

                        Console.Write("Reading File: ");

                        for (; ;)
                        {
                            int i = fatFileStream.ReadByte();

                            if (i < 0)
                            {
                                break;
                            }

                            Console.Write((char)i);
                        }

                        Console.WriteLine();
                    }

                    const string bmpname = "WALLP.BMP";

                    var bmploc = fat.FindEntry(bmpname);

                    if (bmploc.IsValid)
                    {
                        Console.Write("Found: " + bmpname);

                        var fatFileStream = new FatFileStream(fat, bmploc);

                        uint len = (uint)fatFileStream.Length;

                        Console.WriteLine(" - Length: " + len.ToString() + " bytes");
                        Console.WriteLine();
                    }
                }
            }

            // Get StandardKeyboard
            var keyboards = DeviceService.GetDevices("StandardKeyboard");

            if (keyboards.Count == 0)
            {
                Console.WriteLine("No Keyboard!");
                ForeverLoop();
            }

            var stdKeyboard = keyboards[0].DeviceDriver as IKeyboardDevice;

            // setup keymap
            var keymap = new US();

            // setup keyboard (state machine)
            var keyboard = new DeviceSystem.Keyboard(stdKeyboard, keymap);

            // setup app manager
            var manager = new AppManager(Console, keyboard, serviceManager);

            IDT.SetInterruptHandler(manager.ProcessInterrupt);

            Logger.Log("<SELFTEST:PASSED>");

            manager.Start();
        }