Lines Matching refs:shp

45 smb_strip(smbios_hdl_t *shp)
49 for (i = 0; i < shp->sh_nstructs; i++) {
50 const smb_header_t *hp = shp->sh_structs[i].smbst_hdr;
66 if (smbios_info_common(shp, hp->smbh_hdl, &info) != SMB_ERR) {
79 smbios_hdl_t *shp = smb_zalloc(sizeof (smbios_hdl_t));
94 return (smb_open_error(shp, errp, ESMB_VERSION));
98 return (smb_open_error(shp, errp, ESMB_INVAL));
100 if (shp == NULL)
101 return (smb_open_error(shp, errp, ESMB_NOMEM));
104 shp->sh_flags |= SMB_FL_DEBUG;
107 return (smb_open_error(shp, errp, ESMB_HEADER));
110 return (smb_open_error(shp, errp, ESMB_HEADER));
112 smb_dprintf(shp, "opening SMBIOS version %u.%u bcdrev 0x%x\n",
117 return (smb_open_error(shp, errp, ESMB_NEW));
122 return (smb_open_error(shp, errp, ESMB_OLD));
127 return (smb_open_error(shp, errp, ESMB_SHORT));
140 smb_dprintf(shp, "bad cksum: e=%x i=%x\n", esum, isum);
141 return (smb_open_error(shp, errp, ESMB_CKSUM));
150 bcopy(ep, &shp->sh_ent, sizeof (smbios_entry_t));
151 shp->sh_ent.smbe_elen = sizeof (smbios_entry_t);
152 smbios_checksum(shp, &shp->sh_ent);
154 shp->sh_buf = buf;
155 shp->sh_buflen = len;
156 shp->sh_structs = smb_alloc(sizeof (smb_struct_t) * ep->smbe_stnum);
157 shp->sh_nstructs = 0;
158 shp->sh_hashlen = _smb_hashlen;
159 shp->sh_hash = smb_zalloc(sizeof (smb_struct_t *) * shp->sh_hashlen);
160 shp->sh_libvers = version;
161 shp->sh_smbvers = SMB_MAJMIN(ep->smbe_major, ep->smbe_minor);
163 if (shp->sh_structs == NULL || shp->sh_hash == NULL)
164 return (smb_open_error(shp, errp, ESMB_NOMEM));
166 hp = shp->sh_buf;
170 smb_struct_t *stp = &shp->sh_structs[i];
174 shp->sh_flags |= SMB_FL_TRUNC;
178 smb_dprintf(shp, "struct [%u] type %u len %u hdl %u at %p\n",
185 shp->sh_flags |= SMB_FL_TRUNC;
189 h = hp->smbh_hdl & (shp->sh_hashlen - 1);
198 shp->sh_flags |= SMB_FL_TRUNC;
208 stp->smbst_next = shp->sh_hash[h];
213 return (smb_open_error(shp, errp, ESMB_NOMEM));
215 shp->sh_hash[h] = stp;
217 shp->sh_nstructs++;
229 if ((shp->sh_flags & SMB_FL_TRUNC) && i == 0)
230 return (smb_open_error(shp, errp, ESMB_CORRUPT));
233 smb_strip(shp);
235 return (shp);
239 smbios_close(smbios_hdl_t *shp)
241 const smbios_entry_t *ep = &shp->sh_ent;
244 for (i = 0; i < shp->sh_nstructs; i++) {
245 smb_free(shp->sh_structs[i].smbst_strtab,
246 sizeof (uint16_t) * shp->sh_structs[i].smbst_strtablen);
249 smb_free(shp->sh_structs, sizeof (smb_struct_t) * ep->smbe_stnum);
250 smb_free(shp->sh_hash, sizeof (smb_struct_t *) * shp->sh_hashlen);
252 if (shp->sh_flags & SMB_FL_BUFALLOC)
253 smb_free((void *)shp->sh_buf, shp->sh_buflen);
255 smb_free(shp, sizeof (smbios_hdl_t));
260 * of the specified SMBIOS entry point. We don't need 'shp' but require it
265 smbios_checksum(smbios_hdl_t *shp, smbios_entry_t *ep)
284 smbios_buf(smbios_hdl_t *shp)
286 return (shp->sh_buf);
290 smbios_buflen(smbios_hdl_t *shp)
292 return (shp->sh_buflen);
309 smbios_lookup_id(smbios_hdl_t *shp, id_t id, smbios_struct_t *sp)
311 const smb_struct_t *stp = smb_lookup_id(shp, id);
323 smbios_lookup_type(smbios_hdl_t *shp, uint_t type, smbios_struct_t *sp)
325 const smb_struct_t *stp = smb_lookup_type(shp, type);
337 smbios_iter(smbios_hdl_t *shp, smbios_struct_f *func, void *data)
339 const smb_struct_t *sp = shp->sh_structs;
343 for (i = 0; i < shp->sh_nstructs; i++, sp++) {
345 (rv = func(shp, smb_export(sp, &s), data)) != 0)
353 smb_lookup_type(smbios_hdl_t *shp, uint_t type)
357 for (i = 0; i < shp->sh_nstructs; i++) {
358 if (shp->sh_structs[i].smbst_hdr->smbh_type == type)
359 return (&shp->sh_structs[i]);
362 (void) smb_set_errno(shp, ESMB_NOENT);
367 smb_lookup_id(smbios_hdl_t *shp, uint_t id)
369 const smb_struct_t *stp = shp->sh_hash[id & (shp->sh_hashlen - 1)];
373 (void) smb_set_errno(shp, ESMB_NOTSUP);
376 (void) smb_set_errno(shp, ESMB_NOENT);
386 (void) smb_set_errno(shp, ESMB_NOENT);
401 smb_gteq(smbios_hdl_t *shp, int version)
403 return (SMB_MAJOR(shp->sh_smbvers) > SMB_MAJOR(version) || (
404 SMB_MAJOR(shp->sh_smbvers) == SMB_MAJOR(version) &&
405 SMB_MINOR(shp->sh_smbvers) >= SMB_MINOR(version)));
409 smbios_truncated(smbios_hdl_t *shp)
411 return ((shp->sh_flags & SMB_FL_TRUNC) != 0);