Changeset 9330 in vbox for trunk/include
- Timestamp:
- Jun 2, 2008 10:56:54 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/pci.h
r8155 r9330 33 33 #include <VBox/cdefs.h> 34 34 #include <VBox/types.h> 35 #include <iprt/assert.h> 35 36 36 37 /** @defgroup grp_pci PCI - The PCI Controller. … … 102 103 #define VBOX_PCI_STATUS 0x06 /**< 16-bit RW */ 103 104 #define VBOX_PCI_REVISION_ID 0x08 /**< 8-bit RO */ 104 #define VBOX_PCI_CLASS_PROG 0x09 /**< 8-bit RO */ 105 #define VBOX_PCI_CLASS_DEVICE 0x0a /**< 8-bit ?? */ 105 #define VBOX_PCI_CLASS_PROG 0x09 /**< 8-bit RO - - register-level programming class code (device specific). */ 106 #define VBOX_PCI_CLASS_SUB 0x0a /**< 8-bit RO - - sub-class code. */ 107 #define VBOX_PCI_CLASS_DEVICE VBOX_PCI_CLASS_SUB 108 #define VBOX_PCI_CLASS_BASE 0x0b /**< 8-bit RO - - base class code. */ 106 109 #define VBOX_PCI_CACHE_LINE_SIZE 0x0c /**< 8-bit ?? */ 107 110 #define VBOX_PCI_LATENCY_TIMER 0x0d /**< 8-bit ?? */ … … 238 241 } 239 242 243 240 244 /** 241 245 * Sets the device id config register. … … 260 264 } 261 265 266 267 /** 268 * Sets the command config register. 269 * 270 * @param pPciDev The PCI device. 271 * @param u16Command The command register value. 272 */ 273 DECLINLINE(void) PCIDevSetCommand(PPCIDEVICE pPciDev, uint16_t u16Command) 274 { 275 u16Command = RT_H2LE_U16(u16Command); 276 pPciDev->config[VBOX_PCI_COMMAND] = u16Command & 0xff; 277 pPciDev->config[VBOX_PCI_COMMAND + 1] = u16Command >> 8; 278 } 279 280 281 /** 282 * Sets the status config register. 283 * 284 * @param pPciDev The PCI device. 285 * @param u16Status The status register value. 286 */ 287 DECLINLINE(void) PCIDevSetStatus(PPCIDEVICE pPciDev, uint16_t u16Status) 288 { 289 u16Status = RT_H2LE_U16(u16Status); 290 pPciDev->config[VBOX_PCI_STATUS] = u16Status & 0xff; 291 pPciDev->config[VBOX_PCI_STATUS + 1] = u16Status >> 8; 292 } 293 294 295 /** 296 * Sets the revision id config register. 297 * 298 * @param pPciDev The PCI device. 299 * @param u8RevisionId The revision id. 300 */ 301 DECLINLINE(void) PCIDevSetRevisionId(PPCIDEVICE pPciDev, uint8_t u8RevisionId) 302 { 303 pPciDev->config[VBOX_PCI_REVISION_ID] = u8RevisionId; 304 } 305 306 307 /** 308 * Sets the register level programming class config register. 309 * 310 * @param pPciDev The PCI device. 311 * @param u8ClassProg The new value. 312 */ 313 DECLINLINE(void) PCIDevSetClassProg(PPCIDEVICE pPciDev, uint8_t u8ClassProg) 314 { 315 pPciDev->config[VBOX_PCI_CLASS_PROG] = u8ClassProg; 316 } 317 318 319 /** 320 * Sets the sub-class (aka device class) config register. 321 * 322 * @param pPciDev The PCI device. 323 * @param u8SubClass The sub-class. 324 */ 325 DECLINLINE(void) PCIDevSetClassSub(PPCIDEVICE pPciDev, uint8_t u8SubClass) 326 { 327 pPciDev->config[VBOX_PCI_CLASS_SUB] = u8SubClass; 328 } 329 330 331 /** 332 * Sets the base class config register. 333 * 334 * @param pPciDev The PCI device. 335 * @param u8BaseClass The base class. 336 */ 337 DECLINLINE(void) PCIDevSetClassBase(PPCIDEVICE pPciDev, uint8_t u8BaseClass) 338 { 339 pPciDev->config[VBOX_PCI_CLASS_BASE] = u8BaseClass; 340 } 341 342 343 /** 344 * Sets the header type config register. 345 * 346 * @param pPciDev The PCI device. 347 * @param u8HdrType The header type. 348 */ 349 DECLINLINE(void) PCIDevSetHeaderType(PPCIDEVICE pPciDev, uint8_t u8HdrType) 350 { 351 pPciDev->config[VBOX_PCI_HEADER_TYPE] = u8HdrType; 352 } 353 354 355 /** 356 * Sets a base address config register. 357 * 358 * @param pPciDev The PCI device. 359 * @param fIOSpace Whether it's I/O (true) or memory (false) space. 360 * @param fPrefetchable Whether the memory is prefetachable. Must be false if fIOSpace == true. 361 * @param f64Bit Whether the memory can be mapped anywhere in the 64-bit address space. Otherwise restrict to 32-bit. 362 * @param u32Addr The address value. 363 */ 364 DECLINLINE(void) PCIDevSetBaseAddress(PPCIDEVICE pPciDev, uint8_t iReg, bool fIOSpace, bool fPrefetchable, bool f64Bit, uint32_t u32Addr) 365 { 366 if (fIOSpace) 367 { 368 Assert(!(u32Addr & 0x3)); Assert(!fPrefetchable); Assert(!f64Bit); 369 u32Addr |= RT_BIT_32(0); 370 } 371 else 372 { 373 Assert(!(u32Addr & 0xf)); 374 if (fPrefetchable) 375 u32Addr |= RT_BIT_32(3); 376 if (f64Bit) 377 u32Addr |= 0x2 << 1; 378 } 379 switch (iReg) 380 { 381 case 0: iReg = VBOX_PCI_BASE_ADDRESS_0; break; 382 case 1: iReg = VBOX_PCI_BASE_ADDRESS_1; break; 383 case 2: iReg = VBOX_PCI_BASE_ADDRESS_2; break; 384 case 3: iReg = VBOX_PCI_BASE_ADDRESS_3; break; 385 case 4: iReg = VBOX_PCI_BASE_ADDRESS_4; break; 386 case 5: iReg = VBOX_PCI_BASE_ADDRESS_5; break; 387 default: AssertFailedReturnVoid(); 388 } 389 390 u32Addr = RT_H2LE_U32(u32Addr); 391 pPciDev->config[iReg] = u32Addr & 0xff; 392 pPciDev->config[iReg + 1] = (u32Addr >> 16) & 0xff; 393 pPciDev->config[iReg + 2] = (u32Addr >> 16) & 0xff; 394 pPciDev->config[iReg + 3] = (u32Addr >> 24) & 0xff; 395 } 396 397 398 /** 399 * Sets the sub-system vendor id config register. 400 * 401 * @param pPciDev The PCI device. 402 * @param u16SubSysVendorId The sub-system vendor id. 403 */ 404 DECLINLINE(void) PCIDevSetSubSystemVendorId(PPCIDEVICE pPciDev, uint16_t u16SubSysVendorId) 405 { 406 u16SubSysVendorId = RT_H2LE_U16(u16SubSysVendorId); 407 pPciDev->config[VBOX_PCI_SUBSYSTEM_VENDOR_ID] = u16SubSysVendorId & 0xff; 408 pPciDev->config[VBOX_PCI_SUBSYSTEM_VENDOR_ID + 1] = u16SubSysVendorId >> 8; 409 } 410 262 411 /** 263 412 * Gets the sub-system vendor id config register. … … 270 419 } 271 420 421 422 /** 423 * Sets the sub-system id config register. 424 * 425 * @param pPciDev The PCI device. 426 * @param u16SubSystemId The sub-system id. 427 */ 428 DECLINLINE(void) PCIDevSetSubSystemId(PPCIDEVICE pPciDev, uint16_t u16SubSystemId) 429 { 430 u16SubSystemId = RT_H2LE_U16(u16SubSystemId); 431 pPciDev->config[VBOX_PCI_SUBSYSTEM_ID] = u16SubSystemId & 0xff; 432 pPciDev->config[VBOX_PCI_SUBSYSTEM_ID + 1] = u16SubSystemId >> 8; 433 } 434 272 435 /** 273 436 * Gets the sub-system id config register. … … 281 444 282 445 446 /** 447 * Sets the interrupt line config register. 448 * 449 * @param pPciDev The PCI device. 450 * @param u8Line The interrupt line. 451 */ 452 DECLINLINE(void) PCIDevSetInterruptLine(PPCIDEVICE pPciDev, uint8_t u8Line) 453 { 454 pPciDev->config[VBOX_PCI_INTERRUPT_LINE] = u8Line; 455 } 456 457 458 /** 459 * Sets the interrupt pin config register. 460 * 461 * @param pPciDev The PCI device. 462 * @param u8Pin The interrupt pin. 463 */ 464 DECLINLINE(void) PCIDevSetInterruptPin(PPCIDEVICE pPciDev, uint8_t u8Pin) 465 { 466 pPciDev->config[VBOX_PCI_INTERRUPT_PIN] = u8Pin; 467 } 468 469 283 470 /** @} */ 284 471
Note:
See TracChangeset
for help on using the changeset viewer.