xref: /openbmc/qemu/hw/m68k/bootinfo.h (revision d0bf492f)
1 /*
2  * SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
3  *
4  * Bootinfo tags from linux bootinfo.h and bootinfo-mac.h:
5  * This is an easily parsable and extendable structure containing all
6  * information to be passed from the bootstrap to the kernel
7  *
8  * This structure is copied right after the kernel by the bootstrap
9  * routine.
10  */
11 
12 #ifndef HW_M68K_BOOTINFO_H
13 #define HW_M68K_BOOTINFO_H
14 
15 #define BOOTINFO0(base, id) \
16     do { \
17         stw_p(base, id); \
18         base += 2; \
19         stw_p(base, sizeof(struct bi_record)); \
20         base += 2; \
21     } while (0)
22 
23 #define BOOTINFO1(base, id, value) \
24     do { \
25         stw_p(base, id); \
26         base += 2; \
27         stw_p(base, sizeof(struct bi_record) + 4); \
28         base += 2; \
29         stl_p(base, value); \
30         base += 4; \
31     } while (0)
32 
33 #define BOOTINFO2(base, id, value1, value2) \
34     do { \
35         stw_p(base, id); \
36         base += 2; \
37         stw_p(base, sizeof(struct bi_record) + 8); \
38         base += 2; \
39         stl_p(base, value1); \
40         base += 4; \
41         stl_p(base, value2); \
42         base += 4; \
43     } while (0)
44 
45 #define BOOTINFOSTR(base, id, string) \
46     do { \
47         int i; \
48         stw_p(base, id); \
49         base += 2; \
50         stw_p(base, \
51                  (sizeof(struct bi_record) + strlen(string) + \
52                   1 /* null termination */ + 3 /* padding */) & ~3); \
53         base += 2; \
54         for (i = 0; string[i]; i++) { \
55             stb_p(base++, string[i]); \
56         } \
57         stb_p(base++, 0); \
58         base = QEMU_ALIGN_PTR_UP(base, 4); \
59     } while (0)
60 
61 #define BOOTINFODATA(base, id, data, len) \
62     do { \
63         int i; \
64         stw_p(base, id); \
65         base += 2; \
66         stw_p(base, \
67                  (sizeof(struct bi_record) + len + \
68                   2 /* length field */ + 3 /* padding */) & ~3); \
69         base += 2; \
70         stw_p(base, len); \
71         base += 2; \
72         for (i = 0; i < len; ++i) { \
73             stb_p(base++, data[i]); \
74         } \
75         base = QEMU_ALIGN_PTR_UP(base, 4); \
76     } while (0)
77 #endif
78