blob: c84e84d2428c52a8ebcb0aafd6f690d504a90c0a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SBDP_MEM_H
#define _SBDP_MEM_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/sbd.h>
#include <sys/sbdp_priv.h>
#define SBDP_MAX_MCS_PER_NODE 4
#define SBDP_MAX_MEM_NODES_PER_BOARD 4
#define SBDP_MAX_CORES_PER_CMP 2
typedef uint64_t mc_dc_regs_t[SBDP_MAX_MCS_PER_NODE];
typedef struct {
int board;
pnode_t *nodes;
int nmem;
} mem_op_t;
typedef struct {
uint_t regspec_addr_hi;
uint_t regspec_addr_lo;
uint_t regspec_size_hi;
uint_t regspec_size_lo;
} mc_regspace;
typedef struct {
uint64_t mc_decode[SBDP_MAX_MCS_PER_NODE];
uint64_t mc_memctl;
} mc_regs_t;
/*
* Memory controller register offsets
*/
#define SG_MEM_TIMING1_CTL 0x400000
#define SG_MEM_TIMING2_CTL 0x400008
#define SG_MEM_TIMING3_CTL 0x400038
#define SG_MEM_TIMING4_CTL 0x400040
#define SG_MEM_DECODE0_ADR 0x400028
#define SG_MEM_DECODE1_ADR 0x400010
#define SG_MEM_DECODE2_ADR 0x400018
#define SG_MEM_DECODE3_ADR 0x400020
#define SG_MEM_CONTROL_ADR 0x400030
#define SG_EMU_ACTIVITY_STATUS 0x400050
/*
* Bit fields for the decode registers
*/
#define SG_DECODE_VALID 0x8000000000000000ull
#define SG_DECODE_UK 0x001ffe0000000000ull
#define SG_DECODE_UM 0x000001fffff00000ull
#define SG_DECODE_LK 0x00000000000fc000ull
#define SG_DECODE_LM 0x0000000000003f00ull
#define SG_INVAL_UM 0x0000000ffff00000ull
#define SG_SLICE_INFO 0x000001fc00000000ull
#define SG_ALIGNMENT 0x800000000ULL
/*
* Memory Macros
*/
#define MC_MEMDEC0(mc_addr) \
(mc_addr) | SG_MEM_DECODE0_ADR
#define MC_MEMDEC1(mc_addr) \
(mc_addr) | SG_MEM_DECODE1_ADR
#define MC_MEMDEC2(mc_addr) \
(mc_addr) | SG_MEM_DECODE2_ADR
#define MC_MEMDEC3(mc_addr) \
(mc_addr) | SG_MEM_DECODE3_ADR
#define MC_ACTIVITY_STATUS(mc_addr) \
(mc_addr) | SG_EMU_ACTIVITY_STATUS
/*
* Mappings to the array for the decode registers only
*/
#define SG_MC_DECODE_I 0
#define SG_MC_DECODE_II 1
#define SG_MC_DECODE_III 2
#define SG_MC_DECODE_IV 3
/*
* Memory Macros
*/
#define SG_REG_2_OFFSET(num) \
((num) == SG_MC_DECODE_I ? (uint64_t)SG_MEM_DECODE0_ADR : \
(num) == SG_MC_DECODE_II ? (uint64_t)SG_MEM_DECODE1_ADR : \
(num) == SG_MC_DECODE_III ? (uint64_t)SG_MEM_DECODE2_ADR : \
(num) == SG_MC_DECODE_IV ? (uint64_t)SG_MEM_DECODE3_ADR : \
(uint64_t)-1)
#define MC_VALID_SHIFT 63
#define MC_UK_SHIFT 41
#define MC_UM_SHIFT 20
#define MC_LK_SHIFT 14
#define MC_LM_SHIFT 8
#define PHYS2UM_SHIFT 26
#define MC_UK(memdec) (((memdec) >> MC_UK_SHIFT) & 0xfffu)
#define MC_LK(memdec) (((memdec) >> MC_LK_SHIFT)& 0x3fu)
#define MC_INTLV(memdec) ((~(MC_LK(memdec)) & 0xfu) + 1)
#define MC_UK2SPAN(memdec) ((MC_UK(memdec) + 1) << PHYS2UM_SHIFT)
#define MC_SPANMB(memdec) (MC_UK2SPAN(memdec) >> 20)
#define MC_UM(memdec) (((memdec) >> MC_UM_SHIFT) & 0x1fffffu)
#define MC_LM(memdec) (((memdec) >> MC_LM_SHIFT) & 0x3f)
#define MC_BASE(memdec) (MC_UM(memdec) & ~(MC_UK(memdec)))
#define MC_BASE2UM(base) (((base) & 0x1fffffu) << MC_UM_SHIFT)
#define SAF_MASK 0x000007ffff800000ull
#define MC_OFFSET_MASK 0xffu
/*
* Memory Slice information
*/
#define SG_SLICE_16G_SIZE 0x400000000ULL
#define SG_SLICE_32G_SIZE 0x800000000ULL
#define SG_SLICE_64G_SIZE 0x1000000000ULL
/*
* Copy-rename info
*/
#define SBDP_RENAME_MAXOP (PAGESIZE / sizeof (sbdp_rename_script_t))
/*
* Must be same size as sbdp_rename_script_t.
*/
typedef struct {
uint64_t addr;
uint_t bd_id;
pnode_t node;
uint_t asi;
uint_t _filler;
} sbdp_mc_idle_script_t;
typedef struct {
uint64_t masr_addr;
uint64_t masr;
uint_t asi;
uint_t _filler;
} sbdp_rename_script_t;
typedef struct {
sbdp_bd_t *s_bdp; /* pointer to src bd info */
sbdp_bd_t *t_bdp; /* pointer to tgt bd info */
sbdp_rename_script_t *script; /* points to the actual script */
uint64_t ret;
sbdp_mc_idle_script_t *busy_mc;
} sbdp_cr_handle_t;
extern uint64_t lddsafaddr(uint64_t physaddr);
extern uint64_t lddmcdecode(uint64_t physaddr);
extern void stdmcdecode(uint64_t, uint64_t);
int sbdp_is_mem(pnode_t node, void *arg);
#ifdef DEBUG
int sbdp_passthru_readmem(sbdp_handle_t *hp, void *);
int sbdp_passthru_prep_script(sbdp_handle_t *hp, void *);
#endif
#ifdef __cplusplus
}
#endif
#endif /* _SBDP_MEM_H */
|