smbios.c revision 84ab085a13f931bc78e7415e7ce921dbaa14fcb3
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* smbios(7D) driver
*
* This pseudo-driver makes available a snapshot of the system's SMBIOS image
* that can be accessed using libsmbios. Clients may access a snapshot using
* either read(2) or mmap(2). The driver returns the SMBIOS entry point data
* followed by the SMBIOS structure table. The entry point has its 'staddr'
* field set to indicate the byte offset of the structure table. The driver
*
* At present, the kernel takes a single snapshot of SMBIOS at boot time and
* stores a handle for this snapshot in 'ksmbios'. To keep track of driver
* opens, we simply compare-and-swap this handle into an 'smb_clones' array.
* Future x86 systems may need to support dynamic SMBIOS updates: when that
* happens the SMBIOS API can be extended to support reference counting and
* handles for different snapshots can be stored in smb_clones[].
*/
#include <sys/sysmacros.h>
typedef struct smb_clone {
} smb_clone_t;
static dev_info_t *smb_devi;
static smb_clone_t *smb_clones;
static int smb_nclones;
/*ARGSUSED*/
static int
{
minor_t c;
return (ENXIO);
/*
* Locate and reserve a clone structure. We skip clone 0 as that is
* the real minor number, and we assign a new minor to each clone.
*/
for (c = 1; c < smb_nclones; c++) {
break;
}
if (c >= smb_nclones)
return (EAGAIN);
return (0);
}
/*ARGSUSED*/
static int
{
return (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
{
int err = 0;
}
}
return (err);
}
/*ARGSUSED*/
static int
{
if (uio->uio_offset < 0 ||
return (0);
}
/*ARGSUSED*/
static int
{
int err;
return (EINVAL);
return (EACCES);
return (ENXIO);
else
if (err != 0)
return (err);
return (err);
}
/*ARGSUSED*/
static int
{
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
return (DDI_SUCCESS);
case DDI_INFO_DEVT2INSTANCE:
*result = 0;
return (DDI_SUCCESS);
}
return (DDI_FAILURE);
}
static int
{
if (cmd != DDI_ATTACH)
return (DDI_FAILURE);
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
static int
{
if (cmd != DDI_DETACH)
return (DDI_FAILURE);
return (DDI_SUCCESS);
}
static struct cb_ops smb_cb_ops = {
smb_open, /* open */
smb_close, /* close */
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
smb_read, /* read */
nodev, /* write */
nodev, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
smb_segmap, /* segmap */
nochpoll, /* poll */
ddi_prop_op, /* prop_op */
NULL, /* streamtab */
};
DEVO_REV, /* rev */
0, /* refcnt */
smb_info, /* info */
nulldev, /* identify */
nulldev, /* probe */
smb_attach, /* attach */
smb_detach, /* detach */
nodev, /* reset */
&smb_cb_ops, /* cb ops */
NULL /* bus ops */
};
};
static struct modlinkage modlinkage = {
};
int
_init(void)
{
int err;
if (smb_nclones <= 0)
return (err);
}
int
_fini(void)
{
int err;
return (err);
}
int
{
}