space.c revision 062faf21f9a029e2ef07a49159b5442cdc075c93
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* The intent of this file is to contain any data that must remain
* resident in the kernel.
*
* space_store(), space_fetch(), and space_free() have been added to
* easily store and retrieve kernel resident data.
* These functions are recommended rather than adding new variables to
* this file.
*
* Note that it's possible for name collisions to occur. In order to
* prevent collisions, it's recommended that the convention in
* PSARC/1997/389 be used. If a collision occurs, then space_store will
* fail.
*/
#include <sys/strredir.h>
#ifdef lint
int __lintzero; /* Alway zero for shutting up lint */
#endif
/*
* The following describe the physical memory configuration.
*
* physmem - The amount of physical memory configured
* in pages. ptob(physmem) is the amount
* of physical memory in bytes. Defined in
*
* physmax - The highest numbered physical page in memory.
*
* maxmem - Maximum available memory, in pages. Defined
* in main.c.
*
* physinstalled
* - Pages of physical memory installed;
* physmem.
*/
struct var v;
#include <sys/sysmacros.h>
#include <sys/bootconf.h>
/*
* Data from swapgeneric.c that must be resident.
*/
int root_is_svm; /* root is a mirrored device flag */
int netboot;
int obpdebug;
char *dhcack; /* Used to cache ascii form of DHCPACK handed up by boot */
char *netdev_path; /* Used to cache the netdev_path handed up by boot */
/*
* Data from arp.c that must be resident.
*/
#include <netinet/if_ether.h>
/*
* Data from timod that must be resident
*/
/*
* state transition table for TI interface
*/
/* STATES */
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 */
};
static void store_fetch_initspace();
/*
* Allocate tunable structures at runtime.
*/
void
space_init(void)
{
}
/*
* Previously defined in consmsconf.c ...
*/
/*
* moved from cons.c because they must be resident in the kernel.
*/
/*
* terminal emulator, or is using the kernel terminal emulator.
*/
/*
* The following allows systems to disable use of the kernel
* terminal emulator (retreat to PROM terminal emulator if there
* is PROM).
*/
int cons_tem_disable;
/*
* consconfig() in autoconf.c sets this; it's the vnode of the distinguished
*/
/*
* Platform console abort policy.
* Platforms may override the default software policy, if such hardware
* (e.g. keyswitches with a secure position) exists.
*/
int abort_enable = KIOCABORTENABLE;
/* from cpc.c */
/*
* storing and retrieving data by string key
*
* this mechanism allows a consumer to store and retrieve by name a pointer
* to some space maintained by the consumer.
* For example, a driver or module may want to have persistent data
* kmem_alloced space and it should not be pointing to data that will
* be destroyed when the module is unloaded.
*/
static mod_hash_t *space_hash;
static char *space_hash_name = "space_hash";
static void
{
}
int
{
char *s;
int rval;
size_t l;
/* some sanity checks first */
return (-1);
}
if (l == 0) {
return (-1);
}
/* increment for null terminator */
l++;
/* alloc space for the string, mod_hash_insert will deallocate */
s = kmem_alloc(l, KM_SLEEP);
switch (rval) {
case 0:
break;
#ifdef DEBUG
case MH_ERR_DUPLICATE:
rval = -1;
break;
case MH_ERR_NOMEM:
rval = -1;
break;
default:
key);
rval = -1;
break;
#else
default:
rval = -1;
break;
#endif
}
return (rval);
}
space_fetch(char *key)
{
int rval;
if (key) {
if (rval == 0) {
}
}
return (ptr);
}
void
space_free(char *key)
{
if (key) {
}
}
/*
* Support for CRC32. At present all calculations are done in simple
* macros, so all we need is somewhere to declare the global lookup table.
*/
/*
* We need to fanout load from NIC which can overwhelm a single
* CPU. A 10Gb NIC interrupting a single CPU is a good example.
* Instead of fanning out to random CPUs, it a big performance
* win if you can fanout to the threads on the same core (niagara)
* that is taking interrupts.
*
* We need a better mechanism to figure out the other threads on
* the same core or cores on the same chip which share caches etc.
* but for time being, this will suffice.
*/
#define NUMBER_OF_THREADS_PER_CPU 4