Exemplo n.º 1
0
        public void SystemInformation_BootMode_Get_ReturnsExpected()
        {
            BootMode bootMode = SystemInformation.BootMode;

            Assert.True(Enum.IsDefined(typeof(BootMode), bootMode));
            Assert.Equal(bootMode, SystemInformation.BootMode);
        }
Exemplo n.º 2
0
        public static String GetFriendlyName(this BootMode bootMode)
        {
            switch (bootMode)
            {
            case BootMode.HLE_IPL: return("High-Level PIF Bootstrap");

            case BootMode.IPL_ROM: return("Real PIF Bootstrap");

            default: return("Unknown Bootmode!");
            }
        }
Exemplo n.º 3
0
 public BootControlSheeva()
 {
     if (File.Exists(kBootModeFile))
     {
         string btMode = File.ReadAllText(kBootModeFile).Trim();
         iCurrentBootMode = btMode.Equals("0") ? BootMode.eRfs0 : BootMode.eRfs1;
     }
     else
     {
         iCurrentBootMode = Pending;
         File.WriteAllText(kBootModeFile, (iCurrentBootMode == BootMode.eRfs0) ? "0\n" : "1\n");
     }
 }
Exemplo n.º 4
0
        public static string StringOf(this BootMode x)
        {
            switch (x)
            {
            case BootMode.BIOS_BOOT:
                return(Messages.BIOS_BOOT);

            case BootMode.UEFI_BOOT:
                return(Messages.UEFI_BOOT);

            case BootMode.UEFI_SECURE_BOOT:
                return(Messages.UEFI_SECURE_BOOT);

            default:
                return(Messages.UNAVAILABLE);
            }
        }
Exemplo n.º 5
0
        public static string StringOf(this BootMode x)
        {
            switch (x)
            {
            case BootMode.BIOS_BOOT:
                return("BIOS Boot");

            case BootMode.UEFI_BOOT:
                return("UEFI Boot");

            case BootMode.UEFI_SECURE_BOOT:
                return("UEFI Secure Boot");

            default:
                return("Not Available");
            }
        }
Exemplo n.º 6
0
 public int BootFunctions(BootMode flag)
 {
     return(shutdown((int)flag));
 }
Exemplo n.º 7
0
        public CreateVMAction(IXenConnection connection, VM template, Host copyBiosStringsFrom,
                              string name, string description, InstallMethod installMethod,
                              string pvArgs, VDI cd, string url, BootMode bootMode, Host homeServer, long vcpusMax, long vcpusAtStartup,
                              long memoryDynamicMin, long memoryDynamicMax, long memoryStaticMax,
                              List <DiskDescription> disks, SR fullCopySR, List <VIF> vifs, bool startAfter,
                              Action <VM, bool> warningDialogHAInvalidConfig,
                              Action <VMStartAbstractAction, Failure> startDiagnosisForm,
                              GPU_group gpuGroup, VGPU_type vgpuType, bool modifyVgpuSettings, long coresPerSocket, string cloudConfigDriveTemplateText)
            : base(connection, string.Format(Messages.CREATE_VM, name),
                   string.Format(Messages.CREATE_VM_FROM_TEMPLATE, name, Helpers.GetName(template)))
        {
            Template            = template;
            CopyBiosStringsFrom = copyBiosStringsFrom;
            FullCopySR          = fullCopySR;
            NameLabel           = name;
            NameDescription     = description;
            InsMethod           = installMethod;
            PvArgs           = pvArgs;
            Cd               = cd;
            Url              = url;
            BootMode         = bootMode;
            HomeServer       = homeServer;
            VcpusMax         = vcpusMax;
            VcpusAtStartup   = vcpusAtStartup;
            MemoryDynamicMin = memoryDynamicMin;
            MemoryDynamicMax = memoryDynamicMax;
            MemoryStaticMax  = memoryStaticMax;
            Disks            = disks;
            Vifs             = vifs;
            StartAfter       = startAfter;
            _warningDialogHAInvalidConfig = warningDialogHAInvalidConfig;
            _startDiagnosisForm           = startDiagnosisForm;
            GpuGroup       = gpuGroup;
            VgpuType       = vgpuType;
            CoresPerSocket = coresPerSocket;
            this.cloudConfigDriveTemplateText = cloudConfigDriveTemplateText;

            Pool pool_of_one = Helpers.GetPoolOfOne(Connection);

            if (HomeServer != null || pool_of_one != null) // otherwise we have no where to put the action
            {
                AppliesTo.Add(HomeServer != null ? HomeServer.opaque_ref : pool_of_one.opaque_ref);
            }

            assignOrRemoveVgpu = GpuGroup != null && VgpuType != null || modifyVgpuSettings && Helpers.GpuCapability(Connection);

            #region RBAC Dependencies

            if (StartAfter)
            {
                ApiMethodsToRoleCheck.Add("vm.start");
            }
            if (HomeServerChanged())
            {
                ApiMethodsToRoleCheck.Add("vm.set_affinity");
            }
            if (Template.memory_dynamic_min != MemoryDynamicMin || Template.memory_dynamic_max != MemoryDynamicMax || Template.memory_static_max != MemoryStaticMax)
            {
                ApiMethodsToRoleCheck.Add("vm.set_memory_limits");
            }

            if (assignOrRemoveVgpu)
            {
                ApiMethodsToRoleCheck.Add("VGPU.destroy");
                ApiMethodsToRoleCheck.Add("VGPU.create");
            }

            ApiMethodsToRoleCheck.AddRange(StaticRBACDependencies);

            ApiMethodsToRoleCheck.AddRange(Role.CommonTaskApiList);
            ApiMethodsToRoleCheck.AddRange(Role.CommonSessionApiList);

            #endregion
        }
Exemplo n.º 8
0
        public static void SetupExecutionState(BootMode bootMode)
        {
            if (bootMode == BootMode.IPL_ROM)
            {
                throw new InvalidOperationException("Low-level IPL booting not supported yet");

                //Machine.Current.RCP.State.PC = 0x1FC00000;

                /* TODO:
                 * Schedule CPU and RCP threads to execute MIPS Interpreter
                 * Have CPU sit idle, and RCP execute the PIF Rom
                 * */
            }
            else if (bootMode == BootMode.HLE_IPL)
            {
                if (Machine.Current.DeviceRCP.DevicePI.InsertedCartridge != null)
                {
                    /* Code taken from mupen64plus-core on github */
                    ExecutionState state = Machine.Current.DeviceCPU.State;
                    state.PC = 0xA4000040;

                    /* PI Setup */
                    PIRegisters piRegs = Machine.Current.DeviceRCP.MMIO_PI;
                    PiBusSpeedConfig config = Cartridge.Current.RomImage.BusConfig;
                    piRegs.Domain1Latency = (UInt32)config.DeviceLatency;
                    piRegs.Domain1PageSize = (UInt32)config.PageSize;
                    piRegs.Domain1PulseWidth = (UInt32)config.PulseWidth;
                    piRegs.Domain1Release = (UInt32)config.ReleaseTime;
                    piRegs.Status = 0;

                    /* sp_register.sp_status_reg = 1;
                        rsp_register.rsp_pc = 0;

                        ai_register.ai_dram_addr = 0;
                        ai_register.ai_len = 0;

                        vi_register.vi_v_intr = 1023;
                        vi_register.vi_current = 0;
                        vi_register.vi_h_start = 0;

                        MI_register.mi_intr_reg &= ~(0x10 | 0x8 | 0x4 | 0x1) */

                    logger.Debug("PIF HLE: Copying cartridge bootrom into DMEM + 0x40");
                    Machine.Current.N64MemorySafe.Position = N64MemRegions.SPDMem.ToRegionAddress() + 0x40;
                    Machine.Current.DeviceRCP.DevicePI.InsertedCartridge.RomImage.BootRomInformation.CopyCode(Machine.Current.N64MemorySafe);

                    state.GPRRegs[19] = 0; /* 0: Cart, 1: DiskDrive */
                    state.GPRRegs[20] = (UInt64)((Int32)Cartridge.Current.RomImage.Region) - 1;
                    state.GPRRegs[21] = 0; /* 0: ColdReset, 1: NMI */
                    state.GPRRegs[22] = (UInt64)Cartridge.Current.RomImage.BootRomInformation.CIC.Seed();
                    state.GPRRegs[23] = 0; /* S7: Unknown */

                    /* Required by CIC X105 */
                    BinaryWriter bw = new BinaryWriter(Machine.Current.N64MemorySafe);
                    bw.BaseStream.Position = 0x04001000;
                    bw.Write(0x3c0dbfc0U);
                    bw.Write(0x8da807fcU);
                    bw.Write(0x25ad07c0U);
                    bw.Write(0x31080080U);
                    bw.Write(0x5500fffcU);
                    bw.Write(0x3c0dbfc0U);
                    bw.Write(0x8da80024U);
                    bw.Write(0x3c0bb000U);

                    /* Required by CIC X105 */
                    state.GPRRegs[11] = 0xffffffffa4000040UL; /* T3 */
                    state.GPRRegs[29] = 0xffffffffa4001ff0UL; /* SP */
                    state.GPRRegs[31] = 0xffffffffa4001550UL; /* RA */
                }
                else
                {
                    logger.Warn("No cartridge inserted, skipping IPL boot");
                    Machine.Current.DeviceCPU.State.PC = 0xBFC00000;
                }

                logger.Debug("ROM Entry Point: " + Machine.Current.DeviceCPU.State.PC.ToString("X8"));
            }
            else if (bootMode == BootMode.HLE_IPL_OLD)
            {
                if (Machine.Current.DeviceRCP.DevicePI.InsertedCartridge != null)
                {
                    /* This is the older method of booting the emulator */

                    Machine.Current.DeviceCPU.State.PC = 0xA4000040;

                    /* This simulates the effects of the PIF Bootloader */
                    /* 1. Copy the game cartrdige boot rom into SP Memory
                     * 2. Load a snapshot of the CPU / Memory state generated by the real PIF boot sequence */

                    logger.Debug("PIF HLE: Copying cartridge bootrom into DMEM + 0x40");
                    Machine.Current.N64MemorySafe.Position = N64MemRegions.SPDMem.ToRegionAddress() + 0x40;
                    Machine.Current.DeviceRCP.DevicePI.InsertedCartridge.RomImage.BootRomInformation.CopyCode(Machine.Current.N64MemorySafe);

                    using (Stream stream = typeof(SoftBootManager).Assembly.GetManifestResourceStream("Soft64.BootStateSnapshots.xml"))
                    {
                        CartridgeInfo info = Cartridge.Current.GetCartridgeInfo();
                        CICKeyType cic = Cartridge.Current.RomImage.BootRomInformation.CIC;
                        BootSnapReader bootsnap = new BootSnapReader(stream);
                        bootsnap.LoadBootSnap(cic, info.RegionCode);
                    }
                }
                else
                {
                    logger.Warn("No cartridge inserted, skipping IPL boot");
                    Machine.Current.DeviceCPU.State.PC = 0xBFC00000;
                }

                logger.Debug("ROM Entry Point: " + Machine.Current.DeviceCPU.State.PC.ToString("X8"));
            }
            else
            {
                throw new ArgumentException("Unknown bootmode");
            }
        }
Exemplo n.º 9
0
 public bool ApplyUpdate(BootMode target, CancellationToken ct)
 {
     int status = -1;
     string updateArgs = "-c reflash -r " + ((target == BootMode.eRfs0) ? "0" : "1");
     string filePath = Path.Combine(kPathUpdate, kUpdateFile);
     try
     {
         status = WaitForProc(Process.Start(filePath, updateArgs), ct, ReportReflashProgress);
     }
     catch (Exception e)
     {
         Logger.Error("Exception trying to run update: " + e.Message);
     }
     return (status != 0) ? false : true;
 }
Exemplo n.º 10
0
 public static bool IsSet(this BootMode val, BootMode flag)
 {
     return((val & flag) == flag);
 }
Exemplo n.º 11
0
    }                                     // 0x007BA4C0-0x007BA630

    private static void Startup(BootMode bootMode)
    {
    }                                                     // 0x007BA630-0x007BA800
Exemplo n.º 12
0
        public static void SetupExecutionState(BootMode bootMode)
        {
            if (bootMode == BootMode.IPL_ROM)
            {
                throw new InvalidOperationException("Low-level IPL booting not supported yet");

                //Machine.Current.RCP.State.PC = 0x1FC00000;

                /* TODO:
                 * Schedule CPU and RCP threads to execute MIPS Interpreter
                 * Have CPU sit idle, and RCP execute the PIF Rom
                 * */
            }
            else if (bootMode == BootMode.HLE_IPL)
            {
                if (Machine.Current.DeviceRCP.Interface_Parallel.InsertedCartridge != null)
                {
                    /* Code taken from mupen64plus-core on github */
                    ExecutionState state = Machine.Current.DeviceCPU.State;
                    state.PC = 0xA4000040;

                    /* PI Setup */
                    var pi = Machine.Current.Memory.PI;
                    PiBusSpeedConfig config = Cartridge.Current.RomImage.BusConfig;
                    pi.Domain1Latency    = config.DeviceLatency;
                    pi.Domain1PageSize   = config.PageSize;
                    pi.Domain1PulseWidth = config.PulseWidth;
                    pi.Domain1Release    = config.ReleaseTime;
                    pi.Status.DataShared = 0;



                    /* TODO: sp_register.sp_status_reg = 1;
                     *  rsp_register.rsp_pc = 0;
                     *
                     *  ai_register.ai_dram_addr = 0;
                     *  ai_register.ai_len = 0;
                     *
                     *  vi_register.vi_v_intr = 1023;
                     *  vi_register.vi_current = 0;
                     *  vi_register.vi_h_start = 0;
                     *
                     * /* MI Setup */
                    var mi = Machine.Current.Memory.MI;
                    mi.VersionReg.DataToMaster = 0x02020102;
                    mi.VersionReg.DataToSlave &= ~(0x10U | 0x8U | 0x4U | 0x1U);

                    PifHleCopyBootRom();

                    state.GPRRegs[19] = 0; /* 0: Cart, 1: DiskDrive */
                    state.GPRRegs[20] = (UInt64)((Int32)Cartridge.Current.RomImage.Region) - 1;
                    state.GPRRegs[21] = 0; /* 0: ColdReset, 1: NMI */
                    state.GPRRegs[22] = (UInt64)Cartridge.Current.RomImage.BootRomInformation.CIC.Seed();
                    state.GPRRegs[23] = 0; /* S7: Unknown */

                    /* Required by CIC X105 */
                    BinaryWriter bw = new BinaryWriter(Machine.Current.Memory);
                    bw.BaseStream.Position = 0x04001000;
                    bw.Write(0x3c0dbfc0U);
                    bw.Write(0x8da807fcU);
                    bw.Write(0x25ad07c0U);
                    bw.Write(0x31080080U);
                    bw.Write(0x5500fffcU);
                    bw.Write(0x3c0dbfc0U);
                    bw.Write(0x8da80024U);
                    bw.Write(0x3c0bb000U);

                    /* Required by CIC X105 */
                    state.GPRRegs[11] = 0xffffffffa4000040UL; /* T3 */
                    state.GPRRegs[29] = 0xffffffffa4001ff0UL; /* SP */
                    state.GPRRegs[31] = 0xffffffffa4001550UL; /* RA */
                }
                else
                {
                    logger.Warn("No cartridge inserted, skipping IPL boot");
                    Machine.Current.DeviceCPU.State.PC = 0xBFC00000;
                }

                logger.Debug("ROM Entry Point: " + Machine.Current.DeviceCPU.State.PC.ToString("X8"));
            }
            else if (bootMode == BootMode.HLE_IPL_OLD)
            {
                if (Machine.Current.DeviceRCP.Interface_Parallel.InsertedCartridge != null)
                {
                    /* This is the older method of booting the emulator */

                    Machine.Current.DeviceCPU.State.PC = 0xA4000040;

                    /* This simulates the effects of the PIF Bootloader */

                    /* 1. Copy the game cartrdige boot rom into SP Memory
                     * 2. Load a snapshot of the CPU / Memory state generated by the real PIF boot sequence */

                    PifHleCopyBootRom();

                    using (Stream stream = typeof(SoftBootManager).Assembly.GetManifestResourceStream("Soft64.BootStateSnapshots.xml"))
                    {
                        CartridgeInfo  info     = Cartridge.Current.GetCartridgeInfo();
                        CICKeyType     cic      = Cartridge.Current.RomImage.BootRomInformation.CIC;
                        BootSnapReader bootsnap = new BootSnapReader(stream);
                        bootsnap.LoadBootSnap(cic, info.RegionCode);
                    }
                }
                else
                {
                    logger.Warn("No cartridge inserted, skipping IPL boot");
                    Machine.Current.DeviceCPU.State.PC = 0xBFC00000;
                }

                logger.Debug("ROM Entry Point: " + Machine.Current.DeviceCPU.State.PC.ToString("X8"));
            }
            else
            {
                throw new ArgumentException("Unknown bootmode");
            }
        }