mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-07-01 17:52:26 +00:00
dm:handle shutdown command from UOS
it will send "acked" message to UOS if it receives "shutdown" command from UOS, then wait UOS poweroff itself, it will send shutdown to life_mngr running on SOS to shutdown system. Tracked-On: #4446 Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com> Reviewed-by: Minggui Cao <minggui.cao@intel.com> Reviewed-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
parent
4fdc2be129
commit
8733abef6b
@ -93,8 +93,28 @@ static void *pm_monitor_loop(void *arg)
|
|||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
rc = read_bytes(node_fd, (uint8_t *)buf, CMD_LEN);
|
rc = read_bytes(node_fd, (uint8_t *)buf, CMD_LEN);
|
||||||
|
|
||||||
switch (pm_monitor_state) {
|
switch (pm_monitor_state) {
|
||||||
|
/* it can receive shutdown command from UOS for the following two states,
|
||||||
|
* it will change the state to SHUTDOWN_REQ_FROM_UOS if receive the shutdown
|
||||||
|
* command from UOS, this can prevent the follow-up shutdown command
|
||||||
|
* from UOS or SOS in this state.
|
||||||
|
* it will wait UOS poweroff itself and then send shutdown to
|
||||||
|
* life_mngr running on the SOS to shutdown system
|
||||||
|
*/
|
||||||
|
case SHUTDOWN_REQ_WAITING:
|
||||||
|
case SHUTDOWN_REQ_FROM_UOS:
|
||||||
|
if ((rc > 0) && (strncmp(SHUTDOWN_CMD, (const char *)buf, strlen(SHUTDOWN_CMD)) == 0)) {
|
||||||
|
pm_monitor_state = SHUTDOWN_REQ_FROM_UOS;
|
||||||
|
if (write(node_fd, SHUTDOWN_CMD_ACK, sizeof(SHUTDOWN_CMD_ACK))
|
||||||
|
!= sizeof(SHUTDOWN_CMD_ACK)) {
|
||||||
|
/* here no need to resend ack, it will resend shutdown cmd
|
||||||
|
* if uos can not receive acked message
|
||||||
|
*/
|
||||||
|
pr_err("send acked message to UOS failed!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
/* Waiting acked message from UOS, this is triggered by SOS */
|
/* Waiting acked message from UOS, this is triggered by SOS */
|
||||||
case SHUTDOWN_ACK_WAITING:
|
case SHUTDOWN_ACK_WAITING:
|
||||||
/* Once received the SHUTDOWN ACK from UOS, then wait UOS to set ACPI PM register to change
|
/* Once received the SHUTDOWN ACK from UOS, then wait UOS to set ACPI PM register to change
|
||||||
@ -127,8 +147,8 @@ static void *pm_monitor_loop(void *arg)
|
|||||||
pr_err("Invalid pm_monitor_state(0x%x)\r\n", pm_monitor_state);
|
pr_err("Invalid pm_monitor_state(0x%x)\r\n", pm_monitor_state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user