mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-05 10:20:55 +00:00
HV: vuart: remove console related code from vuart
Move the console related code from dm/vuart.c to debug/console.c as console is not supported in release version. Tracked-On: #2987 Signed-off-by: Conghui Chen <conghui.chen@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
513c9f8744
commit
c61db6ffa0
@ -11,10 +11,15 @@
|
|||||||
#include <timer.h>
|
#include <timer.h>
|
||||||
#include <vuart.h>
|
#include <vuart.h>
|
||||||
#include <logmsg.h>
|
#include <logmsg.h>
|
||||||
|
#include <acrn_hv_defs.h>
|
||||||
|
#include <vm.h>
|
||||||
|
|
||||||
struct hv_timer console_timer;
|
struct hv_timer console_timer;
|
||||||
|
|
||||||
#define CONSOLE_KICK_TIMER_TIMEOUT 40UL /* timeout is 40ms*/
|
#define CONSOLE_KICK_TIMER_TIMEOUT 40UL /* timeout is 40ms*/
|
||||||
|
/* Switching key combinations for shell and uart console */
|
||||||
|
#define GUEST_CONSOLE_TO_HV_SWITCH_KEY 0 /* CTRL + SPACE */
|
||||||
|
uint16_t console_vmid = ACRN_INVALID_VMID;
|
||||||
|
|
||||||
void console_init(void)
|
void console_init(void)
|
||||||
{
|
{
|
||||||
@ -37,6 +42,67 @@ char console_getc(void)
|
|||||||
return uart16550_getc();
|
return uart16550_getc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @post return != NULL
|
||||||
|
*/
|
||||||
|
struct acrn_vuart *vm_console_vuart(struct acrn_vm *vm)
|
||||||
|
{
|
||||||
|
return &vm->vuart[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @pre vu != NULL
|
||||||
|
* @pre vu->active == true
|
||||||
|
*/
|
||||||
|
void vuart_console_rx_chars(struct acrn_vuart *vu)
|
||||||
|
{
|
||||||
|
char ch = -1;
|
||||||
|
|
||||||
|
/* Get data from physical uart */
|
||||||
|
ch = uart16550_getc();
|
||||||
|
|
||||||
|
if (ch == GUEST_CONSOLE_TO_HV_SWITCH_KEY) {
|
||||||
|
/* Switch the console */
|
||||||
|
console_vmid = ACRN_INVALID_VMID;
|
||||||
|
printf("\r\n\r\n ---Entering ACRN SHELL---\r\n");
|
||||||
|
}
|
||||||
|
if (ch != -1) {
|
||||||
|
vuart_putchar(vu, ch);
|
||||||
|
vuart_toggle_intr(vu);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @pre vu != NULL
|
||||||
|
*/
|
||||||
|
void vuart_console_tx_chars(struct acrn_vuart *vu)
|
||||||
|
{
|
||||||
|
char c;
|
||||||
|
|
||||||
|
while ((c = vuart_getchar(vu)) != -1) {
|
||||||
|
printf("%c", c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct acrn_vuart *vuart_console_active(void)
|
||||||
|
{
|
||||||
|
struct acrn_vm *vm = NULL;
|
||||||
|
struct acrn_vuart *vu = NULL;
|
||||||
|
|
||||||
|
if (console_vmid < CONFIG_MAX_VM_NUM) {
|
||||||
|
vm = get_vm_from_vmid(console_vmid);
|
||||||
|
if (is_valid_vm(vm)) {
|
||||||
|
vu = vm_console_vuart(vm);
|
||||||
|
} else {
|
||||||
|
/* Console vm is invalid, switch back to HV-Shell */
|
||||||
|
console_vmid = ACRN_INVALID_VMID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (vu && vu->active) ? vu : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void console_timer_callback(__unused void *data)
|
static void console_timer_callback(__unused void *data)
|
||||||
{
|
{
|
||||||
struct acrn_vuart *vu;
|
struct acrn_vuart *vu;
|
||||||
|
@ -43,8 +43,6 @@ static uint16_t vuart_com_base = CONFIG_COM_BASE;
|
|||||||
#define vuart_lock(vu) spinlock_obtain(&((vu)->lock))
|
#define vuart_lock(vu) spinlock_obtain(&((vu)->lock))
|
||||||
#define vuart_unlock(vu) spinlock_release(&((vu)->lock))
|
#define vuart_unlock(vu) spinlock_release(&((vu)->lock))
|
||||||
|
|
||||||
uint16_t console_vmid = ACRN_INVALID_VMID;
|
|
||||||
|
|
||||||
static inline void fifo_reset(struct fifo *fifo)
|
static inline void fifo_reset(struct fifo *fifo)
|
||||||
{
|
{
|
||||||
fifo->rindex = 0U;
|
fifo->rindex = 0U;
|
||||||
@ -83,6 +81,23 @@ static inline uint32_t fifo_numchars(const struct fifo *fifo)
|
|||||||
return fifo->num;
|
return fifo->num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vuart_putchar(struct acrn_vuart *vu, char ch)
|
||||||
|
{
|
||||||
|
vuart_lock(vu);
|
||||||
|
fifo_putchar(&vu->rxfifo, ch);
|
||||||
|
vuart_unlock(vu);
|
||||||
|
}
|
||||||
|
|
||||||
|
char vuart_getchar(struct acrn_vuart *vu)
|
||||||
|
{
|
||||||
|
char c;
|
||||||
|
|
||||||
|
vuart_lock(vu);
|
||||||
|
c = fifo_getchar(&vu->txfifo);
|
||||||
|
vuart_unlock(vu);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void vuart_fifo_init(struct acrn_vuart *vu)
|
static inline void vuart_fifo_init(struct acrn_vuart *vu)
|
||||||
{
|
{
|
||||||
vu->txfifo.buf = vu->vuart_tx_buf;
|
vu->txfifo.buf = vu->vuart_tx_buf;
|
||||||
@ -129,19 +144,11 @@ struct acrn_vuart *find_vuart_by_port(struct acrn_vm *vm, uint16_t offset)
|
|||||||
return ret_vu;
|
return ret_vu;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @post return != NULL
|
|
||||||
*/
|
|
||||||
struct acrn_vuart *vm_console_vuart(struct acrn_vm *vm)
|
|
||||||
{
|
|
||||||
return &vm->vuart[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Toggle the COM port's intr pin depending on whether or not we have an
|
* Toggle the COM port's intr pin depending on whether or not we have an
|
||||||
* interrupt condition to report to the processor.
|
* interrupt condition to report to the processor.
|
||||||
*/
|
*/
|
||||||
static void vuart_toggle_intr(const struct acrn_vuart *vu)
|
void vuart_toggle_intr(const struct acrn_vuart *vu)
|
||||||
{
|
{
|
||||||
uint8_t intr_reason;
|
uint8_t intr_reason;
|
||||||
union ioapic_rte rte;
|
union ioapic_rte rte;
|
||||||
@ -384,58 +391,6 @@ static bool vuart_register_io_handler(struct acrn_vm *vm, uint16_t port_base, ui
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @pre vu != NULL
|
|
||||||
*/
|
|
||||||
void vuart_console_tx_chars(struct acrn_vuart *vu)
|
|
||||||
{
|
|
||||||
vuart_lock(vu);
|
|
||||||
while (fifo_numchars(&vu->txfifo) > 0U) {
|
|
||||||
printf("%c", fifo_getchar(&vu->txfifo));
|
|
||||||
}
|
|
||||||
vuart_unlock(vu);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @pre vu != NULL
|
|
||||||
* @pre vu->active == true
|
|
||||||
*/
|
|
||||||
void vuart_console_rx_chars(struct acrn_vuart *vu)
|
|
||||||
{
|
|
||||||
char ch = -1;
|
|
||||||
|
|
||||||
vuart_lock(vu);
|
|
||||||
/* Get data from physical uart */
|
|
||||||
ch = uart16550_getc();
|
|
||||||
|
|
||||||
if (ch == GUEST_CONSOLE_TO_HV_SWITCH_KEY) {
|
|
||||||
/* Switch the console */
|
|
||||||
console_vmid = ACRN_INVALID_VMID;
|
|
||||||
printf("\r\n\r\n ---Entering ACRN SHELL---\r\n");
|
|
||||||
}
|
|
||||||
if (ch != -1) {
|
|
||||||
fifo_putchar(&vu->rxfifo, ch);
|
|
||||||
vuart_toggle_intr(vu);
|
|
||||||
}
|
|
||||||
|
|
||||||
vuart_unlock(vu);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct acrn_vuart *vuart_console_active(void)
|
|
||||||
{
|
|
||||||
struct acrn_vm *vm = NULL;
|
|
||||||
struct acrn_vuart *vu = NULL;
|
|
||||||
|
|
||||||
if (console_vmid < CONFIG_MAX_VM_NUM) {
|
|
||||||
vm = get_vm_from_vmid(console_vmid);
|
|
||||||
if (is_valid_vm(vm)) {
|
|
||||||
vu = vm_console_vuart(vm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (vu && vu->active) ? vu : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void vuart_setup(struct acrn_vm *vm,
|
static void vuart_setup(struct acrn_vm *vm,
|
||||||
struct vuart_config *vu_config, uint16_t vuart_idx)
|
struct vuart_config *vu_config, uint16_t vuart_idx)
|
||||||
{
|
{
|
||||||
@ -541,10 +496,6 @@ void vuart_deinit(struct acrn_vm *vm)
|
|||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|
||||||
/* reset console_vmid to switch back to hypervisor console */
|
|
||||||
if (console_vmid == vm->vm_id)
|
|
||||||
console_vmid = ACRN_INVALID_VMID;
|
|
||||||
|
|
||||||
for (i = 0; i < MAX_VUART_NUM_PER_VM; i++) {
|
for (i = 0; i < MAX_VUART_NUM_PER_VM; i++) {
|
||||||
vm->vuart[i].active = false;
|
vm->vuart[i].active = false;
|
||||||
if (vm->vuart[i].target_vu)
|
if (vm->vuart[i].target_vu)
|
||||||
|
@ -7,8 +7,7 @@
|
|||||||
#ifndef CONSOLE_H
|
#ifndef CONSOLE_H
|
||||||
#define CONSOLE_H
|
#define CONSOLE_H
|
||||||
|
|
||||||
/* Switching key combinations for shell and uart console */
|
#include <vuart.h>
|
||||||
#define GUEST_CONSOLE_TO_HV_SWITCH_KEY 0 /* CTRL + SPACE */
|
|
||||||
|
|
||||||
/** Initializes the console module.
|
/** Initializes the console module.
|
||||||
*
|
*
|
||||||
@ -39,5 +38,6 @@ void console_setup_timer(void);
|
|||||||
|
|
||||||
void suspend_console(void);
|
void suspend_console(void);
|
||||||
void resume_console(void);
|
void resume_console(void);
|
||||||
|
struct acrn_vuart *vm_console_vuart(struct acrn_vm *vm);
|
||||||
|
|
||||||
#endif /* CONSOLE_H */
|
#endif /* CONSOLE_H */
|
||||||
|
@ -81,12 +81,12 @@ struct acrn_vuart {
|
|||||||
spinlock_t lock; /* protects all softc elements */
|
spinlock_t lock; /* protects all softc elements */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct acrn_vuart *vm_console_vuart(struct acrn_vm *vm);
|
|
||||||
void vuart_init(struct acrn_vm *vm, struct vuart_config *vu_config);
|
void vuart_init(struct acrn_vm *vm, struct vuart_config *vu_config);
|
||||||
void vuart_deinit(struct acrn_vm *vm);
|
void vuart_deinit(struct acrn_vm *vm);
|
||||||
struct acrn_vuart *vuart_console_active(void);
|
|
||||||
void vuart_console_tx_chars(struct acrn_vuart *vu);
|
void vuart_putchar(struct acrn_vuart *vu, char ch);
|
||||||
void vuart_console_rx_chars(struct acrn_vuart *vu);
|
char vuart_getchar(struct acrn_vuart *vu);
|
||||||
|
void vuart_toggle_intr(const struct acrn_vuart *vu);
|
||||||
|
|
||||||
bool is_vuart_intx(struct acrn_vm *vm, uint32_t intx_pin);
|
bool is_vuart_intx(struct acrn_vm *vm, uint32_t intx_pin);
|
||||||
void vuart_set_property(const char *vuart_info);
|
void vuart_set_property(const char *vuart_info);
|
||||||
|
Loading…
Reference in New Issue
Block a user