summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2001-07-14 00:23:10 +0000
committerpeter <peter@FreeBSD.org>2001-07-14 00:23:10 +0000
commita67c5263965b3cce0db11089854bd6f3f56f2f8e (patch)
treed9f1f06b74b2af532ad2731b1aa39b40c86c209f
parentf798ced9daceafa1c2fb589cdee76726812318de (diff)
downloadFreeBSD-src-a67c5263965b3cce0db11089854bd6f3f56f2f8e.zip
FreeBSD-src-a67c5263965b3cce0db11089854bd6f3f56f2f8e.tar.gz
Go back to having either static OR dynamic hints, with fallback
support. Trying to fix the merged set where dynamic overrode static was getting more and more complicated by the day. This should fix the duplicate atkbd, psm, fd* etc in GENERIC. (which paniced the alpha, but not the i386)
-rw-r--r--sys/kern/subr_bus.c59
-rw-r--r--sys/kern/subr_hints.c55
2 files changed, 82 insertions, 32 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index 4e3f3a0..67819b2 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -91,8 +91,6 @@ void print_devclass_list(void);
#define print_devclass_list() /* nop */
#endif
-extern char static_hints[]; /* by config for now */
-
TAILQ_HEAD(,device) bus_data_devices;
static int bus_data_generation = 1;
@@ -2134,13 +2132,17 @@ bus_data_generation_update(void)
* Access functions for device resources.
*/
+extern char static_hints[]; /* by config for now */
+extern int hintmode; /* 0 = off. 1 = config, 2 = fallback */
+static char *hintp;
+
/*
* Evil wildcarding resource string lookup.
* This walks the supplied env string table and returns a match.
* The start point can be remembered for incremental searches.
*/
static int
-res_find(const char *cp, int *line, int *startln,
+res_find(int *line, int *startln,
const char *name, int *unit, const char *resname, const char *value,
const char **ret_name, int *ret_namelen, int *ret_unit,
const char **ret_resname, int *ret_resnamelen, const char **ret_value)
@@ -2150,9 +2152,43 @@ res_find(const char *cp, int *line, int *startln,
int r_unit;
char r_resname[32];
char r_value[128];
- const char *s;
+ const char *s, *cp;
char *p;
+ if (hintp == NULL) {
+ switch (hintmode) {
+ case 0: /* config supplied nothing */
+ hintp = kern_envp;
+ break;
+ case 1: /* static hints only */
+ hintp = static_hints;
+ break;
+ case 2: /* fallback mode */
+ cp = kern_envp;
+ while (cp) {
+ if (strncmp(cp, "hint.", 5) == 0) {
+ cp = NULL;
+ hintp = kern_envp;
+ break;
+ }
+ while (*cp != '\0')
+ cp++;
+ cp++;
+ if (*cp == '\0') {
+ cp = NULL;
+ hintp = static_hints;
+ break;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ if (hintp == NULL)
+ hintp = kern_envp;
+ }
+
+ cp = hintp;
while (cp) {
hit = 1;
(*line)++;
@@ -2231,12 +2267,7 @@ resource_find(int *line, int *startln,
*line = 0;
/* Search for exact unit matches first */
- i = res_find(kern_envp, line, startln, name, unit, resname, value,
- ret_name, ret_namelen, ret_unit, ret_resname, ret_resnamelen,
- ret_value);
- if (i == 0)
- return 0;
- i = res_find(static_hints, line, startln, name, unit, resname, value,
+ i = res_find(line, startln, name, unit, resname, value,
ret_name, ret_namelen, ret_unit, ret_resname, ret_resnamelen,
ret_value);
if (i == 0)
@@ -2245,13 +2276,7 @@ resource_find(int *line, int *startln,
return ENOENT;
/* If we are still here, search for wildcard matches */
un = -1;
- i = res_find(kern_envp, line, startln, name, &un, resname, value,
- ret_name, ret_namelen, ret_unit, ret_resname, ret_resnamelen,
- ret_value);
- if (i == 0)
- return 0;
- un = -1;
- i = res_find(static_hints, line, startln, name, &un, resname, value,
+ i = res_find(line, startln, name, &un, resname, value,
ret_name, ret_namelen, ret_unit, ret_resname, ret_resnamelen,
ret_value);
if (i == 0)
diff --git a/sys/kern/subr_hints.c b/sys/kern/subr_hints.c
index a201fa0..9e04ef1 100644
--- a/sys/kern/subr_hints.c
+++ b/sys/kern/subr_hints.c
@@ -35,6 +35,8 @@
*/
extern char static_hints[]; /* by config for now */
+extern int hintmode; /* 0 = off. 1 = config, 2 = fallback */
+static char *hintp;
/*
* Evil wildcarding resource string lookup.
@@ -42,7 +44,7 @@ extern char static_hints[]; /* by config for now */
* The start point can be remembered for incremental searches.
*/
static int
-res_find(const char *cp, int *line, int *startln,
+res_find(int *line, int *startln,
const char *name, int *unit, const char *resname, const char *value,
const char **ret_name, int *ret_namelen, int *ret_unit,
const char **ret_resname, int *ret_resnamelen, const char **ret_value)
@@ -52,9 +54,43 @@ res_find(const char *cp, int *line, int *startln,
int r_unit;
char r_resname[32];
char r_value[128];
- const char *s;
+ const char *s, *cp;
char *p;
+ if (hintp == NULL) {
+ switch (hintmode) {
+ case 0: /* config supplied nothing */
+ hintp = kern_envp;
+ break;
+ case 1: /* static hints only */
+ hintp = static_hints;
+ break;
+ case 2: /* fallback mode */
+ cp = kern_envp;
+ while (cp) {
+ if (strncmp(cp, "hint.", 5) == 0) {
+ cp = NULL;
+ hintp = kern_envp;
+ break;
+ }
+ while (*cp != '\0')
+ cp++;
+ cp++;
+ if (*cp == '\0') {
+ cp = NULL;
+ hintp = static_hints;
+ break;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ if (hintp == NULL)
+ hintp = kern_envp;
+ }
+
+ cp = hintp;
while (cp) {
hit = 1;
(*line)++;
@@ -133,12 +169,7 @@ resource_find(int *line, int *startln,
*line = 0;
/* Search for exact unit matches first */
- i = res_find(kern_envp, line, startln, name, unit, resname, value,
- ret_name, ret_namelen, ret_unit, ret_resname, ret_resnamelen,
- ret_value);
- if (i == 0)
- return 0;
- i = res_find(static_hints, line, startln, name, unit, resname, value,
+ i = res_find(line, startln, name, unit, resname, value,
ret_name, ret_namelen, ret_unit, ret_resname, ret_resnamelen,
ret_value);
if (i == 0)
@@ -147,13 +178,7 @@ resource_find(int *line, int *startln,
return ENOENT;
/* If we are still here, search for wildcard matches */
un = -1;
- i = res_find(kern_envp, line, startln, name, &un, resname, value,
- ret_name, ret_namelen, ret_unit, ret_resname, ret_resnamelen,
- ret_value);
- if (i == 0)
- return 0;
- un = -1;
- i = res_find(static_hints, line, startln, name, &un, resname, value,
+ i = res_find(line, startln, name, &un, resname, value,
ret_name, ret_namelen, ret_unit, ret_resname, ret_resnamelen,
ret_value);
if (i == 0)
OpenPOWER on IntegriCloud