From 443ce2a3ac055b4ec13f86a782a04be8453fd393 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 29 Jun 2012 15:16:03 -0700 Subject: Change fdt-specific loader into a generic setup_data loader Make it a generic setup_data loader keyed by type. Signed-off-by: H. Peter Anvin Cc: Thierry Reding --- com32/lib/syslinux/setup_data.c | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 com32/lib/syslinux/setup_data.c (limited to 'com32/lib/syslinux/setup_data.c') diff --git a/com32/lib/syslinux/setup_data.c b/com32/lib/syslinux/setup_data.c new file mode 100644 index 00000000..a36c5b61 --- /dev/null +++ b/com32/lib/syslinux/setup_data.c @@ -0,0 +1,47 @@ +#include +#include +#include + +struct setup_data *setup_data_init(void) +{ + struct setup_data *setup_data; + + setup_data = zalloc(sizeof(*setup_data)); + if (!setup_data) + return NULL; + + setup_data->prev = setup_data->next = setup_data; + return setup_data; +} + +int setup_data_add(struct setup_data *head, uint32_t type, + const void *data, size_t data_len) +{ + struct setup_data *setup_data; + + setup_data = zalloc(sizeof(*setup_data)); + if (!setup_data) + return -1; + + setup_data->data = data; + setup_data->hdr.len = data_len; + setup_data->hdr.type = type; + setup_data->prev = head->prev; + setup_data->next = head; + head->prev->next = setup_data; + head->prev = setup_data; + + return 0; +} + +int setup_data_load(struct setup_data *head, uint32_t type, + const char *filename) +{ + void *data; + size_t len; + + if (loadfile(filename, &data, &len)) + return -1; + + return setup_data_add(head, type, data, len); +} -- cgit v1.2.1