17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*ae115bc7Smrj * Common Development and Distribution License (the "License"). 6*ae115bc7Smrj * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*ae115bc7Smrj * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_CPR_IMPL_H 277c478bd9Sstevel@tonic-gate #define _SYS_CPR_IMPL_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #ifndef _ASM 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #include <sys/processor.h> 397c478bd9Sstevel@tonic-gate #include <sys/machparam.h> 407c478bd9Sstevel@tonic-gate #include <sys/obpdefs.h> 417c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 427c478bd9Sstevel@tonic-gate #include <sys/pte.h> 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate /* 457c478bd9Sstevel@tonic-gate * This file contains machine dependent information for CPR 467c478bd9Sstevel@tonic-gate */ 477c478bd9Sstevel@tonic-gate #define CPR_MACHTYPE_4U 0x3475 /* '4u' */ 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate /* 507c478bd9Sstevel@tonic-gate * Information about the pages allocated via prom_retain(). 517c478bd9Sstevel@tonic-gate * Increase the number of CPR_PROM_RETAIN_CNT if more 527c478bd9Sstevel@tonic-gate * prom_retain() are called. 537c478bd9Sstevel@tonic-gate */ 547c478bd9Sstevel@tonic-gate #define CPR_PROM_RETAIN_CNT 1 557c478bd9Sstevel@tonic-gate #define CPR_PANICBUF 0 /* prom_retain() for panicbuf */ 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate /* 597c478bd9Sstevel@tonic-gate * For 2.7 and later releases, sun4u cprboot is an ELF64 binary and must 607c478bd9Sstevel@tonic-gate * handle both ILP32 and LP64 kernels; while long and ptr sizes are fixed 617c478bd9Sstevel@tonic-gate * at 64-bits for cprboot these sizes are mixed between ILP32/LP64 kernels. 627c478bd9Sstevel@tonic-gate * To simplify handling of statefile data, we define fixed-size types for 637c478bd9Sstevel@tonic-gate * all sun4u kernels. 647c478bd9Sstevel@tonic-gate */ 657c478bd9Sstevel@tonic-gate typedef uint64_t cpr_ptr; 667c478bd9Sstevel@tonic-gate typedef uint64_t cpr_ext; 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate struct cpr_map_info { 697c478bd9Sstevel@tonic-gate cpr_ptr virt; 707c478bd9Sstevel@tonic-gate cpr_ext phys; 717c478bd9Sstevel@tonic-gate uint_t size; 727c478bd9Sstevel@tonic-gate }; 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate #define CPR_MAX_TLB 16 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate struct sun4u_tlb { 787c478bd9Sstevel@tonic-gate tte_t tte; /* tte data */ 797c478bd9Sstevel@tonic-gate cpr_ptr va_tag; /* virt tag */ 807c478bd9Sstevel@tonic-gate int index; /* tlb index */ 817c478bd9Sstevel@tonic-gate int tmp; /* clear during resume */ 827c478bd9Sstevel@tonic-gate }; 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate typedef struct sun4u_tlb sutlb_t; 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate /* 887c478bd9Sstevel@tonic-gate * processor info 897c478bd9Sstevel@tonic-gate */ 907c478bd9Sstevel@tonic-gate struct sun4u_cpu_info { 91fa9e4066Sahrens pnode_t node; 927c478bd9Sstevel@tonic-gate processorid_t cpu_id; 937c478bd9Sstevel@tonic-gate }; 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate /* 977c478bd9Sstevel@tonic-gate * This structure defines the fixed-length machine dependent data for 987c478bd9Sstevel@tonic-gate * sun4u ILP32 and LP64 systems. It is followed in the state file by 997c478bd9Sstevel@tonic-gate * a variable length section of null-terminated prom forth words: 1007c478bd9Sstevel@tonic-gate * 1017c478bd9Sstevel@tonic-gate * cpr_obp_tte_str for translating kernel mappings, unix-tte 1027c478bd9Sstevel@tonic-gate * 1037c478bd9Sstevel@tonic-gate * The total length (fixed plus variable) of the machine-dependent 1047c478bd9Sstevel@tonic-gate * section is stored in cpr_machdep_desc.md_size 1057c478bd9Sstevel@tonic-gate * 1067c478bd9Sstevel@tonic-gate * WARNING: make sure all CPR_MD_* below match this structure 1077c478bd9Sstevel@tonic-gate */ 1087c478bd9Sstevel@tonic-gate struct cpr_sun4u_machdep { 1097c478bd9Sstevel@tonic-gate uint32_t ksb; /* 0x00: kernel stack bias */ 1107c478bd9Sstevel@tonic-gate uint16_t kpstate; /* 0x04: kernel pstate */ 1117c478bd9Sstevel@tonic-gate uint16_t kwstate; /* 0x06: kernel wstate */ 1127c478bd9Sstevel@tonic-gate cpr_ptr thrp; /* 0x08: current thread ptr */ 1137c478bd9Sstevel@tonic-gate cpr_ptr func; /* 0x10: jumpback virt text addr */ 1147c478bd9Sstevel@tonic-gate cpr_ext qsav_pc; /* 0x18: qsav pc */ 1157c478bd9Sstevel@tonic-gate cpr_ext qsav_sp; /* 0x20: qsav sp */ 1167c478bd9Sstevel@tonic-gate int mmu_ctx_pri; /* 0x28: primary context */ 1177c478bd9Sstevel@tonic-gate int mmu_ctx_sec; /* 0x2c: secondary context */ 1187c478bd9Sstevel@tonic-gate cpr_ptr tmp_stack; /* 0x30: base of data page */ 1197c478bd9Sstevel@tonic-gate cpr_ext tmp_stacksize; /* 0x38: leading area of data page */ 1207c478bd9Sstevel@tonic-gate int test_mode; /* 0x40 */ 1217c478bd9Sstevel@tonic-gate int pad; /* 0x44 */ 1227c478bd9Sstevel@tonic-gate sutlb_t dtte[CPR_MAX_TLB]; /* 0x48 */ 1237c478bd9Sstevel@tonic-gate sutlb_t itte[CPR_MAX_TLB]; /* 0x1c8 */ 1247c478bd9Sstevel@tonic-gate struct sun4u_cpu_info sci[NCPU]; /* 0x348 */ 1257c478bd9Sstevel@tonic-gate }; 1267c478bd9Sstevel@tonic-gate typedef struct cpr_sun4u_machdep csu_md_t; 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate #endif /* _ASM */ 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate /* 1327c478bd9Sstevel@tonic-gate * XXX - these should be generated by a genassym, 1337c478bd9Sstevel@tonic-gate * but that doesn't work well for shared psm/kernel use 1347c478bd9Sstevel@tonic-gate */ 1357c478bd9Sstevel@tonic-gate #define CPR_MD_KSB 0x00 1367c478bd9Sstevel@tonic-gate #define CPR_MD_KPSTATE 0x04 1377c478bd9Sstevel@tonic-gate #define CPR_MD_KWSTATE 0x06 1387c478bd9Sstevel@tonic-gate #define CPR_MD_THRP 0x08 1397c478bd9Sstevel@tonic-gate #define CPR_MD_FUNC 0x10 1407c478bd9Sstevel@tonic-gate #define CPR_MD_QSAV_PC 0x18 1417c478bd9Sstevel@tonic-gate #define CPR_MD_QSAV_SP 0x20 1427c478bd9Sstevel@tonic-gate #define CPR_MD_PRI 0x28 1437c478bd9Sstevel@tonic-gate #define CPR_MD_SEC 0x2c 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate #ifndef _ASM 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate #define CPRBOOT "-F cprboot" 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate #define PN_TO_ADDR(pn) ((u_longlong_t)(pn) << MMU_PAGESHIFT) 1517c478bd9Sstevel@tonic-gate #define ADDR_TO_PN(pa) ((pa) >> MMU_PAGESHIFT) 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate #define prom_map_plat(addr, pa, size) \ 1547c478bd9Sstevel@tonic-gate if (prom_map(addr, pa, size) == 0) { \ 155*ae115bc7Smrj prom_printf("PROM_MAP failed: paddr=0x%lx\n", pa); \ 1567c478bd9Sstevel@tonic-gate return (-1); \ 1577c478bd9Sstevel@tonic-gate } 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate typedef u_longlong_t physaddr_t; 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate extern void i_cpr_machdep_setup(void); 1627c478bd9Sstevel@tonic-gate extern void i_cpr_save_machdep_info(void); 1637c478bd9Sstevel@tonic-gate extern void i_cpr_enable_intr(void); 1647c478bd9Sstevel@tonic-gate extern void i_cpr_set_tbr(void); 1657c478bd9Sstevel@tonic-gate extern void i_cpr_stop_intr(void); 1667c478bd9Sstevel@tonic-gate extern void i_cpr_handle_xc(int); 1677c478bd9Sstevel@tonic-gate extern void i_cpr_resume_setup(void *, csu_md_t *); 1687c478bd9Sstevel@tonic-gate extern int i_cpr_write_machdep(vnode_t *); 1697c478bd9Sstevel@tonic-gate extern int i_cpr_prom_pages(int); 1707c478bd9Sstevel@tonic-gate extern int i_cpr_reuseinit(void); 1717c478bd9Sstevel@tonic-gate extern int i_cpr_reusefini(void); 1727c478bd9Sstevel@tonic-gate extern int i_cpr_check_cprinfo(void); 1737c478bd9Sstevel@tonic-gate extern int i_cpr_reusable_supported(void); 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate #endif /* _ASM */ 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1787c478bd9Sstevel@tonic-gate } 1797c478bd9Sstevel@tonic-gate #endif 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate #endif /* _SYS_CPR_IMPL_H */ 182