10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*3446Smrj * Common Development and Distribution License (the "License"). 6*3446Smrj * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*3446Smrj * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_CPR_IMPL_H 270Sstevel@tonic-gate #define _SYS_CPR_IMPL_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #ifdef __cplusplus 320Sstevel@tonic-gate extern "C" { 330Sstevel@tonic-gate #endif 340Sstevel@tonic-gate 350Sstevel@tonic-gate 360Sstevel@tonic-gate #ifndef _ASM 370Sstevel@tonic-gate 380Sstevel@tonic-gate #include <sys/processor.h> 390Sstevel@tonic-gate #include <sys/machparam.h> 400Sstevel@tonic-gate #include <sys/obpdefs.h> 410Sstevel@tonic-gate #include <sys/vnode.h> 420Sstevel@tonic-gate #include <sys/pte.h> 430Sstevel@tonic-gate 440Sstevel@tonic-gate /* 450Sstevel@tonic-gate * This file contains machine dependent information for CPR 460Sstevel@tonic-gate */ 470Sstevel@tonic-gate #define CPR_MACHTYPE_4U 0x3475 /* '4u' */ 480Sstevel@tonic-gate 490Sstevel@tonic-gate /* 500Sstevel@tonic-gate * Information about the pages allocated via prom_retain(). 510Sstevel@tonic-gate * Increase the number of CPR_PROM_RETAIN_CNT if more 520Sstevel@tonic-gate * prom_retain() are called. 530Sstevel@tonic-gate */ 540Sstevel@tonic-gate #define CPR_PROM_RETAIN_CNT 1 550Sstevel@tonic-gate #define CPR_PANICBUF 0 /* prom_retain() for panicbuf */ 560Sstevel@tonic-gate 570Sstevel@tonic-gate 580Sstevel@tonic-gate /* 590Sstevel@tonic-gate * For 2.7 and later releases, sun4u cprboot is an ELF64 binary and must 600Sstevel@tonic-gate * handle both ILP32 and LP64 kernels; while long and ptr sizes are fixed 610Sstevel@tonic-gate * at 64-bits for cprboot these sizes are mixed between ILP32/LP64 kernels. 620Sstevel@tonic-gate * To simplify handling of statefile data, we define fixed-size types for 630Sstevel@tonic-gate * all sun4u kernels. 640Sstevel@tonic-gate */ 650Sstevel@tonic-gate typedef uint64_t cpr_ptr; 660Sstevel@tonic-gate typedef uint64_t cpr_ext; 670Sstevel@tonic-gate 680Sstevel@tonic-gate struct cpr_map_info { 690Sstevel@tonic-gate cpr_ptr virt; 700Sstevel@tonic-gate cpr_ext phys; 710Sstevel@tonic-gate uint_t size; 720Sstevel@tonic-gate }; 730Sstevel@tonic-gate 740Sstevel@tonic-gate 750Sstevel@tonic-gate #define CPR_MAX_TLB 16 760Sstevel@tonic-gate 770Sstevel@tonic-gate struct sun4u_tlb { 780Sstevel@tonic-gate tte_t tte; /* tte data */ 790Sstevel@tonic-gate cpr_ptr va_tag; /* virt tag */ 800Sstevel@tonic-gate int index; /* tlb index */ 810Sstevel@tonic-gate int tmp; /* clear during resume */ 820Sstevel@tonic-gate }; 830Sstevel@tonic-gate 840Sstevel@tonic-gate typedef struct sun4u_tlb sutlb_t; 850Sstevel@tonic-gate 860Sstevel@tonic-gate 870Sstevel@tonic-gate /* 880Sstevel@tonic-gate * processor info 890Sstevel@tonic-gate */ 900Sstevel@tonic-gate struct sun4u_cpu_info { 91789Sahrens pnode_t node; 920Sstevel@tonic-gate processorid_t cpu_id; 930Sstevel@tonic-gate }; 940Sstevel@tonic-gate 950Sstevel@tonic-gate 960Sstevel@tonic-gate /* 970Sstevel@tonic-gate * This structure defines the fixed-length machine dependent data for 980Sstevel@tonic-gate * sun4u ILP32 and LP64 systems. It is followed in the state file by 990Sstevel@tonic-gate * a variable length section of null-terminated prom forth words: 1000Sstevel@tonic-gate * 1010Sstevel@tonic-gate * cpr_obp_tte_str for translating kernel mappings, unix-tte 1020Sstevel@tonic-gate * 1030Sstevel@tonic-gate * The total length (fixed plus variable) of the machine-dependent 1040Sstevel@tonic-gate * section is stored in cpr_machdep_desc.md_size 1050Sstevel@tonic-gate * 1060Sstevel@tonic-gate * WARNING: make sure all CPR_MD_* below match this structure 1070Sstevel@tonic-gate */ 1080Sstevel@tonic-gate struct cpr_sun4u_machdep { 1090Sstevel@tonic-gate uint32_t ksb; /* 0x00: kernel stack bias */ 1100Sstevel@tonic-gate uint16_t kpstate; /* 0x04: kernel pstate */ 1110Sstevel@tonic-gate uint16_t kwstate; /* 0x06: kernel wstate */ 1120Sstevel@tonic-gate cpr_ptr thrp; /* 0x08: current thread ptr */ 1130Sstevel@tonic-gate cpr_ptr func; /* 0x10: jumpback virt text addr */ 1140Sstevel@tonic-gate cpr_ext qsav_pc; /* 0x18: qsav pc */ 1150Sstevel@tonic-gate cpr_ext qsav_sp; /* 0x20: qsav sp */ 1160Sstevel@tonic-gate int mmu_ctx_pri; /* 0x28: primary context */ 1170Sstevel@tonic-gate int mmu_ctx_sec; /* 0x2c: secondary context */ 1180Sstevel@tonic-gate cpr_ptr tmp_stack; /* 0x30: base of data page */ 1190Sstevel@tonic-gate cpr_ext tmp_stacksize; /* 0x38: leading area of data page */ 1200Sstevel@tonic-gate int test_mode; /* 0x40 */ 1210Sstevel@tonic-gate int pad; /* 0x44 */ 1220Sstevel@tonic-gate sutlb_t dtte[CPR_MAX_TLB]; /* 0x48 */ 1230Sstevel@tonic-gate sutlb_t itte[CPR_MAX_TLB]; /* 0x1c8 */ 1240Sstevel@tonic-gate struct sun4u_cpu_info sci[NCPU]; /* 0x348 */ 1250Sstevel@tonic-gate }; 1260Sstevel@tonic-gate typedef struct cpr_sun4u_machdep csu_md_t; 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate #endif /* _ASM */ 1290Sstevel@tonic-gate 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate /* 1320Sstevel@tonic-gate * XXX - these should be generated by a genassym, 1330Sstevel@tonic-gate * but that doesn't work well for shared psm/kernel use 1340Sstevel@tonic-gate */ 1350Sstevel@tonic-gate #define CPR_MD_KSB 0x00 1360Sstevel@tonic-gate #define CPR_MD_KPSTATE 0x04 1370Sstevel@tonic-gate #define CPR_MD_KWSTATE 0x06 1380Sstevel@tonic-gate #define CPR_MD_THRP 0x08 1390Sstevel@tonic-gate #define CPR_MD_FUNC 0x10 1400Sstevel@tonic-gate #define CPR_MD_QSAV_PC 0x18 1410Sstevel@tonic-gate #define CPR_MD_QSAV_SP 0x20 1420Sstevel@tonic-gate #define CPR_MD_PRI 0x28 1430Sstevel@tonic-gate #define CPR_MD_SEC 0x2c 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate 1460Sstevel@tonic-gate #ifndef _ASM 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate #define CPRBOOT "-F cprboot" 1490Sstevel@tonic-gate 1500Sstevel@tonic-gate #define PN_TO_ADDR(pn) ((u_longlong_t)(pn) << MMU_PAGESHIFT) 1510Sstevel@tonic-gate #define ADDR_TO_PN(pa) ((pa) >> MMU_PAGESHIFT) 1520Sstevel@tonic-gate 1530Sstevel@tonic-gate #define prom_map_plat(addr, pa, size) \ 1540Sstevel@tonic-gate if (prom_map(addr, pa, size) == 0) { \ 155*3446Smrj prom_printf("PROM_MAP failed: paddr=0x%lx\n", pa); \ 1560Sstevel@tonic-gate return (-1); \ 1570Sstevel@tonic-gate } 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate typedef u_longlong_t physaddr_t; 1600Sstevel@tonic-gate 1610Sstevel@tonic-gate extern void i_cpr_machdep_setup(void); 1620Sstevel@tonic-gate extern void i_cpr_save_machdep_info(void); 1630Sstevel@tonic-gate extern void i_cpr_enable_intr(void); 1640Sstevel@tonic-gate extern void i_cpr_set_tbr(void); 1650Sstevel@tonic-gate extern void i_cpr_stop_intr(void); 1660Sstevel@tonic-gate extern void i_cpr_handle_xc(int); 1670Sstevel@tonic-gate extern void i_cpr_resume_setup(void *, csu_md_t *); 1680Sstevel@tonic-gate extern int i_cpr_write_machdep(vnode_t *); 1690Sstevel@tonic-gate extern int i_cpr_prom_pages(int); 1700Sstevel@tonic-gate extern int i_cpr_reuseinit(void); 1710Sstevel@tonic-gate extern int i_cpr_reusefini(void); 1720Sstevel@tonic-gate extern int i_cpr_check_cprinfo(void); 1730Sstevel@tonic-gate extern int i_cpr_reusable_supported(void); 1740Sstevel@tonic-gate 1750Sstevel@tonic-gate #endif /* _ASM */ 1760Sstevel@tonic-gate 1770Sstevel@tonic-gate #ifdef __cplusplus 1780Sstevel@tonic-gate } 1790Sstevel@tonic-gate #endif 1800Sstevel@tonic-gate 1810Sstevel@tonic-gate #endif /* _SYS_CPR_IMPL_H */ 182