xref: /titanic_50/usr/src/uts/sun4u/sys/cpr_impl.h (revision 9a411307f0d1eedbc81618ec290e0685284d8a2b)
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  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_CPR_IMPL_H
27 #define	_SYS_CPR_IMPL_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 
36 #ifndef _ASM
37 
38 #include <sys/processor.h>
39 #include <sys/machparam.h>
40 #include <sys/obpdefs.h>
41 #include <sys/vnode.h>
42 #include <sys/pte.h>
43 
44 /*
45  * This file contains machine dependent information for CPR
46  */
47 #define	CPR_MACHTYPE_4U		0x3475		/* '4u' */
48 
49 /*
50  * Information about the pages allocated via prom_retain().
51  * Increase the number of CPR_PROM_RETAIN_CNT if more
52  * prom_retain() are called.
53  */
54 #define	CPR_PROM_RETAIN_CNT	1
55 #define	CPR_PANICBUF		0	/* prom_retain() for panicbuf */
56 
57 
58 /*
59  * For 2.7 and later releases, sun4u cprboot is an ELF64 binary and must
60  * handle both ILP32 and LP64 kernels; while long and ptr sizes are fixed
61  * at 64-bits for cprboot these sizes are mixed between ILP32/LP64 kernels.
62  * To simplify handling of statefile data, we define fixed-size types for
63  * all sun4u kernels.
64  */
65 typedef uint64_t cpr_ptr;
66 typedef uint64_t cpr_ext;
67 
68 struct cpr_map_info {
69 	cpr_ptr	virt;
70 	cpr_ext	phys;
71 	uint_t	size;
72 };
73 
74 
75 #define	CPR_MAX_TLB 16
76 
77 struct sun4u_tlb {
78 	tte_t	tte;			/* tte data */
79 	cpr_ptr va_tag;			/* virt tag */
80 	int	index;			/* tlb index */
81 	int	tmp;			/* clear during resume */
82 };
83 
84 typedef struct sun4u_tlb sutlb_t;
85 
86 
87 /*
88  * processor info
89  */
90 struct sun4u_cpu_info {
91 	pnode_t node;
92 	processorid_t cpu_id;
93 };
94 
95 
96 /*
97  * This structure defines the fixed-length machine dependent data for
98  * sun4u ILP32 and LP64 systems.  It is followed in the state file by
99  * a variable length section of null-terminated prom forth words:
100  *
101  *    cpr_obp_tte_str	for translating kernel mappings, unix-tte
102  *
103  * The total length (fixed plus variable) of the machine-dependent
104  * section is stored in cpr_machdep_desc.md_size
105  *
106  * WARNING: make sure all CPR_MD_* below match this structure
107  */
108 struct cpr_sun4u_machdep {
109 	uint32_t ksb;			/* 0x00: kernel stack bias */
110 	uint16_t kpstate;		/* 0x04: kernel pstate */
111 	uint16_t kwstate;		/* 0x06: kernel wstate */
112 	cpr_ptr thrp;			/* 0x08: current thread ptr */
113 	cpr_ptr func;			/* 0x10: jumpback virt text addr */
114 	cpr_ext qsav_pc;		/* 0x18: qsav pc */
115 	cpr_ext qsav_sp;		/* 0x20: qsav sp */
116 	int	mmu_ctx_pri;		/* 0x28: primary context */
117 	int	mmu_ctx_sec;		/* 0x2c: secondary context */
118 	cpr_ptr	tmp_stack;		/* 0x30: base of data page */
119 	cpr_ext tmp_stacksize;		/* 0x38: leading area of data page */
120 	int	test_mode;		/* 0x40 */
121 	int	pad;			/* 0x44 */
122 	sutlb_t	dtte[CPR_MAX_TLB];	/* 0x48 */
123 	sutlb_t	itte[CPR_MAX_TLB];	/* 0x1c8 */
124 	struct	sun4u_cpu_info sci[NCPU]; /* 0x348 */
125 };
126 typedef struct cpr_sun4u_machdep csu_md_t;
127 
128 #endif /* _ASM */
129 
130 
131 /*
132  * XXX - these should be generated by a genassym,
133  * but that doesn't work well for shared psm/kernel use
134  */
135 #define	CPR_MD_KSB		0x00
136 #define	CPR_MD_KPSTATE		0x04
137 #define	CPR_MD_KWSTATE		0x06
138 #define	CPR_MD_THRP		0x08
139 #define	CPR_MD_FUNC		0x10
140 #define	CPR_MD_QSAV_PC		0x18
141 #define	CPR_MD_QSAV_SP		0x20
142 #define	CPR_MD_PRI		0x28
143 #define	CPR_MD_SEC		0x2c
144 
145 
146 #ifndef _ASM
147 
148 #define	CPRBOOT		"-F cprboot"
149 
150 #define	PN_TO_ADDR(pn)  ((u_longlong_t)(pn) << MMU_PAGESHIFT)
151 #define	ADDR_TO_PN(pa)	((pa) >> MMU_PAGESHIFT)
152 
153 #define	prom_map_plat(addr, pa, size) \
154 	if (prom_map(addr, pa, size) == 0) { \
155 		prom_printf("PROM_MAP failed: paddr=0x%lx\n", pa); \
156 		return (-1); \
157 	}
158 
159 typedef	u_longlong_t	physaddr_t;
160 
161 extern void i_cpr_machdep_setup(void);
162 extern void i_cpr_save_machdep_info(void);
163 extern void i_cpr_enable_intr(void);
164 extern void i_cpr_set_tbr(void);
165 extern void i_cpr_stop_intr(void);
166 extern void i_cpr_handle_xc(int);
167 extern void i_cpr_resume_setup(void *, csu_md_t *);
168 extern int i_cpr_write_machdep(vnode_t *);
169 extern int i_cpr_prom_pages(int);
170 extern int i_cpr_reuseinit(void);
171 extern int i_cpr_reusefini(void);
172 extern int i_cpr_check_cprinfo(void);
173 extern int i_cpr_reusable_supported(void);
174 
175 #endif /* _ASM */
176 
177 #ifdef	__cplusplus
178 }
179 #endif
180 
181 #endif	/* _SYS_CPR_IMPL_H */
182