xref: /titanic_44/usr/src/uts/i86pc/sys/fastboot.h (revision 753a6d457b330b1b29b2d3eefcd0831116ce950d)
119397407SSherry Moore /*
219397407SSherry Moore  * CDDL HEADER START
319397407SSherry Moore  *
419397407SSherry Moore  * The contents of this file are subject to the terms of the
519397407SSherry Moore  * Common Development and Distribution License (the "License").
619397407SSherry Moore  * You may not use this file except in compliance with the License.
719397407SSherry Moore  *
819397407SSherry Moore  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
919397407SSherry Moore  * or http://www.opensolaris.org/os/licensing.
1019397407SSherry Moore  * See the License for the specific language governing permissions
1119397407SSherry Moore  * and limitations under the License.
1219397407SSherry Moore  *
1319397407SSherry Moore  * When distributing Covered Code, include this CDDL HEADER in each
1419397407SSherry Moore  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1519397407SSherry Moore  * If applicable, add the following below this CDDL HEADER, with the
1619397407SSherry Moore  * fields enclosed by brackets "[]" replaced with your own identifying
1719397407SSherry Moore  * information: Portions Copyright [yyyy] [name of copyright owner]
1819397407SSherry Moore  *
1919397407SSherry Moore  * CDDL HEADER END
2019397407SSherry Moore  */
2119397407SSherry Moore 
2219397407SSherry Moore /*
23*753a6d45SSherry Moore  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
2419397407SSherry Moore  * Use is subject to license terms.
2519397407SSherry Moore  */
2619397407SSherry Moore 
2719397407SSherry Moore #ifndef	_SYS_FASTBOOT_H
2819397407SSherry Moore #define	_SYS_FASTBOOT_H
2919397407SSherry Moore 
3019397407SSherry Moore 
3119397407SSherry Moore /*
3219397407SSherry Moore  * Platform dependent instruction sequences for fast reboot
3319397407SSherry Moore  */
3419397407SSherry Moore 
3519397407SSherry Moore #ifdef __cplusplus
3619397407SSherry Moore extern "C" {
3719397407SSherry Moore #endif
3819397407SSherry Moore 
3919397407SSherry Moore #ifndef	_ASM
4019397407SSherry Moore #include <sys/types.h>
4119397407SSherry Moore #include <sys/mach_mmu.h>
42*753a6d45SSherry Moore #include <sys/md5.h>
4319397407SSherry Moore #endif	/* _ASM */
4419397407SSherry Moore 
4519397407SSherry Moore #define	FASTBOOT_NAME_UNIX		0
4619397407SSherry Moore #define	FASTBOOT_NAME_BOOTARCHIVE	1
4719397407SSherry Moore 
4819397407SSherry Moore #define	FASTBOOT_MAX_FILES_MAP	2 /* max number of files that needs mapping */
4919397407SSherry Moore #define	FASTBOOT_MAX_FILES_TOTAL	3 /* max number of files */
5019397407SSherry Moore 
51*753a6d45SSherry Moore #define	FASTBOOT_MAX_MD5_HASH	(FASTBOOT_MAX_FILES_MAP + 1)
52*753a6d45SSherry Moore 
5319397407SSherry Moore #define	FASTBOOT_SWTCH_PA		0x5000	/* low memory */
5419397407SSherry Moore #define	FASTBOOT_STACK_OFFSET		0xe00	/* where the stack starts */
5519397407SSherry Moore #define	FASTBOOT_MAGIC			('F' << 24 | 'A' << 16 | 'S' << 8 | 'T')
5619397407SSherry Moore 
5719397407SSherry Moore #define	FASTBOOT_UNIX		0
5819397407SSherry Moore #define	FASTBOOT_BOOTARCHIVE	1
5919397407SSherry Moore #define	FASTBOOT_SWTCH		2
6019397407SSherry Moore 
6119397407SSherry Moore /*
6219397407SSherry Moore  * Default sizes for varies information we have to save across boot for
6319397407SSherry Moore  * fast reboot.  If the actual size is bigger than what we saved, abort
6419397407SSherry Moore  * fast reboot.
6519397407SSherry Moore  */
6619397407SSherry Moore #define	FASTBOOT_SAVED_MMAP_COUNT	32
6719397407SSherry Moore #define	FASTBOOT_SAVED_DRIVES_COUNT	9
6819397407SSherry Moore #define	FASTBOOT_SAVED_CMDLINE_LEN	MMU_PAGESIZE
6919397407SSherry Moore 
7019397407SSherry Moore 
7119397407SSherry Moore /*
7219397407SSherry Moore  * dboot entry address comes from
7319397407SSherry Moore  * usr/src/uts/i86pc/conf/Mapfile and Mapfile.64.
7419397407SSherry Moore  */
7519397407SSherry Moore #define	DBOOT_ENTRY_ADDRESS	0xc00000
7619397407SSherry Moore 
7719397407SSherry Moore /*
7819397407SSherry Moore  * Fake starting virtual address for creating mapping for the new kernel
7919397407SSherry Moore  * and boot_archive.
8019397407SSherry Moore  */
8119397407SSherry Moore #define	FASTBOOT_FAKE_VA	(2ULL << 30)
8219397407SSherry Moore 
8319397407SSherry Moore #define	FASTBOOT_TERMINATE	0xdeadbee0	/* Terminating PTEs */
8419397407SSherry Moore 
8519397407SSherry Moore #ifndef	_ASM
8619397407SSherry Moore 
8719397407SSherry Moore #define	MAX_ELF32_LOAD_SECTIONS 3
8819397407SSherry Moore 
8919397407SSherry Moore /*
9019397407SSherry Moore  * Data structure for specifying each section in a 32-bit ELF file.
9119397407SSherry Moore  */
9219397407SSherry Moore typedef struct fastboot_section
9319397407SSherry Moore {
9419397407SSherry Moore 	uint32_t		fb_sec_offset;	/* offset */
9519397407SSherry Moore 	uint32_t		fb_sec_paddr;	/* physical address */
9619397407SSherry Moore 	uint32_t		fb_sec_size;	/* size */
9719397407SSherry Moore 	uint32_t		fb_sec_bss_size;	/* section bss size */
9819397407SSherry Moore } fastboot_section_t;
9919397407SSherry Moore 
10019397407SSherry Moore /*
10119397407SSherry Moore  * Data structure for describing each file that needs to be relocated from high
10219397407SSherry Moore  * memory to low memory for fast reboot.  Currently these files are unix, the
10319397407SSherry Moore  * boot_archive, and the relocation function itself.
10419397407SSherry Moore  */
10519397407SSherry Moore typedef struct _fastboot_file {
10619397407SSherry Moore 	uintptr_t		fb_va;	/* virtual address */
10719397407SSherry Moore 	x86pte_t		*fb_pte_list_va;	/* VA for PTE list */
10819397407SSherry Moore 	paddr_t			fb_pte_list_pa;		/* PA for PTE list */
109*753a6d45SSherry Moore 	size_t			fb_pte_list_size;	/* size of PTE list */
11019397407SSherry Moore 	uintptr_t		fb_dest_pa;	/* destination PA */
11119397407SSherry Moore 	size_t			fb_size;	/* file size */
11219397407SSherry Moore 	uintptr_t		fb_next_pa;
11319397407SSherry Moore 	fastboot_section_t	fb_sections[MAX_ELF32_LOAD_SECTIONS];
11419397407SSherry Moore 	int			fb_sectcnt;	/* actual number of sections */
11519397407SSherry Moore } fastboot_file_t;
11619397407SSherry Moore 
11719397407SSherry Moore /*
11819397407SSherry Moore  * Data structure containing all the information the switching routine needs
11919397407SSherry Moore  * for fast rebooting to the new kernel.
120*753a6d45SSherry Moore  *
121*753a6d45SSherry Moore  * NOTE: There is limited stack space (0x200 bytes) in the switcher to
122*753a6d45SSherry Moore  * copy in the data structure.  Fields that are not absolutely necessary for
123*753a6d45SSherry Moore  * the switcher should be added after the fi_valid field.
12419397407SSherry Moore  */
12519397407SSherry Moore typedef struct _fastboot_info {
12619397407SSherry Moore 	uint32_t		fi_magic; /* magic for fast reboot */
12719397407SSherry Moore 	fastboot_file_t		fi_files[FASTBOOT_MAX_FILES_TOTAL];
12819397407SSherry Moore 	int			fi_has_pae;
12919397407SSherry Moore 	uintptr_t		fi_pagetable_va;
13019397407SSherry Moore 	paddr_t			fi_pagetable_pa;
13119397407SSherry Moore 	paddr_t			fi_last_table_pa;
13219397407SSherry Moore 	paddr_t			fi_new_mbi_pa;	/* new multiboot info PA */
13319397407SSherry Moore 	int			fi_valid;	/* is the new kernel valid */
13419397407SSherry Moore 	uintptr_t		fi_next_table_va;
13519397407SSherry Moore 	paddr_t			fi_next_table_pa;
13619397407SSherry Moore 	uint_t			*fi_shift_amt;
13719397407SSherry Moore 	uint_t			fi_ptes_per_table;
13819397407SSherry Moore 	uint_t			fi_lpagesize;
13919397407SSherry Moore 	int			fi_top_level;	/* top level of page tables */
140*753a6d45SSherry Moore 	size_t			fi_pagetable_size; /* size allocated for pt */
141*753a6d45SSherry Moore 	uintptr_t		fi_new_mbi_va;	/* new multiboot info VA */
142*753a6d45SSherry Moore 	size_t			fi_mbi_size;	/* size allocated for mbi */
143*753a6d45SSherry Moore 	uchar_t		fi_md5_hash[FASTBOOT_MAX_MD5_HASH][MD5_DIGEST_LENGTH];
14419397407SSherry Moore } fastboot_info_t;
14519397407SSherry Moore 
14619397407SSherry Moore 
147*753a6d45SSherry Moore /*
148*753a6d45SSherry Moore  * Fast reboot core functions
149*753a6d45SSherry Moore  */
150*753a6d45SSherry Moore extern void fast_reboot();	/* Entry point for fb_switch */
151*753a6d45SSherry Moore extern void fastboot_load_kernel(char *); /* Load a new kernel */
152*753a6d45SSherry Moore 
153*753a6d45SSherry Moore extern int fastboot_cksum_verify(fastboot_info_t *);
154*753a6d45SSherry Moore 
155*753a6d45SSherry Moore /*
156*753a6d45SSherry Moore  * Fast reboot tunables
157*753a6d45SSherry Moore  */
158*753a6d45SSherry Moore 
159*753a6d45SSherry Moore /* If set, the system is capable of fast reboot */
16019397407SSherry Moore extern int fastreboot_capable;
161*753a6d45SSherry Moore 
162*753a6d45SSherry Moore /*
163*753a6d45SSherry Moore  * If set, force fast reboot even if the system has
164*753a6d45SSherry Moore  * drivers without quiesce(9E) implementation.
165*753a6d45SSherry Moore  */
16619397407SSherry Moore extern int force_fastreboot;
16719397407SSherry Moore 
168*753a6d45SSherry Moore /* If set, fast reboot after panic. */
169*753a6d45SSherry Moore extern int fastreboot_onpanic;
170*753a6d45SSherry Moore extern char fastreboot_onpanic_cmdline[FASTBOOT_SAVED_CMDLINE_LEN];
171*753a6d45SSherry Moore 
17219397407SSherry Moore #endif	/* _ASM */
17319397407SSherry Moore 
17419397407SSherry Moore #ifdef __cplusplus
17519397407SSherry Moore }
17619397407SSherry Moore #endif
17719397407SSherry Moore 
17819397407SSherry Moore #endif	/* _SYS_FASTBOOT_H */
179