xref: /openbmc/qemu/hw/m68k/bootinfo.h (revision 5f87dddb)
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         stw_p(base, id); \
48         base += 2; \
49         stw_p(base, \
50                  (sizeof(struct bi_record) + strlen(string) + \
51                   1 /* null termination */ + 3 /* padding */) & ~3); \
52         base += 2; \
53         for (unsigned i_ = 0; string[i_]; i_++) { \
54             stb_p(base++, string[i_]); \
55         } \
56         stb_p(base++, 0); \
57         base = QEMU_ALIGN_PTR_UP(base, 4); \
58     } while (0)
59 
60 #define BOOTINFODATA(base, id, data, len) \
61     do { \
62         stw_p(base, id); \
63         base += 2; \
64         stw_p(base, \
65                  (sizeof(struct bi_record) + len + \
66                   2 /* length field */ + 3 /* padding */) & ~3); \
67         base += 2; \
68         stw_p(base, len); \
69         base += 2; \
70         for (unsigned i_ = 0; i_ < len; ++i_) { \
71             stb_p(base++, data[i_]); \
72         } \
73         base = QEMU_ALIGN_PTR_UP(base, 4); \
74     } while (0)
75 #endif
76