| 142 | } |
| 143 | |
| 144 | static int |
| 145 | smbios_attach (device_t dev) |
| 146 | { |
| 147 | struct smbios_softc *sc; |
| 148 | int error; |
| 149 | |
| 150 | sc = device_get_softc(dev); |
| 151 | error = 0; |
| 152 | |
| 153 | sc->dev = dev; |
| 154 | sc->rid = 0; |
| 155 | sc->res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->rid, |
| 156 | RF_ACTIVE); |
| 157 | if (sc->res == NULL) { |
| 158 | device_printf(dev, "Unable to allocate memory resource.\n"); |
| 159 | error = ENOMEM; |
| 160 | goto bad; |
| 161 | } |
| 162 | sc->eps = RES2EPS(sc->res); |
| 163 | |
| 164 | device_printf(dev, "Version: %u.%u", |
| 165 | sc->eps->major_version, sc->eps->minor_version); |
| 166 | if (bcd2bin(sc->eps->BCD_revision)) |
| 167 | printf(", BCD Revision: %u.%u", |
| 168 | bcd2bin(sc->eps->BCD_revision >> 4), |
| 169 | bcd2bin(sc->eps->BCD_revision & 0x0f)); |
| 170 | printf("\n"); |
| 171 | |
| 172 | return (0); |
| 173 | bad: |
| 174 | if (sc->res) |
| 175 | bus_release_resource(dev, SYS_RES_MEMORY, sc->rid, sc->res); |
| 176 | return (error); |
| 177 | } |
| 178 | |
| 179 | static int |
| 180 | smbios_detach (device_t dev) |
nothing calls this directly
no test coverage detected