hv:Change shell_init to void type

Remove shell_construct
Change shell_init to void type

Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Mingqiang Chi 2018-07-24 14:32:50 +08:00 committed by lijinxia
parent a1923dd6e0
commit 311787032a
4 changed files with 15 additions and 39 deletions

View File

@ -1159,17 +1159,3 @@ void shell_special_serial(struct shell *p_shell, uint8_t ch)
break; break;
} }
} }
int shell_construct(struct shell **p_shell)
{
int status = 0;
/* Allocate memory for shell session */
*p_shell = (struct shell *) calloc(1, sizeof(**p_shell));
if ((*p_shell) == NULL) {
pr_err("Error: out of memory");
status = -ENOMEM;
}
return status;
}

View File

@ -139,7 +139,6 @@ struct shell_cmd {
/* Global function prototypes */ /* Global function prototypes */
int shell_show_req_info(struct shell *p_shell, int argc, char **argv); int shell_show_req_info(struct shell *p_shell, int argc, char **argv);
int shell_construct(struct shell **p_shell);
int shell_cmd_help(struct shell *p_shell, int argc, char **argv); int shell_cmd_help(struct shell *p_shell, int argc, char **argv);
int shell_list_vm(struct shell *p_shell, int argc, char **argv); int shell_list_vm(struct shell *p_shell, int argc, char **argv);
int shell_list_vcpu(struct shell *p_shell, int argc, char **argv); int shell_list_vcpu(struct shell *p_shell, int argc, char **argv);

View File

@ -8,7 +8,7 @@
#include "shell_internal.h" #include "shell_internal.h"
/* Shell that uses serial I/O */ /* Shell that uses serial I/O */
static struct shell *serial_session; static struct shell serial_session;
static struct shell_cmd acrn_cmd[] = { static struct shell_cmd acrn_cmd[] = {
{ {
@ -133,31 +133,22 @@ static struct shell_cmd acrn_cmd[] = {
}, },
}; };
int shell_init(void) void shell_init(void)
{ {
int status;
status = shell_construct(&serial_session);
if (status != 0) {
return status;
}
/* Set the function pointers for the shell i/p and o/p functions */ /* Set the function pointers for the shell i/p and o/p functions */
serial_session->session_io.io_init = shell_init_serial; serial_session.session_io.io_init = shell_init_serial;
serial_session->session_io.io_deinit = shell_terminate_serial; serial_session.session_io.io_deinit = shell_terminate_serial;
serial_session->session_io.io_puts = shell_puts_serial; serial_session.session_io.io_puts = shell_puts_serial;
serial_session->session_io.io_getc = shell_getc_serial; serial_session.session_io.io_getc = shell_getc_serial;
serial_session->session_io.io_special = shell_special_serial; serial_session.session_io.io_special = shell_special_serial;
serial_session->session_io.io_echo_on = (bool)true; serial_session.session_io.io_echo_on = (bool)true;
serial_session->shell_cmd = acrn_cmd; serial_session.shell_cmd = acrn_cmd;
serial_session->cmd_count = ARRAY_SIZE(acrn_cmd); serial_session.cmd_count = ARRAY_SIZE(acrn_cmd);
/* Initialize the handler for the serial port that will be used /* Initialize the handler for the serial port that will be used
* for shell i/p and o/p * for shell i/p and o/p
*/ */
status = serial_session->session_io.io_init(serial_session); serial_session.session_io.io_init(&serial_session);
return status;
} }
/** /**
@ -194,7 +185,7 @@ int shell_set_name(struct shell *p_shell, const char *name)
void shell_kick_session(void) void shell_kick_session(void)
{ {
/* Kick the shell */ /* Kick the shell */
kick_shell(serial_session); kick_shell(&serial_session);
} }
int shell_switch_console(void) int shell_switch_console(void)
@ -208,7 +199,7 @@ int shell_switch_console(void)
vuart->active = false; vuart->active = false;
/* Output that switching to ACRN shell */ /* Output that switching to ACRN shell */
shell_puts(serial_session, shell_puts(&serial_session,
"\r\n\r\n----- Entering ACRN Shell -----\r\n"); "\r\n\r\n----- Entering ACRN Shell -----\r\n");
return 0; return 0;
} }

View File

@ -11,11 +11,11 @@
#define GUEST_CONSOLE_TO_HV_SWITCH_KEY 0 /* CTRL + SPACE */ #define GUEST_CONSOLE_TO_HV_SWITCH_KEY 0 /* CTRL + SPACE */
#ifdef HV_DEBUG #ifdef HV_DEBUG
int shell_init(void); void shell_init(void);
void shell_kick_session(void); void shell_kick_session(void);
int shell_switch_console(void); int shell_switch_console(void);
#else #else
static inline int shell_init(void) { return 0; } static inline void shell_init(void) {}
static inline void shell_kick_session(void) {} static inline void shell_kick_session(void) {}
static inline int shell_switch_console(void) { return 0; } static inline int shell_switch_console(void) { return 0; }
#endif #endif