MCPcopy Create free account
hub / github.com/F-Stack/f-stack / xlp_simplebus_alloc_resource

Function xlp_simplebus_alloc_resource

freebsd/mips/nlm/xlp_simplebus.c:166–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166static struct resource *
167xlp_simplebus_alloc_resource(device_t bus, device_t child, int type, int *rid,
168 rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
169{
170 struct rman *rm;
171 struct resource *rv;
172 struct resource_list_entry *rle;
173 struct simplebus_softc *sc;
174 struct simplebus_devinfo *di;
175 bus_space_tag_t bustag;
176 int j, isdefault, passthrough, needsactivate;
177
178 passthrough = (device_get_parent(child) != bus);
179 needsactivate = flags & RF_ACTIVE;
180 sc = device_get_softc(bus);
181 di = device_get_ivars(child);
182 rle = NULL;
183 bustag = NULL;
184
185 if (!passthrough) {
186 isdefault = RMAN_IS_DEFAULT_RANGE(start, end);
187 if (isdefault) {
188 rle = resource_list_find(&di->rl, type, *rid);
189 if (rle == NULL)
190 return (NULL);
191 if (rle->res != NULL)
192 panic("%s: resource entry is busy", __func__);
193 start = rle->start;
194 count = ulmax(count, rle->count);
195 end = ulmax(rle->end, start + count - 1);
196 }
197 if (type == SYS_RES_MEMORY) {
198 /* Remap through ranges property */
199 for (j = 0; j < sc->nranges; j++) {
200 if (start >= sc->ranges[j].bus && end <
201 sc->ranges[j].bus + sc->ranges[j].size) {
202 start -= sc->ranges[j].bus;
203 start += sc->ranges[j].host;
204 end -= sc->ranges[j].bus;
205 end += sc->ranges[j].host;
206 break;
207 }
208 }
209 if (j == sc->nranges && sc->nranges != 0) {
210 if (bootverbose)
211 device_printf(bus, "Could not map resource "
212 "%#jx-%#jx\n", start, end);
213 return (NULL);
214 }
215 }
216 }
217 switch (type) {
218 case SYS_RES_IRQ:
219 rm = &irq_rman;
220 break;
221 case SYS_RES_IOPORT:
222 rm = &port_rman;
223 bustag = rmi_bus_space;

Callers

nothing calls this directly

Calls 13

device_get_parentFunction · 0.85
device_get_softcFunction · 0.85
device_get_ivarsFunction · 0.85
resource_list_findFunction · 0.85
ulmaxFunction · 0.85
device_printfFunction · 0.85
rman_reserve_resourceFunction · 0.85
device_get_nameunitFunction · 0.85
rman_set_ridFunction · 0.85
rman_set_bustagFunction · 0.85
bus_activate_resourceFunction · 0.85
rman_release_resourceFunction · 0.85

Tested by

no test coverage detected