8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / mdb / common / kmdb / kmdb_umemglue.c
blobc2289ec7f7093f4f4c450b0d797b459fe010f7d9
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
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.
39 /*ARGSUSED*/
40 int
41 __umem_assert_failed(const char *assertion, const char *file, int line)
43 #ifdef DEBUG
44 (void) mdb_dassert(assertion, file, line);
45 /*NOTREACHED*/
46 #endif
47 return (0);
50 void
51 umem_panic(const char *format, ...)
53 va_list alist;
55 va_start(alist, format);
56 vfail(format, alist);
57 va_end(alist);
60 void
61 umem_err_recoverable(const char *format, ...)
63 va_list alist;
65 va_start(alist, format);
66 vwarn(format, alist);
67 va_end(alist);
70 int
71 umem_vsnprintf(char *s, size_t n, const char *format, va_list ap)
73 return (mdb_iob_vsnprintf(s, n, format, ap));
76 int
77 umem_snprintf(char *s, size_t n, const char *format, ...)
79 va_list ap;
80 int rc;
82 va_start(ap, format);
83 rc = umem_vsnprintf(s, n, format, ap);
84 va_end(ap);
86 return (rc);
89 /* These aren't atomic, but we're not MT, so it doesn't matter */
90 uint32_t
91 umem_atomic_add_32_nv(uint32_t *target, int32_t delta)
93 return (*target = *target + delta);
96 void
97 umem_atomic_add_64(uint64_t *target, int64_t delta)
99 *target = *target + delta;
102 uint64_t
103 umem_atomic_swap_64(volatile uint64_t *t, uint64_t v)
105 uint64_t old = *t;
106 *t = v;
107 return (old);
111 * Standalone umem must be manually initialized
113 void
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));