355b4669e025ff377602b6fc7caaf30dbc218371jacobs/*
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * CDDL HEADER START
355b4669e025ff377602b6fc7caaf30dbc218371jacobs *
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * The contents of this file are subject to the terms of the
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * Common Development and Distribution License, Version 1.0 only
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * (the "License"). You may not use this file except in compliance
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * with the License.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs *
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * or http://www.opensolaris.org/os/licensing.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * See the License for the specific language governing permissions
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * and limitations under the License.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs *
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * When distributing Covered Code, include this CDDL HEADER in each
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * If applicable, add the following below this CDDL HEADER, with the
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * fields enclosed by brackets "[]" replaced with your own identifying
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * information: Portions Copyright [yyyy] [name of copyright owner]
355b4669e025ff377602b6fc7caaf30dbc218371jacobs *
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * CDDL HEADER END
355b4669e025ff377602b6fc7caaf30dbc218371jacobs */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs/*
4bd2082ff2d009263265d7de938de336894b6009ceastha * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * Use is subject to license terms.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs#pragma ident "%Z%%M% %I% %E% SMI"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs#include <ctf_impl.h>
355b4669e025ff377602b6fc7caaf30dbc218371jacobs#include <sys/kobj.h>
355b4669e025ff377602b6fc7caaf30dbc218371jacobs#include <sys/kobj_impl.h>
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs/*
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * This module is used both during the normal operation of the kernel (i.e.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * after kmem has been initialized) and during boot (before unix`_start has
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * been called). kobj_alloc is able to tell the difference between the two
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * cases, and as such must be used instead of kmem_alloc.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobsvoid *
355b4669e025ff377602b6fc7caaf30dbc218371jacobsctf_data_alloc(size_t size)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs{
355b4669e025ff377602b6fc7caaf30dbc218371jacobs void *buf = kobj_alloc(size, KM_NOWAIT|KM_SCRATCH);
752ec50eb29a9f48e3047116b6c8ceb8dedaefb3jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (buf == NULL)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs return (MAP_FAILED);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs return (buf);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs}
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobsvoid
355b4669e025ff377602b6fc7caaf30dbc218371jacobsctf_data_free(void *buf, size_t size)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs{
4bd2082ff2d009263265d7de938de336894b6009ceastha kobj_free(buf, size);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs}
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs/*ARGSUSED*/
355b4669e025ff377602b6fc7caaf30dbc218371jacobsvoid
355b4669e025ff377602b6fc7caaf30dbc218371jacobsctf_data_protect(void *buf, size_t size)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs{
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* we don't support this operation in the kernel */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs}
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobsvoid *
355b4669e025ff377602b6fc7caaf30dbc218371jacobsctf_alloc(size_t size)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs{
355b4669e025ff377602b6fc7caaf30dbc218371jacobs return (kobj_alloc(size, KM_NOWAIT|KM_TMP));
355b4669e025ff377602b6fc7caaf30dbc218371jacobs}
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs/*ARGSUSED*/
355b4669e025ff377602b6fc7caaf30dbc218371jacobsvoid
355b4669e025ff377602b6fc7caaf30dbc218371jacobsctf_free(void *buf, size_t size)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs{
355b4669e025ff377602b6fc7caaf30dbc218371jacobs kobj_free(buf, size);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs}
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs/*ARGSUSED*/
355b4669e025ff377602b6fc7caaf30dbc218371jacobsconst char *
355b4669e025ff377602b6fc7caaf30dbc218371jacobsctf_strerror(int err)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs{
355b4669e025ff377602b6fc7caaf30dbc218371jacobs return (NULL); /* we don't support this operation in the kernel */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs}
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs/*PRINTFLIKE1*/
4bd2082ff2d009263265d7de938de336894b6009ceasthavoid
355b4669e025ff377602b6fc7caaf30dbc218371jacobsctf_dprintf(const char *format, ...)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs{
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (_libctf_debug) {
355b4669e025ff377602b6fc7caaf30dbc218371jacobs va_list alist;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs va_start(alist, format);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs (void) printf("ctf DEBUG: ");
355b4669e025ff377602b6fc7caaf30dbc218371jacobs (void) vprintf(format, alist);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs va_end(alist);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs }
355b4669e025ff377602b6fc7caaf30dbc218371jacobs}
355b4669e025ff377602b6fc7caaf30dbc218371jacobs