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*5ee8e422SKonstantin Ananyev * Copyright 2010 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> 42753a6d45SSherry 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 51753a6d45SSherry Moore #define FASTBOOT_MAX_MD5_HASH (FASTBOOT_MAX_FILES_MAP + 1) 52753a6d45SSherry 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 676915124bSKonstantin Ananyev 686915124bSKonstantin Ananyev #define FASTBOOT_SAVED_DRIVES_MAX 8 696915124bSKonstantin Ananyev #define FASTBOOT_SAVED_DRIVES_PORT_MAX 128 706915124bSKonstantin Ananyev #define FASTBOOT_SAVED_DRIVES_SIZE \ 716915124bSKonstantin Ananyev ((offsetof(struct mb_drive_info, drive_ports) + \ 726915124bSKonstantin Ananyev FASTBOOT_SAVED_DRIVES_PORT_MAX * sizeof (uint16_t)) * \ 736915124bSKonstantin Ananyev FASTBOOT_SAVED_DRIVES_MAX) 746915124bSKonstantin Ananyev 7519397407SSherry Moore #define FASTBOOT_SAVED_CMDLINE_LEN MMU_PAGESIZE 7619397407SSherry Moore 7719397407SSherry Moore 7819397407SSherry Moore /* 7919397407SSherry Moore * dboot entry address comes from 8019397407SSherry Moore * usr/src/uts/i86pc/conf/Mapfile and Mapfile.64. 8119397407SSherry Moore */ 8219397407SSherry Moore #define DBOOT_ENTRY_ADDRESS 0xc00000 8319397407SSherry Moore 8419397407SSherry Moore /* 8519397407SSherry Moore * Fake starting virtual address for creating mapping for the new kernel 8619397407SSherry Moore * and boot_archive. 8719397407SSherry Moore */ 8819397407SSherry Moore #define FASTBOOT_FAKE_VA (2ULL << 30) 8919397407SSherry Moore 9019397407SSherry Moore #define FASTBOOT_TERMINATE 0xdeadbee0 /* Terminating PTEs */ 9119397407SSherry Moore 9219397407SSherry Moore #ifndef _ASM 9319397407SSherry Moore 9419397407SSherry Moore #define MAX_ELF32_LOAD_SECTIONS 3 9519397407SSherry Moore 9619397407SSherry Moore /* 9719397407SSherry Moore * Data structure for specifying each section in a 32-bit ELF file. 9819397407SSherry Moore */ 9919397407SSherry Moore typedef struct fastboot_section 10019397407SSherry Moore { 10119397407SSherry Moore uint32_t fb_sec_offset; /* offset */ 10219397407SSherry Moore uint32_t fb_sec_paddr; /* physical address */ 10319397407SSherry Moore uint32_t fb_sec_size; /* size */ 10419397407SSherry Moore uint32_t fb_sec_bss_size; /* section bss size */ 10519397407SSherry Moore } fastboot_section_t; 10619397407SSherry Moore 10719397407SSherry Moore /* 10819397407SSherry Moore * Data structure for describing each file that needs to be relocated from high 10919397407SSherry Moore * memory to low memory for fast reboot. Currently these files are unix, the 11019397407SSherry Moore * boot_archive, and the relocation function itself. 11119397407SSherry Moore */ 11219397407SSherry Moore typedef struct _fastboot_file { 11319397407SSherry Moore uintptr_t fb_va; /* virtual address */ 11419397407SSherry Moore x86pte_t *fb_pte_list_va; /* VA for PTE list */ 11519397407SSherry Moore paddr_t fb_pte_list_pa; /* PA for PTE list */ 116753a6d45SSherry Moore size_t fb_pte_list_size; /* size of PTE list */ 11719397407SSherry Moore uintptr_t fb_dest_pa; /* destination PA */ 11819397407SSherry Moore size_t fb_size; /* file size */ 11919397407SSherry Moore uintptr_t fb_next_pa; 12019397407SSherry Moore fastboot_section_t fb_sections[MAX_ELF32_LOAD_SECTIONS]; 12119397407SSherry Moore int fb_sectcnt; /* actual number of sections */ 12219397407SSherry Moore } fastboot_file_t; 12319397407SSherry Moore 12419397407SSherry Moore /* 12519397407SSherry Moore * Data structure containing all the information the switching routine needs 12619397407SSherry Moore * for fast rebooting to the new kernel. 127753a6d45SSherry Moore * 128753a6d45SSherry Moore * NOTE: There is limited stack space (0x200 bytes) in the switcher to 129753a6d45SSherry Moore * copy in the data structure. Fields that are not absolutely necessary for 130753a6d45SSherry Moore * the switcher should be added after the fi_valid field. 13119397407SSherry Moore */ 13219397407SSherry Moore typedef struct _fastboot_info { 13319397407SSherry Moore uint32_t fi_magic; /* magic for fast reboot */ 13419397407SSherry Moore fastboot_file_t fi_files[FASTBOOT_MAX_FILES_TOTAL]; 13519397407SSherry Moore int fi_has_pae; 13619397407SSherry Moore uintptr_t fi_pagetable_va; 13719397407SSherry Moore paddr_t fi_pagetable_pa; 13819397407SSherry Moore paddr_t fi_last_table_pa; 13919397407SSherry Moore paddr_t fi_new_mbi_pa; /* new multiboot info PA */ 14019397407SSherry Moore int fi_valid; /* is the new kernel valid */ 14119397407SSherry Moore uintptr_t fi_next_table_va; 14219397407SSherry Moore paddr_t fi_next_table_pa; 14319397407SSherry Moore uint_t *fi_shift_amt; 14419397407SSherry Moore uint_t fi_ptes_per_table; 14519397407SSherry Moore uint_t fi_lpagesize; 14619397407SSherry Moore int fi_top_level; /* top level of page tables */ 147753a6d45SSherry Moore size_t fi_pagetable_size; /* size allocated for pt */ 148753a6d45SSherry Moore uintptr_t fi_new_mbi_va; /* new multiboot info VA */ 149753a6d45SSherry Moore size_t fi_mbi_size; /* size allocated for mbi */ 150753a6d45SSherry Moore uchar_t fi_md5_hash[FASTBOOT_MAX_MD5_HASH][MD5_DIGEST_LENGTH]; 15119397407SSherry Moore } fastboot_info_t; 15219397407SSherry Moore 15319397407SSherry Moore 154753a6d45SSherry Moore /* 155753a6d45SSherry Moore * Fast reboot core functions 156753a6d45SSherry Moore */ 157753a6d45SSherry Moore extern void fast_reboot(); /* Entry point for fb_switch */ 158753a6d45SSherry Moore extern void fastboot_load_kernel(char *); /* Load a new kernel */ 159753a6d45SSherry Moore 160753a6d45SSherry Moore extern int fastboot_cksum_verify(fastboot_info_t *); 161753a6d45SSherry Moore 162753a6d45SSherry Moore /* 163*5ee8e422SKonstantin Ananyev * Additional messages explaining why Fast Reboot is not 164*5ee8e422SKonstantin Ananyev * supported. 165*5ee8e422SKonstantin Ananyev */ 166*5ee8e422SKonstantin Ananyev extern const char *fastreboot_nosup_message(void); 167*5ee8e422SKonstantin Ananyev /* 168753a6d45SSherry Moore * Fast reboot tunables 169753a6d45SSherry Moore */ 170753a6d45SSherry Moore 171753a6d45SSherry Moore /* If set, the system is capable of fast reboot */ 172*5ee8e422SKonstantin Ananyev extern int volatile fastreboot_capable; 173753a6d45SSherry Moore 174753a6d45SSherry Moore /* 175753a6d45SSherry Moore * If set, force fast reboot even if the system has 176753a6d45SSherry Moore * drivers without quiesce(9E) implementation. 177753a6d45SSherry Moore */ 17819397407SSherry Moore extern int force_fastreboot; 17919397407SSherry Moore 180753a6d45SSherry Moore /* If set, fast reboot after panic. */ 181c90a5fbeSSherry Moore extern volatile int fastreboot_onpanic; 182753a6d45SSherry Moore extern char fastreboot_onpanic_cmdline[FASTBOOT_SAVED_CMDLINE_LEN]; 183753a6d45SSherry Moore 184835b9930SSherry Moore /* Variables for avoiding panic/reboot loop */ 185835b9930SSherry Moore extern clock_t fastreboot_onpanic_uptime; 186835b9930SSherry Moore extern clock_t lbolt_at_boot, panic_lbolt; 187835b9930SSherry Moore 18819397407SSherry Moore #endif /* _ASM */ 18919397407SSherry Moore 19019397407SSherry Moore #ifdef __cplusplus 19119397407SSherry Moore } 19219397407SSherry Moore #endif 19319397407SSherry Moore 19419397407SSherry Moore #endif /* _SYS_FASTBOOT_H */ 195