VirtualBox

Changeset 59114 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Dec 14, 2015 1:46:52 PM (9 years ago)
Author:
vboxsync
Message:

BIOS: Merged RMW sequences into single instructions.

Location:
trunk/src/VBox/Devices/PC/BIOS
Files:
4 edited

Legend:

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

    r56316 r59114  
    8282uint8_t floppy_wait_for_interrupt(void)
    8383{
     84    uint32_t    retries = 18;
     85
    8486    int_disable();
    85     for (;;)
     87    for (;retries;--retries)
    8688    {
    8789        uint8_t val8 = read_byte(0x0040, 0x003e);
     
    9092        int_enable_hlt_disable();
    9193    }
     94    return 0;
    9295}
    9396
     
    175178        // wait on 40:3e bit 7 to become 1
    176179        do {
     180            val8 = inb(0x80);
    177181            val8 = read_byte(0x0040, 0x003e);
    178         } while ( (val8 & 0x80) == 0 );
     182        } while ( (val8 & 0x80) == 0 && --retries);
    179183        val8 &= 0x7f;
    180184        int_disable();
  • trunk/src/VBox/Devices/PC/BIOS/keyboard.c

    r56292 r59114  
    5555void jmp_post(void);
    5656#pragma aux jmp_post = "jmp far ptr post" aborts;
     57
     58extern void eoi_master_pic(void);    /* in assembly code */
     59#pragma aux eoi_master_pic "*";
     60
     61/* Manually save/restore BP around invoking user Ctrl-Break handler.
     62 * The handler could conceivably clobber BP and the compiler does not
     63 * believe us when we say 'modify [bp]' (BP is considered unalterable).
     64 */
     65void int_1b(void);
     66#pragma aux int_1b =    \
     67    "push bp"           \
     68    "int 1Bh"           \
     69    "pop bp"            \
     70    value [bp] modify [bp];
     71
    5772
    5873#define none 0
     
    358373    }
    359374
    360 
    361     shift_flags = read_byte(0x0040, 0x17);
    362375    mf2_flags = read_byte(0x0040, 0x18);
    363376    mf2_state = read_byte(0x0040, 0x96);
     377    /* Check if suspend flag set but no E1 prefix (i.e. not Pause). */
     378    if ((mf2_flags & 0x08) && !(shift_flags & 0x01)) {
     379        /* Pause had been pressed. Clear suspend flag and do nothing. */
     380        mf2_flags &= ~0x08;
     381        write_byte(0x0040, 0x18, mf2_flags);
     382        return;
     383    }
     384
     385    shift_flags = read_byte(0x0040, 0x17);
    364386    asciicode = 0;
    365387
     
    441463        break;
    442464
    443     case 0x45: /* Num Lock press */
     465    case 0x45: /* Num Lock/Pause press */
    444466        if ((mf2_state & 0x03) == 0) {
     467            /* Num Lock */
    445468            mf2_flags |= 0x20;
    446469            write_byte(0x0040, 0x18, mf2_flags);
    447470            shift_flags ^= 0x20;
    448471            write_byte(0x0040, 0x17, shift_flags);
    449         }
    450         break;
    451     case 0xc5: /* Num Lock release */
     472        } else {
     473            /* Pause */
     474            mf2_flags |= 0x08;  /* Set the suspend flag */
     475            write_byte(0x0040, 0x18, mf2_flags);
     476
     477            /* Enable keyboard and send EOI. */
     478            outp(0x64, 0xae);
     479            eoi_master_pic();
     480
     481            while (read_byte(0x0040, 0x18) & 0x08)
     482                ;   /* Hold on and wait... */
     483
     484            //@todo: We will send EOI again (and enable keyboard) on the way out; we shouldn't
     485        }
     486        break;
     487    case 0xc5: /* Num Lock/Pause release */
    452488        if ((mf2_state & 0x03) == 0) {
    453489            mf2_flags &= ~0x20;
     
    456492        break;
    457493
    458     case 0x46: /* Scroll Lock press */
    459         mf2_flags |= 0x10;
    460         write_byte(0x0040, 0x18, mf2_flags);
    461         shift_flags ^= 0x10;
    462         write_byte(0x0040, 0x17, shift_flags);
    463         break;
    464 
    465     case 0xc6: /* Scroll Lock release */
    466         mf2_flags &= ~0x10;
    467         write_byte(0x0040, 0x18, mf2_flags);
     494    case 0x46: /* Scroll Lock/Break press */
     495        if (mf2_state & 0x02) { /* E0 prefix? */
     496            /* Zap the keyboard buffer. */
     497            write_word(0x0040, 0x001c, read_word(0x0040, 0x001a));
     498
     499            write_byte(0x0040, 0x71, 0x80); /* Set break flag */
     500            outp(0x64, 0xae);               /* Enable keyboard */
     501            int_1b();                       /* Invoke user handler */
     502            enqueue_key(0, 0);              /* Dummy key press*/
     503        } else {
     504            mf2_flags |= 0x10;
     505            write_byte(0x0040, 0x18, mf2_flags);
     506            shift_flags ^= 0x10;
     507            write_byte(0x0040, 0x17, shift_flags);
     508        }
     509        break;
     510
     511    case 0xc6: /* Scroll Lock/Break release */
     512        if (!(mf2_state & 0x02)) {  /* Only if no E0 prefix */
     513            mf2_flags &= ~0x10;
     514            write_byte(0x0040, 0x18, mf2_flags);
     515        }
    468516        break;
    469517
  • trunk/src/VBox/Devices/PC/BIOS/makefile

    r50160 r59114  
    1616CFLAGS   = -q -0 -wx -zu -s -oas -d1+ -ms
    1717CFLAGS32 = -q -wx -zu -s -oas -d1+ -ms -nt=BIOS32 -nd=BIOS32
     18# -oat seems to prevent ENTER/LEAVE generation
     19#CFLAGS32 = -q -wx -zu -s -oat -d1+ -ms -nt=BIOS32 -nd=BIOS32
    1820
    1921DEFS = -DVBOX -DVBOX_LANBOOT_SEG=0xE200 -DVBOX_VERSION_STRING=$(Q)0.9$(Q) &
     
    4547         clname DATA segaddr=0xF000 segment _DATA &
    4648         clname CODE &
    47          segment _TEXT segaddr=0xF000 offset=0x1600 &
     49         segment _TEXT segaddr=0xF000 offset=0x1C00 &
    4850         segment BIOS32 segaddr=0xF000 offset=0xDB00 &
    4951         segment BIOSSEG segaddr=0xF000 offset=0xE000 &
  • trunk/src/VBox/Devices/PC/BIOS/orgs.asm

    r57162 r59114  
    908908                xor     ax, ax
    909909                mov     ds, ax
    910                 mov     al, ds:[496h]   ; mf2_state |= 0x02
    911                 or      al, 2           ; TODO: why not RMW?
    912                 mov     ds:[496h], al
     910                or      byte ptr ds:[496h], 2   ; mf2_state |= 0x02
    913911                jmp     int09_done
    914912
     
    917915                jne     int09_process_key
    918916                xor     ax, ax
    919                 mov     ds, ax          ; TODO: haven't we just done that??
    920                 mov     al, ds:[496h]
    921                 or      al, 1
    922                 mov     ds:[496h], al   ; TODO: why not RMW?
     917                mov     ds, ax
     918                or      byte ptr ds:[496h], 1   ; mf2_state | 0x01
    923919                jmp     int09_done
    924920
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