logo.c revision 6939e4b349be6ef24806ad5edc331dec413d55a6
#define COMPRESS_NONE 0
#define COMPRESS_RLE8 1
#define COMPRESS_RLE4 2
#define BMP_HEADER_OS21 12
#define BMP_HEADER_OS22 64
#define BMP_HEADER_WIN3 40
#define WAIT_HZ 64
#define WAIT_MS 16
#define F12_SCAN_CODE 0x86
#define LOGO_SHOW_STEPS 64
#define LOGO_IMAGE_DEFAULT 0
#define LOGO_IMAGE_EXTERNAL 1
#define LOGO_CMD_NOP 0
#define LOGO_CMD_SET_OFFSET 0x100
#define LOGO_CMD_SET_X 0x200
#define LOGO_CMD_SET_Y 0x300
#define LOGO_CMD_SET_WIDTH 0x400
#define LOGO_CMD_SET_HEIGHT 0x500
#define LOGO_CMD_SET_DEPTH 0x600
#define LOGO_CMD_SET_PALSIZE 0x700
#define LOGO_CMD_SET_DEFAULT 0x800
#define LOGO_CMD_SET_PAL 0x900
#define LOGO_CMD_SHOW_BMP 0xA00
#define LOGO_CMD_SHOW_TEXT 0xB00
#define LOGO_CMD_CLS 0xC00
#define LOGO_IO_PORT 0x3b8
typedef struct
{
} RGBPAL;
/* BMP File Format Bitmap Header. */
typedef struct
{
} BMPINFO;
/* OS/2 1.x Information Header Format. */
typedef struct
{
} OS2HDR;
/* OS/2 2.0 Information Header Format. */
typedef struct
{
} OS22HDR;
/* Windows 3.x Information Header Format. */
typedef struct
{
} WINHDR;
// Logo settings header
typedef struct
{
} LOGOHDR;
static unsigned char get_mode();
static void set_mode();
static void write_pixel();
static Bit8u read_logo_byte();
static Bit16u read_logo_word();
/**
* Get current video mode (VGA).
* @returns Video mode.
*/
unsigned char get_mode()
{
int #0x10
}
/**
* 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;
}
void vesa_set_bank(bank)
{
int #0x10
}
{
if (offset)
{
}
else
return inb(LOGO_IO_PORT);
}
{
if (offset)
{
}
else
return inw(LOGO_IO_PORT);
}
Bit16u set_logo_x(x)
Bit16u x;
{
outw(LOGO_IO_PORT, x);
}
Bit16u set_logo_y(y)
Bit16u y;
{
outw(LOGO_IO_PORT, y);
}
Bit16u w;
{
outw(LOGO_IO_PORT, w);
}
Bit16u h;
{
outw(LOGO_IO_PORT, h);
}
Bit16u d;
{
outw(LOGO_IO_PORT, d);
}
Bit16u s;
{
outw(LOGO_IO_PORT, s);
}
{
}
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 c;
// Set PIT to 1ms ticks
wait_init();
is_logo_failed = 0;
logo_hdr = 0;
logo_hdr_size = sizeof(LOGOHDR);
// Get main signature
if (tmp != 0x66BB)
goto done;
// Get options
// Is Logo disabled?
goto done;
// Set offset of bitmap header
// Check bitmap ID
{
goto error;
}
else
{
// Check the size of the information header that indicates
// the structure type
{
clr_used = 0;
}
else
{
}
else
{
}
else
goto error;
// Test some bitmap fields
goto error;
if (planes != 1)
goto error;
goto error;
if (clr_used > 256)
goto error;
// Bitmap processing
if (compr != COMPRESS_NONE)
goto error;
// Screen size
scr_width = 640;
scr_height = 480;
// Center of screen
// Read palette
if (hdr_size == BMP_HEADER_OS21)
{
}
else
{
if (clr_used)
else
}
// Set video mode #0x142 640x480x32bpp
vesa_set_mode(0x142);
// 0 bank
vesa_set_bank(0);
// Show bitmap
// Clear screen
if (is_fade_in)
{
for (i = 0; i <= LOGO_SHOW_STEPS; i++)
{
if (uBootMenu == 2)
show_boot_text(i);
}
}
else
{
if (uBootMenu == 2)
}
// 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 (uBootMenu == 2)
show_boot_text(i);
if (scode == F12_SCAN_CODE)
f12_pressed = 1;
}
}
}
goto done;
if (!is_logo_failed)
{
is_logo_failed = 1;
logo_hdr_size = 0;
// Switch to defaul logo
goto show_bmp;
}
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
printf("\n"
"VirtualBox temporary boot device selection\n"
"\n"
"Detected Hard disks:\n"
"\n");
printf("\n"
"Other 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();
}