VirtualBox

Changeset 60433 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Apr 11, 2016 5:14:35 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
106519
Message:

PCBIOS: 286 fixes, improved the BIOSORG checking as overflows in this area are hard to figure out.

Location:
trunk/src/VBox/Devices
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/BiosCommonCode/biosorg_check.sed

    r60422 r60433  
    1818
    1919
    20 /biosorg_check_/!b end 
     20/biosorg_check_at_/b check_at
     21/biosorg_check_before_or_at_/b check_before_or_at
     22b end
     23
     24:check_at
     25#p # --debug
    2126s/\(.*\)/\L\1/g
    22 s/f000:\(....\). *biosorg_check_0\(\1\)h *//
     27s/....:\(....\). *biosorg_check_at_0\(\1\)h *//
    2328/^$/b end
     29q 1
     30b end
     31
     32# after or equal.
     33:check_before_or_at
     34#p # --debug
     35s/\(.*\)/\L\1/g
     36
     37h
     38s/^....:\(....\). *biosorg_check_before_or_at_0\(....\)h */\2/
     39x
     40s/^....:\(....\)/\1 /
     41
     42
     43# Loop for comparing the two addresses.  The one in the pattern buffer (left) must be
     44# smaller or equal to the one in in the pattern buffer (BIOSORG address).
     45:compare_loop
     46/^f/b match_f_or_greater
     47/^e/b match_e_or_greater
     48/^d/b match_d_or_greater
     49/^c/b match_c_or_greater
     50/^b/b match_b_or_greater
     51/^a/b match_a_or_greater
     52/^9/b match_9_or_greater
     53/^8/b match_8_or_greater
     54/^7/b match_7_or_greater
     55/^6/b match_6_or_greater
     56/^5/b match_5_or_greater
     57/^4/b match_4_or_greater
     58/^3/b match_3_or_greater
     59/^2/b match_2_or_greater
     60/^1/b match_1_or_greater
     61/^0/b match_0_or_greater
     62:bad
     63p
     64x
    2465p
    2566q 1
     67b end
     68
     69:bad_other
     70x
     71b bad
     72
     73
     74:match_f_or_greater
     75x
     76/^f/b next_compare
     77b bad_other
     78
     79:match_e_or_greater
     80x
     81/^f/b end
     82/^e/b next_compare
     83b bad_other
     84
     85:match_d_or_greater
     86x
     87/^[e-f]/b end
     88/^d/b next_compare
     89b bad_other
     90
     91:match_c_or_greater
     92x
     93/^[d-f]/b end
     94/^c/b next_compare
     95b bad_other
     96
     97:match_b_or_greater
     98x
     99/^[c-f]/b end
     100/^b/b next_compare
     101b bad_other
     102
     103:match_a_or_greater
     104x
     105/^[b-f]/b end
     106/^a/b next_compare
     107b bad_other
     108
     109:match_9_or_greater
     110x
     111/^[a-f]/b end
     112/^9/b next_compare
     113b bad_other
     114
     115:match_8_or_greater
     116x
     117/^[9a-f]/b end
     118/^8/b next_compare
     119b bad_other
     120
     121:match_7_or_greater
     122x
     123/^[8-9a-f]/b end
     124/^7/b next_compare
     125b bad_other
     126
     127:match_6_or_greater
     128x
     129/^[7-9a-f]/b end
     130/^6/b next_compare
     131b bad_other
     132
     133:match_5_or_greater
     134x
     135/^[6-9a-f]/b end
     136/^5/b next_compare
     137b bad_other
     138
     139:match_4_or_greater
     140x
     141/^[5-9a-f]/b end
     142/^4/b next_compare
     143b bad_other
     144
     145:match_3_or_greater
     146x
     147/^[4-9a-f]/b end
     148/^3/b next_compare
     149b bad_other
     150
     151:match_2_or_greater
     152x
     153/^[3-9a-f]/b end
     154/^2/b next_compare
     155b bad_other
     156
     157:match_1_or_greater
     158x
     159/^[2-9a-f]/b end
     160/^1/b next_compare
     161b bad_other
     162
     163:match_0_or_greater
     164x
     165/^[1-9a-f]/b end
     166/^0/b next_compare
     167b bad_other
     168
     169
     170# Next round of the loop.
     171# 1. Drop the leading digit of the max address (BIOSORG).
     172# 2. Check if we've reached end of the address. If so, check that we've reached the space in the actual address.
     173# 3. Switch buffers so the actual address in the pattern space.
     174# 4. Drop the leading digit of the actual address.
     175# 5. Repeat.
     176:next_compare
     177s/^.//
     178/^$/b end_of_compare
     179x
     180s/^.//
     181b compare_loop
     182
     183:end_of_compare
     184x
     185/^. /b end
     186b bad
     187
    26188:end
    27189
  • trunk/src/VBox/Devices/BiosCommonCode/commondefs.inc

    r60422 r60433  
    119119
    120120;; Adds a special label that will have its address checked after linking.
    121 BIOSORG_CHECK macro     addr
    122 public          biosorg_check_&addr
    123 biosorg_check_&addr:
     121BIOSORG_CHECK macro addr
     122public biosorg_check_at_&addr
     123biosorg_check_at_&addr:
    124124                endm
    125125
     126;; Adds a special label that will have its address checked after linking.
     127BIOSORG_CHECK_BEFORE macro addr
     128public  biosorg_check_before_or_at_&addr
     129biosorg_check_before_or_at_&addr:
     130                endm
     131
     132
  • trunk/src/VBox/Devices/PC/BIOS/ata.c

    r60422 r60433  
    475475
    476476            removable = (*(buffer+0) & 0x80) ? 1 : 0;
     477#if VBOX_BIOS_CPU >= 80386
    477478            mode      = *(buffer+96) ? ATA_MODE_PIO32 : ATA_MODE_PIO16;
     479#else
     480            mode      = ATA_MODE_PIO16;
     481#endif
    478482            blksize   = 512;  /* There is no sector size field any more. */
    479483
     
    572576            type      = *(buffer+1) & 0x1f;
    573577            removable = (*(buffer+0) & 0x80) ? 1 : 0;
     578#if VBOX_BIOS_CPU >= 80386
    574579            mode      = *(buffer+96) ? ATA_MODE_PIO32 : ATA_MODE_PIO16;
     580#else
     581            mode      = ATA_MODE_PIO16;
     582#endif
    575583            blksize   = 2048;
    576584
  • trunk/src/VBox/Devices/PC/BIOS/ata.h

    r56292 r60433  
    5050#define ATA_MODE_NONE    0x00
    5151#define ATA_MODE_PIO16   0x00
    52 #define ATA_MODE_PIO32   0x01
     52#if VBOX_BIOS_CPU >= 80386
     53# define ATA_MODE_PIO32  0x01
     54#endif
    5355#define ATA_MODE_ISADMA  0x02
    5456#define ATA_MODE_PCIDMA  0x03
  • trunk/src/VBox/Devices/PC/BIOS/disk.c

    r58724 r60433  
    487487            options  = (translation == GEO_TRANSLATION_NONE ? 0 : 1 << 3);  // chs translation
    488488            options |= (1 << 4);    // lba translation
     489#if VBOX_BIOS_CPU >= 80386
    489490            options |= (mode == ATA_MODE_PIO32 ? 1 : 0 << 7);
     491#endif
    490492            options |= (translation == GEO_TRANSLATION_LBA ? 1 : 0 << 9);
    491493            options |= (translation == GEO_TRANSLATION_RECHS ? 3 : 0 << 9);
  • trunk/src/VBox/Devices/PC/BIOS/eltorito.c

    r58841 r60433  
    921921            options |= (1<<5); // removable device
    922922            options |= (1<<6); // atapi device
     923#if VBOX_BIOS_CPU >= 80386
    923924            options |= (mode==ATA_MODE_PIO32?1:0<<7);
     925#endif
    924926
    925927            bios_dsk->dpte.iobase1  = iobase1;
  • trunk/src/VBox/Devices/PC/BIOS/logo.c

    r56292 r60433  
    116116 */
    117117void wait_uninit(void);
    118 #pragma aux wait_uninit =   \
     118#if VBOX_BIOS_CPU >= 80386
     119# pragma aux wait_uninit =   \
    119120    ".386"                  \
    120121    "mov    al, 34h"        \
     
    130131    "popad"                 \
    131132    modify [ax] nomemory;
     133#else
     134# pragma aux wait_uninit = \
     135    "mov    al, 34h" \
     136    "out    43h, al" \
     137    "xor    ax, ax" \
     138    "out    40h, al" \
     139    "out    40h, al" \
     140    "push   bp" \
     141    "push   ds" \
     142    "mov    ds, ax" \
     143    "call   rtc_post" \
     144    "pop    ds" \
     145    "pop    bp" \
     146    modify [ax bx cx dx si di];
     147#endif
    132148
    133149
     
    331347
    332348
    333     // Set PIT to 1ms ticks
     349    // Set PIT to 64hz.
    334350    wait_init();
    335351
  • trunk/src/VBox/Devices/PC/BIOS/orgs.asm

    r60422 r60433  
    7474
    7575;; Set a fixed BIOS location, with a marker for verification
    76 BIOSORG         macro   addr
     76BIOSORG         macro   addr, addr_minus_two
     77.errnz (addr - 2 - addr_minus_two) ;; Couldn't convince wasm to accept $ here. Would've save us a lot of bother and ugly SED.
     78                BIOSORG_CHECK_BEFORE addr_minus_two
    7779                org     addr - BIOS_FIX_BASE - 2
    7880                db      'XM'
     
    204206;; Start of fixed code - eoi_jmp_post is kept near here to allow short jumps.
    205207;;
    206                 BIOSORG 0E030h
     208                BIOSORG 0E030h, 0E02Eh
    207209eoi_both_pics:
    208210                mov     al, PIC_CMD_EOI
     
    236238;; POST entry point
    237239;; --------------------------------------------------------
    238                 BIOSORG 0E05Bh
     240                BIOSORG 0E05Bh, 0E059h
    239241post:
    240242                cli
     
    426428
    427429                ;; Initialize PCI devices. This can and should be done early.
    428 if VBOX_BIOS_CPU ge 80386
     430if VBOX_BIOS_CPU ge 80386 ; (Impossible to do on 16-bit CPUs.)
    429431                call    pcibios_init_iomem_bases
    430432                call    pcibios_init_irqs
     
    532534;; NMI handler
    533535;; --------------------------------------------------------
    534                 BIOSORG 0E2C3h
     536                BIOSORG 0E2C3h, 0E2C1h
    535537nmi:
    536538                C_SETUP
     
    660662;; INT 13h handler - Disk services
    661663;; --------------------------------------------------------
    662                 BIOSORG 0E3FEh
     664                BIOSORG 0E3FEh, 0E3FCh
    663665
    664666int13_handler:
     
    676678;; INT 19h handler - Boot load service
    677679;; --------------------------------------------------------
    678                 BIOSORG 0E6F2h
     680                BIOSORG 0E6F2h, 0E6F0h
    679681
    680682int19_handler:
     
    744746;; Baud Rate Generator Table
    745747;; --------------------------------------------------------
    746                 BIOSORG 0E729h
     748                BIOSORG 0E729h, 0E727h
    747749
    748750
     
    750752;; INT 14h handler -  Serial Communication Service
    751753;; --------------------------------------------------------
    752                 BIOSORG 0E739h
     754                BIOSORG 0E739h, 0E737h
    753755int14_handler:
    754756                push    ds
     
    826828;; INT 16h handler - Keyboard service
    827829;; --------------------------------------------------------
    828                 BIOSORG 0E82Eh
     830                BIOSORG 0E82Eh, 0E82Ch
    829831int16_handler:
    830832                sti
     
    898900;; INT 09h handler - Keyboard ISR (IRQ 1)
    899901;; --------------------------------------------------------
    900                 BIOSORG 0E987h
     902                BIOSORG 0E987h, 0E985h
    901903int09_handler:
    902904                cli                     ; TODO: why? they're off already!
     
    976978;; INT 13h handler - Diskette service
    977979;; --------------------------------------------------------
    978                 BIOSORG 0EC59h
     980                BIOSORG 0EC59h, 0EC57h
    979981int13_diskette:
    980982                jmp     int13_noeltorito
     
    12971299               jnz      rtc_pos_hour_loop
    12981300
    1299 
    1300                 mov     ax, [46Ch]
    1301                 mov     dx, [46Ch+2]
    1302 
    13031301rtc_pos_shift:
    13041302                mov     cl, ch
     
    13651363;; INT 0Eh handler - Diskette IRQ 6 ISR
    13661364;; --------------------------------------------------------
    1367                 BIOSORG 0EF57h
     1365                BIOSORG 0EF57h, 0EF55h
    13681366int0e_handler:
    13691367                push    ax
     
    14091407;; Diskette Parameter Table
    14101408;; --------------------------------------------------------
    1411                 BIOSORG 0EFC7h
     1409                BIOSORG 0EFC7h, 0EFC5h
    14121410_diskette_param_table:
    14131411                db      0AFh
     
    14831481;; INT 10h functions 0-Fh entry point
    14841482;; --------------------------------------------------------
    1485                 BIOSORG 0F045h
     1483                BIOSORG 0F045h, 0F043h
    14861484i10f0f_entry:
    14871485                iret
     
    14911489;; INT 10h handler - MDA/CGA video
    14921490;; --------------------------------------------------------
    1493                 BIOSORG 0F065h
     1491                BIOSORG 0F065h, 0F063h
    14941492int10_handler:
    14951493                ;; do nothing - assumes VGA
     
    15001498;; MDA/CGA Video Parameter Table (INT 1Dh)
    15011499;; --------------------------------------------------------
    1502                 BIOSORG 0F0A4h
     1500                BIOSORG 0F0A4h, 0F0A2h
    15031501mdacga_vpt:
    15041502
     
    16141612;; INT 12h handler - Memory size
    16151613;; --------------------------------------------------------
    1616                 BIOSORG 0F841h
     1614                BIOSORG 0F841h, 0F83Fh
    16171615int12_handler:
    16181616                ;; Don't touch - fixed size!
     
    17651763;; 8x8 font (first 128 characters)
    17661764;; --------------------------------------------------------
    1767                 BIOSORG 0FA6Eh
     1765                BIOSORG 0FA6Eh, 0FA6Ch
    17681766include font8x8.inc
    17691767
     
    18181816                iret
    18191817
     1818if VBOX_BIOS_CPU lt 80386
     1819;
     1820; We're tight on space down below in the int08_handler, so put
     1821; the 16-bit rollover code here.
     1822;
     1823int08_maybe_rollover:
     1824               ja       int08_rollover
     1825                cmp     ax, 00B0h
     1826               jb       int08_store_ticks
     1827                ;; there has been a midnight rollover
     1828int08_rollover:
     1829                xor     dx, dx
     1830                xor     ax, ax
     1831
     1832                inc     byte ptr ds:[70h]       ; increment rollover flag
     1833                jmp     int08_store_ticks
     1834endif
    18201835
    18211836;; --------------------------------------------------------
    18221837;; Timer tick - IRQ 0 handler
    18231838;; --------------------------------------------------------
    1824                 BIOSORG 0FEA5h
     1839                BIOSORG 0FEA5h, 0FEA3h
    18251840int08_handler:
    18261841if VBOX_BIOS_CPU ge 80386
     
    18311846                sti
    18321847                push    ax
    1833                 push    bx
    18341848endif
    18351849                push    ds
     
    18431857else
    18441858                mov     ax, ds:[6Ch]    ; get ticks dword
    1845                mov     bx, ds:[6Ch+2]
    1846                 add     ax, 1
    1847                adc      bx, 0
     1859               mov     dx, ds:[6Ch+2]
     1860               inc      ax              ; inc+jz+inc saves two bytes over add+adc.
     1861               jnz      int08_compare
     1862               inc      dx
     1863int08_compare:
    18481864endif
    18491865
     
    18511867if VBOX_BIOS_CPU ge 80386
    18521868                cmp     eax, 1800B0h
     1869               jb       int08_store_ticks
    18531870else
    1854                 cmp     bx, 18h
    1855                jb       int08_store_ticks
    1856                ja       int08_rollover
    1857                cmp      ax, 00B0h
    1858 endif
    1859                 jb      int08_store_ticks
     1871                cmp     dx, 18h
     1872               jae      int08_maybe_rollover
     1873endif
     1874
     1875if VBOX_BIOS_CPU ge 80386
    18601876                ;; there has been a midnight rollover
    1861 int08_rollover:
    1862 if VBOX_BIOS_CPU ge 80386
    18631877                xor     eax, eax
    1864 else
    1865                 xor     ax, ax
    1866                 xor     bx, bx
    1867 endif
    18681878                inc     byte ptr ds:[70h]       ; increment rollover flag
    18691879
    18701880int08_store_ticks:
    1871 if VBOX_BIOS_CPU ge 80386
    18721881                mov     ds:[6Ch], eax
    18731882else
     1883int08_store_ticks:
    18741884                mov     ds:[6Ch], ax
    1875                 mov     ds:[6Ch+2], bx
     1885                mov     ds:[6Ch+2], dx
    18761886endif
    18771887
     
    19001910                .286
    19011911else
    1902                 pop     bx
    19031912                pop     ax
    19041913endif
     
    19091918;; Initial interrupt vector offsets for POST
    19101919;; --------------------------------------------------------
    1911                 BIOSORG 0FEF3h
     1920                BIOSORG 0FEF3h, 0FEF1h
    19121921vector_table:
    19131922
     
    19171926;; BIOS copyright string
    19181927;; --------------------------------------------------------
    1919                 BIOSORG 0FF00h
     1928                BIOSORG 0FF00h, 0FEFEh
    19201929bios_string:
    19211930                db      BIOS_COPYRIGHT
     
    19251934;; IRET - default interrupt handler
    19261935;; --------------------------------------------------------
    1927                 BIOSORG 0FF53h
     1936                BIOSORG 0FF53h, 0FF51h
    19281937
    19291938dummy_iret:
     
    19441953;; Processor reset entry point
    19451954;; --------------------------------------------------------
    1946                 BIOSORG 0FFF0h
     1955                BIOSORG 0FFF0h, 0FFEEh
    19471956cpu_reset:
    19481957                ;; This is where the CPU starts executing after a reset
  • trunk/src/VBox/Devices/PC/BIOS/pciutil.c

    r56292 r60433  
    4545
    4646
     47#if VBOX_BIOS_CPU >= 80386
    4748/* Warning: Destroys high bits of ECX. */
    4849uint16_t pci_find_class(uint16_t op, uint32_t dev_class, uint16_t start_bdf);
    49 #pragma aux pci_find_class =    \
     50# pragma aux pci_find_class =    \
    5051    ".386"                  \
    5152    "shl    ecx, 16"        \
     
    5758    "found:"                \
    5859    parm [ax] [cx dx] [si] value [bx];
     60#endif
    5961
    6062uint16_t pci_find_dev(uint16_t op, uint16_t dev_id, uint16_t ven_id, uint16_t start_bdf);
     
    7779    parm [ax] [bx] [di] value [cx];
    7880
     81#if VBOX_BIOS_CPU >= 80386
    7982/* Warning: Destroys high bits of ECX. */
    8083uint32_t pci_read_cfgd(uint16_t op, uint16_t bus_dev_fn, uint16_t reg);
    81 #pragma aux pci_read_cfgd = \
     84# pragma aux pci_read_cfgd = \
    8285    ".386"                  \
    8386    "int    0x1a"           \
     
    8588    "shr    ecx, 16"        \
    8689    parm [ax] [bx] [di] value [cx ax];
     90#endif
    8791
    8892uint8_t pci_write_cfgb(uint16_t op, uint16_t bus_dev_fn, uint16_t reg, uint8_t val);
     
    96100    parm [ax] [bx] [di] [cx];
    97101
     102#if VBOX_BIOS_CPU >= 80386
    98103/* Warning: Destroys high bits of ECX. */
    99104uint8_t pci_write_cfgd(uint16_t op, uint16_t bus_dev_fn, uint16_t reg, uint32_t val);
    100 #pragma aux pci_write_cfgd = \
     105# pragma aux pci_write_cfgd = \
    101106    ".386"                  \
    102107    "xchg   cx, dx"         \
     
    105110    "int    0x1a"           \
    106111    parm [ax] [bx] [di] [dx cx];
     112#endif
    107113
    108114
     
    119125uint16_t pci_find_classcode(uint32_t dev_class)
    120126{
     127#if VBOX_BIOS_CPU >= 80386
    121128    return pci_find_class((PCIBIOS_ID << 8) | PCIBIOS_FIND_CLASS_CODE, dev_class, 0);
     129#else
     130    return UINT16_C(0xffff);
     131#endif
    122132}
    123133
     
    134144uint32_t pci_read_config_dword(uint8_t bus, uint8_t dev_fn, uint8_t reg)
    135145{
     146#if VBOX_BIOS_CPU >= 80386
    136147    return pci_read_cfgd((PCIBIOS_ID << 8) | PCIBIOS_READ_CONFIG_DWORD, (bus << 8) | dev_fn, reg);
     148#else
     149    return pci_read_cfgw((PCIBIOS_ID << 8) | PCIBIOS_READ_CONFIG_WORD, (bus << 8) | dev_fn, reg)
     150        || ((uint32_t)pci_read_cfgw((PCIBIOS_ID << 8) | PCIBIOS_READ_CONFIG_WORD, (bus << 8) | dev_fn, reg + 2) << 16);
     151#endif
    137152}
    138153
  • trunk/src/VBox/Devices/PC/DevPcBios.cpp

    r60422 r60433  
    13471347    }
    13481348
     1349    /*
     1350     * Get the CPU arch so we can load the appropriate ROMs.
     1351     */
     1352    PVM pVM = PDMDevHlpGetVM(pDevIns);
     1353    CPUMMICROARCH const enmMicroarch = pVM ? pVM->cpum.ro.GuestFeatures.enmMicroarch : kCpumMicroarch_Intel_P6;
     1354
    13491355    if (pThis->pszPcBiosFile)
    13501356    {
     
    14051411         * Use one of the embedded BIOS ROM images.
    14061412         */
    1407         PVM pVM = PDMDevHlpGetVM(pDevIns);
    1408         CPUMMICROARCH enmMicroarch = pVM ? pVM->cpum.ro.GuestFeatures.enmMicroarch : kCpumMicroarch_Intel_P6;
    14091413        uint8_t const *pbBios;
    14101414        uint32_t       cbBios;
     
    15341538    }
    15351539
    1536     uint64_t cbFileLanBoot;
    1537     const uint8_t *pu8LanBootBinary = NULL;
    1538     uint64_t cbLanBootBinary;
    1539 
    1540     /*
    1541      * Determine the LAN boot ROM size, open specified ROM file in the process.
    1542      */
    1543     RTFILE FileLanBoot = NIL_RTFILE;
    1544     if (pThis->pszLanBootFile)
    1545     {
    1546         rc = RTFileOpen(&FileLanBoot, pThis->pszLanBootFile,
    1547                         RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
    1548         if (RT_SUCCESS(rc))
    1549         {
    1550             rc = RTFileGetSize(FileLanBoot, &cbFileLanBoot);
     1540    /*
     1541     * Not loading LAN ROM for old CPUs.
     1542     */
     1543    if (   enmMicroarch != kCpumMicroarch_Intel_8086
     1544        && enmMicroarch != kCpumMicroarch_Intel_80186
     1545        && enmMicroarch != kCpumMicroarch_NEC_V20
     1546        && enmMicroarch != kCpumMicroarch_NEC_V30
     1547        && enmMicroarch != kCpumMicroarch_Intel_80286)
     1548    {
     1549        const uint8_t  *pu8LanBootBinary = NULL;
     1550        uint64_t        cbLanBootBinary;
     1551        uint64_t        cbFileLanBoot;
     1552
     1553        /*
     1554         * Open the LAN boot ROM and figure it size.
     1555         * Determine the LAN boot ROM size, open specified ROM file in the process.
     1556         */
     1557        if (pThis->pszLanBootFile)
     1558        {
     1559            RTFILE hFileLanBoot = NIL_RTFILE;
     1560            rc = RTFileOpen(&hFileLanBoot, pThis->pszLanBootFile,
     1561                            RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
    15511562            if (RT_SUCCESS(rc))
    15521563            {
    1553                 if (cbFileLanBoot > _64K - (VBOX_LANBOOT_SEG << 4 & 0xffff))
    1554                     rc = VERR_TOO_MUCH_DATA;
    1555             }
    1556         }
    1557         if (RT_FAILURE(rc))
    1558         {
    1559             /*
    1560              * Ignore failure and fall back to the built-in LAN boot ROM.
    1561              */
    1562             LogRel(("PcBios: Failed to open LAN boot ROM file '%s', rc=%Rrc!\n", pThis->pszLanBootFile, rc));
    1563             RTFileClose(FileLanBoot);
    1564             FileLanBoot = NIL_RTFILE;
    1565             MMR3HeapFree(pThis->pszLanBootFile);
    1566             pThis->pszLanBootFile = NULL;
    1567         }
    1568     }
    1569 
    1570     /*
    1571      * Get the LAN boot ROM data.
    1572      */
    1573     if (pThis->pszLanBootFile)
    1574     {
    1575         LogRel(("PcBios: Using LAN ROM '%s' with a size of %#x bytes\n", pThis->pszLanBootFile, cbFileLanBoot));
     1564                rc = RTFileGetSize(hFileLanBoot, &cbFileLanBoot);
     1565                if (RT_SUCCESS(rc))
     1566                {
     1567                    if (cbFileLanBoot <= _64K - (VBOX_LANBOOT_SEG << 4 & 0xffff))
     1568                    {
     1569                        LogRel(("PcBios: Using LAN ROM '%s' with a size of %#x bytes\n", pThis->pszLanBootFile, cbFileLanBoot));
     1570
     1571                        /*
     1572                         * Allocate buffer for the LAN boot ROM data and load it.
     1573                         */
     1574                        pThis->pu8LanBoot = (uint8_t *)PDMDevHlpMMHeapAllocZ(pDevIns, cbFileLanBoot);
     1575                        if (pThis->pu8LanBoot)
     1576                        {
     1577                            rc = RTFileRead(hFileLanBoot, pThis->pu8LanBoot, cbFileLanBoot, NULL);
     1578                            AssertLogRelRCReturnStmt(rc, RTFileClose(hFileLanBoot), rc);
     1579                        }
     1580                        else
     1581                            rc = VERR_NO_MEMORY;
     1582                    }
     1583                    else
     1584                        rc = VERR_TOO_MUCH_DATA;
     1585                }
     1586                RTFileClose(hFileLanBoot);
     1587            }
     1588            if (RT_FAILURE(rc))
     1589            {
     1590                /*
     1591                 * Play stupid and ignore failures, falling back to the built-in LAN boot ROM.
     1592                 */
     1593                /** @todo r=bird: This should have some kind of rational. We don't usually
     1594                 *        ignore the VM configuration.  */
     1595                LogRel(("PcBios: Failed to open LAN boot ROM file '%s', rc=%Rrc!\n", pThis->pszLanBootFile, rc));
     1596                MMR3HeapFree(pThis->pszLanBootFile);
     1597                pThis->pszLanBootFile = NULL;
     1598            }
     1599        }
     1600
     1601        /* If we were unable to get the data from file for whatever reason, fall
     1602         * back to the built-in LAN boot ROM image.
     1603         */
     1604        if (pThis->pu8LanBoot == NULL)
     1605        {
     1606#ifdef VBOX_WITH_PXE_ROM
     1607            pu8LanBootBinary = g_abNetBiosBinary;
     1608            cbLanBootBinary  = g_cbNetBiosBinary;
     1609#endif
     1610        }
     1611        else
     1612        {
     1613            pu8LanBootBinary = pThis->pu8LanBoot;
     1614            cbLanBootBinary  = cbFileLanBoot;
     1615        }
     1616
    15761617        /*
    1577          * Allocate buffer for the LAN boot ROM data.
     1618         * Map the Network Boot ROM into memory.
     1619         *
     1620         * Currently there is a fixed mapping: 0x000e2000 to 0x000effff contains
     1621         * the (up to) 56 kb ROM image.  The mapping size is fixed to trouble with
     1622         * the saved state (in PGM).
    15781623         */
    1579         pThis->pu8LanBoot = (uint8_t *)PDMDevHlpMMHeapAllocZ(pDevIns, cbFileLanBoot);
    1580         if (pThis->pu8LanBoot)
    1581         {
    1582             rc = RTFileRead(FileLanBoot, pThis->pu8LanBoot, cbFileLanBoot, NULL);
    1583             if (RT_FAILURE(rc))
    1584             {
    1585                 AssertMsgFailed(("RTFileRead(,,%d,NULL) -> %Rrc\n", cbFileLanBoot, rc));
    1586                 MMR3HeapFree(pThis->pu8LanBoot);
    1587                 pThis->pu8LanBoot = NULL;
    1588             }
    1589             rc = VINF_SUCCESS;
    1590         }
    1591         else
    1592             rc = VERR_NO_MEMORY;
    1593     }
     1624        if (pu8LanBootBinary)
     1625        {
     1626            pThis->cbLanBoot = cbLanBootBinary;
     1627
     1628            rc = PDMDevHlpROMRegister(pDevIns, VBOX_LANBOOT_SEG << 4,
     1629                                      RT_MAX(cbLanBootBinary, _64K - (VBOX_LANBOOT_SEG << 4 & 0xffff)),
     1630                                      pu8LanBootBinary, cbLanBootBinary,
     1631                                      PGMPHYS_ROM_FLAGS_SHADOWED, "Net Boot ROM");
     1632            AssertRCReturn(rc, rc);
     1633        }
     1634    }
     1635    else if (pThis->pszLanBootFile)
     1636        LogRel(("PcBios: Skipping LAN ROM '%s' due to ancient target CPU.\n", pThis->pszLanBootFile));
     1637#ifdef VBOX_WITH_PXE_ROM
    15941638    else
    1595         pThis->pu8LanBoot = NULL;
    1596 
    1597     /* cleanup */
    1598     if (FileLanBoot != NIL_RTFILE)
    1599         RTFileClose(FileLanBoot);
    1600 
    1601     /* If we were unable to get the data from file for whatever reason, fall
    1602      * back to the built-in LAN boot ROM image.
    1603      */
    1604     if (pThis->pu8LanBoot == NULL)
    1605     {
    1606 #ifdef VBOX_WITH_PXE_ROM
    1607         pu8LanBootBinary = g_abNetBiosBinary;
    1608         cbLanBootBinary  = g_cbNetBiosBinary;
     1639        LogRel(("PcBios: Skipping built in ROM due to ancient target CPU.\n"));
    16091640#endif
    1610     }
    1611     else
    1612     {
    1613         pu8LanBootBinary = pThis->pu8LanBoot;
    1614         cbLanBootBinary  = cbFileLanBoot;
    1615     }
    1616 
    1617     /*
    1618      * Map the Network Boot ROM into memory.
    1619      *
    1620      * Currently there is a fixed mapping: 0x000e2000 to 0x000effff contains
    1621      * the (up to) 56 kb ROM image.  The mapping size is fixed to trouble with
    1622      * the saved state (in PGM).
    1623      */
    1624     if (pu8LanBootBinary)
    1625     {
    1626         pThis->cbLanBoot = cbLanBootBinary;
    1627 
    1628         rc = PDMDevHlpROMRegister(pDevIns, VBOX_LANBOOT_SEG << 4,
    1629                                   RT_MAX(cbLanBootBinary, _64K - (VBOX_LANBOOT_SEG << 4 & 0xffff)),
    1630                                   pu8LanBootBinary, cbLanBootBinary,
    1631                                   PGMPHYS_ROM_FLAGS_SHADOWED, "Net Boot ROM");
    1632         AssertRCReturn(rc, rc);
    1633     }
    1634 
     1641
     1642    /*
     1643     * Configure Boot delay.
     1644     */
    16351645    rc = CFGMR3QueryU8Def(pCfg, "DelayBoot", &pThis->uBootDelay, 0);
    16361646    if (RT_FAILURE(rc))
Note: See TracChangeset for help on using the changeset viewer.

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