#include <xen/hypervisor.h>
#include <xen/xen_intr.h>
#include <xen/interface/io/console.h>
+#include <xen/hvm.h>
#include "opt_ddb.h"
#include "opt_printf.h"
static void
xencons_early_init_ring(struct xencons_priv *cons)
{
+ /*
+ * The ring is initialized later for the HVM console as the
+ * pmap code is not yet fully initialized
+ * TODO: See if we can map the ring in another way earlier.
+ */
+ if (!xen_hvm_domain())
+ return;
+
/* The shared page for PV is already mapped by the boot code */
cons->intf = (struct xencons_interface *)console_page;
cons->evtchn = HYPERVISOR_start_info->console.domU.evtchn;
{
struct xencons_priv *cons;
int err;
+ xen_pfn_t pfn;
cons = tty_softc(tp);
+ /*
+ * The information are already retrieved in
+ * xencons_early_init_ring for PV guest
+ */
+ if (xen_hvm_domain()) {
+ cons->evtchn = hvm_get_parameter(HVM_PARAM_CONSOLE_EVTCHN);
+ pfn = hvm_get_parameter(HVM_PARAM_CONSOLE_PFN);
+ if (!pfn)
+ return (ENODEV);
+ cons->intf = xen_pmap(pfn << PAGE_SHIFT, PAGE_SIZE);
+ }
+
if (cons->evtchn == 0)
return (ENODEV);
xencons_lock_assert(cons);
+ /* The console page may have not yet been initialized for HVM domain */
+ if (__predict_false(!intf))
+ return -1;
+
wcons = intf->out_cons;
wprod = intf->out_prod;
xencons_lock_assert(cons);
+ /* The console page may have not yet been initialized for HVM domain */
+ if (__predict_false(!intf))
+ return 0;
+
rcons = intf->in_cons;
rprod = intf->in_prod;
rmb();
xencons_cnprobe(struct consdev *cp)
{
+#if defined(__arm__) || defined(__aarch64__)
+ if (!xen_domain())
+ return;
+#else
if (!xen_pv_domain())
return;
+#endif
cp->cn_pri = CN_REMOTE;
sprintf(cp->cn_name, "%s0", driver_name);