Changeset 66130 in vbox
- Timestamp:
- Mar 16, 2017 2:21:01 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 114032
- Location:
- trunk/src/VBox/Devices/PC
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/VBox/Devices/PC/BIOS/apm.c ¶
r63562 r66130 77 77 }; 78 78 79 #define APM_PORT 0x 8900 /* Bochs power control port. */79 #define APM_PORT 0x040f /* Relocated Bochs power control port, original value of 0x9800 causes potential trouble with PCI resource allocation. */ 80 80 81 81 /// @todo merge with system.c -
TabularUnified trunk/src/VBox/Devices/PC/DevPcBios.cpp ¶
r65859 r66130 5 5 6 6 /* 7 * Copyright (C) 2006-201 6Oracle Corporation7 * Copyright (C) 2006-2017 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 213 213 /** Number of soft resets we've logged. */ 214 214 uint32_t cLoggedSoftResets; 215 /** Current port number for Bochs shutdown (used by APM). */ 216 RTIOPORT ShutdownPort; 217 /** True=use new port number for Bochs shutdown (used by APM). */ 218 bool fNewShutdownPort; 215 219 } DEVPCBIOS; 216 220 /** Pointer to the BIOS device state. */ … … 218 222 219 223 220 /** 221 * @callback_method_impl{FNIOMIOPORTIN, Boch Debug and Shutdown ports.} 224 /********************************************************************************************************************************* 225 * Defined Constants And Macros * 226 *********************************************************************************************************************************/ 227 /** The saved state version. */ 228 #define PCBIOS_SSM_VERSION 0 229 230 231 /********************************************************************************************************************************* 232 * Global Variables * 233 *********************************************************************************************************************************/ 234 /** Saved state DEVPCBIOS field descriptors. */ 235 static SSMFIELD const g_aPcBiosFields[] = 236 { 237 SSMFIELD_ENTRY( DEVPCBIOS, fNewShutdownPort), 238 SSMFIELD_ENTRY_TERM() 239 }; 240 241 242 /** 243 * @callback_method_impl{FNIOMIOPORTIN, Bochs Debug and Shutdown ports.} 222 244 */ 223 245 static DECLCALLBACK(int) pcbiosIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb) … … 229 251 230 252 /** 231 * @callback_method_impl{FNIOMIOPORTOUT, Boch Debug and Shutdown ports.}253 * @callback_method_impl{FNIOMIOPORTOUT, Bochs Debug and Shutdown ports.} 232 254 */ 233 255 static DECLCALLBACK(int) pcbiosIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) 234 256 { 235 257 RT_NOREF1(pvUser); 258 PDEVPCBIOS pThis = PDMINS_2_DATA(pDevIns, PDEVPCBIOS); 236 259 237 260 /* … … 242 265 || Port == 0x403)) 243 266 { 244 PDEVPCBIOS pThis = PDMINS_2_DATA(pDevIns, PDEVPCBIOS);245 267 /* The raw version. */ 246 268 switch (u32) … … 277 299 * Bochs BIOS shutdown request. 278 300 */ 279 if (cb == 1 && Port == 0x8900)301 if (cb == 1 && Port == pThis->ShutdownPort) 280 302 { 281 303 static const unsigned char szShutdown[] = "Shutdown"; … … 287 309 { 288 310 pThis->iShutdown = 0; 289 LogRel(("PcBios: 8900hshutdown request\n"));311 LogRel(("PcBios: APM shutdown request\n")); 290 312 return PDMDevHlpVMPowerOff(pDevIns); 291 313 } … … 298 320 /* not in use. */ 299 321 return VINF_SUCCESS; 322 } 323 324 325 /** 326 * Register the Bochs shutdown port. 327 * This is used by pcbiosConstruct, pcbiosReset and pcbiosLoadExec. 328 */ 329 static int pcbiosRegisterShutdown(PPDMDEVINS pDevIns, PDEVPCBIOS pThis, bool fNewShutdownPort) 330 { 331 if (pThis->ShutdownPort != 0) 332 { 333 int rc = PDMDevHlpIOPortDeregister(pDevIns, pThis->ShutdownPort, 1); 334 AssertRC(rc); 335 } 336 pThis->fNewShutdownPort = fNewShutdownPort; 337 if (fNewShutdownPort) 338 pThis->ShutdownPort = 0x040f; 339 else 340 pThis->ShutdownPort = 0x9800; 341 return PDMDevHlpIOPortRegister(pDevIns, pThis->ShutdownPort, 1, NULL, 342 pcbiosIOPortWrite, pcbiosIOPortRead, 343 NULL, NULL, "Bochs PC BIOS - Shutdown"); 344 } 345 346 /** 347 * Execute state save operation. 348 * 349 * @returns VBox status code. 350 * @param pDevIns Device instance which registered the data unit. 351 * @param pSSM SSM operation handle. 352 */ 353 static DECLCALLBACK(int) pcbiosSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 354 { 355 PDEVPCBIOS pThis = PDMINS_2_DATA(pDevIns, PDEVPCBIOS); 356 SSMR3PutStruct(pSSM, pThis, g_aPcBiosFields); 357 return VINF_SUCCESS; 358 } 359 360 361 /** 362 * Prepare state load operation. 363 * 364 * @returns VBox status code. 365 * @param pDevIns Device instance which registered the data unit. 366 * @param pSSM SSM operation handle. 367 */ 368 static DECLCALLBACK(int) pcbiosLoadPrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 369 { 370 RT_NOREF(pSSM); 371 PDEVPCBIOS pThis = PDMINS_2_DATA(pDevIns, PDEVPCBIOS); 372 /* Since there are legacy saved state files without any SSM data for PCBIOS 373 * this is the only way to handle them correctly. */ 374 pThis->fNewShutdownPort = false; 375 376 return VINF_SUCCESS; 377 } 378 379 /** 380 * Execute state load operation. 381 * 382 * @returns VBox status code. 383 * @param pDevIns Device instance which registered the data unit. 384 * @param pSSM SSM operation handle. 385 * @param uVersion Data layout version. 386 * @param uPass The data pass. 387 */ 388 static DECLCALLBACK(int) pcbiosLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 389 { 390 PDEVPCBIOS pThis = PDMINS_2_DATA(pDevIns, PDEVPCBIOS); 391 392 if (uVersion > PCBIOS_SSM_VERSION) 393 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; 394 Assert(uPass == SSM_PASS_FINAL); NOREF(uPass); 395 396 SSMR3GetStruct(pSSM, &pThis, g_aPcBiosFields); 397 398 return VINF_SUCCESS; 399 } 400 401 /** 402 * Finish state load operation. 403 * 404 * @returns VBox status code. 405 * @param pDevIns Device instance which registered the data unit. 406 * @param pSSM SSM operation handle. 407 */ 408 static DECLCALLBACK(int) pcbiosLoadDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 409 { 410 RT_NOREF(pSSM); 411 PDEVPCBIOS pThis = PDMINS_2_DATA(pDevIns, PDEVPCBIOS); 412 413 /* Update the shutdown port registration to match the flag. */ 414 return pcbiosRegisterShutdown(pDevIns, pThis, pThis->fNewShutdownPort); 300 415 } 301 416 … … 378 493 } 379 494 } 495 496 /* After reset the new BIOS code is active, use the new shutdown port. */ 497 pcbiosRegisterShutdown(pDevIns, pThis, true /* fNewShutdownPort */); 380 498 } 381 499 … … 1256 1374 if (RT_FAILURE(rc)) 1257 1375 return rc; 1258 rc = PDMDevHlpIOPortRegister(pDevIns, 0x8900, 1, NULL, pcbiosIOPortWrite, pcbiosIOPortRead, 1259 NULL, NULL, "Bochs PC BIOS - Shutdown"); 1376 rc = pcbiosRegisterShutdown(pDevIns, pThis, true /* fNewShutdownPort */); 1260 1377 if (RT_FAILURE(rc)) 1261 1378 return rc; 1379 1380 /* 1381 * Register SSM handlers, for remembering which shutdown port to use. 1382 */ 1383 rc = PDMDevHlpSSMRegisterEx(pDevIns, PCBIOS_SSM_VERSION, 1 /* cbGuess */, NULL, 1384 NULL, NULL, NULL, 1385 NULL, pcbiosSaveExec, NULL, 1386 pcbiosLoadPrep, pcbiosLoadExec, pcbiosLoadDone); 1262 1387 1263 1388 /*
Note:
See TracChangeset
for help on using the changeset viewer.