xref: /titanic_51/usr/src/uts/i86pc/sys/fastboot.h (revision 193974072f41a843678abf5f61979c748687e66b)
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 2008 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 #endif	/* _ASM */
43 
44 #define	FASTBOOT_NAME_UNIX		0
45 #define	FASTBOOT_NAME_BOOTARCHIVE	1
46 
47 #define	FASTBOOT_MAX_FILES_MAP	2 /* max number of files that needs mapping */
48 #define	FASTBOOT_MAX_FILES_TOTAL	3 /* max number of files */
49 
50 #define	FASTBOOT_SWTCH_PA		0x5000	/* low memory */
51 #define	FASTBOOT_STACK_OFFSET		0xe00	/* where the stack starts */
52 #define	FASTBOOT_MAGIC			('F' << 24 | 'A' << 16 | 'S' << 8 | 'T')
53 
54 #define	FASTBOOT_UNIX		0
55 #define	FASTBOOT_BOOTARCHIVE	1
56 #define	FASTBOOT_SWTCH		2
57 
58 /*
59  * Default sizes for varies information we have to save across boot for
60  * fast reboot.  If the actual size is bigger than what we saved, abort
61  * fast reboot.
62  */
63 #define	FASTBOOT_SAVED_MMAP_COUNT	32
64 #define	FASTBOOT_SAVED_DRIVES_COUNT	9
65 #define	FASTBOOT_SAVED_CMDLINE_LEN	MMU_PAGESIZE
66 
67 
68 /*
69  * dboot entry address comes from
70  * usr/src/uts/i86pc/conf/Mapfile and Mapfile.64.
71  */
72 #define	DBOOT_ENTRY_ADDRESS	0xc00000
73 
74 /*
75  * Fake starting virtual address for creating mapping for the new kernel
76  * and boot_archive.
77  */
78 #define	FASTBOOT_FAKE_VA	(2ULL << 30)
79 
80 #define	FASTBOOT_TERMINATE	0xdeadbee0	/* Terminating PTEs */
81 
82 #ifndef	_ASM
83 
84 #define	MAX_ELF32_LOAD_SECTIONS 3
85 
86 /*
87  * Data structure for specifying each section in a 32-bit ELF file.
88  */
89 typedef struct fastboot_section
90 {
91 	uint32_t		fb_sec_offset;	/* offset */
92 	uint32_t		fb_sec_paddr;	/* physical address */
93 	uint32_t		fb_sec_size;	/* size */
94 	uint32_t		fb_sec_bss_size;	/* section bss size */
95 } fastboot_section_t;
96 
97 /*
98  * Data structure for describing each file that needs to be relocated from high
99  * memory to low memory for fast reboot.  Currently these files are unix, the
100  * boot_archive, and the relocation function itself.
101  */
102 typedef struct _fastboot_file {
103 	uintptr_t		fb_va;	/* virtual address */
104 	x86pte_t		*fb_pte_list_va;	/* VA for PTE list */
105 	paddr_t			fb_pte_list_pa;		/* PA for PTE list */
106 	uintptr_t		fb_dest_pa;	/* destination PA */
107 	size_t			fb_size;	/* file size */
108 	uintptr_t		fb_next_pa;
109 	fastboot_section_t	fb_sections[MAX_ELF32_LOAD_SECTIONS];
110 	int			fb_sectcnt;	/* actual number of sections */
111 } fastboot_file_t;
112 
113 /*
114  * Data structure containing all the information the switching routine needs
115  * for fast rebooting to the new kernel.
116  */
117 typedef struct _fastboot_info {
118 	uint32_t		fi_magic; /* magic for fast reboot */
119 	fastboot_file_t		fi_files[FASTBOOT_MAX_FILES_TOTAL];
120 	int			fi_has_pae;
121 	uintptr_t		fi_pagetable_va;
122 	paddr_t			fi_pagetable_pa;
123 	paddr_t			fi_last_table_pa;
124 	paddr_t			fi_new_mbi_pa;	/* new multiboot info PA */
125 	int			fi_valid;	/* is the new kernel valid */
126 	uintptr_t		fi_next_table_va;
127 	paddr_t			fi_next_table_pa;
128 	uint_t			*fi_shift_amt;
129 	uint_t			fi_ptes_per_table;
130 	uint_t			fi_lpagesize;
131 	int			fi_top_level;	/* top level of page tables */
132 } fastboot_info_t;
133 
134 extern void fast_reboot();
135 extern void load_kernel(char *);
136 
137 extern int fastreboot_capable;
138 extern int force_fastreboot;
139 
140 #endif	/* _ASM */
141 
142 #ifdef __cplusplus
143 }
144 #endif
145 
146 #endif	/* _SYS_FASTBOOT_H */
147