- dev->n_options = n_options;
-
- list_init(&dev->boot_options);
-
- for (i = 0; i < n_options; i++) {
- struct boot_option *opt;
-
- opt = talloc(dev, struct boot_option);
-
- if (read_string(opt, &pos, &len, &opt->id))
- goto out_err;
- if (read_string(opt, &pos, &len, &opt->name))
- goto out_err;
- if (read_string(opt, &pos, &len,
- &opt->description))
- goto out_err;
- if (read_string(opt, &pos, &len,
- &opt->icon_file))
- goto out_err;
- if (read_string(opt, &pos, &len,
- &opt->boot_image_file))
- goto out_err;
- if (read_string(opt, &pos, &len,
- &opt->initrd_file))
- goto out_err;
- if (read_string(opt, &pos, &len,
- &opt->boot_args))
- goto out_err;
-
- list_add(&dev->boot_options, &opt->list);
+int pb_protocol_deserialise_boot_option(struct boot_option *opt,
+ const struct pb_protocol_message *message)
+{
+ unsigned int len;
+ const char *pos;
+ int rc = -1;
+
+ len = message->payload_len;
+ pos = message->payload;
+
+ if (read_string(opt, &pos, &len, &opt->device_id))
+ goto out;
+
+ if (read_string(opt, &pos, &len, &opt->id))
+ goto out;
+
+ if (read_string(opt, &pos, &len, &opt->name))
+ goto out;
+
+ if (read_string(opt, &pos, &len, &opt->description))
+ goto out;
+
+ if (read_string(opt, &pos, &len, &opt->icon_file))
+ goto out;
+
+ if (read_string(opt, &pos, &len, &opt->boot_image_file))
+ goto out;
+
+ if (read_string(opt, &pos, &len, &opt->initrd_file))
+ goto out;
+
+ if (read_string(opt, &pos, &len, &opt->dtb_file))
+ goto out;
+
+ if (read_string(opt, &pos, &len, &opt->boot_args))
+ goto out;
+
+ if (len < sizeof(bool))
+ goto out;
+ opt->is_default = *(bool *)(pos);
+
+ rc = 0;
+
+out:
+ return rc;
+}
+
+int pb_protocol_deserialise_boot_command(struct boot_command *cmd,
+ const struct pb_protocol_message *message)
+{
+ unsigned int len;
+ const char *pos;
+ int rc = -1;
+
+ len = message->payload_len;
+ pos = message->payload;
+
+ if (read_string(cmd, &pos, &len, &cmd->option_id))
+ goto out;
+
+ if (read_string(cmd, &pos, &len, &cmd->boot_image_file))
+ goto out;
+
+ if (read_string(cmd, &pos, &len, &cmd->initrd_file))
+ goto out;
+
+ if (read_string(cmd, &pos, &len, &cmd->dtb_file))
+ goto out;
+
+ if (read_string(cmd, &pos, &len, &cmd->boot_args))
+ goto out;
+
+ rc = 0;
+
+out:
+ return rc;
+}
+
+int pb_protocol_deserialise_boot_status(struct boot_status *status,
+ const struct pb_protocol_message *message)
+{
+ unsigned int len;
+ const char *pos;
+ int rc = -1;
+
+ len = message->payload_len;
+ pos = message->payload;
+
+ /* first up, the type enum... */
+ if (len < sizeof(uint32_t))
+ goto out;
+
+ status->type = __be32_to_cpu(*(uint32_t *)(pos));
+
+ switch (status->type) {
+ case BOOT_STATUS_ERROR:
+ case BOOT_STATUS_INFO:
+ break;
+ default:
+ goto out;