VirtualBox

Changeset 82278 in vbox


Ignore:
Timestamp:
Nov 28, 2019 9:23:32 PM (5 years ago)
Author:
vboxsync
Message:

VGABIOS: Use inlines instead of calls for far memory access. Saves over 700 bytes of code.

Location:
trunk/src/VBox/Devices/Graphics/BIOS
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/BIOS/inlines.h

    r82246 r82278  
    3131#define outw(p, v)  outpw(p, v)
    3232
    33 extern  uint8_t     read_byte(uint16_t seg, uint16_t offset);
    34 extern  uint16_t    read_word(uint16_t seg, uint16_t offset);
    35 extern  uint32_t    read_dword(uint16_t seg, uint16_t offset);
    36 extern  void        write_byte(uint16_t seg, uint16_t offset, uint8_t data);
    37 extern  void        write_word(uint16_t seg, uint16_t offset, uint16_t data);
    38 extern  void        write_dword(uint16_t seg, uint16_t offset, uint32_t data);
     33/* Far byte/word/dword access routines. */
     34
     35inline uint8_t read_byte(uint16_t seg, uint16_t offset)
     36{
     37    return( *(seg:>(uint8_t *)offset) );
     38}
     39
     40inline void write_byte(uint16_t seg, uint16_t offset, uint8_t data)
     41{
     42    *(seg:>(uint8_t *)offset) = data;
     43}
     44
     45inline uint16_t read_word(uint16_t seg, uint16_t offset)
     46{
     47    return( *(seg:>(uint16_t *)offset) );
     48}
     49
     50inline void write_word(uint16_t seg, uint16_t offset, uint16_t data)
     51{
     52    *(seg:>(uint16_t *)offset) = data;
     53}
     54
     55inline uint32_t read_dword(uint16_t seg, uint16_t offset)
     56{
     57    return( *(seg:>(uint32_t *)offset) );
     58}
     59
     60inline void write_dword(uint16_t seg, uint16_t offset, uint32_t data)
     61{
     62    *(seg:>(uint32_t *)offset) = data;
     63}
    3964
    4065void int_enable(void);
  • trunk/src/VBox/Devices/Graphics/BIOS/vgabios.c

    r82246 r82278  
    7878static uint8_t find_vga_entry();
    7979
     80extern uint8_t xread_byte(uint16_t seg, uint16_t offset);
     81
    8082#ifdef VBE
    8183extern uint16_t __cdecl vbe_has_vbe_display(void);
     
    13911393     mask=0x80>>j;
    13921394     outw(VGAREG_GRDC_ADDRESS, (mask << 8) | 0x08);
    1393      read_byte(0xa000,dest);
     1395     xread_byte(0xa000,dest);
    13941396     if(fdata[src+i]&mask)
    13951397      {
     
    16381640     outw(VGAREG_GRDC_ADDRESS, (mask << 8) | 0x08);
    16391641     outw(VGAREG_GRDC_ADDRESS, 0x0205);
    1640      data = read_byte(0xa000,addr);
     1642     data = xread_byte(0xa000,addr);
    16411643     if (AL & 0x80)
    16421644      {
     
    23252327/* =========================================================== */
    23262328
    2327 uint8_t read_byte(uint16_t seg, uint16_t offset)
     2329/* This function is used for planar VGA memory reads to defeat the
     2330 * optimizer. We must read exactly one byte, otherwise the screen
     2331 * may be corrupted.
     2332 */
     2333uint8_t xread_byte(uint16_t seg, uint16_t offset)
    23282334{
    23292335    return( *(seg:>(uint8_t *)offset) );
    2330 }
    2331 
    2332 void write_byte(uint16_t seg, uint16_t offset, uint8_t data)
    2333 {
    2334     *(seg:>(uint8_t *)offset) = data;
    2335 }
    2336 
    2337 uint16_t read_word(uint16_t seg, uint16_t offset)
    2338 {
    2339     return( *(seg:>(uint16_t *)offset) );
    2340 }
    2341 
    2342 void write_word(uint16_t seg, uint16_t offset, uint16_t data)
    2343 {
    2344     *(seg:>(uint16_t *)offset) = data;
    2345 }
    2346 
    2347 uint32_t read_dword(uint16_t seg, uint16_t offset)
    2348 {
    2349     return( *(seg:>(uint32_t *)offset) );
    2350 }
    2351 
    2352 void write_dword(uint16_t seg, uint16_t offset, uint32_t data)
    2353 {
    2354     *(seg:>(uint32_t *)offset) = data;
    23552336}
    23562337
     
    25662547        if (GET_AL() < 2) {
    25672548            write_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL,
    2568               (read_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL) & ~1) | GET_AL());
     2549              (xread_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL) & ~1) | GET_AL());
    25692550            SET_AL(0x12);
    25702551        }
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