Changeset 26164 in vbox
- Timestamp:
- Feb 2, 2010 7:44:51 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/pdmdev.h
r26160 r26164 4334 4334 */ 4335 4335 DECLR3CALLBACKMEMBER(int, pfnRegister,(PPDMDEVREGCB pCallbacks, PCPDMDEVREG pReg)); 4336 4337 /**4338 * Allocate memory which is associated with current VM instance4339 * and automatically freed on it's destruction.4340 *4341 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.4342 * @param pCallbacks Pointer to the callback table.4343 * @param cb Number of bytes to allocate.4344 */4345 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAlloc,(PPDMDEVREGCB pCallbacks, size_t cb));4346 4336 } PDMDEVREGCB; 4347 4337 -
trunk/include/VBox/pdmusb.h
r26163 r26164 822 822 */ 823 823 DECLR3CALLBACKMEMBER(int, pfnRegister,(PCPDMUSBREGCB pCallbacks, PCPDMUSBREG pReg)); 824 825 /**826 * Allocate memory which is associated with current VM instance827 * and automatically freed on it's destruction.828 *829 * @returns Pointer to allocated memory. The memory is *NOT* zero-ed.830 * @param pCallbacks Pointer to the callback table.831 * @param cb Number of bytes to allocate.832 */833 DECLR3CALLBACKMEMBER(void *, pfnMMHeapAlloc,(PCPDMUSBREGCB pCallbacks, size_t cb));834 824 } PDMUSBREGCB; 835 825 -
trunk/src/VBox/Devices/PC/DevPcArch.c
r26160 r26164 264 264 "PC Architecture Device", 265 265 /* fFlags */ 266 PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT | PDM_DEVREG_FLAGS_GUEST_BITS_ 32,266 PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT | PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT, 267 267 /* fClass */ 268 268 PDM_DEVREG_CLASS_ARCH, -
trunk/src/VBox/Devices/VMMDev/VMMDev.cpp
r26160 r26164 2743 2743 "VirtualBox VMM Device\n", 2744 2744 /* fFlags */ 2745 PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT | PDM_DEVREG_FLAGS_GUEST_BITS_ 32,2745 PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT | PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT, 2746 2746 /* fClass */ 2747 2747 PDM_DEVREG_CLASS_VMM_DEV, -
trunk/src/VBox/VMM/PDMDevice.cpp
r26161 r26164 76 76 *******************************************************************************/ 77 77 static DECLCALLBACK(int) pdmR3DevReg_Register(PPDMDEVREGCB pCallbacks, PCPDMDEVREG pReg); 78 static DECLCALLBACK(void *) pdmR3DevReg_MMHeapAlloc(PPDMDEVREGCB pCallbacks, size_t cb);79 78 static int pdmR3DevLoadModules(PVM pVM); 80 79 static int pdmR3DevLoad(PVM pVM, PPDMDEVREGCBINT pRegCB, const char *pszFilename, const char *pszName); … … 458 457 RegCB.Core.u32Version = PDM_DEVREG_CB_VERSION; 459 458 RegCB.Core.pfnRegister = pdmR3DevReg_Register; 460 RegCB.Core.pfnMMHeapAlloc = pdmR3DevReg_MMHeapAlloc;461 459 RegCB.pVM = pVM; 462 460 … … 610 608 */ 611 609 Assert(pReg); 612 if (pReg->u32Version != PDM_DEVREG_VERSION) 613 { 614 AssertMsgFailed(("Unknown struct version %#x!\n", pReg->u32Version)); 615 return VERR_PDM_UNKNOWN_DEVREG_VERSION; 616 } 617 if ( !pReg->szDeviceName[0] 618 || strlen(pReg->szDeviceName) >= sizeof(pReg->szDeviceName)) 619 { 620 AssertMsgFailed(("Invalid name '%s'\n", pReg->szDeviceName)); 621 return VERR_PDM_INVALID_DEVICE_REGISTRATION; 622 } 623 if ( (pReg->fFlags & PDM_DEVREG_FLAGS_RC) 624 && ( !pReg->szRCMod[0] 625 || strlen(pReg->szRCMod) >= sizeof(pReg->szRCMod))) 626 { 627 AssertMsgFailed(("Invalid GC module name '%s' - (Device %s)\n", pReg->szRCMod, pReg->szDeviceName)); 628 return VERR_PDM_INVALID_DEVICE_REGISTRATION; 629 } 630 if ( (pReg->fFlags & PDM_DEVREG_FLAGS_R0) 631 && ( !pReg->szR0Mod[0] 632 || strlen(pReg->szR0Mod) >= sizeof(pReg->szR0Mod))) 633 { 634 AssertMsgFailed(("Invalid R0 module name '%s' - (Device %s)\n", pReg->szR0Mod, pReg->szDeviceName)); 635 return VERR_PDM_INVALID_DEVICE_REGISTRATION; 636 } 637 if ((pReg->fFlags & PDM_DEVREG_FLAGS_HOST_BITS_MASK) != PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT) 638 { 639 AssertMsgFailed(("Invalid host bits flags! fFlags=%#x (Device %s)\n", pReg->fFlags, pReg->szDeviceName)); 640 return VERR_PDM_INVALID_DEVICE_HOST_BITS; 641 } 642 if (!(pReg->fFlags & PDM_DEVREG_FLAGS_GUEST_BITS_MASK)) 643 { 644 AssertMsgFailed(("Invalid guest bits flags! fFlags=%#x (Device %s)\n", pReg->fFlags, pReg->szDeviceName)); 645 return VERR_PDM_INVALID_DEVICE_REGISTRATION; 646 } 647 if (!pReg->fClass) 648 { 649 AssertMsgFailed(("No class! (Device %s)\n", pReg->szDeviceName)); 650 return VERR_PDM_INVALID_DEVICE_REGISTRATION; 651 } 652 if (pReg->cMaxInstances <= 0) 653 { 654 AssertMsgFailed(("Max instances %u! (Device %s)\n", pReg->cMaxInstances, pReg->szDeviceName)); 655 return VERR_PDM_INVALID_DEVICE_REGISTRATION; 656 } 657 if (pReg->cbInstance > (RTUINT)(pReg->fFlags & (PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_R0) ? 96 * _1K : _1M)) 658 { 659 AssertMsgFailed(("Instance size %d bytes! (Device %s)\n", pReg->cbInstance, pReg->szDeviceName)); 660 return VERR_PDM_INVALID_DEVICE_REGISTRATION; 661 } 662 if (!pReg->pfnConstruct) 663 { 664 AssertMsgFailed(("No constructore! (Device %s)\n", pReg->szDeviceName)); 665 return VERR_PDM_INVALID_DEVICE_REGISTRATION; 666 } 667 /* Check matching guest bits last without any asserting. Enables trial and error registration. */ 668 if (!(pReg->fFlags & PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT)) 669 { 670 Log(("PDM: Rejected device '%s' because it didn't match the guest bits.\n", pReg->szDeviceName)); 671 return VERR_PDM_INVALID_DEVICE_GUEST_BITS; 672 } 610 AssertMsgReturn(pReg->u32Version == PDM_DEVREG_VERSION, 611 ("Unknown struct version %#x!\n", pReg->u32Version), 612 VERR_PDM_UNKNOWN_DEVREG_VERSION); 613 614 AssertMsgReturn( pReg->szDeviceName[0] 615 && strlen(pReg->szDeviceName) < sizeof(pReg->szDeviceName), 616 ("Invalid name '%s'\n", pReg->szDeviceName), 617 VERR_PDM_INVALID_DEVICE_REGISTRATION); 618 AssertMsgReturn( !(pReg->fFlags & PDM_DEVREG_FLAGS_RC) 619 || ( pReg->szRCMod[0] 620 && strlen(pReg->szRCMod) < sizeof(pReg->szRCMod)), 621 ("Invalid GC module name '%s' - (Device %s)\n", pReg->szRCMod, pReg->szDeviceName), 622 VERR_PDM_INVALID_DEVICE_REGISTRATION); 623 AssertMsgReturn( !(pReg->fFlags & PDM_DEVREG_FLAGS_R0) 624 || ( pReg->szR0Mod[0] 625 && strlen(pReg->szR0Mod) < sizeof(pReg->szR0Mod)), 626 ("Invalid R0 module name '%s' - (Device %s)\n", pReg->szR0Mod, pReg->szDeviceName), 627 VERR_PDM_INVALID_DEVICE_REGISTRATION); 628 AssertMsgReturn((pReg->fFlags & PDM_DEVREG_FLAGS_HOST_BITS_MASK) == PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT, 629 ("Invalid host bits flags! fFlags=%#x (Device %s)\n", pReg->fFlags, pReg->szDeviceName), 630 VERR_PDM_INVALID_DEVICE_HOST_BITS); 631 AssertMsgReturn((pReg->fFlags & PDM_DEVREG_FLAGS_GUEST_BITS_MASK), 632 ("Invalid guest bits flags! fFlags=%#x (Device %s)\n", pReg->fFlags, pReg->szDeviceName), 633 VERR_PDM_INVALID_DEVICE_REGISTRATION); 634 AssertMsgReturn(pReg->fClass, 635 ("No class! (Device %s)\n", pReg->szDeviceName), 636 VERR_PDM_INVALID_DEVICE_REGISTRATION); 637 AssertMsgReturn(pReg->cMaxInstances > 0, 638 ("Max instances %u! (Device %s)\n", pReg->cMaxInstances, pReg->szDeviceName), 639 VERR_PDM_INVALID_DEVICE_REGISTRATION); 640 AssertMsgReturn(pReg->cbInstance <= (uint32_t)(pReg->fFlags & (PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_R0) ? 96 * _1K : _1M), 641 ("Instance size %d bytes! (Device %s)\n", pReg->cbInstance, pReg->szDeviceName), 642 VERR_PDM_INVALID_DEVICE_REGISTRATION); 643 AssertMsgReturn(pReg->pfnConstruct, 644 ("No constructore! (Device %s)\n", pReg->szDeviceName), 645 VERR_PDM_INVALID_DEVICE_REGISTRATION); 646 AssertLogRelMsgReturn((pReg->fFlags & PDM_DEVREG_FLAGS_GUEST_BITS_MASK) == PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT, 647 ("PDM: Rejected device '%s' because it didn't match the guest bits.\n", pReg->szDeviceName), 648 VERR_PDM_INVALID_DEVICE_GUEST_BITS); 673 649 AssertLogRelMsg(pReg->u32VersionEnd == PDM_DEVREG_VERSION, 674 650 ("u32VersionEnd=%#x, expected %#x. (szDeviceName=%s)\n", … … 682 658 PPDMDEV pDev = pRegCB->pVM->pdm.s.pDevs; 683 659 for (; pDev; pDevPrev = pDev, pDev = pDev->pNext) 684 { 685 if (!strcmp(pDev->pReg->szDeviceName, pReg->szDeviceName)) 686 { 687 AssertMsgFailed(("Device '%s' already exists\n", pReg->szDeviceName)); 688 return VERR_PDM_DEVICE_NAME_CLASH; 689 } 690 } 660 AssertMsgReturn(strcmp(pDev->pReg->szDeviceName, pReg->szDeviceName), 661 ("Device '%s' already exists\n", pReg->szDeviceName), 662 VERR_PDM_DEVICE_NAME_CLASH); 691 663 692 664 /* … … 710 682 } 711 683 return VERR_NO_MEMORY; 712 }713 714 715 /**716 * @interface_method_impl{PDMDEVREGCB,pfnMMHeapAlloc}717 */718 static DECLCALLBACK(void *) pdmR3DevReg_MMHeapAlloc(PPDMDEVREGCB pCallbacks, size_t cb)719 {720 Assert(pCallbacks);721 Assert(pCallbacks->u32Version == PDM_DEVREG_CB_VERSION);722 723 void *pv = MMR3HeapAlloc(((PPDMDEVREGCBINT)pCallbacks)->pVM, MM_TAG_PDM_DEVICE_USER, cb);724 LogFlow(("pdmR3DevReg_MMHeapAlloc(,%#zx): returns %p\n", cb, pv));725 return pv;726 684 } 727 685
Note:
See TracChangeset
for help on using the changeset viewer.