12df1fe9cSrandyf /* 22df1fe9cSrandyf * CDDL HEADER START 32df1fe9cSrandyf * 42df1fe9cSrandyf * The contents of this file are subject to the terms of the 52df1fe9cSrandyf * Common Development and Distribution License (the "License"). 62df1fe9cSrandyf * You may not use this file except in compliance with the License. 72df1fe9cSrandyf * 82df1fe9cSrandyf * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 92df1fe9cSrandyf * or http://www.opensolaris.org/os/licensing. 102df1fe9cSrandyf * See the License for the specific language governing permissions 112df1fe9cSrandyf * and limitations under the License. 122df1fe9cSrandyf * 132df1fe9cSrandyf * When distributing Covered Code, include this CDDL HEADER in each 142df1fe9cSrandyf * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 152df1fe9cSrandyf * If applicable, add the following below this CDDL HEADER, with the 162df1fe9cSrandyf * fields enclosed by brackets "[]" replaced with your own identifying 172df1fe9cSrandyf * information: Portions Copyright [yyyy] [name of copyright owner] 182df1fe9cSrandyf * 192df1fe9cSrandyf * CDDL HEADER END 202df1fe9cSrandyf */ 212df1fe9cSrandyf 222df1fe9cSrandyf /* 23*3d995820SJoseph A Townsend * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 242df1fe9cSrandyf * Use is subject to license terms. 252df1fe9cSrandyf */ 262df1fe9cSrandyf 272df1fe9cSrandyf #ifndef _CPR_WC_H 282df1fe9cSrandyf #define _CPR_WC_H 292df1fe9cSrandyf 302df1fe9cSrandyf #ifdef __cplusplus 312df1fe9cSrandyf extern "C" { 322df1fe9cSrandyf #endif 332df1fe9cSrandyf 342df1fe9cSrandyf #define WC_CODESIZE 0x400 352df1fe9cSrandyf 362df1fe9cSrandyf #if ! defined(_ASM) 372df1fe9cSrandyf 382df1fe9cSrandyf #include <sys/rm_platter.h> 392df1fe9cSrandyf #include <sys/psm_types.h> 402df1fe9cSrandyf 412df1fe9cSrandyf typedef struct wc_cpu { 422df1fe9cSrandyf uint64_t wc_retaddr; 432df1fe9cSrandyf uint64_t wc_virtaddr; 442df1fe9cSrandyf uint64_t wc_cr0; 452df1fe9cSrandyf uint64_t wc_cr3; 462df1fe9cSrandyf uint64_t wc_cr4; 472df1fe9cSrandyf uint64_t wc_cr8; 482df1fe9cSrandyf uint64_t wc_fs; 492df1fe9cSrandyf uint64_t wc_fsbase; 502df1fe9cSrandyf uint64_t wc_gs; 512df1fe9cSrandyf uint64_t wc_gsbase; 522df1fe9cSrandyf uint64_t wc_kgsbase; 532df1fe9cSrandyf uint64_t wc_r8; 542df1fe9cSrandyf uint64_t wc_r9; 552df1fe9cSrandyf uint64_t wc_r10; 562df1fe9cSrandyf uint64_t wc_r11; 572df1fe9cSrandyf uint64_t wc_r12; 582df1fe9cSrandyf uint64_t wc_r13; 592df1fe9cSrandyf uint64_t wc_r14; 602df1fe9cSrandyf uint64_t wc_r15; 612df1fe9cSrandyf uint64_t wc_rax; 622df1fe9cSrandyf uint64_t wc_rbp; 632df1fe9cSrandyf uint64_t wc_rbx; 642df1fe9cSrandyf uint64_t wc_rcx; 652df1fe9cSrandyf uint64_t wc_rdi; 662df1fe9cSrandyf uint64_t wc_rdx; 672df1fe9cSrandyf uint64_t wc_rsi; 682df1fe9cSrandyf uint64_t wc_rsp; 692df1fe9cSrandyf 702df1fe9cSrandyf #if defined(__amd64) 712df1fe9cSrandyf /* 722df1fe9cSrandyf * The compiler will want to 64-bit align the 64-bit rm_gdt_base 732df1fe9cSrandyf * pointer, so we need to add an extra four bytes of padding here to 742df1fe9cSrandyf * make sure rm_gdt_lim and rm_gdt_base will align to create a proper 752df1fe9cSrandyf * ten byte GDT pseudo-descriptor. 762df1fe9cSrandyf */ 772df1fe9cSrandyf uint32_t wc_gdt_pad1; 782df1fe9cSrandyf #endif 792df1fe9cSrandyf ushort_t wc_gdt_pad2; 802df1fe9cSrandyf ushort_t wc_gdt_limit; 812df1fe9cSrandyf user_desc_t *wc_gdt_base; 822df1fe9cSrandyf 832df1fe9cSrandyf #if defined(__amd64) 842df1fe9cSrandyf /* 852df1fe9cSrandyf * The compiler will want to 64-bit align the 64-bit rm_idt_base 862df1fe9cSrandyf * pointer, so we need to add an extra four bytes of padding here to 872df1fe9cSrandyf * make sure rm_idt_lim and rm_idt_base will align to create a proper 882df1fe9cSrandyf * ten byte IDT pseudo-descriptor. 892df1fe9cSrandyf */ 902df1fe9cSrandyf uint32_t wc_idt_pad1; 912df1fe9cSrandyf #endif 922df1fe9cSrandyf ushort_t wc_idt_pad2; 932df1fe9cSrandyf ushort_t wc_idt_limit; 942df1fe9cSrandyf user_desc_t *wc_idt_base; 952df1fe9cSrandyf 962df1fe9cSrandyf #if defined(__amd64) 972df1fe9cSrandyf uint64_t wc_tr; 982df1fe9cSrandyf uint64_t wc_ldt; 992df1fe9cSrandyf uint64_t wc_eflags; 1002df1fe9cSrandyf #else 1012df1fe9cSrandyf uint32_t wc_tr; 1022df1fe9cSrandyf uint32_t wc_ldt; 1032df1fe9cSrandyf uint32_t wc_eflags; 1042df1fe9cSrandyf #endif 1052df1fe9cSrandyf 1062df1fe9cSrandyf uint32_t wc_ebx; 1072df1fe9cSrandyf uint32_t wc_edi; 1082df1fe9cSrandyf uint32_t wc_esi; 1092df1fe9cSrandyf uint32_t wc_ebp; 1102df1fe9cSrandyf uint32_t wc_esp; 1112df1fe9cSrandyf uint16_t wc_ss; 1122df1fe9cSrandyf uint16_t wc_cs; 1132df1fe9cSrandyf uint16_t wc_ds; 1142df1fe9cSrandyf uint16_t wc_es; 1152df1fe9cSrandyf psm_state_request_t wc_apic_state; 116*3d995820SJoseph A Townsend processorid_t wc_cpu_id; /* which CPU are we running on */ 117*3d995820SJoseph A Townsend greg_t *wc_saved_stack; /* pointer to where stack contents are saved */ 118*3d995820SJoseph A Townsend size_t wc_saved_stack_size; /* size of the saved stack */ 1192df1fe9cSrandyf 1202df1fe9cSrandyf 1212df1fe9cSrandyf /* temp stack grows down to here */ 1222df1fe9cSrandyf } wc_cpu_t; 1232df1fe9cSrandyf 1242df1fe9cSrandyf typedef struct wc_wakecode { 1252df1fe9cSrandyf rm_platter_t wc_platter; 1262df1fe9cSrandyf wc_cpu_t wc_cpu; 1272df1fe9cSrandyf 1282df1fe9cSrandyf /* temp stack grows down to here */ 1292df1fe9cSrandyf } wakecode_t; 1302df1fe9cSrandyf 1312df1fe9cSrandyf /* 1322df1fe9cSrandyf * this is NOT correctly aligned, see description of idt & gdt, limit and 1332df1fe9cSrandyf * base in wc_cpu_t above 1342df1fe9cSrandyf */ 1352df1fe9cSrandyf typedef struct wc_desctbr { 1362df1fe9cSrandyf ushort_t limit; 1372df1fe9cSrandyf void *base; 1382df1fe9cSrandyf } wc_desctbr_t; 1392df1fe9cSrandyf 1402df1fe9cSrandyf extern int wc_save_context(wc_cpu_t *); 1412df1fe9cSrandyf extern void wc_rm_start(void); 1422df1fe9cSrandyf extern void wc_rm_end(void); 1432df1fe9cSrandyf extern void (*cpr_start_cpu_func)(void); 1442df1fe9cSrandyf 1452df1fe9cSrandyf #endif /* ! defined(_ASM) */ 1462df1fe9cSrandyf 1472df1fe9cSrandyf #define WC_STKSTART 0x7fc /* end of rm_platter page */ 1482df1fe9cSrandyf 1492df1fe9cSrandyf #ifdef __cplusplus 1502df1fe9cSrandyf } 1512df1fe9cSrandyf #endif 1522df1fe9cSrandyf 1532df1fe9cSrandyf #endif /* _CPR_WC_H */ 154