4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #include <mdb/mdb_debug.h>
28 #include <mdb/mdb_err.h>
29 #include <mdb/mdb_io.h>
31 #define UMEM_STANDALONE
32 #include <umem_impl.h>
35 * The standalone umem requires that kmdb provide some error-handling
36 * services. These are them.
41 __umem_assert_failed(const char *assertion
, const char *file
, int line
)
44 (void) mdb_dassert(assertion
, file
, line
);
51 umem_panic(const char *format
, ...)
55 va_start(alist
, format
);
61 umem_err_recoverable(const char *format
, ...)
65 va_start(alist
, format
);
71 umem_vsnprintf(char *s
, size_t n
, const char *format
, va_list ap
)
73 return (mdb_iob_vsnprintf(s
, n
, format
, ap
));
77 umem_snprintf(char *s
, size_t n
, const char *format
, ...)
83 rc
= umem_vsnprintf(s
, n
, format
, ap
);
89 /* These aren't atomic, but we're not MT, so it doesn't matter */
91 umem_atomic_add_32_nv(uint32_t *target
, int32_t delta
)
93 return (*target
= *target
+ delta
);
97 umem_atomic_add_64(uint64_t *target
, int64_t delta
)
99 *target
= *target
+ delta
;
103 umem_atomic_swap_64(volatile uint64_t *t
, uint64_t v
)
111 * Standalone umem must be manually initialized
114 mdb_umem_startup(caddr_t base
, size_t len
, size_t pgsize
)
116 umem_startup(base
, len
, pgsize
, base
, base
+ len
);
120 * The kernel will tell us when there's more memory available for us to use.
121 * This is most common on amd64, which boots with only 4G of VA available, and
122 * later expands to the full 64-bit address space.
125 mdb_umem_add(caddr_t base
, size_t len
)
127 return (umem_add(base
, len
));