Path: blob/main/sys/cddl/contrib/opensolaris/uts/common/ctf/ctf_subr.c
96395 views
/*1* CDDL HEADER START2*3* The contents of this file are subject to the terms of the4* Common Development and Distribution License, Version 1.0 only5* (the "License"). You may not use this file except in compliance6* with the License.7*8* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE9* or http://www.opensolaris.org/os/licensing.10* See the License for the specific language governing permissions11* and limitations under the License.12*13* When distributing Covered Code, include this CDDL HEADER in each14* file and include the License file at usr/src/OPENSOLARIS.LICENSE.15* If applicable, add the following below this CDDL HEADER, with the16* fields enclosed by brackets "[]" replaced with your own identifying17* information: Portions Copyright [yyyy] [name of copyright owner]18*19* CDDL HEADER END20*/21/*22* Copyright 2004 Sun Microsystems, Inc. All rights reserved.23* Use is subject to license terms.24*/2526#pragma ident "%Z%%M% %I% %E% SMI"2728#include <ctf_impl.h>29#include <sys/kobj.h>30#include <sys/kobj_impl.h>3132/*33* This module is used both during the normal operation of the kernel (i.e.34* after kmem has been initialized) and during boot (before unix`_start has35* been called). kobj_alloc is able to tell the difference between the two36* cases, and as such must be used instead of kmem_alloc.37*/3839void *40ctf_data_alloc(size_t size)41{42void *buf = kobj_alloc(size, KM_NOWAIT|KM_SCRATCH);4344if (buf == NULL)45return (MAP_FAILED);4647return (buf);48}4950void51ctf_data_free(void *buf, size_t size)52{53kobj_free(buf, size);54}5556/*ARGSUSED*/57void58ctf_data_protect(void *buf, size_t size)59{60/* we don't support this operation in the kernel */61}6263void *64ctf_alloc(size_t size)65{66return (kobj_alloc(size, KM_NOWAIT|KM_TMP));67}6869/*ARGSUSED*/70void71ctf_free(void *buf, size_t size)72{73kobj_free(buf, size);74}7576/*ARGSUSED*/77const char *78ctf_strerror(int err)79{80return (NULL); /* we don't support this operation in the kernel */81}8283/*PRINTFLIKE1*/84void85ctf_dprintf(const char *format, ...)86{87if (_libctf_debug) {88va_list alist;8990va_start(alist, format);91(void) printf("ctf DEBUG: ");92(void) vprintf(format, alist);93va_end(alist);94}95}969798