bootinfo.h revision 1.5 1 1.5 martin /* $NetBSD: bootinfo.h,v 1.5 2010/04/02 18:34:16 martin Exp $ */
2 1.1 mrg
3 1.2 cdi /*-
4 1.2 cdi * Copyright (c) 2005 The NetBSD Foundation, Inc.
5 1.2 cdi * All rights reserved.
6 1.2 cdi *
7 1.2 cdi * Redistribution and use in source and binary forms, with or without
8 1.2 cdi * modification, are permitted provided that the following conditions
9 1.2 cdi * are met:
10 1.2 cdi * 1. Redistributions of source code must retain the above copyright
11 1.2 cdi * notice, this list of conditions and the following disclaimer.
12 1.2 cdi * 2. Redistributions in binary form must reproduce the above copyright
13 1.2 cdi * notice, this list of conditions and the following disclaimer in the
14 1.2 cdi * documentation and/or other materials provided with the distribution.
15 1.2 cdi *
16 1.2 cdi * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 1.2 cdi * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 1.2 cdi * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 1.2 cdi * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 1.2 cdi * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 1.2 cdi * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 1.2 cdi * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 1.2 cdi * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 1.2 cdi * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 1.2 cdi * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 1.2 cdi * POSSIBILITY OF SUCH DAMAGE.
27 1.2 cdi */
28 1.2 cdi
29 1.2 cdi #ifndef _BOOTINFO_H_
30 1.2 cdi #define _BOOTINFO_H_
31 1.2 cdi
32 1.2 cdi #include <machine/param.h>
33 1.1 mrg #include <sparc/bootinfo.h>
34 1.2 cdi
35 1.2 cdi /*
36 1.2 cdi * The bootloader v1.9 and higher makes a call into a kernel with the following
37 1.2 cdi * arguments:
38 1.2 cdi *
39 1.2 cdi * %o0 OpenFirmware entry point, to keep Sun's updaters happy
40 1.2 cdi * %o1 Address of boot information vector (see below)
41 1.2 cdi * %o2 Length of the vector, in bytes
42 1.2 cdi * %o3 OpenFirmware entry point, to mimic Sun bootloader behavior
43 1.2 cdi * %o4 OpenFirmware entry point, to meet earlier NetBSD kernels
44 1.2 cdi * expectations
45 1.2 cdi *
46 1.2 cdi * All parameters are of void* type except for vector length which is of
47 1.2 cdi * integer type.
48 1.2 cdi *
49 1.2 cdi * The boot information vector format was dictated by earlier kernels and
50 1.2 cdi * starting from ofwboot v1.9 has four entries:
51 1.2 cdi *
52 1.2 cdi * +-------------------------------------+
53 1.2 cdi * #0 | NetBSD boot magic number ('DDB2') |
54 1.2 cdi * +-------------------------------------+
55 1.2 cdi * #1 | ksyms' table end address |
56 1.2 cdi * +-------------------------------------+
57 1.2 cdi * #2 | ksyms' table start address |
58 1.2 cdi * +-------------------------------------+
59 1.2 cdi * #3 | Pointer to a bootinfo binary object |
60 1.2 cdi * +-------------------------------------+
61 1.2 cdi *
62 1.2 cdi * Kernels written for pre-v1.8 ofwboot require first three cells to present
63 1.2 cdi * in this particular order, those that rely on v1.9 and higher won't work if
64 1.2 cdi * the last pointer is not in the table; therefore, the vector cannot be
65 1.3 cdi * shorter than 4 * sizeof(uint32_t) or 4 * sizeof(uint64_t) for 32-bit and
66 1.2 cdi * 64-bit boot loader, respectively.
67 1.2 cdi *
68 1.2 cdi * As of ofwboot v1.9, bootinfo binary object is placed right after the kernel
69 1.2 cdi * data segment end, i.e. in the permanently locked 4MB page. There is no order
70 1.2 cdi * for the data located in bootinfo binary object. The kernel however expects
71 1.2 cdi * at least following parameters to exist in there:
72 1.2 cdi *
73 1.2 cdi * - Symbol information (size, start, end; see struct btinfo_symtab)
74 1.2 cdi * - Kernel end address, calculated as true kernel end address plus size of
75 1.2 cdi * space reserved for bootinfo binary object (struct btinfo_kernend)
76 1.2 cdi * - Number of text segment pages (struct btinfo_count)
77 1.2 cdi * - Number of data segment pages (struct btinfo_count)
78 1.2 cdi * - Array of text pages VA/PA (struct btinfo_tlb)
79 1.2 cdi * - Array of data pages VA/PA (struct btinfo_tlb)
80 1.2 cdi *
81 1.2 cdi * The last four data structures fully describe kernel mappings. ofwboot v1.9
82 1.2 cdi * and higher map the kernel with 4MB permanent pages and this is the only
83 1.2 cdi * way to let kernel know how exactly it was mapped.
84 1.2 cdi */
85 1.2 cdi
86 1.2 cdi /* Boot magic number */
87 1.2 cdi #define SPARC_MACHINE_OPENFIRMWARE 0x44444230
88 1.2 cdi
89 1.2 cdi #ifdef BOOTINFO_SIZE
90 1.2 cdi #undef BOOTINFO_SIZE
91 1.2 cdi #endif
92 1.2 cdi
93 1.2 cdi #define BOOTINFO_SIZE NBPG
94 1.2 cdi
95 1.2 cdi #define BTINFO_DTLB_SLOTS 100
96 1.2 cdi #define BTINFO_ITLB_SLOTS 101
97 1.2 cdi #define BTINFO_DTLB 102
98 1.2 cdi #define BTINFO_ITLB 103
99 1.2 cdi #define BTINFO_KERNEND 104
100 1.5 martin #define BTINFO_BOOTDEV 105
101 1.2 cdi
102 1.2 cdi #define LOOKUP_BOOTINFO(btp, info) \
103 1.2 cdi do { \
104 1.2 cdi if ( ((btp) = lookup_bootinfo(info)) == NULL) { \
105 1.2 cdi panic("lookup_bootinfo: No " #info " found.\n"); \
106 1.2 cdi } \
107 1.2 cdi } while (0)
108 1.2 cdi
109 1.2 cdi struct tlb_entry {
110 1.2 cdi uint64_t te_pa;
111 1.2 cdi uint64_t te_va;
112 1.2 cdi };
113 1.2 cdi
114 1.2 cdi struct btinfo_count {
115 1.2 cdi struct btinfo_common common;
116 1.2 cdi int count;
117 1.2 cdi };
118 1.2 cdi
119 1.2 cdi struct btinfo_tlb {
120 1.2 cdi struct btinfo_common common;
121 1.2 cdi struct tlb_entry tlb[1];
122 1.2 cdi };
123 1.2 cdi
124 1.2 cdi struct btinfo_kernend {
125 1.2 cdi struct btinfo_common common;
126 1.2 cdi uint64_t addr;
127 1.2 cdi };
128 1.2 cdi
129 1.5 martin struct btinfo_bootdev {
130 1.5 martin struct btinfo_common common;
131 1.5 martin char name[1];
132 1.5 martin };
133 1.5 martin
134 1.2 cdi #endif /* _BOOTINFO_H_ */
135