1 /* 2 * Copyright (C)2021-2022 Intel Corporation. 3 * SPDX-License-Identifier: BSD-3-Clause 4 */ 5 #ifndef _CMD_HANDLER_H_ 6 #define _CMD_HANDLER_H_ 7 8 #define SEND_RETRY_TIMES 3 9 10 extern struct uart_channel *channel; 11 extern struct socket_dev *sock_server; 12 /** 13 * @brief Get the system shutdown flag 14 */ 15 bool get_system_shutdown_flag(void); 16 /** 17 * @brief Get the reboot flag 18 */ 19 bool get_vm_reboot_flag(void); 20 /** 21 * @brief The handler of request system shutdown command on socket in service VM 22 */ 23 int socket_req_shutdown_service_vm_handler(void *arg, int fd); 24 /** 25 * @brief The handler of request user shutdown command on socket in service VM 26 */ 27 int socket_req_user_vm_shutdown_handler(void *arg, int fd); 28 /** 29 * @brief The handler of request user reboot command on socket in service VM 30 */ 31 int socket_req_user_vm_reboot_handler(void *arg, int fd); 32 33 /** 34 * @brief The handler of request system reboot command on socket in user VM 35 */ 36 int socket_req_system_reboot_user_vm_handler(void *arg, int fd); 37 /** 38 * @brief The handler of request system shutdown command on socket in user VM 39 */ 40 int socket_req_system_shutdown_user_vm_handler(void *arg, int fd); 41 42 /** 43 * @brief The handler of sync command of lifecycle manager in service VM 44 * 45 * @param arg uart channel device instance 46 * @param fd the file directory of the uart which receives message 47 * @return indicate this command is handled successful or not 48 */ 49 int sync_cmd_handler(void *arg, int fd); 50 /** 51 * @brief The handler of system shutdown request command of lifecycle manager in service VM 52 * 53 * @param arg uart channel device instance 54 * @param fd the file directory of the uart which receives message 55 * @return indicate this command is handled successful or not 56 */ 57 int req_shutdown_handler(void *arg, int fd); 58 /** 59 * @brief The handler of system reboot request command of lifecycle manager in service VM 60 * 61 * @param arg uart channel device instance 62 * @param fd the file directory of the uart which receives message 63 * @return indicate this command is handled successful or not 64 */ 65 int req_reboot_handler(void *arg, int fd); 66 /** 67 * @brief The handler of acked poweroff command of lifecycle manager in service VM 68 * 69 * @param arg uart channel instance 70 * @param fd the file directory of the uart which receives message 71 * @return indicate this command is handled successful or not 72 */ 73 int ack_poweroff_handler(void *arg, int fd); 74 /** 75 * @brief The handler of poweroff timeout command of lifecycle manager in service VM 76 * 77 * @param arg uart channel instance 78 * @param fd the file directory of the uart which receives message 79 * @return indicate this command is handled successful or not 80 */ 81 int ack_timeout_handler(void *arg, int fd); 82 /** 83 * @brief The handler of ACK user vm shutdown command of 84 * lifecycle manager in service VM 85 * 86 * @param arg uart channel instance 87 * @param fd the file directory of the uart which receives message 88 * @return indicate this command is handled successful or not 89 */ 90 int ack_user_vm_shutdown_cmd_handler(void *arg, int fd); 91 /** 92 * @brief The handler of ACK user vm reboot command of 93 * lifecycle manager in service VM 94 * 95 * @param arg uart channel instance 96 * @param fd the file directory of the uart which receives message 97 * @return indicate this command is handled successful or not 98 */ 99 int ack_user_vm_reboot_cmd_handler(void *arg, int fd); 100 /** 101 * @brief The handler of acked sync command of lifecycle manager in user VM 102 * 103 * @param arg uart channel device instance 104 * @param fd the file directory of the uart which receives message 105 * @return indicate this command is handled successful or not 106 */ 107 int acked_sync_handler(void *arg, int fd); 108 /** 109 * @brief The handler of acked system shutdown request command of lifecycle manager in user VM 110 * 111 * @param arg uart channel instance 112 * @param fd the file directory of the uart which receives message 113 * @return indicate this command is handled successful or not 114 */ 115 int acked_req_shutdown_reboot_handler(void *arg, int fd); 116 /** 117 * @brief The handler of poweroff command of lifecycle manager in user VM 118 * 119 * @param arg uart channel device instance 120 * @param fd the file directory of the uart which receives message 121 * @return indicate this command is handled successful or not 122 */ 123 int poweroff_cmd_handler(void *arg, int fd); 124 /** 125 * @brief The handler of user VM shutdown command of lifecycle manager in user VM 126 */ 127 int user_vm_shutdown_cmd_handler(void *arg, int fd); 128 /** 129 * @brief The handler of user VM reboot command of lifecycle manager in user VM 130 */ 131 int user_vm_reboot_cmd_handler(void *arg, int fd); 132 /** 133 * @brief The handler of ACK timeout command of lifecycle manager in user VM 134 * 135 * @param arg uart channel instance 136 * @param fd the file directory of the uart which receives message 137 * @return indicate this command is handled successful or not 138 */ 139 int ack_timeout_default_handler(void *arg, int fd); 140 #endif 141