logo.c revision d8f69ec3ee1d4035c0c198a94de92b7c50873832
/* $Id$ */
/** @file
* Stuff for drawing the BIOS logo.
*/
/*
* Copyright (C) 2004-2008 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#define WAIT_HZ 64
#define WAIT_MS 16
#define F12_SCAN_CODE 0x86
#include <VBox/bioslogo.h>
//static void set_mode(mode);
//static void vesa_set_mode(mode);
//static Bit8u wait(ticks, stop_on_key);
/**
* Set video mode (VGA).
* @params New video mode.
*/
{
int #0x10
}
/**
* Set VESA video mode.
* @params New video mode.
*/
{
int #0x10
}
/**
* Check for keystroke.
* @returns True if keystroke available, False if not.
*/
{
int #0x16
done:
}
/**
* Get keystroke.
* @returns BIOS scan code.
*/
{
int #0x16
}
void wait_init()
{
// The default is 18.2 ticks per second (~55ms tick interval).
// Set the timer to 16ms ticks (64K / (Hz / (PIT_HZ / 64K)) = count).
// 0x10000 / (1000 / (1193182 / 0x10000)) = 1193 (0x04a9)
// 0x10000 / ( 128 / (1193182 / 0x10000)) = 9321 (0x2469)
// 0x10000 / ( 64 / (1193182 / 0x10000)) = 18643 (0x48d3)
}
void wait_uninit()
{
/* Restore the timer to the default 18.2Hz. */
/*
* Reinitialize the tick and rollover counts since we've
* screwed them up by running the timer at WAIT_HZ for a while.
*/
}
/**
* Waits (sleeps) for the given number of ticks.
* Checks for keystroke.
*
* @returns BIOS scan code if available, 0 if not.
* @param ticks Number of ticks to sleep.
* @param stop_on_key Whether to stop immediately upon keypress.
*/
{
long ticks_to_wait, delta;
Bit32u prev_ticks, t;
/*
* The 0:046c wraps around at 'midnight' according to a 18.2Hz clock.
* We also have to be careful about interrupt storms.
*/
do
{
if (t > prev_ticks)
{
ticks_to_wait -= delta;
}
else if (t < prev_ticks)
ticks_to_wait -= t; /* wrapped */
prev_ticks = t;
if (check_for_keystroke())
{
scan_code = get_keystroke();
if (stop_on_key)
return scan_code;
}
} while (ticks_to_wait > 0);
return scan_code;
}
{
return inb(LOGO_IO_PORT);
}
{
return inw(LOGO_IO_PORT);
}
void clear_screen()
{
// Hide cursor, clear screen and move cursor to starting position
int #0x10
int #0x10
int #0x10
}
void print_detected_harddisks()
{
Bit8u ide_ctrl_printed = 0;
Bit8u sata_ctrl_printed = 0;
Bit8u scsi_ctrl_printed = 0;
{
if (!VBOX_IS_SCSI_DEVICE(device))
{
{
printf("IDE controller:\n");
ide_ctrl_printed = 1;
}
{
printf("\n\nAHCI controller:\n");
sata_ctrl_printed = 1;
}
/*
* If actual_device is bigger than or equal 4
* this is the next controller and
* the positions start at the beginning.
*/
if (device >= 4)
device -= 4;
if (device / 2)
printf("Secondary ");
else
printf("Primary ");
if (device % 2)
printf("Slave");
else
printf("Master");
}
else
{
if (scsi_ctrl_printed == 0)
{
printf("\n\nSCSI controller:\n");
scsi_ctrl_printed = 1;
}
}
}
if ( (ide_ctrl_printed == 0)
&& (sata_ctrl_printed == 0)
&& (scsi_ctrl_printed == 0))
printf("No hard disks found");
printf("\n");
}
{
/* Check that the scan code is in the range of detected hard disks. */
/* The key '1' has scancode 0x02 which represents the first disk */
scode -= 2;
return scode;
/* Scancode is higher than number of available devices */
return 0xff;
}
void show_logo()
{
Bit8u f12_pressed = 0;
// Set PIT to 1ms ticks
wait_init();
// Get main signature
if (tmp != 0x66BB)
goto done;
// Get options
// Is Logo disabled?
goto done;
// Set video mode #0x142 640x480x32bpp
vesa_set_mode(0x142);
if (is_fade_in)
{
for (i = 0; i <= LOGO_SHOW_STEPS; i++)
{
if (scode == F12_SCAN_CODE)
{
f12_pressed = 1;
break;
}
}
}
else
// Wait (interval in milliseconds)
if (!f12_pressed)
{
if (scode == F12_SCAN_CODE)
f12_pressed = 1;
}
// Fade out (only if F12 was not pressed)
if (is_fade_out && !f12_pressed)
{
for (i = LOGO_SHOW_STEPS; i > 0 ; i--)
{
if (scode == F12_SCAN_CODE)
{
f12_pressed = 1;
break;
}
}
}
done:
// Clear forced boot drive setting.
// Don't restore previous video mode
// The default text mode should be set up. (defect #1235)
set_mode(0x0003);
// If Setup menu enabled
if (uBootMenu)
{
// If the graphics logo disabled
{
int i;
if (uBootMenu == 2)
printf("Press F12 to select boot device.\n");
// if the user has pressed F12 don't wait here
if (!f12_pressed)
{
// Wait for timeout or keystroke
if (scode == F12_SCAN_CODE)
f12_pressed = 1;
}
}
// If F12 pressed, show boot menu
if (f12_pressed)
{
Bit8u boot_device = 0;
Bit8u boot_drive = 0;
clear_screen();
// Show menu. Note that some versions of bcc freak out if we split these strings.
printf("\nVirtualBox temporary boot device selection\n\nDetected Hard disks:\n\n");
printf("\nOther boot devices:\n f) Floppy\n c) CD-ROM\n l) LAN\n\n b) Continue booting\n");
// Wait for keystroke
for (;;)
{
do
{
} while (scode == 0);
if (scode == 0x30)
{
// 'b' ... continue
break;
}
// Check if hard disk was selected
{
/*
* 0xff indicates that there is no mapping
* from the scan code to a hard drive.
* Wait for next keystroke.
*/
if (boot_drive == 0xff)
continue;
boot_device = 0x02;
break;
}
switch (scode)
{
case 0x21:
// Floppy
boot_device = 0x01;
break;
case 0x2e:
// CD-ROM
boot_device = 0x03;
break;
case 0x26:
// LAN
boot_device = 0x04;
break;
}
if (boot_device != 0)
break;
}
// Switch to text mode. Clears screen and enables cursor again.
set_mode(0x0003);
}
}
// Restore PIT ticks
wait_uninit();
return;
}
void delay_boot(secs)
{
Bit16u i;
if (!secs)
return;
// Set PIT to 1ms ticks
wait_init();
for (i = secs; i > 0; i--)
{
printf(" %d", i);
}
printf("\n");
// Restore PIT ticks
wait_uninit();
}