Changeset 65960 in vbox
- Timestamp:
- Mar 6, 2017 11:21:22 PM (8 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 1 deleted
- 2 edited
-
Storage/DevATA.cpp (modified) (32 diffs)
-
Storage/PIIX3ATABmDma.h (deleted)
-
testcase/tstDeviceStructSizeRC.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevATA.cpp
r65648 r65960 64 64 #include <VBox/ata.h> 65 65 66 #include "PIIX3ATABmDma.h"67 66 #include "ATAPIPassthrough.h" 68 67 #include "VBoxDD.h" … … 110 109 #define ATA_MEDIA_NO_DISC 0x70 /**< Door closed, no medium */ 111 110 111 /** @defgroup grp_piix3atabmdma PIIX3 ATA Bus Master DMA 112 * @{ 113 */ 114 115 /** @name BM_STATUS 116 * @{ 117 */ 118 /** Currently performing a DMA operation. */ 119 #define BM_STATUS_DMAING 0x01 120 /** An error occurred during the DMA operation. */ 121 #define BM_STATUS_ERROR 0x02 122 /** The DMA unit has raised the IDE interrupt line. */ 123 #define BM_STATUS_INT 0x04 124 /** User-defined bit 0, commonly used to signal that drive 0 supports DMA. */ 125 #define BM_STATUS_D0DMA 0x20 126 /** User-defined bit 1, commonly used to signal that drive 1 supports DMA. */ 127 #define BM_STATUS_D1DMA 0x40 128 /** @} */ 129 130 /** @name BM_CMD 131 * @{ 132 */ 133 /** Start the DMA operation. */ 134 #define BM_CMD_START 0x01 135 /** Data transfer direction: from device to memory if set. */ 136 #define BM_CMD_WRITE 0x08 137 /** @} */ 138 139 /** @} */ 112 140 113 141 /********************************************************************************************************************************* 114 142 * Structures and Typedefs * 115 143 *********************************************************************************************************************************/ 144 /** @defgroup grp_piix3atabmdma PIIX3 ATA Bus Master DMA 145 * @{ 146 */ 147 /** PIIX3 Bus Master DMA unit state. */ 148 typedef struct BMDMAState 149 { 150 /** Command register. */ 151 uint8_t u8Cmd; 152 /** Status register. */ 153 uint8_t u8Status; 154 /** Address of the MMIO region in the guest's memory space. */ 155 RTGCPHYS32 GCPhysAddr; 156 } BMDMAState; 157 158 /** PIIX3 Bus Master DMA descriptor entry. */ 159 typedef struct BMDMADesc 160 { 161 /** Address of the DMA source/target buffer. */ 162 RTGCPHYS32 GCPhysBuffer; 163 /** Size of the DMA source/target buffer. */ 164 uint32_t cbBuffer; 165 } BMDMADesc; 166 /** @} */ 167 168 116 169 /** 117 170 * The state of an ATA device. … … 124 177 { 125 178 /** Flag indicating whether the current command uses LBA48 mode. */ 126 bool fLBA48;179 bool fLBA48; 127 180 /** Flag indicating whether this drive implements the ATAPI command set. */ 128 bool fATAPI;181 bool fATAPI; 129 182 /** Set if this interface has asserted the IRQ. */ 130 bool fIrqPending;183 bool fIrqPending; 131 184 /** Currently configured number of sectors in a multi-sector transfer. */ 132 uint8_t cMultSectors;185 uint8_t cMultSectors; 133 186 /** PCHS disk geometry. */ 134 PDMMEDIAGEOMETRY PCHSGeometry;187 PDMMEDIAGEOMETRY PCHSGeometry; 135 188 /** Total number of sectors on this disk. */ 136 uint64_t cTotalSectors;189 uint64_t cTotalSectors; 137 190 /** Sector size of the medium. */ 138 uint32_t cbSector;191 uint32_t cbSector; 139 192 /** Number of sectors to transfer per IRQ. */ 140 uint32_t cSectorsPerIRQ;193 uint32_t cSectorsPerIRQ; 141 194 142 195 /** ATA/ATAPI register 1: feature (write-only). */ 143 uint8_t uATARegFeature;196 uint8_t uATARegFeature; 144 197 /** ATA/ATAPI register 1: feature, high order byte. */ 145 uint8_t uATARegFeatureHOB;198 uint8_t uATARegFeatureHOB; 146 199 /** ATA/ATAPI register 1: error (read-only). */ 147 uint8_t uATARegError;200 uint8_t uATARegError; 148 201 /** ATA/ATAPI register 2: sector count (read/write). */ 149 uint8_t uATARegNSector;202 uint8_t uATARegNSector; 150 203 /** ATA/ATAPI register 2: sector count, high order byte. */ 151 uint8_t uATARegNSectorHOB;204 uint8_t uATARegNSectorHOB; 152 205 /** ATA/ATAPI register 3: sector (read/write). */ 153 uint8_t uATARegSector;206 uint8_t uATARegSector; 154 207 /** ATA/ATAPI register 3: sector, high order byte. */ 155 uint8_t uATARegSectorHOB;208 uint8_t uATARegSectorHOB; 156 209 /** ATA/ATAPI register 4: cylinder low (read/write). */ 157 uint8_t uATARegLCyl;210 uint8_t uATARegLCyl; 158 211 /** ATA/ATAPI register 4: cylinder low, high order byte. */ 159 uint8_t uATARegLCylHOB;212 uint8_t uATARegLCylHOB; 160 213 /** ATA/ATAPI register 5: cylinder high (read/write). */ 161 uint8_t uATARegHCyl;214 uint8_t uATARegHCyl; 162 215 /** ATA/ATAPI register 5: cylinder high, high order byte. */ 163 uint8_t uATARegHCylHOB;216 uint8_t uATARegHCylHOB; 164 217 /** ATA/ATAPI register 6: select drive/head (read/write). */ 165 uint8_t uATARegSelect;218 uint8_t uATARegSelect; 166 219 /** ATA/ATAPI register 7: status (read-only). */ 167 uint8_t uATARegStatus;220 uint8_t uATARegStatus; 168 221 /** ATA/ATAPI register 7: command (write-only). */ 169 uint8_t uATARegCommand;222 uint8_t uATARegCommand; 170 223 /** ATA/ATAPI drive control register (write-only). */ 171 uint8_t uATARegDevCtl;224 uint8_t uATARegDevCtl; 172 225 173 226 /** Currently active transfer mode (MDMA/UDMA) and speed. */ 174 uint8_t uATATransferMode;227 uint8_t uATATransferMode; 175 228 /** Current transfer direction. */ 176 uint8_t uTxDir;229 uint8_t uTxDir; 177 230 /** Index of callback for begin transfer. */ 178 uint8_t iBeginTransfer;231 uint8_t iBeginTransfer; 179 232 /** Index of callback for source/sink of data. */ 180 uint8_t iSourceSink;233 uint8_t iSourceSink; 181 234 /** Flag indicating whether the current command transfers data in DMA mode. */ 182 bool fDMA;235 bool fDMA; 183 236 /** Set to indicate that ATAPI transfer semantics must be used. */ 184 bool fATAPITransfer;237 bool fATAPITransfer; 185 238 186 239 /** Total ATA/ATAPI transfer size, shared PIO/DMA. */ 187 uint32_t cbTotalTransfer;240 uint32_t cbTotalTransfer; 188 241 /** Elementary ATA/ATAPI transfer size, shared PIO/DMA. */ 189 uint32_t cbElementaryTransfer;242 uint32_t cbElementaryTransfer; 190 243 /** Maximum ATAPI elementary transfer size, PIO only. */ 191 uint32_t cbPIOTransferLimit;244 uint32_t cbPIOTransferLimit; 192 245 /** ATAPI passthrough transfer size, shared PIO/DMA */ 193 uint32_t cbAtapiPassthroughTransfer;246 uint32_t cbAtapiPassthroughTransfer; 194 247 /** Current read/write buffer position, shared PIO/DMA. */ 195 uint32_t iIOBufferCur;248 uint32_t iIOBufferCur; 196 249 /** First element beyond end of valid buffer content, shared PIO/DMA. */ 197 uint32_t iIOBufferEnd;250 uint32_t iIOBufferEnd; 198 251 /** Align the following fields correctly. */ 199 uint32_t Alignment0;252 uint32_t Alignment0; 200 253 201 254 /** ATA/ATAPI current PIO read/write transfer position. Not shared with DMA for safety reasons. */ 202 uint32_t iIOBufferPIODataStart;255 uint32_t iIOBufferPIODataStart; 203 256 /** ATA/ATAPI current PIO read/write transfer end. Not shared with DMA for safety reasons. */ 204 uint32_t iIOBufferPIODataEnd;257 uint32_t iIOBufferPIODataEnd; 205 258 206 259 /** ATAPI current LBA position. */ 207 uint32_t iATAPILBA;260 uint32_t iATAPILBA; 208 261 /** ATAPI current sector size. */ 209 uint32_t cbATAPISector;262 uint32_t cbATAPISector; 210 263 /** ATAPI current command. */ 211 uint8_t aATAPICmd[ATAPI_PACKET_SIZE];264 uint8_t aATAPICmd[ATAPI_PACKET_SIZE]; 212 265 /** ATAPI sense data. */ 213 uint8_t abATAPISense[ATAPI_SENSE_SIZE];266 uint8_t abATAPISense[ATAPI_SENSE_SIZE]; 214 267 /** HACK: Countdown till we report a newly unmounted drive as mounted. */ 215 uint8_t cNotifiedMediaChange;268 uint8_t cNotifiedMediaChange; 216 269 /** The same for GET_EVENT_STATUS for mechanism */ 217 volatile uint32_t MediaEventStatus;270 volatile uint32_t MediaEventStatus; 218 271 219 272 /** Media type if known. */ 220 volatile uint32_t MediaTrackType;273 volatile uint32_t MediaTrackType; 221 274 222 275 /** The status LED state for this drive. */ 223 PDMLED Led;276 PDMLED Led; 224 277 225 278 /** Size of I/O buffer. */ 226 uint32_t cbIOBuffer;279 uint32_t cbIOBuffer; 227 280 /** Pointer to the I/O buffer. */ 228 R3PTRTYPE(uint8_t *) pbIOBufferR3;281 R3PTRTYPE(uint8_t *) pbIOBufferR3; 229 282 /** Pointer to the I/O buffer. */ 230 R0PTRTYPE(uint8_t *) pbIOBufferR0;283 R0PTRTYPE(uint8_t *) pbIOBufferR0; 231 284 /** Pointer to the I/O buffer. */ 232 RCPTRTYPE(uint8_t *) pbIOBufferRC;233 234 RTRCPTR Aligmnent1; /**< Align the statistics at an 8-byte boundary. */285 RCPTRTYPE(uint8_t *) pbIOBufferRC; 286 287 RTRCPTR Aligmnent1; /**< Align the statistics at an 8-byte boundary. */ 235 288 236 289 /* … … 239 292 240 293 /* Release statistics: number of ATA DMA commands. */ 241 STAMCOUNTER StatATADMA;294 STAMCOUNTER StatATADMA; 242 295 /* Release statistics: number of ATA PIO commands. */ 243 STAMCOUNTER StatATAPIO;296 STAMCOUNTER StatATAPIO; 244 297 /* Release statistics: number of ATAPI PIO commands. */ 245 STAMCOUNTER StatATAPIDMA;298 STAMCOUNTER StatATAPIDMA; 246 299 /* Release statistics: number of ATAPI PIO commands. */ 247 STAMCOUNTER StatATAPIPIO;300 STAMCOUNTER StatATAPIPIO; 248 301 #ifdef VBOX_INSTRUMENT_DMA_WRITES 249 302 /* Release statistics: number of DMA sector writes and the time spent. */ 250 STAMPROFILEADV StatInstrVDWrites;303 STAMPROFILEADV StatInstrVDWrites; 251 304 #endif 252 305 253 306 /** Statistics: number of read operations and the time spent reading. */ 254 STAMPROFILEADV StatReads;307 STAMPROFILEADV StatReads; 255 308 /** Statistics: number of bytes read. */ 256 STAMCOUNTER StatBytesRead;309 STAMCOUNTER StatBytesRead; 257 310 /** Statistics: number of write operations and the time spent writing. */ 258 STAMPROFILEADV StatWrites;311 STAMPROFILEADV StatWrites; 259 312 /** Statistics: number of bytes written. */ 260 STAMCOUNTER StatBytesWritten;313 STAMCOUNTER StatBytesWritten; 261 314 /** Statistics: number of flush operations and the time spend flushing. */ 262 STAMPROFILE StatFlushes;315 STAMPROFILE StatFlushes; 263 316 264 317 /** Enable passing through commands directly to the ATAPI drive. */ 265 bool fATAPIPassthrough;318 bool fATAPIPassthrough; 266 319 /** Flag whether to overwrite inquiry data in passthrough mode. */ 267 bool fOverwriteInquiry;320 bool fOverwriteInquiry; 268 321 /** Number of errors we've reported to the release log. 269 322 * This is to prevent flooding caused by something going horribly wrong. 270 323 * this value against MAX_LOG_REL_ERRORS in places likely to cause floods 271 324 * like the ones we currently seeing on the linux smoke tests (2006-11-10). */ 272 uint32_t cErrors;325 uint32_t cErrors; 273 326 /** Timestamp of last started command. 0 if no command pending. */ 274 uint64_t u64CmdTS;327 uint64_t u64CmdTS; 275 328 276 329 /** Pointer to the attached driver's base interface. */ 277 R3PTRTYPE(PPDMIBASE) pDrvBase;330 R3PTRTYPE(PPDMIBASE) pDrvBase; 278 331 /** Pointer to the attached driver's block interface. */ 279 R3PTRTYPE(PPDMIMEDIA) pDrvMedia;332 R3PTRTYPE(PPDMIMEDIA) pDrvMedia; 280 333 /** Pointer to the attached driver's mount interface. 281 334 * This is NULL if the driver isn't a removable unit. */ 282 R3PTRTYPE(PPDMIMOUNT) pDrvMount;335 R3PTRTYPE(PPDMIMOUNT) pDrvMount; 283 336 /** The base interface. */ 284 PDMIBASE IBase;337 PDMIBASE IBase; 285 338 /** The block port interface. */ 286 PDMIMEDIAPORT IPort;339 PDMIMEDIAPORT IPort; 287 340 /** The mount notify interface. */ 288 PDMIMOUNTNOTIFY IMountNotify;341 PDMIMOUNTNOTIFY IMountNotify; 289 342 /** The LUN #. */ 290 RTUINT iLUN;343 RTUINT iLUN; 291 344 #if HC_ARCH_BITS == 64 292 RTUINT Alignment2; /**< Align pDevInsR3 correctly. */345 RTUINT Alignment2; /**< Align pDevInsR3 correctly. */ 293 346 #endif 294 347 /** Pointer to device instance. */ … … 330 383 331 384 385 /** 386 * Transfer request forwarded to the async I/O thread. 387 */ 332 388 typedef struct ATATransferRequest 333 389 { 390 /** The interface index the request is for. */ 391 uint8_t iIf; 392 /** The index of the begin transfer callback to call. */ 393 uint8_t iBeginTransfer; 394 /** The index of the source sink callback to call for doing the transfer. */ 395 uint8_t iSourceSink; 396 /** How many bytes to transfer. */ 397 uint32_t cbTotalTransfer; 398 /** Transfer direction. */ 399 uint8_t uTxDir; 400 } ATATransferRequest; 401 402 403 /** 404 * Abort request forwarded to the async I/O thread. 405 */ 406 typedef struct ATAAbortRequest 407 { 408 /** The interface index the request is for. */ 334 409 uint8_t iIf; 335 uint8_t iBeginTransfer; 336 uint8_t iSourceSink; 337 uint32_t cbTotalTransfer; 338 uint8_t uTxDir; 339 } ATATransferRequest; 340 341 342 typedef struct ATAAbortRequest 343 { 344 uint8_t iIf; 345 bool fResetDrive; 410 /** Flag whether to reset the drive. */ 411 bool fResetDrive; 346 412 } ATAAbortRequest; 347 413 348 414 415 /** 416 * Request type indicator. 417 */ 349 418 typedef enum 350 419 { … … 364 433 365 434 435 /** 436 * Combining structure for an ATA request to the async I/O thread 437 * started with the request type insicator. 438 */ 366 439 typedef struct ATARequest 367 440 { 368 ATAAIO ReqType; 441 /** Request type. */ 442 ATAAIO ReqType; 443 /** Request type dependent data. */ 369 444 union 370 445 { 446 /** Transfer request specific data. */ 371 447 ATATransferRequest t; 372 ATAAbortRequest a; 448 /** Abort request specific data. */ 449 ATAAbortRequest a; 373 450 } u; 374 451 } ATARequest; 375 452 376 453 454 /** 455 * The state of an ATA controller containing to devices (master and slave). 456 */ 377 457 typedef struct ATACONTROLLER 378 458 { 379 459 /** The base of the first I/O Port range. */ 380 RTIOPORT IOPortBase1;460 RTIOPORT IOPortBase1; 381 461 /** The base of the second I/O Port range. (0 if none) */ 382 RTIOPORT IOPortBase2;462 RTIOPORT IOPortBase2; 383 463 /** The assigned IRQ. */ 384 RTUINT irq;464 RTUINT irq; 385 465 /** Access critical section */ 386 PDMCRITSECT lock;466 PDMCRITSECT lock; 387 467 388 468 /** Selected drive. */ 389 uint8_t iSelectedIf;469 uint8_t iSelectedIf; 390 470 /** The interface on which to handle async I/O. */ 391 uint8_t iAIOIf;471 uint8_t iAIOIf; 392 472 /** The state of the async I/O thread. */ 393 uint8_t uAsyncIOState;473 uint8_t uAsyncIOState; 394 474 /** Flag indicating whether the next transfer is part of the current command. */ 395 bool fChainedTransfer;475 bool fChainedTransfer; 396 476 /** Set when the reset processing is currently active on this controller. */ 397 bool fReset;477 bool fReset; 398 478 /** Flag whether the current transfer needs to be redone. */ 399 bool fRedo;479 bool fRedo; 400 480 /** Flag whether the redo suspend has been finished. */ 401 bool fRedoIdle;481 bool fRedoIdle; 402 482 /** Flag whether the DMA operation to be redone is the final transfer. */ 403 bool fRedoDMALastDesc;483 bool fRedoDMALastDesc; 404 484 /** The BusMaster DMA state. */ 405 BMDMAState BmDma;485 BMDMAState BmDma; 406 486 /** Pointer to first DMA descriptor. */ 407 RTGCPHYS32 pFirstDMADesc;487 RTGCPHYS32 GCPhysFirstDMADesc; 408 488 /** Pointer to last DMA descriptor. */ 409 RTGCPHYS32 pLastDMADesc;489 RTGCPHYS32 GCPhysLastDMADesc; 410 490 /** Pointer to current DMA buffer (for redo operations). */ 411 RTGCPHYS32 pRedoDMABuffer;491 RTGCPHYS32 GCPhysRedoDMABuffer; 412 492 /** Size of current DMA buffer (for redo operations). */ 413 uint32_t cbRedoDMABuffer;493 uint32_t cbRedoDMABuffer; 414 494 415 495 /** The ATA/ATAPI interfaces of this controller. */ 416 ATADevState aIfs[2];496 ATADevState aIfs[2]; 417 497 418 498 /** Pointer to device instance. */ … … 446 526 /** The lock protecting the request queue. */ 447 527 PDMCRITSECT AsyncIORequestLock; 448 #if 0 /*HC_ARCH_BITS == 32*/449 uint32_t Alignment0;450 #endif451 528 452 529 /** Timestamp we started the reset. */ … … 454 531 455 532 /* Statistics */ 456 STAMCOUNTER StatAsyncOps;457 uint64_t StatAsyncMinWait;458 uint64_t StatAsyncMaxWait;459 STAMCOUNTER StatAsyncTimeUS;460 STAMPROFILEADV StatAsyncTime;461 STAMPROFILE StatLockWait;533 STAMCOUNTER StatAsyncOps; 534 uint64_t StatAsyncMinWait; 535 uint64_t StatAsyncMaxWait; 536 STAMCOUNTER StatAsyncTimeUS; 537 STAMPROFILEADV StatAsyncTime; 538 STAMPROFILE StatLockWait; 462 539 } ATACONTROLLER, *PATACONTROLLER; 463 540 AssertCompileMemberAlignment(ATACONTROLLER, lock, 8); … … 486 563 typedef struct PCIATAState 487 564 { 488 PDMPCIDEV dev;565 PDMPCIDEV dev; 489 566 /** The controllers. */ 490 ATACONTROLLER aCts[2];567 ATACONTROLLER aCts[2]; 491 568 /** Pointer to device instance. */ 492 PPDMDEVINSR3 pDevIns;569 PPDMDEVINSR3 pDevIns; 493 570 /** Status LUN: Base interface. */ 494 PDMIBASE IBase;571 PDMIBASE IBase; 495 572 /** Status LUN: Leds interface. */ 496 PDMILEDPORTS ILeds;573 PDMILEDPORTS ILeds; 497 574 /** Status LUN: Partner of ILeds. */ 498 575 R3PTRTYPE(PPDMILEDCONNECTORS) pLedsConnector; … … 500 577 R3PTRTYPE(PPDMIMEDIANOTIFY) pMediaNotify; 501 578 /** Flag whether RC is enabled. */ 502 bool fRCEnabled;579 bool fRCEnabled; 503 580 /** Flag whether R0 is enabled. */ 504 bool fR0Enabled;581 bool fR0Enabled; 505 582 /** Flag indicating chipset being emulated. */ 506 uint8_t u8Type;507 bool Alignment0[HC_ARCH_BITS == 64 ? 5 : 1 ]; /**< Align the struct size. */583 uint8_t u8Type; 584 bool Alignment0[HC_ARCH_BITS == 64 ? 5 : 1 ]; /**< Align the struct size. */ 508 585 } PCIATAState; 509 510 #define PDMIBASE_2_PCIATASTATE(pInterface) ( (PCIATAState *)((uintptr_t)(pInterface) - RT_OFFSETOF(PCIATAState, IBase)) )511 #define PDMILEDPORTS_2_PCIATASTATE(pInterface) ( (PCIATAState *)((uintptr_t)(pInterface) - RT_OFFSETOF(PCIATAState, ILeds)) )512 #define PDMIMEDIAPORT_2_ATASTATE(pInterface) ( (ATADevState *)((uintptr_t)(pInterface) - RT_OFFSETOF(ATADevState, IPort)) )513 #define PDMIMOUNT_2_ATASTATE(pInterface) ( (ATADevState *)((uintptr_t)(pInterface) - RT_OFFSETOF(ATADevState, IMount)) )514 #define PDMIMOUNTNOTIFY_2_ATASTATE(pInterface) ( (ATADevState *)((uintptr_t)(pInterface) - RT_OFFSETOF(ATADevState, IMountNotify)) )515 #define PCIDEV_2_PCIATASTATE(pPciDev) ( (PCIATAState *)(pPciDev) )516 586 517 587 #define ATACONTROLLER_IDX(pController) ( (pController) - PDMINS_2_DATA(CONTROLLER_2_DEVINS(pController), PCIATAState *)->aCts ) … … 520 590 #define ATADEVSTATE_2_DEVINS(pIf) ( (pIf)->CTX_SUFF(pDevIns) ) 521 591 #define CONTROLLER_2_DEVINS(pController) ( (pController)->CTX_SUFF(pDevIns) ) 522 #define PDMIBASE_2_ATASTATE(pInterface) ( (ATADevState *)((uintptr_t)(pInterface) - RT_OFFSETOF(ATADevState, IBase)) )523 #define PDMIMEDIAPORT_2_ATASTATE(pInterface) ( (ATADevState *)((uintptr_t)(pInterface) - RT_OFFSETOF(ATADevState, IPort)) )524 592 525 593 #ifndef VBOX_DEVICE_STRUCT_TESTCASE … … 3707 3775 static DECLCALLBACK(void) ataR3MountNotify(PPDMIMOUNTNOTIFY pInterface) 3708 3776 { 3709 ATADevState *pIf = PDMIMOUNTNOTIFY_2_ATASTATE(pInterface);3777 ATADevState *pIf = RT_FROM_MEMBER(pInterface, ATADevState, IMountNotify); 3710 3778 Log(("%s: changing LUN#%d\n", __FUNCTION__, pIf->iLUN)); 3711 3779 … … 3733 3801 static DECLCALLBACK(void) ataR3UnmountNotify(PPDMIMOUNTNOTIFY pInterface) 3734 3802 { 3735 ATADevState *pIf = PDMIMOUNTNOTIFY_2_ATASTATE(pInterface);3803 ATADevState *pIf = RT_FROM_MEMBER(pInterface, ATADevState, IMountNotify); 3736 3804 Log(("%s:\n", __FUNCTION__)); 3737 3805 pIf->cTotalSectors = 0; … … 5113 5181 ATADevState *s = &pCtl->aIfs[pCtl->iAIOIf]; 5114 5182 bool fRedo; 5115 RTGCPHYS32 pDesc;5183 RTGCPHYS32 GCPhysDesc; 5116 5184 uint32_t cbTotalTransfer, cbElementaryTransfer; 5117 5185 uint32_t iIOBufferCur, iIOBufferEnd; 5118 uint32_t dmalen;5119 5186 PDMMEDIATXDIR uTxDir; 5120 5187 bool fLastDesc = false; … … 5140 5207 cbTotalTransfer, cbElementaryTransfer, 5141 5208 iIOBufferCur, iIOBufferEnd)); 5142 for (pDesc = pCtl->pFirstDMADesc; pDesc <= pCtl->pLastDMADesc; pDesc += sizeof(BMDMADesc)) 5209 for (GCPhysDesc = pCtl->GCPhysFirstDMADesc; 5210 GCPhysDesc <= pCtl->GCPhysLastDMADesc; 5211 GCPhysDesc += sizeof(BMDMADesc)) 5143 5212 { 5144 5213 BMDMADesc DMADesc; 5145 RTGCPHYS32 pBuffer;5214 RTGCPHYS32 GCPhysBuffer; 5146 5215 uint32_t cbBuffer; 5147 5216 5148 5217 if (RT_UNLIKELY(fRedo)) 5149 5218 { 5150 pBuffer = pCtl->pRedoDMABuffer;5219 GCPhysBuffer = pCtl->GCPhysRedoDMABuffer; 5151 5220 cbBuffer = pCtl->cbRedoDMABuffer; 5152 5221 fLastDesc = pCtl->fRedoDMALastDesc; 5153 DMADesc. pBuffer = DMADesc.cbBuffer = 0; /* Shut up MSC. */5222 DMADesc.GCPhysBuffer = DMADesc.cbBuffer = 0; /* Shut up MSC. */ 5154 5223 } 5155 5224 else 5156 5225 { 5157 PDMDevHlpPhysRead(pDevIns, pDesc, &DMADesc, sizeof(BMDMADesc));5158 pBuffer = RT_LE2H_U32(DMADesc.pBuffer);5226 PDMDevHlpPhysRead(pDevIns, GCPhysDesc, &DMADesc, sizeof(BMDMADesc)); 5227 GCPhysBuffer = RT_LE2H_U32(DMADesc.GCPhysBuffer); 5159 5228 cbBuffer = RT_LE2H_U32(DMADesc.cbBuffer); 5160 5229 fLastDesc = !!(cbBuffer & 0x80000000); … … 5170 5239 if (RT_LIKELY(!fRedo)) 5171 5240 { 5172 dmalen= RT_MIN(cbBuffer, iIOBufferEnd - iIOBufferCur);5241 uint32_t cbXfer = RT_MIN(cbBuffer, iIOBufferEnd - iIOBufferCur); 5173 5242 Log2(("%s: DMA desc %#010x: addr=%#010x size=%#010x orig_size=%#010x\n", __FUNCTION__, 5174 (int) pDesc, pBuffer, cbBuffer, RT_LE2H_U32(DMADesc.cbBuffer) & 0xfffe));5243 (int)GCPhysDesc, GCPhysBuffer, cbBuffer, RT_LE2H_U32(DMADesc.cbBuffer) & 0xfffe)); 5175 5244 5176 5245 if (uTxDir == PDMMEDIATXDIR_FROM_DEVICE) 5177 PDMDevHlpPCIPhysWrite(pDevIns, pBuffer, s->CTX_SUFF(pbIOBuffer) + iIOBufferCur, dmalen);5246 PDMDevHlpPCIPhysWrite(pDevIns, GCPhysBuffer, s->CTX_SUFF(pbIOBuffer) + iIOBufferCur, cbXfer); 5178 5247 else 5179 PDMDevHlpPCIPhysRead(pDevIns, pBuffer, s->CTX_SUFF(pbIOBuffer) + iIOBufferCur, dmalen);5180 5181 iIOBufferCur += dmalen;5182 cbTotalTransfer -= dmalen;5183 cbBuffer -= dmalen;5184 pBuffer += dmalen;5248 PDMDevHlpPCIPhysRead(pDevIns, GCPhysBuffer, s->CTX_SUFF(pbIOBuffer) + iIOBufferCur, cbXfer); 5249 5250 iIOBufferCur += cbXfer; 5251 cbTotalTransfer -= cbXfer; 5252 cbBuffer -= cbXfer; 5253 GCPhysBuffer += cbXfer; 5185 5254 } 5186 5255 if ( iIOBufferCur == iIOBufferEnd … … 5210 5279 if (RT_UNLIKELY(fRedo)) 5211 5280 { 5212 pCtl-> pFirstDMADesc = pDesc;5213 pCtl-> pRedoDMABuffer = pBuffer;5281 pCtl->GCPhysFirstDMADesc = GCPhysDesc; 5282 pCtl->GCPhysRedoDMABuffer = GCPhysBuffer; 5214 5283 pCtl->cbRedoDMABuffer = cbBuffer; 5215 5284 pCtl->fRedoDMALastDesc = fLastDesc; … … 5230 5299 { 5231 5300 /* This forces the loop to exit immediately. */ 5232 pDesc = pCtl->pLastDMADesc + 1;5301 GCPhysDesc = pCtl->GCPhysLastDMADesc + 1; 5233 5302 } 5234 5303 … … 5258 5327 ataR3DMATransferStop(s); 5259 5328 /* This forces the loop to exit immediately. */ 5260 pDesc = pCtl->pLastDMADesc + 1;5329 GCPhysDesc = pCtl->GCPhysLastDMADesc + 1; 5261 5330 } 5262 5331 … … 5560 5629 /* The specs say that the descriptor table must not cross a 5561 5630 * 4K boundary. */ 5562 pCtl-> pFirstDMADesc = bm->pvAddr;5563 pCtl-> pLastDMADesc = RT_ALIGN_32(bm->pvAddr + 1, _4K) - sizeof(BMDMADesc);5631 pCtl->GCPhysFirstDMADesc = bm->GCPhysAddr; 5632 pCtl->GCPhysLastDMADesc = RT_ALIGN_32(bm->GCPhysAddr + 1, _4K) - sizeof(BMDMADesc); 5564 5633 } 5565 5634 ataR3DMATransfer(pCtl); … … 5877 5946 static uint32_t ataBMDMAAddrReadL(PATACONTROLLER pCtl, uint32_t addr) 5878 5947 { 5879 uint32_t val = (uint32_t)pCtl->BmDma. pvAddr;5948 uint32_t val = (uint32_t)pCtl->BmDma.GCPhysAddr; 5880 5949 RT_NOREF1(addr); 5881 5950 Log2(("%s: addr=%#06x val=%#010x\n", __FUNCTION__, addr, val)); … … 5887 5956 RT_NOREF1(addr); 5888 5957 Log2(("%s: addr=%#06x val=%#010x\n", __FUNCTION__, addr, val)); 5889 pCtl->BmDma. pvAddr = val & ~3;5958 pCtl->BmDma.GCPhysAddr = val & ~3; 5890 5959 } 5891 5960 … … 5894 5963 RT_NOREF1(addr); 5895 5964 Log2(("%s: addr=%#06x val=%#010x\n", __FUNCTION__, addr, val)); 5896 pCtl->BmDma. pvAddr = (pCtl->BmDma.pvAddr & 0xFFFF0000) | RT_LOWORD(val & ~3);5965 pCtl->BmDma.GCPhysAddr = (pCtl->BmDma.GCPhysAddr & 0xFFFF0000) | RT_LOWORD(val & ~3); 5897 5966 5898 5967 } … … 5902 5971 Log2(("%s: addr=%#06x val=%#010x\n", __FUNCTION__, addr, val)); 5903 5972 RT_NOREF1(addr); 5904 pCtl->BmDma. pvAddr = (RT_LOWORD(val) << 16) | RT_LOWORD(pCtl->BmDma.pvAddr);5973 pCtl->BmDma.GCPhysAddr = (RT_LOWORD(val) << 16) | RT_LOWORD(pCtl->BmDma.GCPhysAddr); 5905 5974 } 5906 5975 … … 5985 6054 RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType) 5986 6055 { 5987 RT_NOREF(iRegion, cb, enmType );5988 PCIATAState *pThis = P CIDEV_2_PCIATASTATE(pPciDev);6056 RT_NOREF(iRegion, cb, enmType, pPciDev); 6057 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 5989 6058 int rc = VINF_SUCCESS; 5990 6059 Assert(enmType == PCI_ADDRESS_SPACE_IO); … … 6032 6101 static DECLCALLBACK(void *) ataR3Status_QueryInterface(PPDMIBASE pInterface, const char *pszIID) 6033 6102 { 6034 PCIATAState *pThis = PDMIBASE_2_PCIATASTATE(pInterface);6103 PCIATAState *pThis = RT_FROM_MEMBER(pInterface, PCIATAState, IBase); 6035 6104 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase); 6036 6105 PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThis->ILeds); … … 6051 6120 static DECLCALLBACK(int) ataR3Status_QueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed) 6052 6121 { 6053 PCIATAState *pThis = PDMILEDPORTS_2_PCIATASTATE(pInterface);6122 PCIATAState *pThis = RT_FROM_MEMBER(pInterface, PCIATAState, ILeds); 6054 6123 if (iLUN < 4) 6055 6124 { … … 6075 6144 static DECLCALLBACK(void *) ataR3QueryInterface(PPDMIBASE pInterface, const char *pszIID) 6076 6145 { 6077 ATADevState *pIf = PDMIBASE_2_ATASTATE(pInterface);6146 ATADevState *pIf = RT_FROM_MEMBER(pInterface, ATADevState, IBase); 6078 6147 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pIf->IBase); 6079 6148 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAPORT, &pIf->IPort); … … 6091 6160 uint32_t *piInstance, uint32_t *piLUN) 6092 6161 { 6093 ATADevState *pIf = PDMIMEDIAPORT_2_ATASTATE(pInterface);6162 ATADevState *pIf = RT_FROM_MEMBER(pInterface, ATADevState, IPort); 6094 6163 PPDMDEVINS pDevIns = pIf->CTX_SUFF(pDevIns); 6095 6164 … … 6604 6673 SSMR3PutBool(pSSM, pThis->aCts[i].fRedoDMALastDesc); 6605 6674 SSMR3PutMem(pSSM, &pThis->aCts[i].BmDma, sizeof(pThis->aCts[i].BmDma)); 6606 SSMR3PutGCPhys32(pSSM, pThis->aCts[i]. pFirstDMADesc);6607 SSMR3PutGCPhys32(pSSM, pThis->aCts[i]. pLastDMADesc);6608 SSMR3PutGCPhys32(pSSM, pThis->aCts[i]. pRedoDMABuffer);6675 SSMR3PutGCPhys32(pSSM, pThis->aCts[i].GCPhysFirstDMADesc); 6676 SSMR3PutGCPhys32(pSSM, pThis->aCts[i].GCPhysLastDMADesc); 6677 SSMR3PutGCPhys32(pSSM, pThis->aCts[i].GCPhysRedoDMABuffer); 6609 6678 SSMR3PutU32(pSSM, pThis->aCts[i].cbRedoDMABuffer); 6610 6679 … … 6777 6846 SSMR3GetBool(pSSM, (bool *)&pThis->aCts[i].fRedoDMALastDesc); 6778 6847 SSMR3GetMem(pSSM, &pThis->aCts[i].BmDma, sizeof(pThis->aCts[i].BmDma)); 6779 SSMR3GetGCPhys32(pSSM, &pThis->aCts[i]. pFirstDMADesc);6780 SSMR3GetGCPhys32(pSSM, &pThis->aCts[i]. pLastDMADesc);6781 SSMR3GetGCPhys32(pSSM, &pThis->aCts[i]. pRedoDMABuffer);6848 SSMR3GetGCPhys32(pSSM, &pThis->aCts[i].GCPhysFirstDMADesc); 6849 SSMR3GetGCPhys32(pSSM, &pThis->aCts[i].GCPhysLastDMADesc); 6850 SSMR3GetGCPhys32(pSSM, &pThis->aCts[i].GCPhysRedoDMABuffer); 6782 6851 SSMR3GetU32(pSSM, &pThis->aCts[i].cbRedoDMABuffer); 6783 6852 … … 6985 7054 pThis->aCts[i].BmDma.u8Status = (pThis->aCts[i].aIfs[0].pDrvBase != NULL ? BM_STATUS_D0DMA : 0) 6986 7055 | (pThis->aCts[i].aIfs[1].pDrvBase != NULL ? BM_STATUS_D1DMA : 0); 6987 pThis->aCts[i].BmDma. pvAddr = 0;7056 pThis->aCts[i].BmDma.GCPhysAddr = 0; 6988 7057 6989 7058 pThis->aCts[i].fReset = true; -
trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp
r65922 r65960 799 799 GEN_CHECK_OFF(BMDMAState, u8Cmd); 800 800 GEN_CHECK_OFF(BMDMAState, u8Status); 801 GEN_CHECK_OFF(BMDMAState, pvAddr);801 GEN_CHECK_OFF(BMDMAState, GCPhysAddr); 802 802 GEN_CHECK_SIZE(BMDMADesc); 803 GEN_CHECK_OFF(BMDMADesc, pBuffer);803 GEN_CHECK_OFF(BMDMADesc, GCPhysBuffer); 804 804 GEN_CHECK_OFF(BMDMADesc, cbBuffer); 805 805 GEN_CHECK_SIZE(ATADevState); … … 921 921 GEN_CHECK_OFF(ATACONTROLLER, fRedoDMALastDesc); 922 922 GEN_CHECK_OFF(ATACONTROLLER, BmDma); 923 GEN_CHECK_OFF(ATACONTROLLER, pFirstDMADesc);924 GEN_CHECK_OFF(ATACONTROLLER, pLastDMADesc);925 GEN_CHECK_OFF(ATACONTROLLER, pRedoDMABuffer);923 GEN_CHECK_OFF(ATACONTROLLER, GCPhysFirstDMADesc); 924 GEN_CHECK_OFF(ATACONTROLLER, GCPhysLastDMADesc); 925 GEN_CHECK_OFF(ATACONTROLLER, GCPhysRedoDMABuffer); 926 926 GEN_CHECK_OFF(ATACONTROLLER, cbRedoDMABuffer); 927 927 GEN_CHECK_OFF(ATACONTROLLER, aIfs);
Note:
See TracChangeset
for help on using the changeset viewer.

