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.
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.
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]
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_FASTBOOT_H
28 #define _SYS_FASTBOOT_H
32 * Platform dependent instruction sequences for fast reboot
40 #include <sys/types.h>
41 #include <sys/mach_mmu.h>
45 #define FASTBOOT_NAME_UNIX 0
46 #define FASTBOOT_NAME_BOOTARCHIVE 1
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 */
51 #define FASTBOOT_MAX_MD5_HASH (FASTBOOT_MAX_FILES_MAP + 1)
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')
57 #define FASTBOOT_UNIX 0
58 #define FASTBOOT_BOOTARCHIVE 1
59 #define FASTBOOT_SWTCH 2
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
66 #define FASTBOOT_SAVED_MMAP_COUNT 32
68 #define FASTBOOT_SAVED_DRIVES_MAX 8
69 #define FASTBOOT_SAVED_DRIVES_PORT_MAX 128
70 #define FASTBOOT_SAVED_DRIVES_SIZE \
71 ((offsetof(struct mb_drive_info, drive_ports) + \
72 FASTBOOT_SAVED_DRIVES_PORT_MAX * sizeof (uint16_t)) * \
73 FASTBOOT_SAVED_DRIVES_MAX)
75 #define FASTBOOT_SAVED_CMDLINE_LEN MMU_PAGESIZE
79 * dboot entry address comes from
80 * usr/src/uts/i86pc/conf/Mapfile and Mapfile.64.
82 #define DBOOT_ENTRY_ADDRESS 0xc00000
85 * Fake starting virtual address for creating mapping for the new kernel
88 #define FASTBOOT_FAKE_VA (2ULL << 30)
90 #define FASTBOOT_TERMINATE 0xdeadbee0 /* Terminating PTEs */
94 #define MAX_ELF32_LOAD_SECTIONS 3
97 * Data structure for specifying each section in a 32-bit ELF file.
99 typedef struct fastboot_section
101 uint32_t fb_sec_offset
; /* offset */
102 uint32_t fb_sec_paddr
; /* physical address */
103 uint32_t fb_sec_size
; /* size */
104 uint32_t fb_sec_bss_size
; /* section bss size */
105 } fastboot_section_t
;
108 * Data structure for describing each file that needs to be relocated from high
109 * memory to low memory for fast reboot. Currently these files are unix, the
110 * boot_archive, and the relocation function itself.
112 typedef struct _fastboot_file
{
113 uintptr_t fb_va
; /* virtual address */
114 x86pte_t
*fb_pte_list_va
; /* VA for PTE list */
115 paddr_t fb_pte_list_pa
; /* PA for PTE list */
116 size_t fb_pte_list_size
; /* size of PTE list */
117 uintptr_t fb_dest_pa
; /* destination PA */
118 size_t fb_size
; /* file size */
119 uintptr_t fb_next_pa
;
120 fastboot_section_t fb_sections
[MAX_ELF32_LOAD_SECTIONS
];
121 int fb_sectcnt
; /* actual number of sections */
125 * Data structure containing all the information the switching routine needs
126 * for fast rebooting to the new kernel.
128 * NOTE: There is limited stack space (0x200 bytes) in the switcher to
129 * copy in the data structure. Fields that are not absolutely necessary for
130 * the switcher should be added after the fi_valid field.
132 typedef struct _fastboot_info
{
133 uint32_t fi_magic
; /* magic for fast reboot */
134 fastboot_file_t fi_files
[FASTBOOT_MAX_FILES_TOTAL
];
136 uintptr_t fi_pagetable_va
;
137 paddr_t fi_pagetable_pa
;
138 paddr_t fi_last_table_pa
;
139 paddr_t fi_new_mbi_pa
; /* new multiboot info PA */
140 int fi_valid
; /* is the new kernel valid */
141 uintptr_t fi_next_table_va
;
142 paddr_t fi_next_table_pa
;
143 uint_t
*fi_shift_amt
;
144 uint_t fi_ptes_per_table
;
146 int fi_top_level
; /* top level of page tables */
147 size_t fi_pagetable_size
; /* size allocated for pt */
148 uintptr_t fi_new_mbi_va
; /* new multiboot info VA */
149 size_t fi_mbi_size
; /* size allocated for mbi */
150 uchar_t fi_md5_hash
[FASTBOOT_MAX_MD5_HASH
][MD5_DIGEST_LENGTH
];
155 * Fast reboot core functions
157 extern void fast_reboot(); /* Entry point for fb_switch */
158 extern void fastboot_load_kernel(char *); /* Load a new kernel */
160 extern int fastboot_cksum_verify(fastboot_info_t
*);
163 * Additional messages explaining why Fast Reboot is not
166 extern const char *fastreboot_nosup_message(void);
168 * Fast reboot tunables
171 /* If set, the system is capable of fast reboot */
172 extern int volatile fastreboot_capable
;
175 * If set, force fast reboot even if the system has
176 * drivers without quiesce(9E) implementation.
178 extern int force_fastreboot
;
180 /* If set, fast reboot after panic. */
181 extern volatile int fastreboot_onpanic
;
182 extern char fastreboot_onpanic_cmdline
[FASTBOOT_SAVED_CMDLINE_LEN
];
184 /* Variables for avoiding panic/reboot loop */
185 extern clock_t fastreboot_onpanic_uptime
;
186 extern clock_t lbolt_at_boot
, panic_lbolt
;
194 #endif /* _SYS_FASTBOOT_H */