17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5fea9cb91Slq150181 * Common Development and Distribution License (the "License"). 6fea9cb91Slq150181 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21fea9cb91Slq150181 227c478bd9Sstevel@tonic-gate /* 23361ed64aSJames Anderson * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*e373b6e4SYuri Pankov * Copyright 2016 Nexenta Systems, Inc. 267c478bd9Sstevel@tonic-gate */ 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate /* 297c478bd9Sstevel@tonic-gate * The intent of this file is to contain any data that must remain 307c478bd9Sstevel@tonic-gate * resident in the kernel. 317c478bd9Sstevel@tonic-gate * 327c478bd9Sstevel@tonic-gate * space_store(), space_fetch(), and space_free() have been added to 337c478bd9Sstevel@tonic-gate * easily store and retrieve kernel resident data. 347c478bd9Sstevel@tonic-gate * These functions are recommended rather than adding new variables to 357c478bd9Sstevel@tonic-gate * this file. 367c478bd9Sstevel@tonic-gate * 377c478bd9Sstevel@tonic-gate * Note that it's possible for name collisions to occur. In order to 387c478bd9Sstevel@tonic-gate * prevent collisions, it's recommended that the convention in 397c478bd9Sstevel@tonic-gate * PSARC/1997/389 be used. If a collision occurs, then space_store will 407c478bd9Sstevel@tonic-gate * fail. 417c478bd9Sstevel@tonic-gate */ 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #include <sys/types.h> 447c478bd9Sstevel@tonic-gate #include <sys/param.h> 457c478bd9Sstevel@tonic-gate #include <sys/var.h> 467c478bd9Sstevel@tonic-gate #include <sys/proc.h> 477c478bd9Sstevel@tonic-gate #include <sys/signal.h> 487c478bd9Sstevel@tonic-gate #include <sys/utsname.h> 497c478bd9Sstevel@tonic-gate #include <sys/buf.h> 507c478bd9Sstevel@tonic-gate #include <sys/cred.h> 517c478bd9Sstevel@tonic-gate #include <sys/vfs.h> 527c478bd9Sstevel@tonic-gate #include <sys/vnode.h> 537c478bd9Sstevel@tonic-gate #include <sys/sysinfo.h> 547c478bd9Sstevel@tonic-gate #include <sys/t_lock.h> 557c478bd9Sstevel@tonic-gate #include <sys/vmem.h> 567c478bd9Sstevel@tonic-gate #include <sys/modhash.h> 577c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h> 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate #include <sys/strredir.h> 607c478bd9Sstevel@tonic-gate #include <sys/kbio.h> 61fea9cb91Slq150181 #include <sys/consdev.h> 62fea9cb91Slq150181 #include <sys/wscons.h> 636cefaae1SJack Meng #include <sys/bootprops.h> 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate struct buf bfreelist; /* Head of the free list of buffers */ 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate sysinfo_t sysinfo; 687c478bd9Sstevel@tonic-gate vminfo_t vminfo; /* VM stats protected by sysinfolock mutex */ 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate #ifdef lint 717c478bd9Sstevel@tonic-gate int __lintzero; /* Alway zero for shutting up lint */ 727c478bd9Sstevel@tonic-gate #endif 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate /* 757c478bd9Sstevel@tonic-gate * The following describe the physical memory configuration. 767c478bd9Sstevel@tonic-gate * 777c478bd9Sstevel@tonic-gate * physmem - The amount of physical memory configured 787c478bd9Sstevel@tonic-gate * in pages. ptob(physmem) is the amount 797c478bd9Sstevel@tonic-gate * of physical memory in bytes. Defined in 807c478bd9Sstevel@tonic-gate * .../os/startup.c. 817c478bd9Sstevel@tonic-gate * 827c478bd9Sstevel@tonic-gate * physmax - The highest numbered physical page in memory. 837c478bd9Sstevel@tonic-gate * 847c478bd9Sstevel@tonic-gate * maxmem - Maximum available memory, in pages. Defined 857c478bd9Sstevel@tonic-gate * in main.c. 867c478bd9Sstevel@tonic-gate * 877c478bd9Sstevel@tonic-gate * physinstalled 887c478bd9Sstevel@tonic-gate * - Pages of physical memory installed; 897c478bd9Sstevel@tonic-gate * includes use by PROM/boot not counted in 907c478bd9Sstevel@tonic-gate * physmem. 917c478bd9Sstevel@tonic-gate */ 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate pfn_t physmax; 947c478bd9Sstevel@tonic-gate pgcnt_t physinstalled; 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate struct var v; 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate #include <sys/systm.h> 997c478bd9Sstevel@tonic-gate #include <sys/conf.h> 1007c478bd9Sstevel@tonic-gate #include <sys/kmem.h> 1017c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h> 1027c478bd9Sstevel@tonic-gate #include <sys/bootconf.h> 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate /* 105af4c679fSSean McEnroe * Data for segkmem pages that should be resident 106af4c679fSSean McEnroe */ 107af4c679fSSean McEnroe struct vnode kvps[KV_MAX]; 108af4c679fSSean McEnroe 109af4c679fSSean McEnroe /* 1107c478bd9Sstevel@tonic-gate * Data from swapgeneric.c that must be resident. 1117c478bd9Sstevel@tonic-gate */ 1127c478bd9Sstevel@tonic-gate struct vnode *rootvp; /* vnode of the root device */ 1137c478bd9Sstevel@tonic-gate dev_t rootdev; /* dev_t of the root device */ 114986fd29aSsetje boolean_t root_is_ramdisk; /* root is ramdisk */ 115986fd29aSsetje uint32_t ramdisk_size; /* (KB) currently set only for sparc netboots */ 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate /* 118986fd29aSsetje * dhcp 1197c478bd9Sstevel@tonic-gate */ 1207c478bd9Sstevel@tonic-gate #include <sys/socket.h> 1217c478bd9Sstevel@tonic-gate #include <sys/errno.h> 1227c478bd9Sstevel@tonic-gate #include <sys/sockio.h> 1237c478bd9Sstevel@tonic-gate #include <sys/stream.h> 1247c478bd9Sstevel@tonic-gate #include <sys/stropts.h> 1257c478bd9Sstevel@tonic-gate #include <sys/dlpi.h> 1267c478bd9Sstevel@tonic-gate #include <net/if.h> 127986fd29aSsetje 128986fd29aSsetje int netboot; 129986fd29aSsetje int obpdebug; 130986fd29aSsetje char *dhcack; /* dhcp response packet */ 131986fd29aSsetje int dhcacklen; 132986fd29aSsetje char *netdev_path; /* Used to cache the netdev_path handed up by boot */ 133986fd29aSsetje char dhcifname[IFNAMSIZ]; 134986fd29aSsetje 135986fd29aSsetje /* 136986fd29aSsetje * Data from arp.c that must be resident. 137986fd29aSsetje */ 1387c478bd9Sstevel@tonic-gate #include <net/if_arp.h> 1397c478bd9Sstevel@tonic-gate #include <netinet/in.h> 1407c478bd9Sstevel@tonic-gate #include <netinet/in_var.h> 1417c478bd9Sstevel@tonic-gate #include <netinet/if_ether.h> 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate ether_addr_t etherbroadcastaddr = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 1447c478bd9Sstevel@tonic-gate 145986fd29aSsetje 1467c478bd9Sstevel@tonic-gate /* 1477c478bd9Sstevel@tonic-gate * Data from timod that must be resident 1487c478bd9Sstevel@tonic-gate */ 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate /* 1517c478bd9Sstevel@tonic-gate * state transition table for TI interface 1527c478bd9Sstevel@tonic-gate */ 1537c478bd9Sstevel@tonic-gate #include <sys/tihdr.h> 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate #define nr 127 /* not reachable */ 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate char ti_statetbl[TE_NOEVENTS][TS_NOSTATES] = { 1587c478bd9Sstevel@tonic-gate /* STATES */ 1597c478bd9Sstevel@tonic-gate /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 */ 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate { 1, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr}, 1627c478bd9Sstevel@tonic-gate {nr, nr, nr, 2, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr}, 1637c478bd9Sstevel@tonic-gate {nr, nr, nr, 4, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr}, 1647c478bd9Sstevel@tonic-gate {nr, 3, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr}, 1657c478bd9Sstevel@tonic-gate {nr, nr, nr, nr, 3, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr}, 1667c478bd9Sstevel@tonic-gate {nr, 0, 3, nr, 3, 3, nr, nr, 7, nr, nr, nr, 6, 7, 9, 10, 11}, 1677c478bd9Sstevel@tonic-gate {nr, nr, 0, nr, nr, 6, nr, nr, nr, nr, nr, nr, 3, nr, 3, 3, 3}, 1687c478bd9Sstevel@tonic-gate {nr, nr, nr, nr, nr, nr, nr, nr, 9, nr, nr, nr, nr, 3, nr, nr, nr}, 1697c478bd9Sstevel@tonic-gate {nr, nr, nr, nr, nr, nr, nr, nr, 3, nr, nr, nr, nr, 3, nr, nr, nr}, 1707c478bd9Sstevel@tonic-gate {nr, nr, nr, nr, nr, nr, nr, nr, 7, nr, nr, nr, nr, 7, nr, nr, nr}, 1717c478bd9Sstevel@tonic-gate {nr, nr, nr, 5, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr}, 1727c478bd9Sstevel@tonic-gate {nr, nr, nr, nr, nr, nr, nr, 8, nr, nr, nr, nr, nr, nr, nr, nr, nr}, 1737c478bd9Sstevel@tonic-gate {nr, nr, nr, nr, nr, nr, 12, 13, nr, 14, 15, 16, nr, nr, nr, nr, nr}, 1747c478bd9Sstevel@tonic-gate {nr, nr, nr, nr, nr, nr, nr, nr, nr, 9, nr, 11, nr, nr, nr, nr, nr}, 1757c478bd9Sstevel@tonic-gate {nr, nr, nr, nr, nr, nr, nr, nr, nr, 9, nr, 11, nr, nr, nr, nr, nr}, 1767c478bd9Sstevel@tonic-gate {nr, nr, nr, nr, nr, nr, nr, nr, nr, 10, nr, 3, nr, nr, nr, nr, nr}, 1777c478bd9Sstevel@tonic-gate {nr, nr, nr, 7, nr, nr, nr, 7, nr, nr, nr, nr, nr, nr, nr, nr, nr}, 1787c478bd9Sstevel@tonic-gate {nr, nr, nr, nr, nr, nr, 9, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr}, 1797c478bd9Sstevel@tonic-gate {nr, nr, nr, nr, nr, nr, nr, nr, nr, 9, 10, nr, nr, nr, nr, nr, nr}, 1807c478bd9Sstevel@tonic-gate {nr, nr, nr, nr, nr, nr, nr, nr, nr, 9, 10, nr, nr, nr, nr, nr, nr}, 1817c478bd9Sstevel@tonic-gate {nr, nr, nr, nr, nr, nr, nr, nr, nr, 11, 3, nr, nr, nr, nr, nr, nr}, 1827c478bd9Sstevel@tonic-gate {nr, nr, nr, nr, nr, nr, 3, nr, nr, 3, 3, 3, nr, nr, nr, nr, nr}, 1837c478bd9Sstevel@tonic-gate {nr, nr, nr, nr, nr, nr, nr, 3, nr, nr, nr, nr, nr, nr, nr, nr, nr}, 1847c478bd9Sstevel@tonic-gate {nr, nr, nr, nr, nr, nr, nr, 7, nr, nr, nr, nr, nr, nr, nr, nr, nr}, 1857c478bd9Sstevel@tonic-gate {nr, nr, nr, 9, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr}, 1867c478bd9Sstevel@tonic-gate {nr, nr, nr, 3, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr}, 1877c478bd9Sstevel@tonic-gate {nr, nr, nr, 3, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr}, 1887c478bd9Sstevel@tonic-gate {nr, nr, nr, 3, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr, nr}, 1897c478bd9Sstevel@tonic-gate }; 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate #include <sys/tty.h> 1937c478bd9Sstevel@tonic-gate #include <sys/ptyvar.h> 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate static void store_fetch_initspace(); 1967c478bd9Sstevel@tonic-gate 1977c478bd9Sstevel@tonic-gate /* 1987c478bd9Sstevel@tonic-gate * Allocate tunable structures at runtime. 1997c478bd9Sstevel@tonic-gate */ 2007c478bd9Sstevel@tonic-gate void 2017c478bd9Sstevel@tonic-gate space_init(void) 2027c478bd9Sstevel@tonic-gate { 2037c478bd9Sstevel@tonic-gate pty_initspace(); 2047c478bd9Sstevel@tonic-gate store_fetch_initspace(); 2057c478bd9Sstevel@tonic-gate } 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gate int ts_dispatch_extended = -1; /* set in ts_getdptbl or set_platform_default */ 2087c478bd9Sstevel@tonic-gate 2097c478bd9Sstevel@tonic-gate /* 2107c478bd9Sstevel@tonic-gate * Previously defined in consmsconf.c ... 2117c478bd9Sstevel@tonic-gate */ 2127c478bd9Sstevel@tonic-gate dev_t kbddev = NODEV; 2137c478bd9Sstevel@tonic-gate dev_t mousedev = NODEV; 2147c478bd9Sstevel@tonic-gate dev_t stdindev = NODEV; 2157c478bd9Sstevel@tonic-gate struct vnode *wsconsvp; 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate dev_t fbdev = NODEV; 2187c478bd9Sstevel@tonic-gate struct vnode *fbvp; 2197c478bd9Sstevel@tonic-gate dev_info_t *fbdip; 2207c478bd9Sstevel@tonic-gate 2217c478bd9Sstevel@tonic-gate /* 2227c478bd9Sstevel@tonic-gate * moved from cons.c because they must be resident in the kernel. 2237c478bd9Sstevel@tonic-gate */ 2247c478bd9Sstevel@tonic-gate vnode_t *rconsvp; 2257c478bd9Sstevel@tonic-gate dev_t rconsdev; 2267c478bd9Sstevel@tonic-gate dev_t uconsdev = NODEV; 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate /* 229361ed64aSJames Anderson * serial virtual console vnode pointer. 230361ed64aSJames Anderson */ 231361ed64aSJames Anderson vnode_t *vsconsvp = NULL; 232361ed64aSJames Anderson 233361ed64aSJames Anderson /* 234fea9cb91Slq150181 * Flag whether console fb output is using PROM/PROM emulation 235fea9cb91Slq150181 * terminal emulator, or is using the kernel terminal emulator. 236fea9cb91Slq150181 */ 237fea9cb91Slq150181 int consmode = CONS_FW; 238fea9cb91Slq150181 239fea9cb91Slq150181 /* 240fea9cb91Slq150181 * The following allows systems to disable use of the kernel 241fea9cb91Slq150181 * terminal emulator (retreat to PROM terminal emulator if there 242fea9cb91Slq150181 * is PROM). 243fea9cb91Slq150181 */ 244fea9cb91Slq150181 int cons_tem_disable; 245fea9cb91Slq150181 246fea9cb91Slq150181 /* 2477c478bd9Sstevel@tonic-gate * consconfig() in autoconf.c sets this; it's the vnode of the distinguished 2487c478bd9Sstevel@tonic-gate * keyboard/frame buffer combination, aka the workstation console. 2497c478bd9Sstevel@tonic-gate */ 2507c478bd9Sstevel@tonic-gate vnode_t *rwsconsvp; 2517c478bd9Sstevel@tonic-gate dev_t rwsconsdev; 2527c478bd9Sstevel@tonic-gate 2537c478bd9Sstevel@tonic-gate /* 2547c478bd9Sstevel@tonic-gate * Platform console abort policy. 2557c478bd9Sstevel@tonic-gate * Platforms may override the default software policy, if such hardware 2567c478bd9Sstevel@tonic-gate * (e.g. keyswitches with a secure position) exists. 2577c478bd9Sstevel@tonic-gate */ 2587c478bd9Sstevel@tonic-gate int abort_enable = KIOCABORTENABLE; 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate /* from cpc.c */ 2617c478bd9Sstevel@tonic-gate uint_t kcpc_key; /* TSD key for CPU performance counter context */ 2627c478bd9Sstevel@tonic-gate 2637c478bd9Sstevel@tonic-gate /* 2647c478bd9Sstevel@tonic-gate * storing and retrieving data by string key 2657c478bd9Sstevel@tonic-gate * 2667c478bd9Sstevel@tonic-gate * this mechanism allows a consumer to store and retrieve by name a pointer 2677c478bd9Sstevel@tonic-gate * to some space maintained by the consumer. 2687c478bd9Sstevel@tonic-gate * For example, a driver or module may want to have persistent data 2697c478bd9Sstevel@tonic-gate * over unloading/loading cycles. The pointer is typically to some 2707c478bd9Sstevel@tonic-gate * kmem_alloced space and it should not be pointing to data that will 2717c478bd9Sstevel@tonic-gate * be destroyed when the module is unloaded. 2727c478bd9Sstevel@tonic-gate */ 2737c478bd9Sstevel@tonic-gate static mod_hash_t *space_hash; 2747c478bd9Sstevel@tonic-gate static char *space_hash_name = "space_hash"; 2757c478bd9Sstevel@tonic-gate static size_t space_hash_nchains = 8; 2767c478bd9Sstevel@tonic-gate 2777c478bd9Sstevel@tonic-gate static void 2787c478bd9Sstevel@tonic-gate store_fetch_initspace() 2797c478bd9Sstevel@tonic-gate { 2807c478bd9Sstevel@tonic-gate space_hash = mod_hash_create_strhash(space_hash_name, 2817c478bd9Sstevel@tonic-gate space_hash_nchains, mod_hash_null_valdtor); 2827c478bd9Sstevel@tonic-gate ASSERT(space_hash); 2837c478bd9Sstevel@tonic-gate } 2847c478bd9Sstevel@tonic-gate 2857c478bd9Sstevel@tonic-gate int 2867c478bd9Sstevel@tonic-gate space_store(char *key, uintptr_t ptr) 2877c478bd9Sstevel@tonic-gate { 2887c478bd9Sstevel@tonic-gate char *s; 2897c478bd9Sstevel@tonic-gate int rval; 2907c478bd9Sstevel@tonic-gate size_t l; 2917c478bd9Sstevel@tonic-gate 2927c478bd9Sstevel@tonic-gate /* some sanity checks first */ 2937c478bd9Sstevel@tonic-gate if (key == NULL) { 2947c478bd9Sstevel@tonic-gate return (-1); 2957c478bd9Sstevel@tonic-gate } 2967c478bd9Sstevel@tonic-gate l = (size_t)strlen(key); 2977c478bd9Sstevel@tonic-gate if (l == 0) { 2987c478bd9Sstevel@tonic-gate return (-1); 2997c478bd9Sstevel@tonic-gate } 3007c478bd9Sstevel@tonic-gate 3017c478bd9Sstevel@tonic-gate /* increment for null terminator */ 3027c478bd9Sstevel@tonic-gate l++; 3037c478bd9Sstevel@tonic-gate 3047c478bd9Sstevel@tonic-gate /* alloc space for the string, mod_hash_insert will deallocate */ 3057c478bd9Sstevel@tonic-gate s = kmem_alloc(l, KM_SLEEP); 3067c478bd9Sstevel@tonic-gate bcopy(key, s, l); 3077c478bd9Sstevel@tonic-gate 3087c478bd9Sstevel@tonic-gate rval = mod_hash_insert(space_hash, 3097c478bd9Sstevel@tonic-gate (mod_hash_key_t)s, (mod_hash_val_t)ptr); 3107c478bd9Sstevel@tonic-gate 3117c478bd9Sstevel@tonic-gate switch (rval) { 3127c478bd9Sstevel@tonic-gate case 0: 3137c478bd9Sstevel@tonic-gate break; 3147c478bd9Sstevel@tonic-gate #ifdef DEBUG 3157c478bd9Sstevel@tonic-gate case MH_ERR_DUPLICATE: 3167c478bd9Sstevel@tonic-gate cmn_err(CE_WARN, "space_store: duplicate key %s", key); 3177c478bd9Sstevel@tonic-gate rval = -1; 3187c478bd9Sstevel@tonic-gate break; 3197c478bd9Sstevel@tonic-gate case MH_ERR_NOMEM: 3207c478bd9Sstevel@tonic-gate cmn_err(CE_WARN, "space_store: no mem for key %s", key); 3217c478bd9Sstevel@tonic-gate rval = -1; 3227c478bd9Sstevel@tonic-gate break; 3237c478bd9Sstevel@tonic-gate default: 3247c478bd9Sstevel@tonic-gate cmn_err(CE_WARN, "space_store: unspecified error for key %s", 3257c478bd9Sstevel@tonic-gate key); 3267c478bd9Sstevel@tonic-gate rval = -1; 3277c478bd9Sstevel@tonic-gate break; 3287c478bd9Sstevel@tonic-gate #else 3297c478bd9Sstevel@tonic-gate default: 3307c478bd9Sstevel@tonic-gate rval = -1; 3317c478bd9Sstevel@tonic-gate break; 3327c478bd9Sstevel@tonic-gate #endif 3337c478bd9Sstevel@tonic-gate } 3347c478bd9Sstevel@tonic-gate 3357c478bd9Sstevel@tonic-gate return (rval); 3367c478bd9Sstevel@tonic-gate } 3377c478bd9Sstevel@tonic-gate 3387c478bd9Sstevel@tonic-gate uintptr_t 3397c478bd9Sstevel@tonic-gate space_fetch(char *key) 3407c478bd9Sstevel@tonic-gate { 3417c478bd9Sstevel@tonic-gate uintptr_t ptr = 0; 3427c478bd9Sstevel@tonic-gate mod_hash_val_t val; 3437c478bd9Sstevel@tonic-gate int rval; 3447c478bd9Sstevel@tonic-gate 3457c478bd9Sstevel@tonic-gate if (key) { 3467c478bd9Sstevel@tonic-gate rval = mod_hash_find(space_hash, (mod_hash_key_t)key, &val); 3477c478bd9Sstevel@tonic-gate if (rval == 0) { 3487c478bd9Sstevel@tonic-gate ptr = (uintptr_t)val; 3497c478bd9Sstevel@tonic-gate } 3507c478bd9Sstevel@tonic-gate } 3517c478bd9Sstevel@tonic-gate 3527c478bd9Sstevel@tonic-gate return (ptr); 3537c478bd9Sstevel@tonic-gate } 3547c478bd9Sstevel@tonic-gate 3557c478bd9Sstevel@tonic-gate void 3567c478bd9Sstevel@tonic-gate space_free(char *key) 3577c478bd9Sstevel@tonic-gate { 3587c478bd9Sstevel@tonic-gate if (key) { 3597c478bd9Sstevel@tonic-gate (void) mod_hash_destroy(space_hash, (mod_hash_key_t)key); 3607c478bd9Sstevel@tonic-gate } 3617c478bd9Sstevel@tonic-gate } 3627c478bd9Sstevel@tonic-gate 3637c478bd9Sstevel@tonic-gate /* 3647c478bd9Sstevel@tonic-gate * Support for CRC32. At present all calculations are done in simple 3657c478bd9Sstevel@tonic-gate * macros, so all we need is somewhere to declare the global lookup table. 3667c478bd9Sstevel@tonic-gate */ 3677c478bd9Sstevel@tonic-gate 3687c478bd9Sstevel@tonic-gate #include <sys/crc32.h> 3697c478bd9Sstevel@tonic-gate 3707c478bd9Sstevel@tonic-gate const uint32_t crc32_table[256] = { CRC32_TABLE }; 3714b46d1efSkrgopi 3724b46d1efSkrgopi /* 373da14cebeSEric Cheng * We need to fanout load from NIC which can overwhelm a single CPU. 374da14cebeSEric Cheng * This becomes especially important on systems having slow CPUs 375da14cebeSEric Cheng * (sun4v architecture). mac_soft_ring_enable is false on all 376da14cebeSEric Cheng * systems except sun4v. On sun4v, they get enabled by default (see 377da14cebeSEric Cheng * sun4v/os/mach_startup.c). 3784b46d1efSkrgopi */ 379da14cebeSEric Cheng boolean_t mac_soft_ring_enable = B_FALSE; 3806cefaae1SJack Meng 3816cefaae1SJack Meng /* 3826cefaae1SJack Meng * Global iscsi boot prop 3836cefaae1SJack Meng */ 3846cefaae1SJack Meng ib_boot_prop_t *iscsiboot_prop = NULL; 385