2 * General bootinfo record utilities
3 * Author: Randy Vinson <rvinson@mvista.com>
5 * 2002 (c) MontaVista Software, Inc. This file is licensed under the terms
6 * of the GNU General Public License version 2. This program is licensed
7 * "as is" without any warranty of any kind, whether express or implied.
10 #include <linux/types.h>
11 #include <linux/string.h>
12 #include <asm/bootinfo.h>
16 static struct bi_record * birec = NULL;
18 static struct bi_record *
19 __bootinfo_build(struct bi_record *rec, unsigned long tag, unsigned long size,
25 /* if the caller has any data, copy it */
27 memcpy(rec->data, (char *)data, size);
29 /* set the record size */
30 rec->size = sizeof(struct bi_record) + size;
32 /* advance to the next available space */
33 rec = (struct bi_record *)((unsigned long)rec + rec->size);
39 bootinfo_init(struct bi_record *rec)
42 /* save start of birec area */
45 /* create an empty list */
46 rec = __bootinfo_build(rec, BI_FIRST, 0, NULL);
47 (void) __bootinfo_build(rec, BI_LAST, 0, NULL);
52 bootinfo_append(unsigned long tag, unsigned long size, void * data)
55 struct bi_record *rec = birec;
58 if ((rec == NULL) || (rec->tag != BI_FIRST))
61 /* find the last entry in the list */
62 while (rec->tag != BI_LAST)
63 rec = (struct bi_record *)((ulong)rec + rec->size);
65 /* overlay BI_LAST record with new one and tag on a new BI_LAST */
66 rec = __bootinfo_build(rec, tag, size, data);
67 (void) __bootinfo_build(rec, BI_LAST, 0, NULL);