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 2009 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _X86PI_IMPL_H 28 #define _X86PI_IMPL_H 29 30 /* 31 * i86pc Generic Enumerator private interfaces 32 */ 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 #include <smbios.h> 39 #include <ctype.h> 40 41 42 /* 43 * Table showing the relationship between hc-canonical names and the 44 * SMBIOS tables/values. 45 * 46 * ************************************************************************** 47 * | hc-name | SMB Table | Offset - Name | Value | 48 * -------------------------------------------------------------------------- 49 * -------------------------------------------------------------------------- 50 * | "motherboard" | Type 2 | 0x0D - Board Type | 0x0A | 51 * -------------------------------------------------------------------------- 52 * | "cpuboard" | Type 2 | 0x0D - Board Type | 0x06 | 53 * -------------------------------------------------------------------------- 54 * | "memboard" | Type 2 | 0x0D - Board Type | 0x08 | 55 * -------------------------------------------------------------------------- 56 * | "ioboard" | Type 2 | 0x0D - Board Type | 0x07 | 57 * -------------------------------------------------------------------------- 58 * | "systemboard" | Type 2 | 0x0D - Board Type | 0x03,0x09,| 59 * | | | | 0x0B,0x0C | 60 * -------------------------------------------------------------------------- 61 * | "hostbridge" | Type 138 | | 62 * -------------------------------------------------------------------------- 63 * | "pciexrc" | Type 138 | | 64 * ************************************************************************** 65 */ 66 67 68 /* Definitions used when registering the enumerator with libtopo */ 69 #define X86PI_DESC "i86pc Generic Topology Enumerator" 70 #define X86PI_SCHEME "hc" 71 #define X86PI_VERSION TOPO_VERSION 72 73 /* 74 * Solaris FMA Compliance level for SMBIOS. 75 * The same X86PI_* definitions are used in chip.h 76 * please keep them in sync 77 */ 78 #define X86PI_FULL 1 79 #define X86PI_NONE 2 80 81 /* used in traversing contained bboards */ 82 #define X86PI_VISITED 1 83 84 #define LABEL 1 85 86 /* Flags used by x86pi_enum_generic */ 87 #define X86PI_ENUM_FRU 0x0001 /* Indicates a FRU */ 88 89 /* max allowed contained count */ 90 #define SMB_MAX_ID 0x40 91 92 /* indication of successful fac node creation */ 93 int fac_done; 94 95 /* 96 * Count and smbios struct id(s) for each smbios struct type. 97 */ 98 typedef struct smbs_con_ids { 99 id_t id; /* smbios struct id */ 100 id_t con_cnt; /* containee count */ 101 id_t con_ids[SMB_MAX_ID]; /* containee ids */ 102 id_t con_by_id; /* container id */ 103 int visited; /* visit flag */ 104 tnode_t *node; 105 } smbs_con_ids_t; 106 107 typedef struct smbs_cnt { 108 int type; /* SMBIOS stucture type */ 109 int count; /* number of table entries */ 110 smbs_con_ids_t ids[SMB_MAX_ID]; /* SMBIOS table entry id(s) */ 111 } smbs_cnt_t; 112 113 smbs_cnt_t stypes[SMB_TYPE_OEM_HI]; /* one for each struct */ 114 115 /* 116 * The enumerator needs to pass some state in to the function that walks 117 * the PRI graph. This structure contains the necessary information. 118 */ 119 struct x86pi_enum_s { 120 topo_mod_t *mod; /* Topo module handle */ 121 tnode_t *t_parent; /* "Chassis" parent */ 122 uint32_t force; /* force legacy */ 123 void *priv; /* Private data */ 124 }; 125 typedef struct x86pi_enum_s x86pi_enum_t; 126 127 /* 128 * x86gentopo hcfmri info structure. 129 * 130 * Available unformed SMBIOS strings: 131 * smbi_manufacturer 132 * smbi_product 133 * smbi_version 134 * smbi_serial 135 * smbi_asset 136 * smbi_location 137 * smbi_part 138 * 139 */ 140 struct x86pi_hcfmri_info_s { 141 int instance; 142 int rev; 143 144 const char *hc_name; 145 const char *manufacturer; 146 const char *product; 147 const char *version; 148 const char *serial_number; 149 const char *asset_tag; 150 const char *location; 151 const char *part_number; 152 }; 153 typedef struct x86pi_hcfmri_info_s x86pi_hcfmri_t; 154 155 /* 156 * Prototypes 157 */ 158 159 /* SMBIOS */ 160 smbios_hdl_t *x86pi_smb_open(topo_mod_t *); 161 void x86pi_smb_strcnt(smbios_hdl_t *, smbs_cnt_t *); 162 int x86pi_check_comp(topo_mod_t *, smbios_hdl_t *); 163 164 /* Node generation */ 165 tnode_t *x86pi_gen_chassis(topo_mod_t *, tnode_t *, smbios_hdl_t *, int, int); 166 tnode_t *x86pi_gen_bboard(topo_mod_t *, tnode_t *, smbios_hdl_t *, int, int, 167 int); 168 int x86pi_gen_cmp(topo_mod_t *, tnode_t *, smbios_hdl_t *, int, int, int); 169 int x86pi_gen_core(topo_mod_t *, tnode_t *, int, int, int); 170 int x86pi_gen_strand(topo_mod_t *, tnode_t *, int, int, int); 171 int x86pi_gen_memarray(topo_mod_t *, tnode_t *, smbios_hdl_t *, int, int); 172 void x86pi_gen_memdev(topo_mod_t *, tnode_t *, smbios_hdl_t *, int, int, int); 173 int x86pi_gen_hbr(topo_mod_t *, tnode_t *, smbios_hdl_t *, int, 174 topo_instance_t, topo_instance_t *); 175 176 /* support routines */ 177 int x86pi_enum_generic(topo_mod_t *, x86pi_hcfmri_t *, tnode_t *, tnode_t *, 178 tnode_t **, int); 179 tnode_t *x86pi_node_bind(topo_mod_t *, tnode_t *, x86pi_hcfmri_t *, nvlist_t *, 180 int); 181 void x86pi_hcfmri_info_fini(topo_mod_t *, x86pi_hcfmri_t *); 182 183 /* get/set info */ 184 char *x86pi_get_serverid(topo_mod_t *); 185 int x86pi_set_frufmri(topo_mod_t *, x86pi_hcfmri_t *, tnode_t *, tnode_t *, 186 int); 187 int x86pi_set_label(topo_mod_t *, const char *, const char *, tnode_t *); 188 int x86pi_set_auth(topo_mod_t *, x86pi_hcfmri_t *, tnode_t *, tnode_t *); 189 int x86pi_set_system(topo_mod_t *, tnode_t *); 190 191 /* hostbridge */ 192 int x86pi_hbr_enum_init(topo_mod_t *); 193 void x86pi_hbr_enum_fini(topo_mod_t *); 194 195 /* base board */ 196 id_t x86pi_bb_topparent(smbios_hdl_t *, int, tnode_t **, id_t *); 197 int x86pi_bb_contains(topo_mod_t *, smbios_hdl_t *); 198 int x86pi_bb_getchips(topo_mod_t *, smbios_hdl_t *, int, int); 199 200 const char *x86pi_cleanup_smbios_str(topo_mod_t *, const char *, int); 201 202 #ifdef __cplusplus 203 } 204 #endif 205 206 #endif /* _X86PI_IMPL_H */ 207