xref: /titanic_44/usr/src/uts/i86pc/sys/fastboot.h (revision 2e107de79998f3036decec2454002940afb9a6ff)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_FASTBOOT_H
28 #define	_SYS_FASTBOOT_H
29 
30 
31 /*
32  * Platform dependent instruction sequences for fast reboot
33  */
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #ifndef	_ASM
40 #include <sys/types.h>
41 #include <sys/mach_mmu.h>
42 #include <sys/md5.h>
43 #endif	/* _ASM */
44 
45 #define	FASTBOOT_NAME_UNIX		0
46 #define	FASTBOOT_NAME_BOOTARCHIVE	1
47 
48 #define	FASTBOOT_MAX_FILES_MAP	2 /* max number of files that needs mapping */
49 #define	FASTBOOT_MAX_FILES_TOTAL	3 /* max number of files */
50 
51 #define	FASTBOOT_MAX_MD5_HASH	(FASTBOOT_MAX_FILES_MAP + 1)
52 
53 #define	FASTBOOT_SWTCH_PA		0x5000	/* low memory */
54 #define	FASTBOOT_STACK_OFFSET		0xe00	/* where the stack starts */
55 #define	FASTBOOT_MAGIC			('F' << 24 | 'A' << 16 | 'S' << 8 | 'T')
56 
57 #define	FASTBOOT_UNIX		0
58 #define	FASTBOOT_BOOTARCHIVE	1
59 #define	FASTBOOT_SWTCH		2
60 
61 /*
62  * Default sizes for varies information we have to save across boot for
63  * fast reboot.  If the actual size is bigger than what we saved, abort
64  * fast reboot.
65  */
66 #define	FASTBOOT_SAVED_MMAP_COUNT	32
67 #define	FASTBOOT_SAVED_DRIVES_COUNT	9
68 #define	FASTBOOT_SAVED_CMDLINE_LEN	MMU_PAGESIZE
69 
70 
71 /*
72  * dboot entry address comes from
73  * usr/src/uts/i86pc/conf/Mapfile and Mapfile.64.
74  */
75 #define	DBOOT_ENTRY_ADDRESS	0xc00000
76 
77 /*
78  * Fake starting virtual address for creating mapping for the new kernel
79  * and boot_archive.
80  */
81 #define	FASTBOOT_FAKE_VA	(2ULL << 30)
82 
83 #define	FASTBOOT_TERMINATE	0xdeadbee0	/* Terminating PTEs */
84 
85 #ifndef	_ASM
86 
87 #define	MAX_ELF32_LOAD_SECTIONS 3
88 
89 /*
90  * Data structure for specifying each section in a 32-bit ELF file.
91  */
92 typedef struct fastboot_section
93 {
94 	uint32_t		fb_sec_offset;	/* offset */
95 	uint32_t		fb_sec_paddr;	/* physical address */
96 	uint32_t		fb_sec_size;	/* size */
97 	uint32_t		fb_sec_bss_size;	/* section bss size */
98 } fastboot_section_t;
99 
100 /*
101  * Data structure for describing each file that needs to be relocated from high
102  * memory to low memory for fast reboot.  Currently these files are unix, the
103  * boot_archive, and the relocation function itself.
104  */
105 typedef struct _fastboot_file {
106 	uintptr_t		fb_va;	/* virtual address */
107 	x86pte_t		*fb_pte_list_va;	/* VA for PTE list */
108 	paddr_t			fb_pte_list_pa;		/* PA for PTE list */
109 	size_t			fb_pte_list_size;	/* size of PTE list */
110 	uintptr_t		fb_dest_pa;	/* destination PA */
111 	size_t			fb_size;	/* file size */
112 	uintptr_t		fb_next_pa;
113 	fastboot_section_t	fb_sections[MAX_ELF32_LOAD_SECTIONS];
114 	int			fb_sectcnt;	/* actual number of sections */
115 } fastboot_file_t;
116 
117 /*
118  * Data structure containing all the information the switching routine needs
119  * for fast rebooting to the new kernel.
120  *
121  * NOTE: There is limited stack space (0x200 bytes) in the switcher to
122  * copy in the data structure.  Fields that are not absolutely necessary for
123  * the switcher should be added after the fi_valid field.
124  */
125 typedef struct _fastboot_info {
126 	uint32_t		fi_magic; /* magic for fast reboot */
127 	fastboot_file_t		fi_files[FASTBOOT_MAX_FILES_TOTAL];
128 	int			fi_has_pae;
129 	uintptr_t		fi_pagetable_va;
130 	paddr_t			fi_pagetable_pa;
131 	paddr_t			fi_last_table_pa;
132 	paddr_t			fi_new_mbi_pa;	/* new multiboot info PA */
133 	int			fi_valid;	/* is the new kernel valid */
134 	uintptr_t		fi_next_table_va;
135 	paddr_t			fi_next_table_pa;
136 	uint_t			*fi_shift_amt;
137 	uint_t			fi_ptes_per_table;
138 	uint_t			fi_lpagesize;
139 	int			fi_top_level;	/* top level of page tables */
140 	size_t			fi_pagetable_size; /* size allocated for pt */
141 	uintptr_t		fi_new_mbi_va;	/* new multiboot info VA */
142 	size_t			fi_mbi_size;	/* size allocated for mbi */
143 	uchar_t		fi_md5_hash[FASTBOOT_MAX_MD5_HASH][MD5_DIGEST_LENGTH];
144 } fastboot_info_t;
145 
146 
147 /*
148  * Fast reboot core functions
149  */
150 extern void fast_reboot();	/* Entry point for fb_switch */
151 extern void fastboot_load_kernel(char *); /* Load a new kernel */
152 
153 extern int fastboot_cksum_verify(fastboot_info_t *);
154 
155 /*
156  * Fast reboot tunables
157  */
158 
159 /* If set, the system is capable of fast reboot */
160 extern int fastreboot_capable;
161 
162 /*
163  * If set, force fast reboot even if the system has
164  * drivers without quiesce(9E) implementation.
165  */
166 extern int force_fastreboot;
167 
168 /* If set, fast reboot after panic. */
169 extern int fastreboot_onpanic;
170 extern char fastreboot_onpanic_cmdline[FASTBOOT_SAVED_CMDLINE_LEN];
171 
172 #endif	/* _ASM */
173 
174 #ifdef __cplusplus
175 }
176 #endif
177 
178 #endif	/* _SYS_FASTBOOT_H */
179