summaryrefslogtreecommitdiffstats
path: root/lib/pb-protocol/pb-protocol.c
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2017-02-14 15:56:14 +1100
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2017-08-15 13:03:22 +1000
commit9f191cc3c194ed51534c22e2dae15b2c08c8abc2 (patch)
tree63158b566e95e496f238864ea8f791101ed9100c /lib/pb-protocol/pb-protocol.c
parent98b04aa42a4f1dc8e585f00d75c3b28d9e9aa2a9 (diff)
downloadtalos-petitboot-9f191cc3c194ed51534c22e2dae15b2c08c8abc2.tar.gz
talos-petitboot-9f191cc3c194ed51534c22e2dae15b2c08c8abc2.zip
discover/pxe-parser: Recognise plugin sources
Extend the pxe-parser to recognise 'PLUGIN' as well as the usual 'LABEL' when parsing a config file. 'PLUGIN' will be used to specify an option that provides the location of an installable pb-plugin file, named by the 'TARBALL' label. Since plugin options are discovered via the same mechanism as boot options treat them the same as boot options and at the 'type' field to the boot_option struct to differentiate between them. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'lib/pb-protocol/pb-protocol.c')
-rw-r--r--lib/pb-protocol/pb-protocol.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c
index ed61fe1..dbbda40 100644
--- a/lib/pb-protocol/pb-protocol.c
+++ b/lib/pb-protocol/pb-protocol.c
@@ -75,6 +75,8 @@ void pb_protocol_dump_device(const struct device *dev, const char *text,
fprintf(stream, "%s\t\tdtb: %s\n", text, opt->dtb_file);
fprintf(stream, "%s\t\targs: %s\n", text, opt->boot_args);
fprintf(stream, "%s\t\tasig: %s\n", text, opt->args_sig_file);
+ fprintf(stream, "%s\t\ttype: %s\n", text,
+ opt->type == DISCOVER_BOOT_OPTION ? "boot" : "plugin");
}
}
@@ -201,7 +203,8 @@ int pb_protocol_boot_option_len(const struct boot_option *opt)
4 + optional_strlen(opt->dtb_file) +
4 + optional_strlen(opt->boot_args) +
4 + optional_strlen(opt->args_sig_file) +
- sizeof(opt->is_default);
+ sizeof(opt->is_default) +
+ sizeof(opt->type);
}
int pb_protocol_boot_len(const struct boot_command *boot)
@@ -397,6 +400,9 @@ int pb_protocol_serialise_boot_option(const struct boot_option *opt,
*(bool *)pos = opt->is_default;
pos += sizeof(bool);
+ *(uint32_t *)pos = __cpu_to_be32(opt->type);
+ pos += 4;
+
assert(pos <= buf + buf_len);
(void)buf_len;
@@ -825,6 +831,11 @@ int pb_protocol_deserialise_boot_option(struct boot_option *opt,
if (len < sizeof(bool))
goto out;
opt->is_default = *(bool *)(pos);
+ pos += sizeof(bool);
+ len -= sizeof(bool);
+
+ if (read_u32(&pos, &len, &opt->type))
+ return -1;
rc = 0;
OpenPOWER on IntegriCloud