xenvm: drivers: serial: Implement serial interface to Xen PV console
This commit adds minimal support of Xen hypervisor console via UART-like driver. Implementation allows to use poll_in/poll_out char interface for uart_console.c driver directly to HV console instead of using Xen virtual PL011 UART. Future implementation will support interrupt driven interface on Xen event channels, currently it is under development. Also this commit introduces early console_io Xen interface, which allows to receive printk/stdout messages quickly after start, but requires Xen, built with CONFIG_DEBUG option. Signed-off-by: Dmytro Firsov <dmytro_firsov@epam.com>
This commit is contained in:
parent
c4ab278688
commit
d9a3efb834
13 changed files with 348 additions and 2 deletions
5
drivers/xen/CMakeLists.txt
Normal file
5
drivers/xen/CMakeLists.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Copyright (c) 2021 EPAM Systems
|
||||
|
||||
zephyr_sources(hvm.c)
|
||||
zephyr_sources(events.c)
|
25
drivers/xen/events.c
Normal file
25
drivers/xen/events.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2021 EPAM Systems
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <arch/arm64/hypercall.h>
|
||||
#include <xen/public/xen.h>
|
||||
#include <xen/public/event_channel.h>
|
||||
#include <xen/events.h>
|
||||
|
||||
void notify_evtchn(evtchn_port_t port)
|
||||
{
|
||||
struct evtchn_send send;
|
||||
|
||||
if (port >= EVTCHN_2L_NR_CHANNELS) {
|
||||
printk("%s: trying to send notify for invalid evtchn #%u\n",
|
||||
__func__, port);
|
||||
return;
|
||||
}
|
||||
|
||||
send.port = port;
|
||||
|
||||
HYPERVISOR_event_channel_op(EVTCHNOP_send, &send);
|
||||
}
|
39
drivers/xen/hvm.c
Normal file
39
drivers/xen/hvm.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2021 EPAM Systems
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <arch/arm64/hypercall.h>
|
||||
#include <xen/hvm.h>
|
||||
#include <xen/public/hvm/hvm_op.h>
|
||||
#include <xen/public/hvm/params.h>
|
||||
|
||||
#include <kernel.h>
|
||||
|
||||
int hvm_set_parameter(int idx, uint64_t value)
|
||||
{
|
||||
struct xen_hvm_param xhv;
|
||||
|
||||
xhv.domid = DOMID_SELF;
|
||||
xhv.index = idx;
|
||||
xhv.value = value;
|
||||
|
||||
return HYPERVISOR_hvm_op(HVMOP_set_param, &xhv);
|
||||
}
|
||||
|
||||
int hvm_get_parameter(int idx, uint64_t *value)
|
||||
{
|
||||
int ret = 0;
|
||||
struct xen_hvm_param xhv;
|
||||
|
||||
xhv.domid = DOMID_SELF;
|
||||
xhv.index = idx;
|
||||
|
||||
ret = HYPERVISOR_hvm_op(HVMOP_get_param, &xhv);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
*value = xhv.value;
|
||||
return ret;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue