Lines Matching defs: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) {
76 smbios_bufopen_21(smbios_hdl_t *shp, const smbios_21_entry_t *ep, size_t len,
85 smb_dprintf(shp, "opening SMBIOS version %u.%u bcdrev 0x%x\n",
114 smb_dprintf(shp, "bad cksum: e=%x i=%x\n", esum, isum);
124 shp->sh_ent_type = SMBIOS_ENTRY_POINT_21;
125 bcopy(ep, &shp->sh_ent, sizeof (smbios_entry_t));
126 shp->sh_ent.ep21.smbe_elen = sizeof (smbios_entry_t);
127 smbios_checksum(shp, &shp->sh_ent);
129 shp->sh_ent_stnum = ep->smbe_stnum;
130 shp->sh_smbvers = SMB_MAJMIN(ep->smbe_major, ep->smbe_minor);
135 smbios_bufopen_30(smbios_hdl_t *shp, const smbios_30_entry_t *ep, size_t len,
142 smb_dprintf(shp, "opening SMBIOS version %u.%u\n",
168 smb_dprintf(shp, "bad cksum: e=%x\n", esum);
178 shp->sh_ent_type = SMBIOS_ENTRY_POINT_30;
179 bcopy(ep, &shp->sh_ent, sizeof (smbios_entry_t));
180 shp->sh_ent.ep30.smbe_elen = sizeof (smbios_entry_t);
181 smbios_checksum(shp, &shp->sh_ent);
183 shp->sh_smbvers = SMB_MAJMIN(ep->smbe_major, ep->smbe_minor);
217 smbios_hdl_t *shp = smb_zalloc(sizeof (smbios_hdl_t));
235 return (smb_open_error(shp, errp, ESMB_VERSION));
239 return (smb_open_error(shp, errp, ESMB_INVAL));
241 if (shp == NULL)
242 return (smb_open_error(shp, errp, ESMB_NOMEM));
245 shp->sh_flags |= SMB_FL_DEBUG;
247 err = smbios_bufopen_21(shp, &ep->ep21, len, flags);
249 err = smbios_bufopen_30(shp, &ep->ep30, len, flags);
251 return (smb_open_error(shp, errp, err));
252 shp->sh_ent_stnum =
256 shp->sh_buf = buf;
257 shp->sh_buflen = len;
258 shp->sh_structs = smb_alloc(sizeof (smb_struct_t) * shp->sh_ent_stnum);
259 shp->sh_nstructs = 0;
260 shp->sh_hashlen = _smb_hashlen;
261 shp->sh_hash = smb_zalloc(sizeof (smb_struct_t *) * shp->sh_hashlen);
262 shp->sh_libvers = version;
264 if (shp->sh_structs == NULL || shp->sh_hash == NULL)
265 return (smb_open_error(shp, errp, ESMB_NOMEM));
267 hp = shp->sh_buf;
268 switch (shp->sh_ent_type) {
276 return (smb_open_error(shp, errp, ESMB_VERSION));
279 for (i = 0; i < shp->sh_ent_stnum; i++, hp = nhp) {
280 smb_struct_t *stp = &shp->sh_structs[i];
284 shp->sh_flags |= SMB_FL_TRUNC;
288 smb_dprintf(shp, "struct [%u] type %u len %u hdl %u at %p\n",
295 shp->sh_flags |= SMB_FL_TRUNC;
299 h = hp->smbh_hdl & (shp->sh_hashlen - 1);
308 shp->sh_flags |= SMB_FL_TRUNC;
318 stp->smbst_next = shp->sh_hash[h];
323 return (smb_open_error(shp, errp, ESMB_NOMEM));
325 shp->sh_hash[h] = stp;
327 shp->sh_nstructs++;
339 if ((shp->sh_flags & SMB_FL_TRUNC) && i == 0)
340 return (smb_open_error(shp, errp, ESMB_CORRUPT));
343 smb_strip(shp);
345 return (shp);
349 smbios_close(smbios_hdl_t *shp)
353 for (i = 0; i < shp->sh_nstructs; i++) {
354 smb_free(shp->sh_structs[i].smbst_strtab,
355 sizeof (uint16_t) * shp->sh_structs[i].smbst_strtablen);
358 smb_free(shp->sh_structs, sizeof (smb_struct_t) * shp->sh_ent_stnum);
359 smb_free(shp->sh_hash, sizeof (smb_struct_t *) * shp->sh_hashlen);
361 if (shp->sh_flags & SMB_FL_BUFALLOC)
362 smb_free((void *)shp->sh_buf, shp->sh_buflen);
364 smb_free(shp, sizeof (smbios_hdl_t));
369 * of the specified SMBIOS entry point. We don't need 'shp' but require it
374 smbios_checksum(smbios_hdl_t *shp, smbios_entry_t *ep)
379 switch (shp->sh_ent_type) {
408 smbios_buf(smbios_hdl_t *shp)
410 return (shp->sh_buf);
414 smbios_buflen(smbios_hdl_t *shp)
416 return (shp->sh_buflen);
433 smbios_lookup_id(smbios_hdl_t *shp, id_t id, smbios_struct_t *sp)
435 const smb_struct_t *stp = smb_lookup_id(shp, id);
447 smbios_lookup_type(smbios_hdl_t *shp, uint_t type, smbios_struct_t *sp)
449 const smb_struct_t *stp = smb_lookup_type(shp, type);
461 smbios_iter(smbios_hdl_t *shp, smbios_struct_f *func, void *data)
463 const smb_struct_t *sp = shp->sh_structs;
467 for (i = 0; i < shp->sh_nstructs; i++, sp++) {
469 (rv = func(shp, smb_export(sp, &s), data)) != 0)
477 smb_lookup_type(smbios_hdl_t *shp, uint_t type)
481 for (i = 0; i < shp->sh_nstructs; i++) {
482 if (shp->sh_structs[i].smbst_hdr->smbh_type == type)
483 return (&shp->sh_structs[i]);
486 (void) smb_set_errno(shp, ESMB_NOENT);
491 smb_lookup_id(smbios_hdl_t *shp, uint_t id)
493 const smb_struct_t *stp = shp->sh_hash[id & (shp->sh_hashlen - 1)];
497 (void) smb_set_errno(shp, ESMB_NOTSUP);
500 (void) smb_set_errno(shp, ESMB_NOENT);
510 (void) smb_set_errno(shp, ESMB_NOENT);
525 smb_libgteq(smbios_hdl_t *shp, int version)
527 return (SMB_MAJOR(shp->sh_libvers) > SMB_MAJOR(version) || (
528 SMB_MAJOR(shp->sh_libvers) == SMB_MAJOR(version) &&
529 SMB_MINOR(shp->sh_libvers) >= SMB_MINOR(version)));
533 smb_gteq(smbios_hdl_t *shp, int version)
535 return (SMB_MAJOR(shp->sh_smbvers) > SMB_MAJOR(version) || (
536 SMB_MAJOR(shp->sh_smbvers) == SMB_MAJOR(version) &&
537 SMB_MINOR(shp->sh_smbvers) >= SMB_MINOR(version)));
541 smbios_truncated(smbios_hdl_t *shp)
543 return ((shp->sh_flags & SMB_FL_TRUNC) != 0);