VirtualBox

Changeset 2880 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 25, 2007 3:44:10 PM (18 years ago)
Author:
vboxsync
Message:

Use a 64Hz PIT rate instead of the 1KHz one. Don't spin for keypress in outer loops.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/BIOS/logo.c

    r1896 r2880  
    77#define BMP_HEADER_WIN3  40
    88
    9 #define F12_SCAN_CODE  0x86
    10 #define F12_WAIT_TIME  3 * 1000 /* Milliseconds, used only if logo disabled */
     9#define WAIT_HZ         64
     10#define WAIT_MS         16
     11
     12#define F12_SCAN_CODE   0x86
     13#define F12_WAIT_TIME   (3 * WAIT_HZ)   /* 3 seconds. Used only if logo disabled. */
    1114
    1215typedef struct
     
    127130static unsigned char get_mode();
    128131static void          set_mode();
    129 static Bit8u         wait(ms);
     132static Bit8u         wait(ticks, stop_on_key);
    130133static void          write_pixel();
    131134
     
    231234{
    232235    // The default is 18.2 ticks per second (~55ms tick interval).
    233     // Set the timer to 1ms ticks (65536 / (Hz / 18.2)).
     236    // Set the timer to 16ms ticks (64K / (Hz / (PIT_HZ / 64K)) = count).
     237    // 0x10000 / (1000 / (1193182 / 0x10000)) = 1193 (0x04a9)
     238    // 0x10000 / ( 128 / (1193182 / 0x10000)) = 9321 (0x2469)
     239    // 0x10000 / (  64 / (1193182 / 0x10000)) = 18643 (0x48d3)
    234240ASM_START
    235241    mov al, #0x34 ; timer0: binary count, 16bit count, mode 2
    236242    out 0x43, al
    237     mov al, #0xA9 ; Low byte
     243    mov al, #0xd3 ; Low byte - 64Hz
    238244    out 0x40, al
    239     mov al, #0x04 ; High byte
     245    mov al, #0x48 ; High byte - 64Hz
    240246    out 0x40, al
    241247ASM_END
     
    257263    /*
    258264     * Reinitialize the tick and rollover counts since we've
    259      * screwed them up by running the timer at 1000HZ for a while.
     265     * screwed them up by running the timer at WAIT_HZ for a while.
    260266     */
    261267    pushad
     
    271277
    272278/**
    273  * Waits (sleeps) for the given number of milliseconds.
     279 * Waits (sleeps) for the given number of ticks.
    274280 * Checks for keystroke.
    275281 *
    276282 * @returns BIOS scan code if available, 0 if not.
    277  * @param   ms  Number of milliseconds to sleep.
     283 * @param   ticks       Number of ticks to sleep.
     284 * @param   stop_on_key Whether to stop immediately upon keypress.
    278285 */
    279 Bit8u wait(ms)
    280   Bit16u ms;
     286Bit8u wait(ticks, stop_on_key)
     287  Bit16u ticks;
     288  Bit8u stop_on_key;
    281289{
    282290    long ticks_to_wait, delta;
     
    292300    sti
    293301ASM_END
    294     ticks_to_wait = ms;
     302    ticks_to_wait = ticks;
    295303    prev_ticks = read_dword(0x0, 0x46c);
    296304    do
     
    313321            scan_code = get_keystroke();
    314322            bios_printf(BIOS_PRINTF_INFO, "Key pressed: %x\n", scan_code);
     323            if (stop_on_key)
     324                return scan_code;
    315325        }
    316326    } while (ticks_to_wait > 0);
     
    471481            *palette++;
    472482        }
    473         scode = wait(15);
     483        scode = wait(16 / WAIT_MS, 0);
    474484        if (scode)
    475485            scan_code = scode;
     
    516526            *palette++;
    517527        }
    518         scode = wait(15);
     528        scode = wait(16 / WAIT_MS, 0);
    519529        if (scode)
    520530            scan_code = scode;
     
    973983
    974984        // Wait (interval in milliseconds)
    975         scode = wait(logo_time);
     985        scode = wait(logo_time / WAIT_MS, 0);
    976986        if (scode && scan_code != F12_SCAN_CODE)
    977987            scan_code = scode;
     
    10311041            {
    10321042                // Wait for timeout or keystroke
    1033                 for (i = 0; i < F12_WAIT_TIME; i++)
    1034                 {
    1035                     scan_code = wait(1);
    1036                     if (scan_code)
    1037                         break;
    1038                 }
     1043                scan_code = wait(F12_WAIT_TIME, 1);
    10391044            }
    10401045        }
     
    10801085
    10811086            // Wait for keystroke
    1082             for (;;)
     1087            do
    10831088            {
    1084                 scan_code = wait(1);
    1085                 if (scan_code)
    1086                     break;
    1087             }
     1089                scan_code = wait(WAIT_HZ, 1);
     1090            } while (scan_code == 0);
    10881091
    10891092            // Change first boot device code to selected one
     
    11201123    {
    11211124        printf(" %d", i);
    1122         wait(1000);
     1125        wait(WAIT_HZ, 0);
    11231126    }
    11241127    printf("\n");
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette