X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=lib%2Fpb-protocol%2Fpb-protocol.c;h=4e0af873b710ad8d72707c9fa60190076197e865;hb=69c459db80abece18b5557d9b8a8098a88329c28;hp=fdf24471377160e9a3c51abb87c4197e4e034e1c;hpb=0f29db72ec545322ea065c3b12c87b6fc7045b45;p=petitboot diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c index fdf2447..4e0af87 100644 --- a/lib/pb-protocol/pb-protocol.c +++ b/lib/pb-protocol/pb-protocol.c @@ -38,6 +38,14 @@ * action = 0x2: device remove message * payload: * 4-byte len, id + * + * action = 0x3: boot + * payload: + * 4-byte len, boot option id + * 4-byte len, boot_image_file + * 4-byte len, initrd_file + * 4-byte len, boot_args + * */ void pb_protocol_dump_device(const struct device *dev, const char *text, @@ -175,6 +183,14 @@ int pb_protocol_device_len(const struct device *dev) return len; } +int pb_protocol_boot_len(const struct boot_command *boot) +{ + return 4 + optional_strlen(boot->option_id) + + 4 + optional_strlen(boot->boot_image_file) + + 4 + optional_strlen(boot->initrd_file) + + 4 + optional_strlen(boot->boot_args); +} + int pb_protocol_serialise_device(const struct device *dev, char *buf, int buf_len) { struct boot_option *opt; @@ -215,6 +231,22 @@ int pb_protocol_serialise_device(const struct device *dev, char *buf, int buf_le return 0; } +int pb_protocol_serialise_boot_command(const struct boot_command *boot, + char *buf, int buf_len) +{ + char *pos = buf; + + pos += pb_protocol_serialise_string(pos, boot->option_id); + pos += pb_protocol_serialise_string(pos, boot->boot_image_file); + pos += pb_protocol_serialise_string(pos, boot->initrd_file); + pos += pb_protocol_serialise_string(pos, boot->boot_args); + + assert(pos <= buf + buf_len); + (void)buf_len; + + return 0; +} + int pb_protocol_write_message(int fd, struct pb_protocol_message *message) { int total_len, rc;