/** * Get the information needed to map the basic communication structures in * device memory into our address space. All pointer parameters are optional. * * @param cbVRAM how much video RAM is allocated to the device * @param poffVRAMBaseMapping where to save the offset from the start of the * device VRAM of the whole area to map * @param pcbMapping where to save the mapping size * @param poffGuestHeapMemory where to save the offset into the mapped area * of the guest heap backing memory * @param pcbGuestHeapMemory where to save the size of the guest heap * backing memory * @param poffHostFlags where to save the offset into the mapped area * of the host flags */ RTDECL(void) VBoxHGSMIGetBaseMappingInfo(uint32_t cbVRAM, uint32_t *poffVRAMBaseMapping, uint32_t *pcbMapping, uint32_t *poffGuestHeapMemory, uint32_t *pcbGuestHeapMemory, uint32_t *poffHostFlags) { AssertPtrNullReturnVoid(poffVRAMBaseMapping); AssertPtrNullReturnVoid(pcbMapping); AssertPtrNullReturnVoid(poffGuestHeapMemory); AssertPtrNullReturnVoid(pcbGuestHeapMemory); AssertPtrNullReturnVoid(poffHostFlags); if (poffVRAMBaseMapping) *poffVRAMBaseMapping = cbVRAM - VBVA_ADAPTER_INFORMATION_SIZE; if (pcbMapping) *pcbMapping = VBVA_ADAPTER_INFORMATION_SIZE; if (poffGuestHeapMemory) *poffGuestHeapMemory = 0; if (pcbGuestHeapMemory) *pcbGuestHeapMemory = VBVA_ADAPTER_INFORMATION_SIZE - sizeof(HGSMIHOSTFLAGS); if (poffHostFlags) *poffHostFlags = VBVA_ADAPTER_INFORMATION_SIZE - sizeof(HGSMIHOSTFLAGS); }
/* static */ void dvdCreateDeviceStrings(const char *pcszVendor, const char *pcszModel, char *pszDesc, size_t cchDesc, char *pszUdi, size_t cchUdi) { AssertPtrReturnVoid(pcszVendor); AssertPtrReturnVoid(pcszModel); AssertPtrNullReturnVoid(pszDesc); AssertReturnVoid(!pszDesc || cchDesc > 0); AssertPtrNullReturnVoid(pszUdi); AssertReturnVoid(!pszUdi || cchUdi > 0); char szCleaned[128]; size_t cchVendor = strLenStripped(pcszVendor); size_t cchModel = strLenStripped(pcszModel); /* Create a cleaned version of the model string for the UDI string. */ for (unsigned i = 0; i < sizeof(szCleaned) && pcszModel[i] != '\0'; ++i) if ( (pcszModel[i] >= '0' && pcszModel[i] <= '9') || (pcszModel[i] >= 'A' && pcszModel[i] <= 'z')) szCleaned[i] = pcszModel[i]; else szCleaned[i] = '_'; szCleaned[RT_MIN(cchModel, sizeof(szCleaned) - 1)] = '\0'; /* Construct the description string as "Vendor Product" */ if (pszDesc) { if (cchVendor > 0) RTStrPrintf(pszDesc, cchDesc, "%.*s %s", cchVendor, pcszVendor, cchModel > 0 ? pcszModel : "(unknown drive model)"); else RTStrPrintf(pszDesc, cchDesc, "%s", pcszModel); } /* Construct the UDI string */ if (pszUdi) { if (cchModel > 0) RTStrPrintf(pszUdi, cchUdi, "/org/freedesktop/Hal/devices/storage_model_%s", szCleaned); else pszUdi[0] = '\0'; } }
/** * Create a UDI and a description for a floppy drive based on a number and the * driver's name for it. We deliberately return an ugly sequence of * characters as the description rather than an English language string to * avoid translation issues. * * @returns true if we know the device to be valid, false otherwise * @param pcszName the floppy driver name for the device (optional) * @param Number the number of the floppy (0 to 3 on FDC 0, 4 to 7 on * FDC 1) * @param pszDesc where to store the device description (optional) * @param cchDesc the size of the buffer in @a pszDesc * @param pszUdi where to store the device UDI (optional) * @param cchUdi the size of the buffer in @a pszUdi */ static void floppyCreateDeviceStrings(const floppy_drive_name pcszName, unsigned Number, char *pszDesc, size_t cchDesc, char *pszUdi, size_t cchUdi) { AssertPtrNullReturnVoid(pcszName); AssertPtrNullReturnVoid(pszDesc); AssertReturnVoid(!pszDesc || cchDesc > 0); AssertPtrNullReturnVoid(pszUdi); AssertReturnVoid(!pszUdi || cchUdi > 0); AssertReturnVoid(Number <= 7); if (pcszName) { const char *pcszSize; switch(pcszName[0]) { case 'd': case 'q': case 'h': pcszSize = "5.25\""; break; case 'D': case 'H': case 'E': case 'u': pcszSize = "3.5\""; break; default: pcszSize = "(unknown)"; } if (pszDesc) RTStrPrintf(pszDesc, cchDesc, "%s %s K%s", pcszSize, &pcszName[1], Number > 3 ? ", FDC 2" : ""); } else { if (pszDesc) RTStrPrintf(pszDesc, cchDesc, "FDD %d%s", (Number & 4) + 1, Number > 3 ? ", FDC 2" : ""); } if (pszUdi) RTStrPrintf(pszUdi, cchUdi, "/org/freedesktop/Hal/devices/platform_floppy_%u_storage", Number); }
/* static */ void dvdCreateDeviceString(const char *pcszVendor, const char *pcszModel, char *pszDesc, size_t cchDesc) { AssertPtrReturnVoid(pcszVendor); AssertPtrReturnVoid(pcszModel); AssertPtrNullReturnVoid(pszDesc); AssertReturnVoid(!pszDesc || cchDesc > 0); size_t cchVendor = strLenStripped(pcszVendor); size_t cchModel = strLenStripped(pcszModel); /* Construct the description string as "Vendor Product" */ if (pszDesc) { if (cchVendor > 0) RTStrPrintf(pszDesc, cchDesc, "%.*s %s", cchVendor, pcszVendor, cchModel > 0 ? pcszModel : "(unknown drive model)"); else RTStrPrintf(pszDesc, cchDesc, "%s", pcszModel); } }