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

Function smapi_attach

freebsd/i386/bios/smapi.c:204–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204static int
205smapi_attach (device_t dev)
206{
207 struct smapi_softc *sc;
208 int error;
209
210 sc = device_get_softc(dev);
211 error = 0;
212
213 sc->dev = dev;
214 sc->rid = 0;
215 sc->res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->rid,
216 RF_ACTIVE);
217 if (sc->res == NULL) {
218 device_printf(dev, "Unable to allocate memory resource.\n");
219 error = ENOMEM;
220 goto bad;
221 }
222 sc->header = (struct smapi_bios_header *)rman_get_virtual(sc->res);
223 sc->smapi32_entry = (u_int32_t)BIOS_PADDRTOVADDR(
224 sc->header->prot32_segment +
225 sc->header->prot32_offset);
226
227 sc->cdev = make_dev(&smapi_cdevsw,
228 device_get_unit(sc->dev),
229 UID_ROOT, GID_WHEEL, 0600,
230 "%s%d",
231 smapi_cdevsw.d_name,
232 device_get_unit(sc->dev));
233
234 device_printf(dev, "Version: %d.%02d, Length: %d, Checksum: 0x%02x\n",
235 bcd2bin(sc->header->version_major),
236 bcd2bin(sc->header->version_minor),
237 sc->header->length,
238 sc->header->checksum);
239 device_printf(dev, "Information=0x%b\n",
240 sc->header->information,
241 "\020"
242 "\001REAL_VM86"
243 "\002PROTECTED_16"
244 "\003PROTECTED_32");
245
246 if (bootverbose) {
247 if (sc->header->information & SMAPI_REAL_VM86)
248 device_printf(dev, "Real/VM86 mode: Segment 0x%04x, Offset 0x%04x\n",
249 sc->header->real16_segment,
250 sc->header->real16_offset);
251 if (sc->header->information & SMAPI_PROT_16BIT)
252 device_printf(dev, "16-bit Protected mode: Segment 0x%08x, Offset 0x%04x\n",
253 sc->header->prot16_segment,
254 sc->header->prot16_offset);
255 if (sc->header->information & SMAPI_PROT_32BIT)
256 device_printf(dev, "32-bit Protected mode: Segment 0x%08x, Offset 0x%08x\n",
257 sc->header->prot32_segment,
258 sc->header->prot32_offset);
259 }
260
261 return (0);

Callers

nothing calls this directly

Calls 8

device_get_softcFunction · 0.85
bus_alloc_resource_anyFunction · 0.85
device_printfFunction · 0.85
rman_get_virtualFunction · 0.85
make_devFunction · 0.85
device_get_unitFunction · 0.85
bus_release_resourceFunction · 0.85
bcd2binFunction · 0.50

Tested by

no test coverage detected