/*
* 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 (c) 2012 Gary Mills
*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/machparam.h>
#include <sys/archsystm.h>
#include <sys/boot_console.h>
#include "dboot_asm.h"
#include "dboot_printf.h"
#include "dboot_xboot.h"
#ifdef __xpv
#include <sys/hypervisor.h>
#endif
/*
* This file provides simple output formatting via dboot_printf()
*/
/*
* Primitive version of panic, prints a message then resets the system
*/
void
{
dboot_printf("Press any key to reboot\n");
(void) bcons_getchar();
}
dboot_halt(); /* just in case */
}
/*
* printf for boot code
*/
void
{
}
/*
* output a string
*/
static void
dboot_puts(char *s)
{
while (*s != 0) {
bcons_putchar(*s);
++s;
}
}
static void
{
int i;
bcons_putchar('-');
x = -x;
}
if (i < 0)
buffer[++i] = '0';
while (i >= 0)
bcons_putchar(buffer[i--]);
}
/*
* very primitive printf - only does %s, %d, %x, %lx, or %%
*/
static void
{
char *s;
uint64_t x;
dboot_puts("dboot_printf(): 1st arg is NULL\n");
return;
}
if (*fmt != '%') {
bcons_putchar(*fmt);
continue;
}
size = 0;
++fmt;
switch (*fmt) {
case '%':
bcons_putchar(*fmt);
break;
case 'c':
bcons_putchar(x);
break;
case 's':
if (s == NULL)
dboot_puts("*NULL*");
else
dboot_puts(s);
break;
case 'p':
break;
case 'l':
if (size == 0)
size = sizeof (long);
else if (size == sizeof (long))
size = sizeof (long long);
goto again;
case 'd':
if (size == 0)
else if (size == sizeof (long))
else
break;
case 'b':
base = 2;
goto unsigned_num;
case 'o':
base = 8;
goto unsigned_num;
case 'x':
base = 16;
if (size == 0)
else if (size == sizeof (long))
else
break;
default:
dboot_puts("dboot_printf(): unknown % escape\n");
}
}
}