1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-17 10:26:15 +00:00

Add TUNABLE_LONG and TUNABLE_ULONG, and use the latter for the

hw.pci.host_mem_start tunable.  Add comments to TUNABLE_INT and
TUNABLE_QUAD recommending against their use.

MFC after:	3 weeks
This commit is contained in:
Dag-Erling Smørgrav 2004-10-31 15:50:33 +00:00
parent 38228f7221
commit b0e1e474f7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=137099
6 changed files with 110 additions and 10 deletions

View File

@ -266,10 +266,9 @@ legacy_pcib_write_ivar(device_t dev, device_t child, int which,
SYSCTL_DECL(_hw_pci);
static int legacy_host_mem_start = 0x80000000;
/* No TUNABLE_ULONG :-( */
TUNABLE_INT("hw.pci.host_mem_start", &legacy_host_mem_start);
SYSCTL_INT(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN,
static unsigned long legacy_host_mem_start = 0x80000000;
TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start);
SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN,
&legacy_host_mem_start, 0x80000000,
"Limit the host bridge memory to being above this address. Must be\n\
set at boot via a tunable.");

View File

@ -301,8 +301,8 @@ acpi_pcib_acpi_route_interrupt(device_t pcib, device_t dev, int pin)
return (acpi_pcib_route_interrupt(pcib, dev, pin));
}
static int acpi_host_mem_start = 0x80000000;
TUNABLE_INT("hw.acpi.host_mem_start", &acpi_host_mem_start);
static unsigned long acpi_host_mem_start = 0x80000000;
TUNABLE_ULONG("hw.acpi.host_mem_start", &acpi_host_mem_start);
struct resource *
acpi_pcib_acpi_alloc_resource(device_t dev, device_t child, int type, int *rid,

View File

@ -472,10 +472,9 @@ legacy_pcib_write_ivar(device_t dev, device_t child, int which,
SYSCTL_DECL(_hw_pci);
static int legacy_host_mem_start = 0x80000000;
/* No TUNABLE_ULONG :-( */
TUNABLE_INT("hw.pci.host_mem_start", &legacy_host_mem_start);
SYSCTL_INT(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN,
static unsigned long legacy_host_mem_start = 0x80000000;
TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start);
SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN,
&legacy_host_mem_start, 0x80000000,
"Limit the host bridge memory to being above this address. Must be\n\
set at boot via a tunable.");

View File

@ -414,6 +414,36 @@ getenv_int(const char *name, int *data)
return (rval);
}
/*
* Return a long value from an environment variable.
*/
long
getenv_long(const char *name, long *data)
{
quad_t tmp;
long rval;
rval = getenv_quad(name, &tmp);
if (rval)
*data = (long) tmp;
return (rval);
}
/*
* Return an unsigned long value from an environment variable.
*/
unsigned long
getenv_ulong(const char *name, unsigned long *data)
{
quad_t tmp;
long rval;
rval = getenv_quad(name, &tmp);
if (rval)
*data = (unsigned long) tmp;
return (rval);
}
/*
* Return a quad_t value from an environment variable.
*/
@ -463,6 +493,22 @@ tunable_int_init(void *data)
TUNABLE_INT_FETCH(d->path, d->var);
}
void
tunable_long_init(void *data)
{
struct tunable_long *d = (struct tunable_long *)data;
TUNABLE_LONG_FETCH(d->path, d->var);
}
void
tunable_ulong_init(void *data)
{
struct tunable_ulong *d = (struct tunable_ulong *)data;
TUNABLE_ULONG_FETCH(d->path, d->var);
}
void
tunable_quad_init(void *data)
{

View File

@ -265,6 +265,10 @@ void sysinit_add(struct sysinit **set, struct sysinit **set_end);
* loader.conf(5) for any tunables or conflicts will result.
*/
/*
* int
* please avoid using for new tunables!
*/
extern void tunable_int_init(void *);
struct tunable_int {
const char *path;
@ -285,6 +289,56 @@ struct tunable_int {
#define TUNABLE_INT_FETCH(path, var) getenv_int((path), (var))
/*
* long
*/
extern void tunable_long_init(void *);
struct tunable_long {
const char *path;
long *var;
};
#define TUNABLE_LONG(path, var) \
_TUNABLE_LONG((path), (var), __LINE__)
#define _TUNABLE_LONG(path, var, line) \
__TUNABLE_LONG((path), (var), line)
#define __TUNABLE_LONG(path, var, line) \
static struct tunable_long __tunable_long_ ## line = { \
path, \
var, \
}; \
SYSINIT(__Tunable_init_ ## line, SI_SUB_TUNABLES, SI_ORDER_MIDDLE, \
tunable_long_init, &__tunable_long_ ## line)
#define TUNABLE_LONG_FETCH(path, var) getenv_long((path), (var))
/*
* unsigned long
*/
extern void tunable_ulong_init(void *);
struct tunable_ulong {
const char *path;
unsigned long *var;
};
#define TUNABLE_ULONG(path, var) \
_TUNABLE_ULONG((path), (var), __LINE__)
#define _TUNABLE_ULONG(path, var, line) \
__TUNABLE_ULONG((path), (var), line)
#define __TUNABLE_ULONG(path, var, line) \
static struct tunable_ulong __tunable_ulong_ ## line = {\
path, \
var, \
}; \
SYSINIT(__Tunable_init_ ## line, SI_SUB_TUNABLES, SI_ORDER_MIDDLE, \
tunable_ulong_init, &__tunable_ulong_ ## line)
#define TUNABLE_ULONG_FETCH(path, var) getenv_ulong((path), (var))
/*
* Quad (64-bit)
* please avoid using for new tunables!
*/
extern void tunable_quad_init(void *);
struct tunable_quad {
const char *path;

View File

@ -226,6 +226,8 @@ int cr_canseesocket(struct ucred *cred, struct socket *so);
char *getenv(const char *name);
void freeenv(char *env);
int getenv_int(const char *name, int *data);
long getenv_long(const char *name, long *data);
unsigned long getenv_ulong(const char *name, unsigned long *data);
int getenv_string(const char *name, char *data, int size);
int getenv_quad(const char *name, quad_t *data);
int setenv(const char *name, const char *value);