Deleted Added
full compact
subr_bus.c (78135) subr_bus.c (79696)
1/*-
2 * Copyright (c) 1997,1998 Doug Rabson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1997,1998 Doug Rabson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/kern/subr_bus.c 78135 2001-06-12 09:40:04Z peter $
26 * $FreeBSD: head/sys/kern/subr_bus.c 79696 2001-07-14 00:23:10Z peter $
27 */
28
29#include "opt_bus.h"
30
31#include <sys/param.h>
32#include <sys/queue.h>
33#include <sys/malloc.h>
34#include <sys/kernel.h>

--- 51 unchanged lines hidden (view full) ---

86#define print_driver(d,i) /* nop */
87#define print_driver_list(d,i) /* nop */
88#define print_devclass_short(d,i) /* nop */
89#define print_devclass(d,i) /* nop */
90#define print_devclass_list_short() /* nop */
91#define print_devclass_list() /* nop */
92#endif
93
27 */
28
29#include "opt_bus.h"
30
31#include <sys/param.h>
32#include <sys/queue.h>
33#include <sys/malloc.h>
34#include <sys/kernel.h>

--- 51 unchanged lines hidden (view full) ---

86#define print_driver(d,i) /* nop */
87#define print_driver_list(d,i) /* nop */
88#define print_devclass_short(d,i) /* nop */
89#define print_devclass(d,i) /* nop */
90#define print_devclass_list_short() /* nop */
91#define print_devclass_list() /* nop */
92#endif
93
94extern char static_hints[]; /* by config for now */
95
96TAILQ_HEAD(,device) bus_data_devices;
97static int bus_data_generation = 1;
98
99kobj_method_t null_methods[] = {
100 { 0, 0 }
101};
102
103DEFINE_CLASS(null, null_methods, 0);

--- 2025 unchanged lines hidden (view full) ---

2129 bus_data_generation++;
2130}
2131
2132/*======================================*/
2133/*
2134 * Access functions for device resources.
2135 */
2136
94TAILQ_HEAD(,device) bus_data_devices;
95static int bus_data_generation = 1;
96
97kobj_method_t null_methods[] = {
98 { 0, 0 }
99};
100
101DEFINE_CLASS(null, null_methods, 0);

--- 2025 unchanged lines hidden (view full) ---

2127 bus_data_generation++;
2128}
2129
2130/*======================================*/
2131/*
2132 * Access functions for device resources.
2133 */
2134
2135extern char static_hints[]; /* by config for now */
2136extern int hintmode; /* 0 = off. 1 = config, 2 = fallback */
2137static char *hintp;
2138
2137/*
2138 * Evil wildcarding resource string lookup.
2139 * This walks the supplied env string table and returns a match.
2140 * The start point can be remembered for incremental searches.
2141 */
2142static int
2139/*
2140 * Evil wildcarding resource string lookup.
2141 * This walks the supplied env string table and returns a match.
2142 * The start point can be remembered for incremental searches.
2143 */
2144static int
2143res_find(const char *cp, int *line, int *startln,
2145res_find(int *line, int *startln,
2144 const char *name, int *unit, const char *resname, const char *value,
2145 const char **ret_name, int *ret_namelen, int *ret_unit,
2146 const char **ret_resname, int *ret_resnamelen, const char **ret_value)
2147{
2148 int n = 0, hit;
2149 char r_name[32];
2150 int r_unit;
2151 char r_resname[32];
2152 char r_value[128];
2146 const char *name, int *unit, const char *resname, const char *value,
2147 const char **ret_name, int *ret_namelen, int *ret_unit,
2148 const char **ret_resname, int *ret_resnamelen, const char **ret_value)
2149{
2150 int n = 0, hit;
2151 char r_name[32];
2152 int r_unit;
2153 char r_resname[32];
2154 char r_value[128];
2153 const char *s;
2155 const char *s, *cp;
2154 char *p;
2155
2156 char *p;
2157
2158 if (hintp == NULL) {
2159 switch (hintmode) {
2160 case 0: /* config supplied nothing */
2161 hintp = kern_envp;
2162 break;
2163 case 1: /* static hints only */
2164 hintp = static_hints;
2165 break;
2166 case 2: /* fallback mode */
2167 cp = kern_envp;
2168 while (cp) {
2169 if (strncmp(cp, "hint.", 5) == 0) {
2170 cp = NULL;
2171 hintp = kern_envp;
2172 break;
2173 }
2174 while (*cp != '\0')
2175 cp++;
2176 cp++;
2177 if (*cp == '\0') {
2178 cp = NULL;
2179 hintp = static_hints;
2180 break;
2181 }
2182 }
2183 break;
2184 default:
2185 break;
2186 }
2187 if (hintp == NULL)
2188 hintp = kern_envp;
2189 }
2190
2191 cp = hintp;
2156 while (cp) {
2157 hit = 1;
2158 (*line)++;
2159 if (strncmp(cp, "hint.", 5) != 0)
2160 hit = 0;
2161 else
2162 n = sscanf(cp, "hint.%32[^.].%d.%32[^=]=%128s",
2163 r_name, &r_unit, r_resname, r_value);

--- 62 unchanged lines hidden (view full) ---

2226 const char **ret_resname, int *ret_resnamelen, const char **ret_value)
2227{
2228 int i;
2229 int un;
2230
2231 *line = 0;
2232
2233 /* Search for exact unit matches first */
2192 while (cp) {
2193 hit = 1;
2194 (*line)++;
2195 if (strncmp(cp, "hint.", 5) != 0)
2196 hit = 0;
2197 else
2198 n = sscanf(cp, "hint.%32[^.].%d.%32[^=]=%128s",
2199 r_name, &r_unit, r_resname, r_value);

--- 62 unchanged lines hidden (view full) ---

2262 const char **ret_resname, int *ret_resnamelen, const char **ret_value)
2263{
2264 int i;
2265 int un;
2266
2267 *line = 0;
2268
2269 /* Search for exact unit matches first */
2234 i = res_find(kern_envp, line, startln, name, unit, resname, value,
2270 i = res_find(line, startln, name, unit, resname, value,
2235 ret_name, ret_namelen, ret_unit, ret_resname, ret_resnamelen,
2236 ret_value);
2237 if (i == 0)
2238 return 0;
2271 ret_name, ret_namelen, ret_unit, ret_resname, ret_resnamelen,
2272 ret_value);
2273 if (i == 0)
2274 return 0;
2239 i = res_find(static_hints, line, startln, name, unit, resname, value,
2240 ret_name, ret_namelen, ret_unit, ret_resname, ret_resnamelen,
2241 ret_value);
2242 if (i == 0)
2243 return 0;
2244 if (unit == NULL)
2245 return ENOENT;
2246 /* If we are still here, search for wildcard matches */
2247 un = -1;
2275 if (unit == NULL)
2276 return ENOENT;
2277 /* If we are still here, search for wildcard matches */
2278 un = -1;
2248 i = res_find(kern_envp, line, startln, name, &un, resname, value,
2279 i = res_find(line, startln, name, &un, resname, value,
2249 ret_name, ret_namelen, ret_unit, ret_resname, ret_resnamelen,
2250 ret_value);
2251 if (i == 0)
2252 return 0;
2280 ret_name, ret_namelen, ret_unit, ret_resname, ret_resnamelen,
2281 ret_value);
2282 if (i == 0)
2283 return 0;
2253 un = -1;
2254 i = res_find(static_hints, line, startln, name, &un, resname, value,
2255 ret_name, ret_namelen, ret_unit, ret_resname, ret_resnamelen,
2256 ret_value);
2257 if (i == 0)
2258 return 0;
2259 return ENOENT;
2260}
2261
2262int
2263resource_int_value(const char *name, int unit, const char *resname, int *result)
2264{
2265 int error;
2266 const char *str;

--- 136 unchanged lines hidden ---
2284 return ENOENT;
2285}
2286
2287int
2288resource_int_value(const char *name, int unit, const char *resname, int *result)
2289{
2290 int error;
2291 const char *str;

--- 136 unchanged lines hidden ---