print.c revision b04ba41ea929f16cdc810888f7419a4adb2dfed6
/*
* Copyright (C) 2006-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
* --------------------------------------------------------------------
*
* This code is based on:
*
*
* Copyright (C) 2002 MandrakeSoft S.A.
*
* MandrakeSoft S.A.
* 43, rue d'Aboukir
* 75002 Paris - France
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <stdint.h>
#include <stdarg.h>
#include "inlines.h"
#include "biosint.h"
// Debug printf support
/* Redirect INFO output to backdoor logging port. */
#define PANIC_PORT 0x400
#define PANIC_PORT2 0x401
#define INFO_PORT 0x504
#define DEBUG_PORT 0x403
const char bios_prefix_string[] = "BIOS: ";
{
#if BX_DEBUG_SERIAL
if (c == '\n')
#endif
#if BX_VIRTUAL_PORTS
if (action & BIOS_PRINTF_DEBUG)
outb(DEBUG_PORT, c);
if (action & BIOS_PRINTF_INFO)
#endif
if (action & BIOS_PRINTF_SCREEN) {
if (c == '\n')
wrch('\r');
wrch(c);
}
}
{
if (nval)
else {
while (--width > 0)
if (neg)
}
}
{
if (nval)
else {
while (--width > 0)
if (neg)
}
}
{
if (nval)
else {
while (--width > 0)
if (neg)
}
}
{
uint8_t c;
while (c = *s) {
s++;
}
}
{
uint8_t c;
while (c = *s) {
s++;
}
}
//--------------------------------------------------------------------------
// bios_printf()
// A compact variable argument printf function.
//
// Supports %[format_width][length]format
// where format can be x,X,u,d,s,S,c
// and the optional length modifier is l (ell)
//--------------------------------------------------------------------------
{
uint8_t c;
int i;
in_format = 0;
format_width = 0;
#if BX_VIRTUAL_PORTS
#endif
}
while (c = *s) {
if ( c == '%' ) {
in_format = 1;
format_width = 0;
}
else if (in_format) {
if ( (c>='0') && (c<='9') ) {
}
else {
if (c == 'x' || c == 'X') {
if (format_width == 0)
format_width = 4;
if (c == 'x')
hexadd = 'a';
else
hexadd = 'A';
for (i=format_width-1; i>=0; i--) {
}
}
else if (c == 'u') {
}
else if (c == 'l') {
s++;
c = *s; /* is it ld,lx,lu? */
if (c == 'd') {
if (hibyte & 0x8000)
else
}
else if (c == 'u') {
}
else if (c == 'x' || c == 'X')
{
if (format_width == 0)
format_width = 8;
if (c == 'x')
hexadd = 'a';
else
hexadd = 'A';
for (i=format_width-1; i>=0; i--) {
}
}
}
else if (c == 'd') {
if (arg & 0x8000)
else
}
else if (c == 's') {
}
else if (c == 'S') {
}
else if (c == 'c') {
}
else
BX_PANIC("bios_printf: unknown format\n");
in_format = 0;
}
}
else {
}
++s;
}
if (action & BIOS_PRINTF_HALT) {
// freeze in a busy loop.
int_disable();
halt_forever();
}
}
// End of printf support