1 // SPDX-License-Identifier: CDDL-1.0
2 /*
3 * CDDL HEADER START
4 *
5 * The contents of this file are subject to the terms of the
6 * Common Development and Distribution License (the "License").
7 * You may not use this file except in compliance with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or https://opensource.org/licenses/CDDL-1.0.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright (c) 2012, 2018 by Delphix. All rights reserved.
25 * Copyright (c) 2016 Actifio, Inc. All rights reserved.
26 * Copyright (c) 2025, Klara, Inc.
27 * Copyright (c) 2025, Rob Norris <robn@despairlabs.com>
28 */
29
30 #include <libspl.h>
31 #include <assert.h>
32 #include <unistd.h>
33 #include <sys/misc.h>
34 #include <sys/systm.h>
35 #include <sys/utsname.h>
36 #include "libspl_impl.h"
37
38 static uint64_t hw_physmem = 0;
39 static struct utsname hw_utsname = {};
40
41 uint64_t
libspl_physmem(void)42 libspl_physmem(void)
43 {
44 return (hw_physmem);
45 }
46
47 utsname_t *
utsname(void)48 utsname(void)
49 {
50 return (&hw_utsname);
51 }
52
53 void
libspl_init(void)54 libspl_init(void)
55 {
56 hw_physmem = sysconf(_SC_PHYS_PAGES);
57
58 VERIFY0(uname(&hw_utsname));
59
60 random_init();
61 }
62
63 void
libspl_fini(void)64 libspl_fini(void)
65 {
66 random_fini();
67 }
68