- Timestamp:
- Jul 10, 2023 1:46:21 PM (22 months ago)
- svn:sync-xref-src-repo-rev:
- 158203
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/bios.h
r98103 r100456 42 42 #endif 43 43 44 /** The BIOS shutdown port. 45 * You write "Shutdown" byte by byte to shutdown the VM. 44 /** The BIOS control port. 45 * Write "Shutdown" byte by byte to shutdown the VM. 46 * Write "Bootfail" to indicate no bootable device. 47 * Write "Prochalt" to execute alternative CPU halt. 46 48 * @sa VBOX_BIOS_OLD_SHUTDOWN_PORT */ 47 49 #define VBOX_BIOS_SHUTDOWN_PORT 0x040f 48 50 51 /** Write this value to shut down VM. */ 52 #define VBOX_BIOS_CTL_SHUTDOWN 0x8001 53 /** Write this value to report boot failure. */ 54 #define VBOX_BIOS_CTL_BOOTFAIL 0x8002 55 /** Write this value to halt CPU. */ 56 #define VBOX_BIOS_CTL_PROCHALT 0x8003 57 49 58 /** The old shutdown port number. 50 59 * Older versions of VirtualBox uses this as does Bochs. 51 * @sa VBOX_BIOS_ SHUTDOWN_PORT */60 * @sa VBOX_BIOS_CONTROL_PORT */ 52 61 #define VBOX_BIOS_OLD_SHUTDOWN_PORT 0x8900 53 62 -
trunk/include/VBox/bios.mac
r98103 r100456 41 41 %endif 42 42 %define VBOX_BIOS_SHUTDOWN_PORT 0x040f 43 %define VBOX_BIOS_CTL_SHUTDOWN 0x8001 44 %define VBOX_BIOS_CTL_BOOTFAIL 0x8002 45 %define VBOX_BIOS_CTL_PROCHALT 0x8003 43 46 %define VBOX_BIOS_OLD_SHUTDOWN_PORT 0x8900 44 47 %endif -
trunk/src/VBox/Devices/PC/BIOS/apm.c
r98103 r100456 162 162 /// @todo change connection state 163 163 break; 164 #if VBOX_BIOS_CPU >= 80286 164 165 case APM_PM_CONN: 165 166 /// @todo validate device ID … … 172 173 DI = APM_BIOS_SEG_LEN; /* Data segment length. */ 173 174 break; 175 #endif 174 176 #if VBOX_BIOS_CPU >= 80386 175 177 case APM_32_CONN: -
trunk/src/VBox/Devices/PC/BIOS/apm_pm.asm
r98103 r100456 38 38 public apm_pm16_entry 39 39 40 ; 41 ; This module is for protected mode only and therefore 42 ; 286+ only 43 ; 40 44 SET_DEFAULT_CPU_286 41 45 … … 82 86 83 87 apmf_idle: ; function 05h 88 if 1 89 ; Port I/O based HLT equivalent using a custom BIOS I/O port. 90 ; Works in situations where HLT can't be used, such as Windows 3.1 91 ; in Standard mode or DR-DOS 5.0/6.0 EMM386.SYS. 92 push si 93 push cx 94 push dx 95 96 mov dx, 40Fh 97 mov si, offset hlt_string 98 mov cx,8 99 rep outsb 100 101 pop dx 102 pop cx 103 pop si 104 105 jmp apmw_success 106 107 hlt_string db 'Prochalt' 108 109 else 84 110 ; 85 111 ; Windows 3.1 POWER.DRV in Standard mode calls into APM … … 95 121 hlt 96 122 jmp apmw_success 123 endif 97 124 98 125 apmf_busy: ; function 06h -
trunk/src/VBox/Devices/PC/DevPcBios.cpp
r100444 r100456 227 227 /** Whether to clear the shutdown status on hard reset. */ 228 228 bool fClearShutdownStatusOnHardReset; 229 /** Current port number for B ochs shutdown(used by APM). */230 RTIOPORT ShutdownPort;231 /** True=use new port number for B ochs shutdown(used by APM). */232 bool fNew ShutdownPort;229 /** Current port number for BIOS control (used by APM). */ 230 RTIOPORT ControlPort; 231 /** True=use new port number for BIOS control (used by APM). */ 232 bool fNewControlPort; 233 233 bool afPadding[3+4]; 234 /** The shudown I/O port, either at 0x040f or 0x8900 (old saved state). */ 235 IOMMMIOHANDLE hIoPortShutdown; 234 /** The BIOS I/O port, either at 0x040f or 0x8900 235 * (old saved state). */ 236 IOMMMIOHANDLE hIoPortControl; 236 237 } DEVPCBIOS; 237 238 /** Pointer to the BIOS device state. */ … … 252 253 static SSMFIELD const g_aPcBiosFields[] = 253 254 { 254 SSMFIELD_ENTRY( DEVPCBIOS, fNew ShutdownPort),255 SSMFIELD_ENTRY( DEVPCBIOS, fNewControlPort), 255 256 SSMFIELD_ENTRY_TERM() 256 257 }; … … 325 326 326 327 /** 327 * @callback_method_impl{FNIOMIOPORTNEWIN, B ochs Shutdownport.}328 * @callback_method_impl{FNIOMIOPORTNEWIN, BIOS control port.} 328 329 */ 329 330 static DECLCALLBACK(VBOXSTRICTRC) 330 pcbiosIOPort ShutdownRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb)331 pcbiosIOPortControlRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb) 331 332 { 332 333 RT_NOREF5(pDevIns, pvUser, offPort, pu32, cb); … … 335 336 336 337 337 /** 338 * @callback_method_impl{FNIOMIOPORTNEWOUT, Bochs Shutdown port.} 338 static VBOXSTRICTRC pcbiosApmShutdown(PPDMDEVINS pDevIns) 339 { 340 LogRel(("PcBios: APM shutdown request\n")); 341 return PDMDevHlpVMPowerOff(pDevIns); 342 } 343 344 345 static VBOXSTRICTRC pcbiosApmIdle(PPDMDEVINS pDevIns) 346 { 347 Log3(("PcBios: APM idle request\n")); 348 349 /* This request is used to put the CPU into a halted state *without* using 350 * a HLT instruction. This is especially useful for the APM BIOS 351 * in situations where executing HLT causes problems. See BIOS APM source 352 * code for comments. 353 * NB: The CPU will be woken up by an interrupt regardless of the 354 * state of rFLAGS.IF. 355 */ 356 int rc = PDMDevHlpVMWaitForDeviceReady(pDevIns, PDMDevHlpGetCurrentCpuId(pDevIns)); 357 return rc; 358 } 359 360 static void pcbiosReportBootFail(PPDMDEVINS pDevIns) 361 { 362 LogRel(("PcBios: Boot failure\n")); 363 int rc = PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "VMBootFail", 364 N_("The VM failed to boot. This is possibly caused by not having an operating system installed or a misconfigured boot order. Maybe picking a guest OS install DVD will resolve the situation")); 365 AssertRC(rc); 366 } 367 368 369 /** 370 * @callback_method_impl{FNIOMIOPORTNEWOUT, BIOS control port.} 339 371 */ 340 372 static DECLCALLBACK(VBOXSTRICTRC) 341 pcbiosIOPort ShutdownWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb)373 pcbiosIOPortControlWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb) 342 374 { 343 375 PDEVPCBIOS pThis = PDMDEVINS_2_DATA(pDevIns, PDEVPCBIOS); … … 349 381 static const unsigned char s_szShutdown[] = "Shutdown"; 350 382 static const unsigned char s_szBootfail[] = "Bootfail"; 383 static const unsigned char s_szProchalt[] = "Prochalt"; 351 384 AssertCompile(sizeof(s_szShutdown) == sizeof(s_szBootfail)); 385 AssertCompile(sizeof(s_szShutdown) == sizeof(s_szProchalt)); 352 386 353 387 if (pThis->iControl < sizeof(s_szShutdown)) /* paranoia */ … … 360 394 { 361 395 pThis->iControl = 0; 362 LogRel(("PcBios: APM shutdown request\n")); 363 return PDMDevHlpVMPowerOff(pDevIns); 396 return pcbiosApmShutdown(pDevIns); 364 397 } 365 398 } … … 370 403 { 371 404 pThis->iControl = 0; 372 LogRel(("PcBios: Boot failure\n")); 373 int rc = PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "VMBootFail", 374 N_("The VM failed to boot. This is possibly caused by not having an operating system installed or a misconfigured boot order. Maybe picking a guest OS install DVD will resolve the situation")); 375 AssertRC(rc); 405 pcbiosReportBootFail(pDevIns); 406 } 407 } 408 else if (u32 == s_szProchalt[pThis->iControl]) 409 { 410 411 pThis->iControl++; 412 if (pThis->iControl >= 8) 413 { 414 pThis->iControl = 0; 415 return pcbiosApmIdle(pDevIns); 376 416 } 377 417 } … … 382 422 pThis->iControl = 0; 383 423 } 424 else if (cb == 2) 425 { 426 pThis->iControl = 0; 427 /* Shortcuts for BIOS control, allowing guest to use one simple 16-bit I/O port write. */ 428 switch (u32) 429 { 430 case VBOX_BIOS_CTL_SHUTDOWN: 431 return pcbiosApmShutdown(pDevIns); 432 case VBOX_BIOS_CTL_BOOTFAIL: 433 pcbiosReportBootFail(pDevIns); 434 break; 435 case VBOX_BIOS_CTL_PROCHALT: 436 return pcbiosApmIdle(pDevIns); 437 default: 438 /* Ignore and do nothing. */ 439 LogFunc(("unrecognized control value (u32=%X)\n", u32)); 440 } 441 } 384 442 /* else: not in use. */ 385 443 … … 389 447 390 448 /** 391 * Register the B ochs shutdownport.449 * Register the BIOS control port. 392 450 * This is used by pcbiosConstruct, pcbiosReset and pcbiosLoadExec. 393 451 */ 394 static int pcbiosRegister Shutdown(PPDMDEVINS pDevIns, PDEVPCBIOS pThis, bool fNewShutdownPort)395 { 396 if (pThis-> ShutdownPort != 0)397 { 398 int rc = PDMDevHlpIoPortUnmap(pDevIns, pThis->hIoPort Shutdown);452 static int pcbiosRegisterControl(PPDMDEVINS pDevIns, PDEVPCBIOS pThis, bool fNewControlPort) 453 { 454 if (pThis->ControlPort != 0) 455 { 456 int rc = PDMDevHlpIoPortUnmap(pDevIns, pThis->hIoPortControl); 399 457 AssertRC(rc); 400 458 } 401 459 402 pThis->fNew ShutdownPort = fNewShutdownPort;403 if (fNew ShutdownPort)404 pThis-> ShutdownPort = VBOX_BIOS_SHUTDOWN_PORT;460 pThis->fNewControlPort = fNewControlPort; 461 if (fNewControlPort) 462 pThis->ControlPort = VBOX_BIOS_SHUTDOWN_PORT; 405 463 else 406 pThis-> ShutdownPort = VBOX_BIOS_OLD_SHUTDOWN_PORT;407 return PDMDevHlpIoPortMap(pDevIns, pThis->hIoPort Shutdown, pThis->ShutdownPort);464 pThis->ControlPort = VBOX_BIOS_OLD_SHUTDOWN_PORT; 465 return PDMDevHlpIoPortMap(pDevIns, pThis->hIoPortControl, pThis->ControlPort); 408 466 } 409 467 … … 421 479 /** 422 480 * @callback_method_impl{FNSSMDEVLOADPREP, 423 * Clears the fNew ShutdownPort flag prior to loading the state so that old481 * Clears the fNewControlPort flag prior to loading the state so that old 424 482 * saved VM states keeps using the old port address (no pcbios state)} 425 483 */ … … 431 489 /* Since there are legacy saved state files without any SSM data for PCBIOS 432 490 * this is the only way to handle them correctly. */ 433 pThis->fNew ShutdownPort = false;491 pThis->fNewControlPort = false; 434 492 435 493 return VINF_SUCCESS; … … 460 518 RT_NOREF(pSSM); 461 519 PDEVPCBIOS pThis = PDMDEVINS_2_DATA(pDevIns, PDEVPCBIOS); 462 return pcbiosRegister Shutdown(pDevIns, pThis, pThis->fNewShutdownPort);520 return pcbiosRegisterControl(pDevIns, pThis, pThis->fNewControlPort); 463 521 } 464 522 … … 542 600 } 543 601 544 /* After reset the new BIOS code is active, use the new shutdownport. */545 pcbiosRegister Shutdown(pDevIns, pThis, true /* fNewShutdownPort */);602 /* After reset the new BIOS code is active, use the new control port. */ 603 pcbiosRegisterControl(pDevIns, pThis, true /* fNewControlPort */); 546 604 } 547 605 … … 1506 1564 AssertRCReturn(rc, rc); 1507 1565 1508 rc = PDMDevHlpIoPortCreateIsa(pDevIns, 1 /*cPorts*/, pcbiosIOPort ShutdownWrite, pcbiosIOPortShutdownRead, NULL /*pvUser*/,1509 " Bochs PC BIOS - Shutdown", NULL /*paExtDescs*/, &pThis->hIoPortShutdown);1566 rc = PDMDevHlpIoPortCreateIsa(pDevIns, 1 /*cPorts*/, pcbiosIOPortControlWrite, pcbiosIOPortControlRead, NULL /*pvUser*/, 1567 "PC BIOS - Control", NULL /*paExtDescs*/, &pThis->hIoPortControl); 1510 1568 AssertRCReturn(rc, rc); 1511 rc = pcbiosRegister Shutdown(pDevIns, pThis, true /* fNewShutdownPort */);1569 rc = pcbiosRegisterControl(pDevIns, pThis, true /* fNewControlPort */); 1512 1570 AssertRCReturn(rc, rc); 1513 1571
Note:
See TracChangeset
for help on using the changeset viewer.