Ejemplo n.º 1
0
        /// <summary>
        /// Main
        /// </summary>
        public static void Main()
        {
            Kernel.x86.Kernel.Setup();

            Console = ConsoleManager.Controller.Boot;
            Console.Clear();

            Serial.SetupPort(Serial.COM1);
            IDT.SetInterruptHandler(ProcessInterrupt);

            hal = new Hardware();

            // 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();

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

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

            DeviceService.RegisterDeviceDriver(DeviceDriver.Setup.GetDeviceDriverRegistryEntries());
            DeviceService.Initialize(new X86System(), null);

            partitionService.CreatePartitionDevices();
            var partitions = DeviceService.GetDevices <IPartitionDevice>();

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

                if (hasFS)
                {
                    var location = fat.FindEntry("WALLP.BMP");

                    if (location.IsValid)
                    {
                        var fatFileStream = new FatFileStream(fat, location);
                        var _wall         = new byte[(uint)fatFileStream.Length];

                        for (int k = 0; k < _wall.Length; k++)
                        {
                            _wall[k] = (byte)(char)fatFileStream.ReadByte();
                        }

                        wallpaper = new Bitmap(_wall);
                    }
                }
            }

            var standardMice = DeviceService.GetDevices("StandardMouse");

            if (standardMice.Count == 0)
            {
                hal.Pause();
                hal.Abort("Catastrophic failure, mouse and/or PIT not found.");
            }

            mouse = standardMice[0].DeviceDriver as StandardMouse;
            mouse.SetScreenResolution(VBE.ScreenWidth, VBE.ScreenHeight);

            if (VBEDisplay.InitVBE(hal))
            {
                Log("VBE setup OK!");
                DoGraphics();
            }
            else
            {
                Log("VBE setup ERROR!");
            }
        }