/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/hypervisor.h>
#include <sys/machparam.h>
#include <sys/mach_mmu.h>
void *HYPERVISOR_console_page;
#if defined(_BOOT)
#include "dboot/dboot_printf.h"
#endif /* _BOOT */
/*
* For some unfortunate reason, the hypervisor doesn't bother to include the
* shared info in the original virtual address space. This means we can't
* do any console I/O until we have manipulated some pagetables. So we have to
* do this bit of code with no ability to get debug output.
*/
/*ARGSUSED*/
void
{
#ifdef _BOOT
int i = 0;
/*
* find a page aligned virtual address in "big_empty"
*/
/*
* Sets the "present" and "writable" bits in the PTE
* plus user for amd64.
*/
(void) HYPERVISOR_update_va_mapping(vaddr,
if (!DOMAIN_IS_INITDOMAIN(xen_info)) {
/*
* map the xen console ring buffers
*/
} else {
/*
* Xen will pass dom0 information about the current
* display settings via xen_info->console.dom0. This
* information includes what video mode we're in (vga
* or vesa) and some basic information about the video
* mode. (screen size, cursor location, etc.) We're
* just going to ignore all this info. Here's some
* reasons why:
*
* - Currently Solaris itself has no support for vesa.
* Also, the only way to boot Solaris is using our
* patched version of grub, which conveniently doesn't
* support vesa either.
*
* - By default when solaris boots up it clears the screen
* console messages, so we really don't care about the
* current vga settings.
*
* Initially we'll map device memory for the frame buffer
* and keyboard into some local memory that already has
* page table entries so that we can get very basic debug
* output. Later on when we're initializing page tables
* we'll map re-map these devices to be at their expected
* addresses. Note that these mappings created below will
* be torn down right before the kernel boots up when
* all the memory and mappings associated with dboot are
* released.
*
* Map the frame buffer.
*/
(void) HYPERVISOR_update_va_mapping(vaddr + i,
0xb8000 + i | PTE_DEV_BITS,
/* Map the keyboard */
}
#endif /* _BOOT */
if (!DOMAIN_IS_INITDOMAIN(xen_info)) {
} else {
}
}
/*
* This is the equivalent of polled I/O across the hypervisor CONSOLE
* channel to output 1 character at a time.
*/
void
bcons_putchar_xen(int c)
{
char buffer = (char)c;
if (DOMAIN_IS_INITDOMAIN(xen_info)) {
return;
}
/*
* need to add carriage return for new lines
*/
if (c == '\n')
bcons_putchar_xen('\r');
/*
* We have to wait till we have an open transmit slot.
*/
(void) HYPERVISOR_yield();
(char)c;
/*
* Signal Domain 0 that it has something to do for us.
*/
}
static char buffered;
/*
* See if there is a character on input.
*/
int
bcons_ischar_xen(void)
{
if (DOMAIN_IS_INITDOMAIN(xen_info)) {
if (have_char)
return (1);
return (have_char = 1);
return (0);
}
return (0);
return (1);
}
/*
* get a console input character
*/
int
bcons_getchar_xen(void)
{
char c;
if (DOMAIN_IS_INITDOMAIN(xen_info)) {
while (have_char == 0)
(void) bcons_ischar_xen();
have_char = 0;
return (buffered);
}
(void) HYPERVISOR_yield();
/*
* Signal Domain 0 that we ate a character.
*/
return (c);
}