Skip to content

Commit

Permalink
Hints overhaul:
Browse files Browse the repository at this point in the history
- Replace some very poorly thought out API hacks that should have been
  fixed a long while ago.
- Provide some much more flexible search functions (resource_find_*())
- Use strings for storage instead of an outgrowth of the rather
  inconvenient temporary ioconf table from config().  We already had a
  fallback to using strings before malloc/vm was running anyway.
  • Loading branch information
DarkHelmet433 committed Jun 12, 2001
1 parent b44fc46 commit bbbe887
Show file tree
Hide file tree
Showing 30 changed files with 694 additions and 612 deletions.
2 changes: 1 addition & 1 deletion sys/amd64/amd64/machdep.c
Expand Up @@ -49,7 +49,7 @@
#include "opt_msgbuf.h"
#include "opt_npx.h"
#include "opt_perfmon.h"
#include "opt_userconfig.h"
/* #include "opt_userconfig.h" */

#include <sys/param.h>
#include <sys/systm.h>
Expand Down
4 changes: 2 additions & 2 deletions sys/amd64/conf/GENERIC
Expand Up @@ -43,8 +43,8 @@ options PROCFS #Process filesystem
options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!]
options SCSI_DELAY=15000 #Delay (in ms) before probing SCSI
options UCONSOLE #Allow users to grab the console
options USERCONFIG #boot -c editor
options VISUAL_USERCONFIG #visual boot -c editor
#options USERCONFIG #boot -c editor
#options VISUAL_USERCONFIG #visual boot -c editor
options KTRACE #ktrace(1) support
options SYSVSHM #SYSV-style shared memory
options SYSVMSG #SYSV-style message queues
Expand Down
29 changes: 15 additions & 14 deletions sys/cam/cam_periph.c
Expand Up @@ -303,10 +303,10 @@ camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired,
path_id_t pathid, target_id_t target, lun_id_t lun)
{
struct cam_periph *periph;
char *periph_name, *strval;
char *periph_name;
int s;
int i, val, dunit;
const char *dname;
int i, val, dunit, r;
const char *dname, *strval;

s = splsoftcam();
periph_name = p_drv->driver_name;
Expand Down Expand Up @@ -337,10 +337,12 @@ camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired,
* device, but do match entries like "da 4 target 5"
* or even "da 4 scbus 1".
*/
i = -1;
while ((i = resource_locate(i, periph_name)) != -1) {
dname = resource_query_name(i);
dunit = resource_query_unit(i);
i = 0;
dname = periph_name;
for (;;) {
r = resource_find_dev(&i, dname, &dunit, NULL, NULL);
if (r != 0)
break;
/* if no "target" and no specific scbus, skip */
if (resource_int_value(dname, dunit, "target", &val) &&
(resource_string_value(dname, dunit, "at",&strval)||
Expand All @@ -349,7 +351,7 @@ camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired,
if (newunit == dunit)
break;
}
if (i == -1)
if (r != 0)
break;
}
splx(s);
Expand All @@ -362,18 +364,17 @@ camperiphunit(struct periph_driver *p_drv, path_id_t pathid,
{
u_int unit;
int hit, i, val, dunit;
const char *dname;
char pathbuf[32], *strval, *periph_name;
const char *dname, *strval;
char pathbuf[32], *periph_name;

unit = 0;
hit = 0;

periph_name = p_drv->driver_name;
snprintf(pathbuf, sizeof(pathbuf), "scbus%d", pathid);
i = -1;
while ((i = resource_locate(i, periph_name)) != -1) {
dname = resource_query_name(i);
dunit = resource_query_unit(i);
i = 0;
dname = periph_name;
while ((resource_find_dev(&i, dname, &dunit, NULL, NULL)) == 0) {
if (resource_string_value(dname, dunit, "at", &strval) == 0) {
if (strcmp(strval, pathbuf) != 0)
continue;
Expand Down
10 changes: 5 additions & 5 deletions sys/cam/cam_xpt.c
Expand Up @@ -4346,7 +4346,7 @@ xptnextfreepathid(void)
{
struct cam_eb *bus;
path_id_t pathid;
char *strval;
const char *strval;

pathid = 0;
bus = TAILQ_FIRST(&xpt_busses);
Expand Down Expand Up @@ -4377,16 +4377,16 @@ xptpathid(const char *sim_name, int sim_unit, int sim_bus)
path_id_t pathid;
int i, dunit, val;
char buf[32];
const char *dname;

pathid = CAM_XPT_PATH_ID;
snprintf(buf, sizeof(buf), "%s%d", sim_name, sim_unit);
i = -1;
while ((i = resource_query_string(i, "at", buf)) != -1) {
if (strcmp(resource_query_name(i), "scbus")) {
i = 0;
while ((resource_find_match(&i, &dname, &dunit, "at", buf)) == 0) {
if (strcmp(dname, "scbus")) {
/* Avoid a bit of foot shooting. */
continue;
}
dunit = resource_query_unit(i);
if (dunit < 0) /* unwired?! */
continue;
if (resource_int_value("scbus", dunit, "bus", &val) == 0) {
Expand Down
6 changes: 3 additions & 3 deletions sys/conf/NOTES
Expand Up @@ -403,9 +403,9 @@ options COMPILING_LINT
options UCONSOLE

# XXX - this doesn't belong here either
options USERCONFIG #boot -c editor
options INTRO_USERCONFIG #imply -c and show intro screen
options VISUAL_USERCONFIG #visual boot -c editor
#options USERCONFIG #boot -c editor
#options INTRO_USERCONFIG #imply -c and show intro screen
#options VISUAL_USERCONFIG #visual boot -c editor

#####################################################################
# NETWORKING OPTIONS
Expand Down
2 changes: 1 addition & 1 deletion sys/conf/files.alpha
Expand Up @@ -82,7 +82,7 @@ alpha/alpha/support.s standard
alpha/alpha/swtch.s standard
alpha/alpha/sys_machdep.c standard
alpha/alpha/trap.c standard
alpha/alpha/userconfig.c optional userconfig
#alpha/alpha/userconfig.c optional userconfig
alpha/alpha/vm_machdep.c standard
alpha/isa/isa.c optional isa
alpha/isa/isa_dma.c optional isa
Expand Down
2 changes: 1 addition & 1 deletion sys/conf/files.i386
Expand Up @@ -194,7 +194,7 @@ i386/i386/support.s standard
i386/i386/swtch.s standard
i386/i386/sys_machdep.c standard
i386/i386/trap.c standard
i386/i386/userconfig.c optional userconfig
#i386/i386/userconfig.c optional userconfig
i386/i386/vm86.c standard
i386/i386/vm_machdep.c standard
i386/ibcs2/ibcs2_errno.c optional ibcs2
Expand Down
2 changes: 1 addition & 1 deletion sys/conf/files.ia64
Expand Up @@ -49,7 +49,7 @@ ia64/ia64/sscdisk.c standard
ia64/ia64/swtch.s standard
ia64/ia64/sys_machdep.c standard
ia64/ia64/trap.c standard
ia64/ia64/userconfig.c optional userconfig
#ia64/ia64/userconfig.c optional userconfig
ia64/ia64/vm_machdep.c standard
ia64/isa/isa.c optional isa
ia64/isa/isa_dma.c optional isa
Expand Down
2 changes: 1 addition & 1 deletion sys/conf/files.pc98
Expand Up @@ -372,7 +372,7 @@ netsmb/smb_usr.c optional netsmb
pc98/apm/apm.c optional apm
pc98/apm/apm_bioscall.s optional apm
pc98/i386/machdep.c standard
pc98/i386/userconfig.c optional userconfig
#pc98/i386/userconfig.c optional userconfig
pc98/pc98/atapi.c optional wdc
pc98/pc98/clock.c standard
pc98/pc98/diskslice_machdep.c standard
Expand Down
8 changes: 4 additions & 4 deletions sys/conf/options.i386
Expand Up @@ -111,10 +111,10 @@ KBD_MAXWAIT opt_kbd.h
KBD_RESETDELAY opt_kbd.h
KBDIO_DEBUG opt_kbd.h

USERCONFIG opt_userconfig.h
VISUAL_USERCONFIG opt_userconfig.h
INTRO_USERCONFIG opt_userconfig.h
DEV_EISA opt_userconfig.h
#USERCONFIG opt_userconfig.h
#VISUAL_USERCONFIG opt_userconfig.h
#INTRO_USERCONFIG opt_userconfig.h
#DEV_EISA opt_userconfig.h

EISA_SLOTS opt_eisa.h

Expand Down
8 changes: 4 additions & 4 deletions sys/conf/options.pc98
Expand Up @@ -101,10 +101,10 @@ KBD_MAXWAIT opt_kbd.h
KBD_RESETDELAY opt_kbd.h
KBDIO_DEBUG opt_kbd.h

USERCONFIG opt_userconfig.h
VISUAL_USERCONFIG opt_userconfig.h
INTRO_USERCONFIG opt_userconfig.h
DEV_EISA opt_userconfig.h
#USERCONFIG opt_userconfig.h
#VISUAL_USERCONFIG opt_userconfig.h
#INTRO_USERCONFIG opt_userconfig.h
#DEV_EISA opt_userconfig.h

EISA_SLOTS opt_eisa.h

Expand Down
18 changes: 8 additions & 10 deletions sys/dev/atkbdc/atkbdc_isa.c
Expand Up @@ -169,11 +169,11 @@ static int
atkbdc_attach(device_t dev)
{
atkbdc_softc_t *sc;
int unit;
int unit, dunit;
int error;
int rid;
int i;
const char *name;
const char *name, *dname;

unit = device_get_unit(dev);
sc = *(atkbdc_softc_t **)device_get_softc(dev);
Expand Down Expand Up @@ -215,19 +215,17 @@ atkbdc_attach(device_t dev)
* Add all devices configured to be attached to atkbdc0.
*/
name = device_get_nameunit(dev);
i = -1;
while ((i = resource_query_string(i, "at", name)) != -1)
atkbdc_add_device(dev, resource_query_name(i),
resource_query_unit(i));
i = 0;
while ((resource_find_match(&i, &dname, &dunit, "at", name)) == 0)
atkbdc_add_device(dev, dname, dunit);

/*
* and atkbdc?
*/
name = device_get_name(dev);
i = -1;
while ((i = resource_query_string(i, "at", name)) != -1)
atkbdc_add_device(dev, resource_query_name(i),
resource_query_unit(i));
i = 0;
while ((resource_find_match(&i, &dname, &dunit, "at", name)) == 0)
atkbdc_add_device(dev, dname, dunit);

bus_generic_attach(dev);

Expand Down
18 changes: 8 additions & 10 deletions sys/dev/atkbdc/atkbdc_subr.c
Expand Up @@ -169,11 +169,11 @@ static int
atkbdc_attach(device_t dev)
{
atkbdc_softc_t *sc;
int unit;
int unit, dunit;
int error;
int rid;
int i;
const char *name;
const char *name, *dname;

unit = device_get_unit(dev);
sc = *(atkbdc_softc_t **)device_get_softc(dev);
Expand Down Expand Up @@ -215,19 +215,17 @@ atkbdc_attach(device_t dev)
* Add all devices configured to be attached to atkbdc0.
*/
name = device_get_nameunit(dev);
i = -1;
while ((i = resource_query_string(i, "at", name)) != -1)
atkbdc_add_device(dev, resource_query_name(i),
resource_query_unit(i));
i = 0;
while ((resource_find_match(&i, &dname, &dunit, "at", name)) == 0)
atkbdc_add_device(dev, dname, dunit);

/*
* and atkbdc?
*/
name = device_get_name(dev);
i = -1;
while ((i = resource_query_string(i, "at", name)) != -1)
atkbdc_add_device(dev, resource_query_name(i),
resource_query_unit(i));
i = 0;
while ((resource_find_match(&i, &dname, &dunit, "at", name)) == 0)
atkbdc_add_device(dev, dname, dunit);

bus_generic_attach(dev);

Expand Down
11 changes: 5 additions & 6 deletions sys/dev/fdc/fdc.c
Expand Up @@ -817,8 +817,8 @@ static int
fdc_attach(device_t dev)
{
struct fdc_data *fdc;
int i, error;
const char *name;
int i, error, dunit;
const char *name, *dname;

fdc = device_get_softc(dev);
error = fdc_alloc_resources(fdc);
Expand Down Expand Up @@ -856,10 +856,9 @@ fdc_attach(device_t dev)
* devices from the BIOS unless overridden.
*/
name = device_get_nameunit(dev);
i = -1;
while ((i = resource_query_string(i, "at", name)) != -1)
fdc_add_child(dev, resource_query_name(i),
resource_query_unit(i));
i = 0;
while ((resource_find_match(&i, &dname, &dunit, "at", name)) == 0)
fdc_add_child(dev, dname, dunit);

return (bus_generic_attach(dev));
}
Expand Down
4 changes: 2 additions & 2 deletions sys/i386/conf/GENERIC
Expand Up @@ -43,8 +43,8 @@ options PROCFS #Process filesystem
options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!]
options SCSI_DELAY=15000 #Delay (in ms) before probing SCSI
options UCONSOLE #Allow users to grab the console
options USERCONFIG #boot -c editor
options VISUAL_USERCONFIG #visual boot -c editor
#options USERCONFIG #boot -c editor
#options VISUAL_USERCONFIG #visual boot -c editor
options KTRACE #ktrace(1) support
options SYSVSHM #SYSV-style shared memory
options SYSVMSG #SYSV-style message queues
Expand Down
6 changes: 3 additions & 3 deletions sys/i386/conf/NOTES
Expand Up @@ -403,9 +403,9 @@ options COMPILING_LINT
options UCONSOLE

# XXX - this doesn't belong here either
options USERCONFIG #boot -c editor
options INTRO_USERCONFIG #imply -c and show intro screen
options VISUAL_USERCONFIG #visual boot -c editor
#options USERCONFIG #boot -c editor
#options INTRO_USERCONFIG #imply -c and show intro screen
#options VISUAL_USERCONFIG #visual boot -c editor

#####################################################################
# NETWORKING OPTIONS
Expand Down
2 changes: 1 addition & 1 deletion sys/i386/i386/machdep.c
Expand Up @@ -49,7 +49,7 @@
#include "opt_msgbuf.h"
#include "opt_npx.h"
#include "opt_perfmon.h"
#include "opt_userconfig.h"
/* #include "opt_userconfig.h" */

#include <sys/param.h>
#include <sys/systm.h>
Expand Down
8 changes: 7 additions & 1 deletion sys/i386/isa/isa_compat.c
Expand Up @@ -276,8 +276,14 @@ compat_isa_handler(module_t mod, int type, void *data)
driver->methods = isa_compat_methods;
driver->size = sizeof(struct isa_device);
driver->priv = id;
if (id->sensitive_hw)
if (id->sensitive_hw) {
#if 0
resource_set_int(id->name, -1, "sensitive", 1);
#else
printf("WARNING: isa driver %s is sensitive, but cannot set it!\n",
driver->name);
#endif
}
devclass_add_driver(isa_devclass, driver);
break;
case MOD_UNLOAD:
Expand Down
18 changes: 8 additions & 10 deletions sys/isa/atkbdc_isa.c
Expand Up @@ -169,11 +169,11 @@ static int
atkbdc_attach(device_t dev)
{
atkbdc_softc_t *sc;
int unit;
int unit, dunit;
int error;
int rid;
int i;
const char *name;
const char *name, *dname;

unit = device_get_unit(dev);
sc = *(atkbdc_softc_t **)device_get_softc(dev);
Expand Down Expand Up @@ -215,19 +215,17 @@ atkbdc_attach(device_t dev)
* Add all devices configured to be attached to atkbdc0.
*/
name = device_get_nameunit(dev);
i = -1;
while ((i = resource_query_string(i, "at", name)) != -1)
atkbdc_add_device(dev, resource_query_name(i),
resource_query_unit(i));
i = 0;
while ((resource_find_match(&i, &dname, &dunit, "at", name)) == 0)
atkbdc_add_device(dev, dname, dunit);

/*
* and atkbdc?
*/
name = device_get_name(dev);
i = -1;
while ((i = resource_query_string(i, "at", name)) != -1)
atkbdc_add_device(dev, resource_query_name(i),
resource_query_unit(i));
i = 0;
while ((resource_find_match(&i, &dname, &dunit, "at", name)) == 0)
atkbdc_add_device(dev, dname, dunit);

bus_generic_attach(dev);

Expand Down

0 comments on commit bbbe887

Please sign in to comment.