void setupDeviceProperties(Node *node) { const char *val; uint8_t *binStr; int cnt, cnt2; static char DEVICE_PROPERTIES_PROP[] = "device-properties"; /* Generate devprop string. */ uint32_t strlength; char *string = efi_inject_get_devprop_string(&strlength); /* Use the static "device-properties" boot config key contents if available, * otheriwse use the generated one. */ if (!getValueForKey(kDeviceProperties, &val, &cnt, &bootInfo->bootConfig) && string) { val = (const char*)string; cnt = strlength * 2; } if (cnt > 1) { binStr = convertHexStr2Binary(val, &cnt2); if (cnt2 > 0) DT__AddProperty(node, DEVICE_PROPERTIES_PROP, cnt2, binStr); } }
void addHajoKey(const char* key) { if(key == 0 || strlen(key)<3) return; verbose("addHajoKey: \"%s\" \n", key); //sleep(5); const char *data = getStringForKey(key, &bootInfo->chameleonConfig); const char* colon = strchr(data, ':'); const char* equal = strchr(colon, '='); char nodePath[128]; strncpy(nodePath, data, colon-data); nodePath[colon-data] = 0; char attributeName[128]; strncpy(attributeName, colon+1, equal-colon-1); nodePath[equal-colon-1] = 0; int len = 0; const char* attributeValue = convertHexStr2Binary(equal+1, &len); verbose("in node \"%s\" set property \"%s\" to \"%s\" \n", nodePath, attributeName, attributeValue); Node* node = DT__FindNode(nodePath, true); if (node == 0) stop("Couldn't find/add node"); DT__AddProperty(node, attributeName, len + 1, (char*)attributeValue); }
static EFI_UINT32* getUUIDFromString(const char * givenUUID) // Patch by: rekursor (rewrite by Master Chief). { if (givenUUID) // Sanity check. { static char errStr[] = "getUUIDFromString: Invalid SystemID - "; if (strlen(givenUUID) == 36) // Real UUID's only please. { int size = 0; char szUUID[37]; // 0-35 (36) + 1 char *p = szUUID; while (*givenUUID) { if (*givenUUID != '-') *p++ = *givenUUID++; else givenUUID++; } *p = '\0'; void* binaryString = convertHexStr2Binary(szUUID, &size); if (binaryString && size == 16) return (EFI_UINT32*) binaryString; verbose("%swrong format maybe?\n", errStr); } else verbose("%slength should be 36.\n", errStr); } return (EFI_UINT32*) 0; }
static EFI_CHAR8* getUUIDFromString(const char * szInUUID) { char szUUID[16+1], *p=szUUID; int size=0, x; void* ret; if (!szInUUID || strlen(szInUUID)<16) return (EFI_CHAR8*) 0; while(*szInUUID) if (*szInUUID!='-') *p++=*szInUUID++; else szInUUID++; *p='\0'; ret = convertHexStr2Binary(szUUID, &size); if (!ret || size!=16) { verbose("UUID: cannot convert string <%s> to valid UUID.\n", szUUID); return (EFI_CHAR8*) 0; } return (EFI_CHAR8*) ret; // new allocated buffer containing the converted string to bin }