xref: /titanic_51/usr/src/uts/i86pc/sys/cpr_wakecode.h (revision 342440ec94087b8c751c580ab9ed6c693d31d418)
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 2008 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 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #define	WC_CODESIZE	0x400
35 
36 #if ! defined(_ASM)
37 
38 #include <sys/rm_platter.h>
39 #include <sys/psm_types.h>
40 
41 typedef	struct wc_cpu {
42 	uint64_t wc_retaddr;
43 	uint64_t wc_virtaddr;
44 	uint64_t wc_cr0;
45 	uint64_t wc_cr3;
46 	uint64_t wc_cr4;
47 	uint64_t wc_cr8;
48 	uint64_t wc_fs;
49 	uint64_t wc_fsbase;
50 	uint64_t wc_gs;
51 	uint64_t wc_gsbase;
52 	uint64_t wc_kgsbase;
53 	uint64_t wc_r8;
54 	uint64_t wc_r9;
55 	uint64_t wc_r10;
56 	uint64_t wc_r11;
57 	uint64_t wc_r12;
58 	uint64_t wc_r13;
59 	uint64_t wc_r14;
60 	uint64_t wc_r15;
61 	uint64_t wc_rax;
62 	uint64_t wc_rbp;
63 	uint64_t wc_rbx;
64 	uint64_t wc_rcx;
65 	uint64_t wc_rdi;
66 	uint64_t wc_rdx;
67 	uint64_t wc_rsi;
68 	uint64_t wc_rsp;
69 
70 #if defined(__amd64)
71 	/*
72 	 * The compiler will want to 64-bit align the 64-bit rm_gdt_base
73 	 * pointer, so we need to add an extra four bytes of padding here to
74 	 * make sure rm_gdt_lim and rm_gdt_base will align to create a proper
75 	 * ten byte GDT pseudo-descriptor.
76 	 */
77 uint32_t wc_gdt_pad1;
78 #endif
79 	ushort_t wc_gdt_pad2;
80 	ushort_t wc_gdt_limit;
81 	user_desc_t *wc_gdt_base;
82 
83 #if defined(__amd64)
84 	/*
85 	 * The compiler will want to 64-bit align the 64-bit rm_idt_base
86 	 * pointer, so we need to add an extra four bytes of padding here to
87 	 * make sure rm_idt_lim and rm_idt_base will align to create a proper
88 	 * ten byte IDT pseudo-descriptor.
89 	 */
90 uint32_t wc_idt_pad1;
91 #endif
92 	ushort_t wc_idt_pad2;
93 	ushort_t wc_idt_limit;
94 	user_desc_t *wc_idt_base;
95 
96 #if defined(__amd64)
97 	uint64_t wc_tr;
98 	uint64_t wc_ldt;
99 	uint64_t wc_eflags;
100 #else
101 	uint32_t wc_tr;
102 	uint32_t wc_ldt;
103 	uint32_t wc_eflags;
104 #endif
105 
106 	uint32_t wc_ebx;
107 	uint32_t wc_edi;
108 	uint32_t wc_esi;
109 	uint32_t wc_ebp;
110 	uint32_t wc_esp;
111 	uint16_t wc_ss;
112 	uint16_t wc_cs;
113 	uint16_t wc_ds;
114 	uint16_t wc_es;
115 	psm_state_request_t	wc_apic_state;
116 
117 
118 	/* temp stack grows down to here */
119 } wc_cpu_t;
120 
121 typedef struct wc_wakecode {
122 	rm_platter_t    wc_platter;
123 	wc_cpu_t	wc_cpu;
124 
125 	/* temp stack grows down to here */
126 } wakecode_t;
127 
128 /*
129  * this is NOT correctly aligned, see description of idt & gdt, limit and
130  * base in wc_cpu_t above
131  */
132 typedef struct wc_desctbr {
133 	ushort_t	limit;
134 	void		*base;
135 } wc_desctbr_t;
136 
137 extern int	wc_save_context(wc_cpu_t *);
138 extern void	wc_rm_start(void);
139 extern void	wc_rm_end(void);
140 extern void	(*cpr_start_cpu_func)(void);
141 
142 #endif	/* ! defined(_ASM) */
143 
144 #define	WC_STKSTART	0x7fc	/* end of rm_platter page */
145 
146 #ifdef	__cplusplus
147 }
148 #endif
149 
150 #endif	/* _CPR_WC_H */
151