ksyms.c revision 60946fe0e0cab23f683e9de92451aa45b7913135
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*/
#include <sys/sysmacros.h>
#include <sys/compress.h>
typedef struct ksyms_image {
typedef struct ksyms_buflist {
char buf[1];
typedef struct ksyms_buflist_hdr {
int nchunks;
int nksyms_clones; /* tunable: max clones of this device */
static dev_info_t *ksyms_devi;
static void
{
return;
while (rsize) {
hptr->curbuf_off = 0;
break;
}
}
}
static void
{
}
}
/*
* Allocate 'size'(rounded to BUF_SIZE) bytes in chunks of BUF_SIZE, and
* add it to the buf list.
* Returns the total size rounded to BUF_SIZE.
*/
static size_t
{
int chunks, i;
/*
* Allocate chunks - hdr->nchunks buffers and add them to
* the list.
*/
break;
}
/*
* If we are running short of memory, free memory allocated till now
* and return.
*/
if (i > 0) {
return (0);
}
hdr->curbuf_off = 0;
}
/*
* rlen is in multiples of PAGESIZE
*/
static char *
{
return (NULL);
}
return (addr);
}
static char *
{
return (NULL);
return (NULL);
}
}
return (addr);
}
/*
* Copy a snapshot of the kernel symbol table into the user's address space.
* The symbol table is copied in fragments so that we do not have to
* fragmented.
*/
/* ARGSUSED */
static int
{
char *addr;
for (;;) {
break;
if (size == 0)
return (ENOMEM);
}
return (EOVERFLOW);
/*
* Reserve a clone entry. Note that we don't use clone 0
* since that's the "real" minor number.
*/
"size", realsize);
return (0);
}
}
return (ENXIO);
}
/* ARGSUSED */
static int
{
return (0);
}
static int
{
char *buf;
int error = 0;
/*
* The symbol table is stored in the user address space,
* so we have to copy it into the kernel first,
* then copy it back out to the specified user address.
*/
while (len) {
else
if (error)
break;
}
return (error);
}
/* ARGSUSED */
static int
{
return (EFAULT);
if (len == 0)
return (0);
}
/* ARGSUSED */
static int
{
int error = 0;
return (ENOTSUP);
return (EINVAL);
return (EOVERFLOW);
if (error)
else
return (error);
}
/* ARGSUSED */
static int
{
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
*result = ksyms_devi;
return (DDI_SUCCESS);
case DDI_INFO_DEVT2INSTANCE:
*result = 0;
return (DDI_SUCCESS);
}
return (DDI_FAILURE);
}
static int
{
if (cmd != DDI_ATTACH)
return (DDI_FAILURE);
== DDI_FAILURE) {
return (DDI_FAILURE);
}
ksyms_devi = devi;
return (DDI_SUCCESS);
}
static int
{
if (cmd != DDI_DETACH)
return (DDI_FAILURE);
return (DDI_SUCCESS);
}
static struct cb_ops ksyms_cb_ops = {
ksyms_open, /* open */
ksyms_close, /* close */
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
ksyms_read, /* read */
nodev, /* write */
nodev, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
ksyms_segmap, /* segmap */
nochpoll, /* poll */
ddi_prop_op, /* prop_op */
0, /* streamtab */
};
DEVO_REV, /* devo_rev, */
0, /* refcnt */
ksyms_info, /* info */
nulldev, /* identify */
nulldev, /* probe */
ksyms_attach, /* attach */
ksyms_detach, /* detach */
nodev, /* reset */
&ksyms_cb_ops, /* driver operations */
(struct bus_ops *)0 /* no bus operations */
};
};
static struct modlinkage modlinkage = {
};
int
_init(void)
{
int error;
if (nksyms_clones == 0)
sizeof (ksyms_image_t), KM_SLEEP);
return (error);
}
int
_fini(void)
{
int error;
return (error);
}
int
{
}