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