2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf/*
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * CDDL HEADER START
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf *
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * The contents of this file are subject to the terms of the
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * Common Development and Distribution License (the "License").
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * You may not use this file except in compliance with the License.
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf *
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * or http://www.opensolaris.org/os/licensing.
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * See the License for the specific language governing permissions
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * and limitations under the License.
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf *
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * When distributing Covered Code, include this CDDL HEADER in each
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * If applicable, add the following below this CDDL HEADER, with the
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * fields enclosed by brackets "[]" replaced with your own identifying
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * information: Portions Copyright [yyyy] [name of copyright owner]
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf *
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * CDDL HEADER END
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf */
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf/*
3d995820f4ce8cd712d97f05aae6d30d9952d298Joseph A Townsend * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * Use is subject to license terms.
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf */
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf#ifndef _CPR_WC_H
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf#define _CPR_WC_H
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf#ifdef __cplusplus
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyfextern "C" {
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf#endif
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf#define WC_CODESIZE 0x400
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf#if ! defined(_ASM)
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf#include <sys/rm_platter.h>
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf#include <sys/psm_types.h>
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyftypedef struct wc_cpu {
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_retaddr;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_virtaddr;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_cr0;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_cr3;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_cr4;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_cr8;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_fs;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_fsbase;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_gs;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_gsbase;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_kgsbase;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_r8;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_r9;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_r10;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_r11;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_r12;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_r13;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_r14;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_r15;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_rax;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_rbp;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_rbx;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_rcx;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_rdi;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_rdx;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_rsi;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_rsp;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf#if defined(__amd64)
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf /*
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * The compiler will want to 64-bit align the 64-bit rm_gdt_base
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * pointer, so we need to add an extra four bytes of padding here to
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * make sure rm_gdt_lim and rm_gdt_base will align to create a proper
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * ten byte GDT pseudo-descriptor.
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf */
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyfuint32_t wc_gdt_pad1;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf#endif
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf ushort_t wc_gdt_pad2;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf ushort_t wc_gdt_limit;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf user_desc_t *wc_gdt_base;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf#if defined(__amd64)
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf /*
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * The compiler will want to 64-bit align the 64-bit rm_idt_base
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * pointer, so we need to add an extra four bytes of padding here to
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * make sure rm_idt_lim and rm_idt_base will align to create a proper
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * ten byte IDT pseudo-descriptor.
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf */
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyfuint32_t wc_idt_pad1;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf#endif
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf ushort_t wc_idt_pad2;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf ushort_t wc_idt_limit;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf user_desc_t *wc_idt_base;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf#if defined(__amd64)
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_tr;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_ldt;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint64_t wc_eflags;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf#else
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint32_t wc_tr;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint32_t wc_ldt;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint32_t wc_eflags;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf#endif
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint32_t wc_ebx;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint32_t wc_edi;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint32_t wc_esi;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint32_t wc_ebp;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint32_t wc_esp;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint16_t wc_ss;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint16_t wc_cs;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint16_t wc_ds;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf uint16_t wc_es;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf psm_state_request_t wc_apic_state;
3d995820f4ce8cd712d97f05aae6d30d9952d298Joseph A Townsend processorid_t wc_cpu_id; /* which CPU are we running on */
3d995820f4ce8cd712d97f05aae6d30d9952d298Joseph A Townsend greg_t *wc_saved_stack; /* pointer to where stack contents are saved */
3d995820f4ce8cd712d97f05aae6d30d9952d298Joseph A Townsend size_t wc_saved_stack_size; /* size of the saved stack */
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf /* temp stack grows down to here */
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf} wc_cpu_t;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyftypedef struct wc_wakecode {
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf rm_platter_t wc_platter;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf wc_cpu_t wc_cpu;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf /* temp stack grows down to here */
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf} wakecode_t;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf/*
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * this is NOT correctly aligned, see description of idt & gdt, limit and
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf * base in wc_cpu_t above
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf */
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyftypedef struct wc_desctbr {
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf ushort_t limit;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf void *base;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf} wc_desctbr_t;
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyfextern int wc_save_context(wc_cpu_t *);
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyfextern void wc_rm_start(void);
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyfextern void wc_rm_end(void);
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyfextern void (*cpr_start_cpu_func)(void);
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf#endif /* ! defined(_ASM) */
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf#define WC_STKSTART 0x7fc /* end of rm_platter page */
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf#ifdef __cplusplus
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf}
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf#endif
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf
2df1fe9ca32bb227b9158c67f5c00b54c20b10fdrandyf#endif /* _CPR_WC_H */