Exemplo n.º 1
0
/*
 * Common code to copy out the SMBIOS snapshot used for both read and mmap.
 * The caller must validate uio_offset for us since semantics differ there.
 * The copy is done in two stages, either of which can be skipped based on the
 * offset and length: first we copy the entry point, with 'staddr' recalculated
 * to indicate the offset of the data buffer, and second we copy the table.
 */
static int
smb_uiomove(smb_clone_t *cp, uio_t *uio)
{
	off_t off = uio->uio_offset;
	size_t len = uio->uio_resid;
	int err = 0;

	if (off + len > cp->c_eplen + cp->c_stlen)
		len = cp->c_eplen + cp->c_stlen - off;

	if (off < cp->c_eplen) {
		smbios_entry_t *ep = kmem_zalloc(cp->c_eplen, KM_SLEEP);
		size_t eprlen = MIN(len, cp->c_eplen - off);

		smbios_info_smbios(cp->c_hdl, ep);
		ep->smbe_staddr = (uint32_t)cp->c_eplen;
		smbios_checksum(cp->c_hdl, ep);

		err = uiomove((char *)ep + off, eprlen, UIO_READ, uio);
		kmem_free(ep, cp->c_eplen);

		off += eprlen;
		len -= eprlen;
	}

	if (err == 0 && off >= cp->c_eplen) {
		char *buf = (char *)smbios_buf(cp->c_hdl);
		size_t bufoff = off - cp->c_eplen;

		err = uiomove(buf + bufoff,
		    MIN(len, cp->c_stlen - bufoff), UIO_READ, uio);
	}

	return (err);
}
Exemplo n.º 2
0
static void
print_smbios(smbios_hdl_t *shp, FILE *fp)
{
	smbios_entry_t ep;
	int i;

	smbios_info_smbios(shp, &ep);

	oprintf(fp, "Entry Point Anchor Tag: %*.*s\n",
	    (int)sizeof (ep.smbe_eanchor), (int)sizeof (ep.smbe_eanchor),
	    ep.smbe_eanchor);

	oprintf(fp, "Entry Point Checksum: 0x%x\n", ep.smbe_ecksum);
	oprintf(fp, "Entry Point Length: %u\n", ep.smbe_elen);
	oprintf(fp, "Entry Point Version: %u.%u\n",
	    ep.smbe_major, ep.smbe_minor);
	oprintf(fp, "Max Structure Size: %u\n", ep.smbe_maxssize);
	oprintf(fp, "Entry Point Revision: 0x%x\n", ep.smbe_revision);

	oprintf(fp, "Entry Point Revision Data:");
	for (i = 0; i < sizeof (ep.smbe_format); i++)
		oprintf(fp, " 0x%02x", ep.smbe_format[i]);
	oprintf(fp, "\n");

	oprintf(fp, "Intermediate Anchor Tag: %*.*s\n",
	    (int)sizeof (ep.smbe_ianchor), (int)sizeof (ep.smbe_ianchor),
	    ep.smbe_ianchor);

	oprintf(fp, "Intermediate Checksum: 0x%x\n", ep.smbe_icksum);
	oprintf(fp, "Structure Table Length: %u\n", ep.smbe_stlen);
	oprintf(fp, "Structure Table Address: 0x%x\n", ep.smbe_staddr);
	oprintf(fp, "Structure Table Entries: %u\n", ep.smbe_stnum);
	oprintf(fp, "DMI BCD Revision: 0x%x\n", ep.smbe_bcdrev);
}
Exemplo n.º 3
0
static void
print_slot(smbios_hdl_t *shp, id_t id, FILE *fp)
{
	smbios_slot_t s;
	smbios_entry_t e;

	(void) smbios_info_slot(shp, id, &s);
	(void) smbios_info_smbios(shp, &e);

	oprintf(fp, "  Reference Designator: %s\n", s.smbl_name);
	oprintf(fp, "  Slot ID: 0x%x\n", s.smbl_id);

	desc_printf(smbios_slot_type_desc(s.smbl_type),
	    fp, "  Type: 0x%x", s.smbl_type);

	desc_printf(smbios_slot_width_desc(s.smbl_width),
	    fp, "  Width: 0x%x", s.smbl_width);

	desc_printf(smbios_slot_usage_desc(s.smbl_usage),
	    fp, "  Usage: 0x%x", s.smbl_usage);

	desc_printf(smbios_slot_length_desc(s.smbl_length),
	    fp, "  Length: 0x%x", s.smbl_length);

	flag_printf(fp, "Slot Characteristics 1",
	    s.smbl_ch1, sizeof (s.smbl_ch1) * NBBY,
	    smbios_slot_ch1_name, smbios_slot_ch1_desc);

	flag_printf(fp, "Slot Characteristics 2",
	    s.smbl_ch2, sizeof (s.smbl_ch2) * NBBY,
	    smbios_slot_ch2_name, smbios_slot_ch2_desc);

	if (check_oem(shp) != 0 && (e.smbe_major < 2 || e.smbe_minor < 6))
		return;

	oprintf(fp, "  Segment Group: %u\n", s.smbl_sg);
	oprintf(fp, "  Bus Number: %u\n", s.smbl_bus);
	oprintf(fp, "  Device/Function Number: %u\n", s.smbl_df);
}