VirtualBox

Changeset 92290 in vbox for trunk/src/VBox/Devices/PC


Ignore:
Timestamp:
Nov 9, 2021 12:49:35 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
148136
Message:

BIOS: Use get_cmos_word in other places where we read two adjacent cmos values and combine them into a 16-bit word. Saves 128 bytes. bugref:6549

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

Legend:

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

    r89364 r92290  
    751751                if (idxCmosChsBase && inb_cmos(idxCmosChsBase+7))
    752752                {
    753                     lgeo.cylinders = inb_cmos(idxCmosChsBase + 0) + (inb_cmos(idxCmosChsBase + 1) << 8);
     753                    lgeo.cylinders = get_cmos_word(idxCmosChsBase /*, idxCmosChsBase+1*/);
    754754                    lgeo.heads     = inb_cmos(idxCmosChsBase + 2);
    755755                    lgeo.spt       = inb_cmos(idxCmosChsBase + 7);
  • trunk/src/VBox/Devices/PC/BIOS/ata.c

    r89364 r92290  
    588588            if (chsgeo_base)
    589589            {
    590                 lgeo.cylinders = inb_cmos(chsgeo_base) + (inb_cmos(chsgeo_base + 1) << 8);
     590                lgeo.cylinders = get_cmos_word(chsgeo_base /*, chsgeo_base + 1*/);
    591591                lgeo.heads     = inb_cmos(chsgeo_base + 2);
    592592                lgeo.spt       = inb_cmos(chsgeo_base + 7);
  • trunk/src/VBox/Devices/PC/BIOS/bios.c

    r84752 r92290  
    8282    outb(cmos_port, cmos_reg);
    8383    outb(cmos_port + 1, val);
     84}
     85
     86/**
     87 * Reads two adjacent cmos bytes and return their values as a 16-bit word.
     88 */
     89uint16_t get_cmos_word(uint8_t idxFirst)
     90{
     91    return ((uint16_t)inb_cmos(idxFirst + 1) << 8)
     92         |            inb_cmos(idxFirst);
    8493}
    8594
  • trunk/src/VBox/Devices/PC/BIOS/biosint.h

    r84752 r92290  
    268268extern  uint8_t     inb_cmos(uint8_t cmos_reg);
    269269extern  void        outb_cmos(uint8_t cmos_reg, uint8_t val);
     270extern  uint16_t    get_cmos_word(uint8_t idxFirst);
    270271extern  uint16_t    cdrom_boot(void);
    271272extern  void        show_logo(void);
  • trunk/src/VBox/Devices/PC/BIOS/scsi.c

    r89364 r92290  
    387387                {
    388388                    /* If provided, grab the logical geometry from CMOS. */
    389                     cylinders         = inb_cmos(cmos_base + 0) + (inb_cmos(cmos_base + 1) << 8);
     389                    cylinders         = get_cmos_word(cmos_base /*, cmos_base + 1*/);
    390390                    heads             = inb_cmos(cmos_base + 2);
    391391                    sectors_per_track = inb_cmos(cmos_base + 7);
  • trunk/src/VBox/Devices/PC/BIOS/system.c

    r92288 r92290  
    468468        // Get the amount of extended memory (above 1M)
    469469#if VBOX_BIOS_CPU >= 80286
    470         AX = (inb_cmos(0x31) << 8) | inb_cmos(0x30);
     470        AX = get_cmos_word(0x30 /*, 0x31*/);
    471471
    472472#if VBOX_BIOS_CPU >= 80386
     
    613613    fpRange->xlen   = c64k_above_4G_high;
    614614    fpRange->type   = 1;        /* type is usable */
    615 }
    616 
    617 /**
    618  * Reads two adjacent cmos bytes and return their values as a 16-bit word.
    619  */
    620 static uint16_t get_cmos_word(uint8_t idxFirst)
    621 {
    622     return ((uint16_t)inb_cmos(idxFirst + 1) << 8)
    623          |            inb_cmos(idxFirst);
    624615}
    625616
     
    655646
    656647                /* Go for the amount of memory above 16MB first. */
    657                 extended_memory_size  = get_cmos_word(0x34 /*+ 0x35*/);
     648                extended_memory_size  = get_cmos_word(0x34 /*, 0x35*/);
    658649                if (extended_memory_size > 0)
    659650                {
     
    664655                {
    665656                    /* No memory above 16MB, query memory above 1MB ASSUMING we have at least 1MB. */
    666                     extended_memory_size  = get_cmos_word(0x30 /*+ 0x31*/);
     657                    extended_memory_size  = get_cmos_word(0x30 /*, 0x31*/);
    667658                    extended_memory_size += _1M / _1K;
    668659                    extended_memory_size *= _1K;
     
    671662                /* This is the amount of memory above 4GB measured in 64KB units.
    672663                   Note! 0x65 can be used when we need to go beyond 255 TiB */
    673                 c64k_above_4G_low  = get_cmos_word(0x61 /*+ 0x62*/);
    674                 c64k_above_4G_high = get_cmos_word(0x63 /*+ 0x64*/);
     664                c64k_above_4G_low  = get_cmos_word(0x61 /*, 0x62*/);
     665                c64k_above_4G_high = get_cmos_word(0x63 /*, 0x64*/);
    675666
    676667#ifdef BIOS_WITH_MCFG_E820 /** @todo Actually implement the mcfg reporting. */
     
    776767
    777768            // Get the amount of extended memory (above 1M)
    778             CX = (inb_cmos(0x31) << 8) | inb_cmos(0x30);
     769            CX = get_cmos_word(0x30 /*, 0x31*/);
    779770
    780771            // limit to 15M
     
    783774
    784775            // Get the amount of extended memory above 16M in 64k blocks
    785             DX = (inb_cmos(0x35) << 8) | inb_cmos(0x34);
     776            DX = get_cmos_word(0x34 /*, 0x35*/);
    786777
    787778            // Set configured memory equal to extended memory
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