VirtualBox

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


Ignore:
Timestamp:
Dec 2, 2022 1:01:48 AM (2 years ago)
Author:
vboxsync
Message:

BIOS: The compiler refuses to re-load / restore DS after calling the VGA BIOS init code in rom_scan() because of the small memory model, so do it forcibly as the C compiler assumes DS=f000h everywhere. bugref:6549

File:
1 edited

Legend:

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

    r96407 r97726  
    3131#include "inlines.h"
    3232
    33 #if DEBUG_POST
     33#if DEBUG_POST  || 0
    3434#  define DPRINT(...) BX_DEBUG(__VA_ARGS__)
    3535#else
     
    8181
    8282/* The ROM init routine might trash register. Give the compiler a heads-up. */
    83 typedef void (rom_init_rtn)(void);
    84 #pragma aux rom_init_rtn modify [ax bx cx dx si di es] loadds;
     83typedef void __far (rom_init_rtn)(void);
     84#pragma aux rom_init_rtn modify [ax bx cx dx si di es /*ignored:*/ bp] /*ignored:*/ loadds;
     85
     86/* The loadds bit is ignored for rom_init_rtn, the impression from the code
     87   generator is that this is due to using a memory model where DS is fixed.
     88   If we add DS as a modified register, we'll get run into compiler error
     89   E1122 (BAD_REG) because FixedRegs() in cg/intel/386/c/386rgtbl.c returns
     90   HW_DS as part of the fixed register set that cannot be modified.
     91
     92   The problem of the vga bios trashing DS isn't a biggie, except when
     93   something goes sideways before we can reload it.  Setting a I/O port
     94   breakpoint on port 80h and wait a while before resuming execution
     95   (ba i 1 80 "sleep 400 ; g") will usually trigger a keyboard init panic and
     96   showcase the issue.  The panic message is garbage because it's read from
     97   segment 0c000h instead of 0f000h. */
     98static void restore_ds_as_dgroup(void);
     99#pragma aux restore_ds_as_dgroup = \
     100    "mov ax, 0f000h" \
     101    "mov ds, ax" \
     102    modify exact [ax];
     103
    85104
    86105/* Scan for ROMs in the given range and execute their POST code. */
     
    98117            DPRINT("Found ROM at segment %04X\n", start_seg);
    99118            if (!rom_checksum((void __far *)rom, rom->num_blks)) {
    100                 rom_init_rtn    __far *rom_init;
     119                rom_init_rtn *rom_init;
    101120
    102121                /* Checksum good, initialize ROM. */
    103                 rom_init = (void __far *)&rom->code;
     122                rom_init = (rom_init_rtn *)&rom->code;
    104123                rom_init();
    105124                int_disable();
     125                restore_ds_as_dgroup();
     126                /** @todo BP is not restored. */
    106127                DPRINT("ROM initialized\n");
    107128
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