mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-13 13:56:19 +00:00
dm: introduce system/full reset and suspend
Guest has erquirement to support system/full reboot and S3. Which could trigger different reset path in guest Signed-off-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
parent
76662a634f
commit
8d12c06270
@ -25,6 +25,9 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
@ -53,7 +56,6 @@ reset_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
|
|||||||
uint32_t *eax, void *arg)
|
uint32_t *eax, void *arg)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
static uint8_t reset_control;
|
static uint8_t reset_control;
|
||||||
|
|
||||||
if (bytes != 1)
|
if (bytes != 1)
|
||||||
@ -63,15 +65,17 @@ reset_handler(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
|
|||||||
else {
|
else {
|
||||||
reset_control = *eax;
|
reset_control = *eax;
|
||||||
|
|
||||||
/* Treat hard and soft resets the same. */
|
if (*eax & 0x8) {
|
||||||
if (reset_control & 0x4) {
|
fprintf(stderr, "full reset\r\n");
|
||||||
error = vm_suspend(ctx, VM_SUSPEND_RESET);
|
error = vm_suspend(ctx, VM_SUSPEND_FULL_RESET);
|
||||||
assert(error ==0 || errno == EALREADY);
|
assert(error ==0 || errno == EALREADY);
|
||||||
}
|
mevent_notify();
|
||||||
|
|
||||||
/* cold reset should clear the value in 0xcf9 */
|
|
||||||
if (reset_control & 0x8) {
|
|
||||||
reset_control = 0;
|
reset_control = 0;
|
||||||
|
} else if (*eax & 0x4) {
|
||||||
|
fprintf(stderr, "system reset\r\n");
|
||||||
|
error = vm_suspend(ctx, VM_SUSPEND_SYSTEM_RESET);
|
||||||
|
assert(error ==0 || errno == EALREADY);
|
||||||
|
mevent_notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -887,7 +887,7 @@ main(int argc, char *argv[])
|
|||||||
vm_pause(ctx);
|
vm_pause(ctx);
|
||||||
delete_cpu(ctx, BSP);
|
delete_cpu(ctx, BSP);
|
||||||
|
|
||||||
if (vm_get_suspend_mode() != VM_SUSPEND_RESET)
|
if (vm_get_suspend_mode() != VM_SUSPEND_FULL_RESET)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
vm_deinit_vdevs(ctx);
|
vm_deinit_vdevs(ctx);
|
||||||
|
@ -328,7 +328,8 @@ mevent_dispatch(void)
|
|||||||
*/
|
*/
|
||||||
mevent_handle(eventlist, ret);
|
mevent_handle(eventlist, ret);
|
||||||
|
|
||||||
if (vm_get_suspend_mode() != VM_SUSPEND_NONE)
|
if ((vm_get_suspend_mode() != VM_SUSPEND_NONE) &&
|
||||||
|
(vm_get_suspend_mode() != VM_SUSPEND_SYSTEM_RESET))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ wdt_expired_thread(union sigval v)
|
|||||||
wdt_timeout = 1;
|
wdt_timeout = 1;
|
||||||
|
|
||||||
/* watchdog timer out, set the uos to reboot */
|
/* watchdog timer out, set the uos to reboot */
|
||||||
vm_set_suspend_mode(VM_SUSPEND_RESET);
|
vm_set_suspend_mode(VM_SUSPEND_FULL_RESET);
|
||||||
mevent_notify();
|
mevent_notify();
|
||||||
} else {
|
} else {
|
||||||
/* if not need reboot, just loop timer */
|
/* if not need reboot, just loop timer */
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "ps2kbd.h"
|
#include "ps2kbd.h"
|
||||||
#include "ps2mouse.h"
|
#include "ps2mouse.h"
|
||||||
#include "vmmapi.h"
|
#include "vmmapi.h"
|
||||||
|
#include "mevent.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
atkbdc_assert_kbd_intr(struct atkbdc_base *base)
|
atkbdc_assert_kbd_intr(struct atkbdc_base *base)
|
||||||
@ -359,8 +360,9 @@ atkbdc_sts_ctl_handler(struct vmctx *ctx, int vcpu, int in, int port,
|
|||||||
base->status |= KBDS_AUX_BUFFER_FULL |
|
base->status |= KBDS_AUX_BUFFER_FULL |
|
||||||
KBDS_KBD_BUFFER_FULL;
|
KBDS_KBD_BUFFER_FULL;
|
||||||
break;
|
break;
|
||||||
case KBDC_RESET: /* Pulse "reset" line */
|
case KBDC_RESET: /* Pulse "cold reset" line */
|
||||||
error = vm_suspend(ctx, VM_SUSPEND_RESET);
|
error = vm_suspend(ctx, VM_SUSPEND_FULL_RESET);
|
||||||
|
mevent_notify();
|
||||||
assert(error == 0 || errno == EALREADY);
|
assert(error == 0 || errno == EALREADY);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -57,8 +57,10 @@
|
|||||||
|
|
||||||
enum vm_suspend_how {
|
enum vm_suspend_how {
|
||||||
VM_SUSPEND_NONE,
|
VM_SUSPEND_NONE,
|
||||||
VM_SUSPEND_RESET,
|
VM_SUSPEND_SYSTEM_RESET,
|
||||||
|
VM_SUSPEND_FULL_RESET,
|
||||||
VM_SUSPEND_POWEROFF,
|
VM_SUSPEND_POWEROFF,
|
||||||
|
VM_SUSPEND_SUSPEND,
|
||||||
VM_SUSPEND_HALT,
|
VM_SUSPEND_HALT,
|
||||||
VM_SUSPEND_TRIPLEFAULT,
|
VM_SUSPEND_TRIPLEFAULT,
|
||||||
VM_SUSPEND_LAST
|
VM_SUSPEND_LAST
|
||||||
|
Loading…
Reference in New Issue
Block a user