2 * arch/ppc/common/bootinfo.c
4 * General bootinfo record utilities
5 * Author: Randy Vinson <rvinson@mvista.com>
7 * 2002 (c) MontaVista Software, Inc. This file is licensed under the terms
8 * of the GNU General Public License version 2. This program is licensed
9 * "as is" without any warranty of any kind, whether express or implied.
12 #include <linux/types.h>
13 #include <linux/string.h>
14 #include <asm/bootinfo.h>
18 static struct bi_record * birec = NULL;
20 static struct bi_record *
21 __bootinfo_build(struct bi_record *rec, unsigned long tag, unsigned long size,
27 /* if the caller has any data, copy it */
29 memcpy(rec->data, (char *)data, size);
31 /* set the record size */
32 rec->size = sizeof(struct bi_record) + size;
34 /* advance to the next available space */
35 rec = (struct bi_record *)((unsigned long)rec + rec->size);
41 bootinfo_init(struct bi_record *rec)
44 /* save start of birec area */
47 /* create an empty list */
48 rec = __bootinfo_build(rec, BI_FIRST, 0, NULL);
49 (void) __bootinfo_build(rec, BI_LAST, 0, NULL);
54 bootinfo_append(unsigned long tag, unsigned long size, void * data)
57 struct bi_record *rec = birec;
60 if ((rec == NULL) || (rec->tag != BI_FIRST))
63 /* find the last entry in the list */
64 while (rec->tag != BI_LAST)
65 rec = (struct bi_record *)((ulong)rec + rec->size);
67 /* overlay BI_LAST record with new one and tag on a new BI_LAST */
68 rec = __bootinfo_build(rec, tag, size, data);
69 (void) __bootinfo_build(rec, BI_LAST, 0, NULL);