aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ppc/boot/common/bootinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/ppc/boot/common/bootinfo.c')
-rw-r--r--arch/ppc/boot/common/bootinfo.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/arch/ppc/boot/common/bootinfo.c b/arch/ppc/boot/common/bootinfo.c
new file mode 100644
index 000000000000..9c6e528940e9
--- /dev/null
+++ b/arch/ppc/boot/common/bootinfo.c
@@ -0,0 +1,70 @@
1/*
2 * arch/ppc/common/bootinfo.c
3 *
4 * General bootinfo record utilities
5 * Author: Randy Vinson <rvinson@mvista.com>
6 *
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.
10 */
11
12#include <linux/types.h>
13#include <linux/string.h>
14#include <asm/bootinfo.h>
15
16#include "nonstdio.h"
17
18static struct bi_record * birec = NULL;
19
20static struct bi_record *
21__bootinfo_build(struct bi_record *rec, unsigned long tag, unsigned long size,
22 void *data)
23{
24 /* set the tag */
25 rec->tag = tag;
26
27 /* if the caller has any data, copy it */
28 if (size)
29 memcpy(rec->data, (char *)data, size);
30
31 /* set the record size */
32 rec->size = sizeof(struct bi_record) + size;
33
34 /* advance to the next available space */
35 rec = (struct bi_record *)((unsigned long)rec + rec->size);
36
37 return rec;
38}
39
40void
41bootinfo_init(struct bi_record *rec)
42{
43
44 /* save start of birec area */
45 birec = rec;
46
47 /* create an empty list */
48 rec = __bootinfo_build(rec, BI_FIRST, 0, NULL);
49 (void) __bootinfo_build(rec, BI_LAST, 0, NULL);
50
51}
52
53void
54bootinfo_append(unsigned long tag, unsigned long size, void * data)
55{
56
57 struct bi_record *rec = birec;
58
59 /* paranoia */
60 if ((rec == NULL) || (rec->tag != BI_FIRST))
61 return;
62
63 /* find the last entry in the list */
64 while (rec->tag != BI_LAST)
65 rec = (struct bi_record *)((ulong)rec + rec->size);
66
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);
70}