biosutil.c revision 5d2fc4dce507d2a1bcc9ac8ef02b022c720f0910
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* helper functions for switching to realmode and make a bios call.
* The only interesting functions are copyin_args and copyout_args.
* The rest are for debugging via a serial line.
*/
#include "util.h"
#include "biosint.h"
#include "chario.h"
#include "serial.h"
/* Forward declarations. */
static void putchar(int c);
void
{
extern int ic_int;
}
void
{
}
/*
* Convert the integer D to a string and save the string in BUF. If
* BASE is equal to 'd', interpret that D is decimal, and if BASE is
* equal to 'x', interpret that D is hexadecimal.
*/
static void
{
char *p = buf;
unsigned long ud = d;
int divisor = 10;
/* If %d is specified and D is minus, put `-' in the head. */
if (base == 'd' && d < 0) {
*p++ = '-';
buf++;
ud = -d;
} else if (base == 'x') {
divisor = 16;
}
/* Divide UD by DIVISOR until UD == 0. */
do {
*p++ = (remainder < 10) ?
}
;
/* Terminate BUF. */
*p = 0;
/* Reverse BUF. */
p2 = p - 1;
p1++;
p2--;
}
}
/*
* Printn prints a number n in base b.
* We don't use recursion to avoid deep kernel stacks.
*/
/* XXX need to support 64-bit numbers */
static void
{
char prbuf[40];
char *cp;
do {
*cp++ = "0123456789abcdef"[n%b];
n /= b;
width--;
} while (n);
while (width-- > 0)
do {
}
/*
* Format a string and print it on the screen, just like the libc
* function printf.
*/
void
{
char *s;
int64_t l;
loop:
width = 0;
while ((c = *fmt++) != '%') {
if (c == '\0')
return;
putchar(c);
}
c = *fmt++;
pad = '0';
ells++;
switch (c) {
case 'd':
case 'D':
b = 10;
if (ells == 0)
else if (ells == 1)
else
if (l < 0) {
putchar('-');
width--;
putchar('-');
width--;
ul = -l;
} else
ul = l;
goto number;
case 'p':
ells = 1;
/* FALLTHROUGH */
case 'x':
case 'X':
b = 16;
goto u_number;
case 'u':
b = 10;
goto u_number;
case 'o':
case 'O':
b = 8;
if (ells == 0)
else if (ells == 1)
else
break;
case 'c':
for (i = 24; i >= 0; i -= 8)
if ((c = ((b >> i) & 0x7f)) != 0) {
putchar(c);
}
break;
case 's':
while ((c = *s++) != 0) {
putchar(c);
}
break;
case '%':
putchar('%');
break;
}
goto loop;
}
/*
* Format a string and print it on the screen, just like the libc
* function printf.
*/
void
{
}
/* serial port stuff */
static int port = 0x3f8;
static void
serial_putchar(int c)
{
int checks = 10000;
;
}
static void
_doputchar(int c)
{
serial_putchar(c);
}
void
putchar(int c)
{
static int bhcharpos = 0;
if (c == '\t') {
do {
_doputchar(' ');
} while (++bhcharpos % 8);
return;
} else if (c == '\n') {
bhcharpos = 0;
_doputchar('\r');
_doputchar(c);
return;
} else if (c == '\b') {
if (bhcharpos)
bhcharpos--;
_doputchar(c);
return;
}
bhcharpos++;
_doputchar(c);
}
void
print_long(int reg)
{
}
void
{
}
void
{
}