]> git.ozlabs.org Git - petitboot/commitdiff
discover/platform-powerpc: Handle optional Get Device ID section
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Wed, 14 Jun 2017 02:01:35 +0000 (12:01 +1000)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Tue, 20 Jun 2017 05:35:54 +0000 (15:35 +1000)
The 'auxiliary' section of the 'Get Device ID' response is optional,
and some platforms exclude it from the response entirely. However
Petitboot only recognises the response as valid if it includes the full
16 bytes.
Update get_ipmi_bmc_versions() to also handle responses of only 12 bytes.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
discover/platform-powerpc.c

index 3723ebf824df6fcee31c4571d900f5159f410165..a4b955ef6fd48e3c2daa72cf2696b4e6f9f8159d 100644 (file)
@@ -1050,7 +1050,7 @@ static void get_ipmi_bmc_versions(struct platform *p, struct system_info *info)
                pb_debug("\n");
        }
 
                pb_debug("\n");
        }
 
-       if (rc == 0 && resp_len == 16) {
+       if (rc == 0 && (resp_len == 12 || resp_len == 16)) {
                info->bmc_current = talloc_array(info, char *, 4);
                info->n_bmc_current = 4;
 
                info->bmc_current = talloc_array(info, char *, 4);
                info->n_bmc_current = 4;
 
@@ -1062,9 +1062,14 @@ static void get_ipmi_bmc_versions(struct platform *p, struct system_info *info)
                bcd += 10 * (resp[4] >> 4);
                /* rev1.rev2.aux_revision */
                info->bmc_current[2] = talloc_asprintf(info,
                bcd += 10 * (resp[4] >> 4);
                /* rev1.rev2.aux_revision */
                info->bmc_current[2] = talloc_asprintf(info,
-                                               "Firmware version: %u.%02u.%02x%02x%02x%02x",
-                                               resp[3], bcd, resp[12],
-                                               resp[13], resp[14], resp[15]);
+                               "Firmware version: %u.%02u",
+                               resp[3], bcd);
+               if (resp_len == 16) {
+                       info->bmc_current[2] = talloc_asprintf_append(
+                                       info->bmc_current[2],
+                                       ".%02x%02x%02x%02x",
+                                       resp[12], resp[13], resp[14], resp[15]);
+               }
                bcd = resp[5] & 0x0f;
                bcd += 10 * (resp[5] >> 4);
                info->bmc_current[3] = talloc_asprintf(info, "IPMI version: %u",
                bcd = resp[5] & 0x0f;
                bcd += 10 * (resp[5] >> 4);
                info->bmc_current[3] = talloc_asprintf(info, "IPMI version: %u",
@@ -1089,7 +1094,7 @@ static void get_ipmi_bmc_versions(struct platform *p, struct system_info *info)
                pb_debug("\n");
        }
 
                pb_debug("\n");
        }
 
-       if (rc == 0 && resp_len == 16) {
+       if (rc == 0 && (resp_len == 12 || resp_len == 16)) {
                info->bmc_golden = talloc_array(info, char *, 4);
                info->n_bmc_golden = 4;
 
                info->bmc_golden = talloc_array(info, char *, 4);
                info->n_bmc_golden = 4;
 
@@ -1101,9 +1106,14 @@ static void get_ipmi_bmc_versions(struct platform *p, struct system_info *info)
                bcd += 10 * (resp[4] >> 4);
                /* rev1.rev2.aux_revision */
                info->bmc_golden[2] = talloc_asprintf(info,
                bcd += 10 * (resp[4] >> 4);
                /* rev1.rev2.aux_revision */
                info->bmc_golden[2] = talloc_asprintf(info,
-                                               "Firmware version: %u.%02u.%02x%02x%02x%02x",
-                                               resp[3], bcd, resp[12],
-                                               resp[13], resp[14], resp[15]);
+                               "Firmware version: %u.%02u",
+                               resp[3], bcd);
+               if (resp_len == 16) {
+                       info->bmc_golden[2] = talloc_asprintf_append(
+                                       info->bmc_golden[2],
+                                       ".%02x%02x%02x%02x",
+                                       resp[12], resp[13], resp[14], resp[15]);
+               }
                bcd = resp[5] & 0x0f;
                bcd += 10 * (resp[5] >> 4);
                info->bmc_golden[3] = talloc_asprintf(info, "IPMI version: %u",
                bcd = resp[5] & 0x0f;
                bcd += 10 * (resp[5] >> 4);
                info->bmc_golden[3] = talloc_asprintf(info, "IPMI version: %u",