1179193Sjb/* 2179193Sjb * CDDL HEADER START 3179193Sjb * 4179193Sjb * The contents of this file are subject to the terms of the 5179193Sjb * Common Development and Distribution License, Version 1.0 only 6179193Sjb * (the "License"). You may not use this file except in compliance 7179193Sjb * with the License. 8179193Sjb * 9179193Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10179193Sjb * or http://www.opensolaris.org/os/licensing. 11179193Sjb * See the License for the specific language governing permissions 12179193Sjb * and limitations under the License. 13179193Sjb * 14179193Sjb * When distributing Covered Code, include this CDDL HEADER in each 15179193Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16179193Sjb * If applicable, add the following below this CDDL HEADER, with the 17179193Sjb * fields enclosed by brackets "[]" replaced with your own identifying 18179193Sjb * information: Portions Copyright [yyyy] [name of copyright owner] 19179193Sjb * 20179193Sjb * CDDL HEADER END 21179193Sjb */ 22179193Sjb/* 23179193Sjb * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24179193Sjb * Use is subject to license terms. 25179193Sjb */ 26179193Sjb 27179193Sjb#pragma ident "%Z%%M% %I% %E% SMI" 28179193Sjb 29179193Sjb#include <ctf_impl.h> 30179193Sjb#include <sys/kobj.h> 31179193Sjb#include <sys/kobj_impl.h> 32179193Sjb 33179193Sjb/* 34179193Sjb * This module is used both during the normal operation of the kernel (i.e. 35179193Sjb * after kmem has been initialized) and during boot (before unix`_start has 36179193Sjb * been called). kobj_alloc is able to tell the difference between the two 37179193Sjb * cases, and as such must be used instead of kmem_alloc. 38179193Sjb */ 39179193Sjb 40179193Sjbvoid * 41179193Sjbctf_data_alloc(size_t size) 42179193Sjb{ 43179193Sjb void *buf = kobj_alloc(size, KM_NOWAIT|KM_SCRATCH); 44179193Sjb 45179193Sjb if (buf == NULL) 46179193Sjb return (MAP_FAILED); 47179193Sjb 48179193Sjb return (buf); 49179193Sjb} 50179193Sjb 51179193Sjbvoid 52179193Sjbctf_data_free(void *buf, size_t size) 53179193Sjb{ 54179193Sjb kobj_free(buf, size); 55179193Sjb} 56179193Sjb 57179193Sjb/*ARGSUSED*/ 58179193Sjbvoid 59179193Sjbctf_data_protect(void *buf, size_t size) 60179193Sjb{ 61179193Sjb /* we don't support this operation in the kernel */ 62179193Sjb} 63179193Sjb 64179193Sjbvoid * 65179193Sjbctf_alloc(size_t size) 66179193Sjb{ 67179193Sjb return (kobj_alloc(size, KM_NOWAIT|KM_TMP)); 68179193Sjb} 69179193Sjb 70179193Sjb/*ARGSUSED*/ 71179193Sjbvoid 72179193Sjbctf_free(void *buf, size_t size) 73179193Sjb{ 74179193Sjb kobj_free(buf, size); 75179193Sjb} 76179193Sjb 77179193Sjb/*ARGSUSED*/ 78179193Sjbconst char * 79179193Sjbctf_strerror(int err) 80179193Sjb{ 81179193Sjb return (NULL); /* we don't support this operation in the kernel */ 82179193Sjb} 83179193Sjb 84179193Sjb/*PRINTFLIKE1*/ 85179193Sjbvoid 86179193Sjbctf_dprintf(const char *format, ...) 87179193Sjb{ 88179193Sjb if (_libctf_debug) { 89179193Sjb va_list alist; 90179193Sjb 91179193Sjb va_start(alist, format); 92179193Sjb (void) printf("ctf DEBUG: "); 93179193Sjb (void) vprintf(format, alist); 94179193Sjb va_end(alist); 95179193Sjb } 96179193Sjb} 97