xref: /titanic_52/usr/src/uts/i86pc/sys/cpr_wakecode.h (revision 67e3a03ed4a2813074d36330f062ed6e593a4937)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_CPR_WC_H
28 #define	_CPR_WC_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #define	WC_CODESIZE	0x400
37 
38 #if ! defined(_ASM)
39 
40 #include <sys/rm_platter.h>
41 #include <sys/psm_types.h>
42 
43 typedef	struct wc_cpu {
44 	uint64_t wc_retaddr;
45 	uint64_t wc_virtaddr;
46 	uint64_t wc_cr0;
47 	uint64_t wc_cr3;
48 	uint64_t wc_cr4;
49 	uint64_t wc_cr8;
50 	uint64_t wc_fs;
51 	uint64_t wc_fsbase;
52 	uint64_t wc_gs;
53 	uint64_t wc_gsbase;
54 	uint64_t wc_kgsbase;
55 	uint64_t wc_r8;
56 	uint64_t wc_r9;
57 	uint64_t wc_r10;
58 	uint64_t wc_r11;
59 	uint64_t wc_r12;
60 	uint64_t wc_r13;
61 	uint64_t wc_r14;
62 	uint64_t wc_r15;
63 	uint64_t wc_rax;
64 	uint64_t wc_rbp;
65 	uint64_t wc_rbx;
66 	uint64_t wc_rcx;
67 	uint64_t wc_rdi;
68 	uint64_t wc_rdx;
69 	uint64_t wc_rsi;
70 	uint64_t wc_rsp;
71 
72 #if defined(__amd64)
73 	/*
74 	 * The compiler will want to 64-bit align the 64-bit rm_gdt_base
75 	 * pointer, so we need to add an extra four bytes of padding here to
76 	 * make sure rm_gdt_lim and rm_gdt_base will align to create a proper
77 	 * ten byte GDT pseudo-descriptor.
78 	 */
79 uint32_t wc_gdt_pad1;
80 #endif
81 	ushort_t wc_gdt_pad2;
82 	ushort_t wc_gdt_limit;
83 	user_desc_t *wc_gdt_base;
84 
85 #if defined(__amd64)
86 	/*
87 	 * The compiler will want to 64-bit align the 64-bit rm_idt_base
88 	 * pointer, so we need to add an extra four bytes of padding here to
89 	 * make sure rm_idt_lim and rm_idt_base will align to create a proper
90 	 * ten byte IDT pseudo-descriptor.
91 	 */
92 uint32_t wc_idt_pad1;
93 #endif
94 	ushort_t wc_idt_pad2;
95 	ushort_t wc_idt_limit;
96 	user_desc_t *wc_idt_base;
97 
98 #if defined(__amd64)
99 	uint64_t wc_tr;
100 	uint64_t wc_ldt;
101 	uint64_t wc_eflags;
102 #else
103 	uint32_t wc_tr;
104 	uint32_t wc_ldt;
105 	uint32_t wc_eflags;
106 #endif
107 
108 	uint32_t wc_ebx;
109 	uint32_t wc_edi;
110 	uint32_t wc_esi;
111 	uint32_t wc_ebp;
112 	uint32_t wc_esp;
113 	uint16_t wc_ss;
114 	uint16_t wc_cs;
115 	uint16_t wc_ds;
116 	uint16_t wc_es;
117 	char	wc_stack[400];
118 	psm_state_request_t	wc_apic_state;
119 
120 
121 	/* temp stack grows down to here */
122 } wc_cpu_t;
123 
124 typedef struct wc_wakecode {
125 	rm_platter_t    wc_platter;
126 	wc_cpu_t	wc_cpu;
127 
128 	/* temp stack grows down to here */
129 } wakecode_t;
130 
131 /*
132  * this is NOT correctly aligned, see description of idt & gdt, limit and
133  * base in wc_cpu_t above
134  */
135 typedef struct wc_desctbr {
136 	ushort_t	limit;
137 	void		*base;
138 } wc_desctbr_t;
139 
140 extern int	wc_save_context(wc_cpu_t *);
141 extern void	wc_rm_start(void);
142 extern void	wc_rm_end(void);
143 extern void	(*cpr_start_cpu_func)(void);
144 
145 #endif	/* ! defined(_ASM) */
146 
147 #define	WC_STKSTART	0x7fc	/* end of rm_platter page */
148 
149 #ifdef	__cplusplus
150 }
151 #endif
152 
153 #endif	/* _CPR_WC_H */
154