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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_CPR_IMPL_H 28 #define _SYS_CPR_IMPL_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 37 #ifndef _ASM 38 39 #include <sys/processor.h> 40 #include <sys/machparam.h> 41 #include <sys/obpdefs.h> 42 #include <sys/vnode.h> 43 #include <sys/pte.h> 44 45 /* 46 * This file contains machine dependent information for CPR 47 */ 48 #define CPR_MACHTYPE_4U 0x3475 /* '4u' */ 49 50 /* 51 * Information about the pages allocated via prom_retain(). 52 * Increase the number of CPR_PROM_RETAIN_CNT if more 53 * prom_retain() are called. 54 */ 55 #define CPR_PROM_RETAIN_CNT 1 56 #define CPR_PANICBUF 0 /* prom_retain() for panicbuf */ 57 58 59 /* 60 * For 2.7 and later releases, sun4u cprboot is an ELF64 binary and must 61 * handle both ILP32 and LP64 kernels; while long and ptr sizes are fixed 62 * at 64-bits for cprboot these sizes are mixed between ILP32/LP64 kernels. 63 * To simplify handling of statefile data, we define fixed-size types for 64 * all sun4u kernels. 65 */ 66 typedef uint64_t cpr_ptr; 67 typedef uint64_t cpr_ext; 68 69 struct cpr_map_info { 70 cpr_ptr virt; 71 cpr_ext phys; 72 uint_t size; 73 }; 74 75 76 #define CPR_MAX_TLB 16 77 78 struct sun4u_tlb { 79 tte_t tte; /* tte data */ 80 cpr_ptr va_tag; /* virt tag */ 81 int index; /* tlb index */ 82 int tmp; /* clear during resume */ 83 }; 84 85 typedef struct sun4u_tlb sutlb_t; 86 87 88 /* 89 * processor info 90 */ 91 struct sun4u_cpu_info { 92 pnode_t node; 93 processorid_t cpu_id; 94 }; 95 96 97 /* 98 * This structure defines the fixed-length machine dependent data for 99 * sun4u ILP32 and LP64 systems. It is followed in the state file by 100 * a variable length section of null-terminated prom forth words: 101 * 102 * cpr_obp_tte_str for translating kernel mappings, unix-tte 103 * 104 * The total length (fixed plus variable) of the machine-dependent 105 * section is stored in cpr_machdep_desc.md_size 106 * 107 * WARNING: make sure all CPR_MD_* below match this structure 108 */ 109 struct cpr_sun4u_machdep { 110 uint32_t ksb; /* 0x00: kernel stack bias */ 111 uint16_t kpstate; /* 0x04: kernel pstate */ 112 uint16_t kwstate; /* 0x06: kernel wstate */ 113 cpr_ptr thrp; /* 0x08: current thread ptr */ 114 cpr_ptr func; /* 0x10: jumpback virt text addr */ 115 cpr_ext qsav_pc; /* 0x18: qsav pc */ 116 cpr_ext qsav_sp; /* 0x20: qsav sp */ 117 int mmu_ctx_pri; /* 0x28: primary context */ 118 int mmu_ctx_sec; /* 0x2c: secondary context */ 119 cpr_ptr tmp_stack; /* 0x30: base of data page */ 120 cpr_ext tmp_stacksize; /* 0x38: leading area of data page */ 121 int test_mode; /* 0x40 */ 122 int pad; /* 0x44 */ 123 sutlb_t dtte[CPR_MAX_TLB]; /* 0x48 */ 124 sutlb_t itte[CPR_MAX_TLB]; /* 0x1c8 */ 125 struct sun4u_cpu_info sci[NCPU]; /* 0x348 */ 126 }; 127 typedef struct cpr_sun4u_machdep csu_md_t; 128 129 #endif /* _ASM */ 130 131 132 /* 133 * XXX - these should be generated by a genassym, 134 * but that doesn't work well for shared psm/kernel use 135 */ 136 #define CPR_MD_KSB 0x00 137 #define CPR_MD_KPSTATE 0x04 138 #define CPR_MD_KWSTATE 0x06 139 #define CPR_MD_THRP 0x08 140 #define CPR_MD_FUNC 0x10 141 #define CPR_MD_QSAV_PC 0x18 142 #define CPR_MD_QSAV_SP 0x20 143 #define CPR_MD_PRI 0x28 144 #define CPR_MD_SEC 0x2c 145 146 147 #ifndef _ASM 148 149 #define CPRBOOT "-F cprboot" 150 151 #define PN_TO_ADDR(pn) ((u_longlong_t)(pn) << MMU_PAGESHIFT) 152 #define ADDR_TO_PN(pa) ((pa) >> MMU_PAGESHIFT) 153 154 #define prom_map_plat(addr, pa, size) \ 155 if (prom_map(addr, pa, size) == 0) { \ 156 errp("PROM_MAP failed: paddr=0x%lx\n", pa); \ 157 return (-1); \ 158 } 159 160 typedef u_longlong_t physaddr_t; 161 162 extern void i_cpr_machdep_setup(void); 163 extern void i_cpr_save_machdep_info(void); 164 extern void i_cpr_enable_intr(void); 165 extern void i_cpr_set_tbr(void); 166 extern void i_cpr_stop_intr(void); 167 extern void i_cpr_handle_xc(int); 168 extern void i_cpr_resume_setup(void *, csu_md_t *); 169 extern int i_cpr_write_machdep(vnode_t *); 170 extern int i_cpr_prom_pages(int); 171 extern int i_cpr_reuseinit(void); 172 extern int i_cpr_reusefini(void); 173 extern int i_cpr_check_cprinfo(void); 174 extern int i_cpr_reusable_supported(void); 175 176 #endif /* _ASM */ 177 178 #ifdef __cplusplus 179 } 180 #endif 181 182 #endif /* _SYS_CPR_IMPL_H */ 183