VirtualBox

Changeset 60404 in vbox for trunk/include


Ignore:
Timestamp:
Apr 9, 2016 11:45:55 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
106490
Message:

VMM,Devices,Main: Implemented soft/warm reset for shutdown status codes 05h, 09h and 0Ah.

This is a shot at adjusting our VM reset handling to handle the ancient way of
getting a 286 out of protected mode and back to real mode. Our exiting reset
code (XXXR3Reset, PDMDEVREG::pfnReset, and so on) is doing a cold reset of the
system and then some additional device & memory initialization that the firmware
is usually responsible for doing. When the guest triggers a reset via the
keyboard controller, system control port A, CPU triple fault, and possibly ACPI,
only the CPU is supposed to be reset. The BIOS would then decide whether memory
and devices needed resetting as well, or if the resetter justed wanted to get out
protected mode and resume executing some real mode code pointed to by 467h.

  • New states SOFT_RESETTING and SOFT_RESETTING_LS. The latter returns to RUNNING_LS, not SUSPENDED_LS like for hard reset.
  • Added a firmware interface so the VMM/PDM can ask it whether we're supposed to do a hard reset or a soft(/warm) one.
  • Implemented firmware interface for the PC BIOS (but not EFI). It indicates soft(/warm) reset when CMOS[0xf] is 5, 9 or 10.
  • Moved the CMOS[0xf] resetting from the RTC device to the PC BIOS since it's firmware thing, not RTC.
  • Added a flag parameter to PDMDevHlpVMReset for specifying the source of the reset operation. One class of sources (GIM) will always trigger hard resets, whereas the others will check with the firmware first.
  • Added PDMR3GetResetInfo for query the flags passed to PDMDevHlpVMReset and for asking the firmware whether it's a hard or soft reset. The latter, however, is only done if only CPU 0 is active. Systems with more than one CPU in a state other than EMSTATE_WAIT_SIPI status will always be hard reset.
  • Added internal VMR3ResetFF and VMR3ResetTripleFault APIs for handling the VM_FF_RESET and VINF_EM_TRIPLE_FAULT conditions.
  • Added PMDR3ResetSoft and had it call pfnSoftReset (which is now defined).

Warning! Major PDM_DEVHLPR3_VERSION change, minor PDM_DEVREG_VERSION change.

Location:
trunk/include/VBox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/types.h

    r58111 r60404  
    163163    /** Live save: The VM is being reset and immediately suspended. */
    164164    VMSTATE_RESETTING_LS,
     165    /** The VM is being soft/warm reset. */
     166    VMSTATE_SOFT_RESETTING,
     167    /** Live save: The VM is being soft/warm reset (not suspended afterwards). */
     168    VMSTATE_SOFT_RESETTING_LS,
    165169    /** The VM is being suspended. */
    166170    VMSTATE_SUSPENDING,
  • trunk/include/VBox/vmm/pdmapi.h

    r60396 r60404  
    8585VMMR3_INT_DECL(int)     PDMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
    8686VMMR3DECL(void)         PDMR3PowerOn(PVM pVM);
     87VMMR3_INT_DECL(bool)    PDMR3GetResetInfo(PVM pVM, uint32_t fOverride, uint32_t *pfResetFlags);
    8788VMMR3_INT_DECL(void)    PDMR3ResetCpu(PVMCPU pVCpu);
    8889VMMR3_INT_DECL(void)    PDMR3Reset(PVM pVM);
    8990VMMR3_INT_DECL(void)    PDMR3MemSetup(PVM pVM, bool fAtReset);
     91VMMR3_INT_DECL(void)    PDMR3SoftReset(PVM pVM, uint32_t fResetFlags);
    9092VMMR3_INT_DECL(void)    PDMR3Suspend(PVM pVM);
    9193VMMR3_INT_DECL(void)    PDMR3Resume(PVM pVM);
  • trunk/include/VBox/vmm/pdmdev.h

    r60396 r60404  
    132132/** Pointer to a FNPDMDEVRESET() function. */
    133133typedef FNPDMDEVRESET *PFNPDMDEVRESET;
     134
     135/**
     136 * Soft reset notification.
     137 *
     138 * This is mainly for emulating the 286 style protected mode exits, in which
     139 * most devices should remain in their current state.
     140 *
     141 * @returns VBox status.
     142 * @param   pDevIns     The device instance data.
     143 * @param   fFlags      PDMVMRESET_F_XXX (only bits relevant to soft resets).
     144 *
     145 * @remarks Caller enters the device critical section.
     146 */
     147typedef DECLCALLBACK(void)  FNPDMDEVSOFTRESET(PPDMDEVINS pDevIns, uint32_t fFlags);
     148/** Pointer to a FNPDMDEVSOFTRESET() function. */
     149typedef FNPDMDEVSOFTRESET *PFNPDMDEVSOFTRESET;
     150
     151/** @name PDMVMRESET_F_XXX - VM reset flags.
     152 * These flags are used both for FNPDMDEVSOFTRESET and for hardware signalling
     153 * reset via PDMDevHlpVMReset.
     154 * @{ */
     155/** Unknown reason. */
     156#define PDMVMRESET_F_UNKNOWN            UINT32_C(0x00000000)
     157/** GIM triggered reset. */
     158#define PDMVMRESET_F_GIM                UINT32_C(0x00000001)
     159/** The last source always causing hard resets. */
     160#define PDMVMRESET_F_LAST_ALWAYS_HARD   PDMVMRESET_F_GIM
     161/** ACPI triggered reset. */
     162#define PDMVMRESET_F_ACPI               UINT32_C(0x0000000c)
     163/** PS/2 system port A (92h) reset. */
     164#define PDMVMRESET_F_PORT_A             UINT32_C(0x0000000d)
     165/** Keyboard reset. */
     166#define PDMVMRESET_F_KBD                UINT32_C(0x0000000e)
     167/** Tripple fault. */
     168#define PDMVMRESET_F_TRIPLE_FAULT       UINT32_C(0x0000000f)
     169/** Reset source mask. */
     170#define PDMVMRESET_F_SRC_MASK           UINT32_C(0x0000000f)
     171/** @} */
    134172
    135173/**
     
    334372     * Critical section is entered. */
    335373    PFNPDMDEVPOWEROFF   pfnPowerOff;
    336     /** @todo */
    337     PFNRT               pfnSoftReset;
     374    /** Software system reset notification - optional.
     375     * Critical section is entered. */
     376    PFNPDMDEVSOFTRESET  pfnSoftReset;
    338377    /** Initialization safty marker. */
    339378    uint32_t            u32VersionEnd;
     
    345384
    346385/** Current DEVREG version number. */
    347 #define PDM_DEVREG_VERSION                      PDM_VERSION_MAKE(0xffff, 2, 0)
     386#define PDM_DEVREG_VERSION                      PDM_VERSION_MAKE(0xffff, 2, 1)
    348387
    349388/** PDM Device Flags.
     
    10531092
    10541093/**
     1094 * Firmware registration structure.
     1095 */
     1096typedef struct PDMFWREG
     1097{
     1098    /** Struct version+magic number (PDM_FWREG_VERSION). */
     1099    uint32_t                u32Version;
     1100
     1101    /**
     1102     * Checks whether this is a hard or soft reset.
     1103     *
     1104     * The current definition of soft reset is what the PC BIOS does when CMOS[0xF]
     1105     * is 5, 9 or 0xA.
     1106     *
     1107     * @returns true if hard reset, false if soft.
     1108     * @param   pDevIns         Device instance of the firmware.
     1109     * @param   fFlags          PDMRESET_F_XXX passed to the PDMDevHlpVMReset API.
     1110     */
     1111    DECLR3CALLBACKMEMBER(bool, pfnIsHardReset,(PPDMDEVINS pDevIns, uint32_t fFlags));
     1112
     1113    /** Just a safety precaution. */
     1114    uint32_t                u32TheEnd;
     1115} PDMFWREG;
     1116/** Pointer to a FW registration structure. */
     1117typedef PDMFWREG *PPDMFWREG;
     1118/** Pointer to a const FW registration structure. */
     1119typedef PDMFWREG const *PCPDMFWREG;
     1120
     1121/** Current PDMFWREG version number. */
     1122#define PDM_FWREG_VERSION                       PDM_VERSION_MAKE(0xffdd, 1, 0)
     1123
     1124/**
     1125 * Firmware R3 helpers.
     1126 */
     1127typedef struct PDMFWHLPR3
     1128{
     1129    /** Structure version. PDM_FWHLP_VERSION defines the current version. */
     1130    uint32_t                u32Version;
     1131
     1132    /** Just a safety precaution. */
     1133    uint32_t                u32TheEnd;
     1134} PDMFWHLPR3;
     1135
     1136/** Pointer to FW R3 helpers. */
     1137typedef R3PTRTYPE(PDMFWHLPR3 *) PPDMFWHLPR3;
     1138/** Pointer to const FW R3 helpers. */
     1139typedef R3PTRTYPE(const PDMFWHLPR3 *) PCPDMFWHLPR3;
     1140
     1141/** Current PDMFWHLPR3 version number. */
     1142#define PDM_FWHLPR3_VERSION                     PDM_VERSION_MAKE(0xffdb, 1, 0)
     1143
     1144
     1145/**
    10551146 * Advanced Programmable Interrupt Controller registration structure.
    10561147 */
     
    35743665
    35753666    /**
    3576      * Unregisters the VMM device heap - OBSOLETE.
    3577      *
    3578      * This entry can be reused.
    3579      * This entry can be reused.
    3580      * This entry can be reused.
     3667     * Registers the firmware (BIOS, EFI) device with PDM.
     3668     *
     3669     * The firmware provides a callback table and gets a special PDM helper table.
     3670     * There can only be one firmware device for a VM.
    35813671     *
    35823672     * @returns VBox status code.
    35833673     * @param   pDevIns             The device instance.
    3584      * @param   GCPhys              The physical address.
    3585      * @thread  EMT.
    3586      * @obsolete
    3587      */
    3588     DECLR3CALLBACKMEMBER(int, pfnUnregisterVMMDevHeap,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys));
     3674     * @param   pFwReg              Firmware registration structure.
     3675     * @param   ppFwHlp             Where to return the firmware helper structure.
     3676     * @remarks Only valid during device construction.
     3677     * @thread  EMT(0)
     3678     */
     3679    DECLR3CALLBACKMEMBER(int, pfnFirmwareRegister,(PPDMDEVINS pDevIns, PCPDMFWREG pFwReg, PCPDMFWHLPR3 *ppFwHlpR3));
    35893680
    35903681    /**
     
    35933684     * @returns The appropriate VBox status code to pass around on reset.
    35943685     * @param   pDevIns             The device instance.
     3686     * @param   fFlags              PDMVMRESET_F_XXX flags.
    35953687     * @thread  The emulation thread.
    35963688     */
    3597     DECLR3CALLBACKMEMBER(int, pfnVMReset,(PPDMDEVINS pDevIns));
     3689    DECLR3CALLBACKMEMBER(int, pfnVMReset,(PPDMDEVINS pDevIns, uint32_t fFlags));
    35983690
    35993691    /**
     
    37053797
    37063798/** Current PDMDEVHLPR3 version number. */
    3707 #define PDM_DEVHLPR3_VERSION                    PDM_VERSION_MAKE(0xffe7, 15, 1)
     3799#define PDM_DEVHLPR3_VERSION                    PDM_VERSION_MAKE(0xffe7, 16, 0)
    37083800
    37093801
     
    52985390
    52995391/**
     5392 * @copydoc PDMDEVHLPR3::pfnFirmwareRegister
     5393 */
     5394DECLINLINE(int) PDMDevHlpFirmwareRegister(PPDMDEVINS pDevIns, PCPDMFWREG pFwReg, PCPDMFWHLPR3 *ppFwHlpR3)
     5395{
     5396    return pDevIns->pHlpR3->pfnFirmwareRegister(pDevIns, pFwReg, ppFwHlpR3);
     5397}
     5398
     5399/**
    53005400 * @copydoc PDMDEVHLPR3::pfnVMReset
    53015401 */
    5302 DECLINLINE(int) PDMDevHlpVMReset(PPDMDEVINS pDevIns)
    5303 {
    5304     return pDevIns->pHlpR3->pfnVMReset(pDevIns);
     5402DECLINLINE(int) PDMDevHlpVMReset(PPDMDEVINS pDevIns, uint32_t fFlags)
     5403{
     5404    return pDevIns->pHlpR3->pfnVMReset(pDevIns, fFlags);
    53055405}
    53065406
  • trunk/include/VBox/vmm/vmapi.h

    r58125 r60404  
    412412VMMR3DECL(VMRESUMEREASON) VMR3GetResumeReason(PUVM);
    413413VMMR3DECL(int)          VMR3Reset(PUVM pUVM);
     414VMMR3_INT_DECL(VBOXSTRICTRC) VMR3ResetFF(PVM pVM);
     415VMMR3_INT_DECL(VBOXSTRICTRC) VMR3ResetTripleFault(PVM pVM);
    414416VMMR3DECL(int)          VMR3Save(PUVM pUVM, const char *pszFilename, bool fContinueAfterwards, PFNVMPROGRESS pfnProgress, void *pvUser, bool *pfSuspended);
    415417VMMR3_INT_DECL(int)     VMR3SaveFT(PUVM pUVM, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser, bool *pfSuspended, bool fSkipStateChanges);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette