summaryrefslogtreecommitdiff
path: root/com32/lib/syslinux/setup_data.c
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2012-11-29 11:58:47 +0000
committerJonathan Maw <jonathan.maw@codethink.co.uk>2012-11-29 11:58:47 +0000
commit0846de0e1795a30512f5575388d163ea548125de (patch)
treee1bc03fa83c61165f48ffe3f528ac5496332872a /com32/lib/syslinux/setup_data.c
parentede8500d7c710e4ddf650f1a1ef3ccf2a89e5313 (diff)
parent7307d60063ee4303da4de45f9d984fdc8df92146 (diff)
downloadsyslinux-baserock/genivi/morph.tar.gz
Merge the latest changes from upstreambaserock/genivi/morph
Diffstat (limited to 'com32/lib/syslinux/setup_data.c')
-rw-r--r--com32/lib/syslinux/setup_data.c47
1 files changed, 47 insertions, 0 deletions
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 <stdlib.h>
+#include <syslinux/linux.h>
+#include <syslinux/loadfile.h>
+
+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);
+}