logo.c revision f227ace9b3ddde1b2043e515602477d599f4a4a7
#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 actual_device = 0;
Bit8u first_ctrl_printed = 0;
Bit8u second_ctrl_printed = 0;
{
{
printf("IDE controller:\n");
first_ctrl_printed = 1;
}
{
printf("\n\nAHCI controller:\n");
second_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_position >= 4)
device_position -= 4;
if (device_position / 2)
printf("Secondary ");
else
printf("Primary ");
if (device_position % 2)
printf("Slave");
else
printf("Master");
}
printf("\n");
}
{
Bit8u detected_devices = 0;
{
if (device < BX_MAX_ATA_DEVICES)
{
scode--;
if (scode == 0x01)
return actual_device;
}
}
/* Scancode is higher than number of available devices */
return 0x08;
}
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.");
// 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
{
/*
* We support a maximum of 8 boot drives.
* If this value is bigger than 7 not all
* values are used and the user pressed
* and invalid key.
* Wait for the next pressed key.
*/
if (boot_drive > 7)
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();
}